UNPKG

evotars

Version:

Show animated characters on stream

981 lines 538 kB
(function(at,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(at=typeof globalThis<"u"?globalThis:at||self,b(at.evotars={}))})(this,function(at){"use strict";var gx=Object.defineProperty;var _x=(at,b,Wt)=>b in at?gx(at,b,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):at[b]=Wt;var T=(at,b,Wt)=>(_x(at,typeof b!="symbol"?b+"":b,Wt),Wt);var b=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s))(b||{});const Wt=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},ws=(s,t)=>Wt(s).priority??t,O={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Wt).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Wt).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>ws(a.value,e)-ws(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>ws(n,e)-ws(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},Ml={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>ux)}},Bl={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>dx)}};class ft{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ft(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function _i(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var wn={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},o.prototype.listenerCount=function(c){var l=e?e+c:c,u=this._events[l];return u?u.fn?1:u.length:0},o.prototype.emit=function(c,l,u,d,f,p){var g=e?e+c:c;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,x,y;if(m.fn){switch(m.once&&this.removeListener(c,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,l),!0;case 3:return m.fn.call(m.context,l,u),!0;case 4:return m.fn.call(m.context,l,u,d),!0;case 5:return m.fn.call(m.context,l,u,d,f),!0;case 6:return m.fn.call(m.context,l,u,d,f,p),!0}for(y=1,x=new Array(_-1);y<_;y++)x[y-1]=arguments[y];m.fn.apply(m.context,x)}else{var v=m.length,w;for(y=0;y<v;y++)switch(m[y].once&&this.removeListener(c,m[y].fn,void 0,!0),_){case 1:m[y].fn.call(m[y].context);break;case 2:m[y].fn.call(m[y].context,l);break;case 3:m[y].fn.call(m[y].context,l,u);break;case 4:m[y].fn.call(m[y].context,l,u,d);break;default:if(!x)for(w=1,x=new Array(_-1);w<_;w++)x[w-1]=arguments[w];m[y].fn.apply(m[y].context,x)}}return!0},o.prototype.on=function(c,l,u){return n(this,c,l,u,!1)},o.prototype.once=function(c,l,u){return n(this,c,l,u,!0)},o.prototype.removeListener=function(c,l,u,d){var f=e?e+c:c;if(!this._events[f])return this;if(!l)return a(this,f),this;var p=this._events[f];if(p.fn)p.fn===l&&(!d||p.once)&&(!u||p.context===u)&&a(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==l||d&&!p[g].once||u&&p[g].context!==u)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(c){var l;return c?(l=e?e+c:c,this._events[l]&&a(this,l)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})(wn);var Rl=wn.exports;const gt=_i(Rl),kl=Math.PI*2,Il=180/Math.PI,Fl=Math.PI/180;class X{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new X(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return xi.x=0,xi.y=0,xi}}const xi=new X;class I{constructor(t=1,e=0,i=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new X;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new X;const i=this.a,r=this.b,n=this.c,a=this.d,o=this.tx,h=this.ty,c=1/(i*a+n*-r),l=t.x,u=t.y;return e.x=a*c*l+-n*c*u+(h*n-o*a)*c,e.y=i*c*u+-r*c*l+(-h*i+o*r)*c,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,a=t.d,o=t.tx,h=t.ty,c=e.a,l=e.b,u=e.c,d=e.d;return this.a=i*c+r*u,this.b=i*l+r*d,this.c=n*c+a*u,this.d=n*l+a*d,this.tx=o*c+h*u+e.tx,this.ty=o*l+h*d+e.ty,this}setTransform(t,e,i,r,n,a,o,h,c){return this.a=Math.cos(o+c)*n,this.b=Math.sin(o+c)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(i,e),c=Math.abs(o+h);return c<1e-5||Math.abs(kl-c)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new I;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Ul.identity()}static get shared(){return Gl.identity()}}const Gl=new I,Ul=new I,he=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ce=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],le=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ue=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],yi=[],Tn=[],Ts=Math.sign;function Dl(){for(let s=0;s<16;s++){const t=[];yi.push(t);for(let e=0;e<16;e++){const i=Ts(he[s]*he[e]+le[s]*ce[e]),r=Ts(ce[s]*he[e]+ue[s]*ce[e]),n=Ts(he[s]*le[e]+le[s]*ue[e]),a=Ts(ce[s]*le[e]+ue[s]*ue[e]);for(let o=0;o<16;o++)if(he[o]===i&&ce[o]===r&&le[o]===n&&ue[o]===a){t.push(o);break}}}for(let s=0;s<16;s++){const t=new I;t.set(he[s],ce[s],le[s],ue[s],0,0),Tn.push(t)}}Dl();const tt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>he[s],uY:s=>ce[s],vX:s=>le[s],vY:s=>ue[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>yi[s][t],sub:(s,t)=>yi[s][tt.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?tt.S:tt.N:Math.abs(t)*2<=Math.abs(s)?s>0?tt.E:tt.W:t>0?s>0?tt.SE:tt.SW:s>0?tt.NE:tt.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Tn[tt.inv(t)];r.tx=e,r.ty=i,s.append(r)}},As=[new X,new X,new X,new X];class Y{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Y(0,0,0,0)}clone(){return new Y(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i){const{width:r,height:n}=this;if(r<=0||n<=0)return!1;const a=this.x,o=this.y,h=a-i/2,c=a+r+i/2,l=o-i/2,u=o+n+i/2,d=a+i/2,f=a+r-i/2,p=o+i/2,g=o+n-i/2;return t>=h&&t<=c&&e>=l&&e<=u&&!(t>d&&t<f&&e>p&&e<g)}intersects(t,e){if(!e){const P=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=P)return!1;const A=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>A}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=As[0].set(t.left,t.top),h=As[1].set(t.left,t.bottom),c=As[2].set(t.right,t.top),l=As[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,g=d*r+f*n,m=d*i+f*a,_=d*r+f*a;if(Math.max(p,g,m,_)<=d*o.x+f*o.y||Math.min(p,g,m,_)>=d*l.x+f*l.y)return!1;const x=u*(o.y-c.y),y=u*(c.x-o.x),v=x*i+y*n,w=x*r+y*n,C=x*i+y*a,E=x*r+y*a;return!(Math.max(v,w,C,E)<=x*o.x+y*o.y||Math.min(v,w,C,E)>=x*l.x+y*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new Y,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const bi={default:-1};function et(s="default"){return bi[s]===void 0&&(bi[s]=-1),++bi[s]}const An={},W="8.0.0";function N(s,t,e=3){if(An[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${s}`):(i=i.split(`
`).splice(e).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${s}`),console.warn(i))),An[t]=!0}const Pn=()=>{};function Te(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function En(s){return!(s&s-1)&&!!s}function Ol(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Cn=Object.create(null);function Ll(s){const t=Cn[s];return t===void 0&&(Cn[s]=et("resource")),t}const Mn=class dl extends gt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...dl.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){N(W,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Ll(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Mn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Hl=Mn;const Bn=class fl extends gt{constructor(t={}){super(),this.options=t,this.uid=et("textureSource"),this._resourceType="textureSource",this._resourceId=et("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...fl.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Hl(Ol(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=et("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=et("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=En(this.pixelWidth)&&En(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Bn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ut=Bn;class vi extends ut{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}vi.extension=b.TextureSource;const Rn=new I;class kn{constructor(t,e){this.mapCoord=new I,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],a=t[r+1];e[r]=n*i.a+a*i.c+i.tx,e[r+1]=n*i.b+a*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(Rn.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Rn));const n=t.source,a=this.uClampFrame,o=this.clampMargin/n._resolution,h=this.clampOffset;return a[0]=(t.frame.x+o+h)/n.width,a[1]=(t.frame.y+o+h)/n.height,a[2]=(t.frame.x+t.frame.width-o+h)/n.width,a[3]=(t.frame.y+t.frame.height-o+h)/n.height,this.uClampOffset[0]=h/n.pixelWidth,this.uClampOffset[1]=h/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class M extends gt{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:a,defaultBorders:o,rotate:h,dynamic:c}={}){if(super(),this.uid=et("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Y,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new ut,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:l,height:u}=this._source;this.frame.width=l,this.frame.height=u}this.orig=r||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new kn(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,a=e.y/r,o=e.width/i,h=e.height/r;let c=this.rotate;if(c){const l=o/2,u=h/2,d=n+l,f=a+u;c=tt.add(c,tt.NW),t.x0=d+l*tt.uX(c),t.y0=f+u*tt.uY(c),c=tt.add(c,2),t.x1=d+l*tt.uX(c),t.y1=f+u*tt.uY(c),c=tt.add(c,2),t.x2=d+l*tt.uX(c),t.y2=f+u*tt.uY(c),c=tt.add(c,2),t.x3=d+l*tt.uX(c),t.y3=f+u*tt.uY(c)}else t.x0=n,t.y0=a,t.x1=n+o,t.y1=a,t.x2=n+o,t.y2=a+h,t.x3=n,t.y3=a+h}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return N(W,"Texture.baseTexture is now Texture.source"),this._source}}M.EMPTY=new M({label:"EMPTY",source:new ut({label:"EMPTY"})}),M.EMPTY.destroy=Pn,M.WHITE=new M({source:new vi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),M.WHITE.destroy=Pn;function Ps(s,t,e,i){const{width:r,height:n}=e.orig,a=e.trim;if(a){const o=a.width,h=a.height;s.minX=a.x-t._x*r-i,s.maxX=s.minX+o,s.minY=a.y-t._y*n-i,s.maxY=s.minY+h}else s.minX=-t._x*r-i,s.maxX=s.minX+r,s.minY=-t._y*n-i,s.maxY=s.minY+n}var Nl={grad:.9,turn:360,rad:360/(2*Math.PI)},Vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},ot=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},St=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},In=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Fn=function(s){return{r:St(s.r,0,255),g:St(s.g,0,255),b:St(s.b,0,255),a:St(s.a)}},Si=function(s){return{r:ot(s.r),g:ot(s.g),b:ot(s.b),a:ot(s.a,3)}},zl=/^#([0-9a-f]{3,8})$/i,Es=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Gn=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},Un=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},Dn=function(s){return{h:In(s.h),s:St(s.s,0,100),l:St(s.l,0,100),a:St(s.a)}},On=function(s){return{h:ot(s.h),s:ot(s.s),l:ot(s.l),a:ot(s.a,3)}},Ln=function(s){return Un((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},ze=function(s){return{h:(t=Gn(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Wl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jl=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$l=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wi={string:[[function(s){var t=zl.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?ot(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?ot(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=jl.exec(s)||$l.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Fn({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Wl.exec(s)||Vl.exec(s);if(!t)return null;var e,i,r=Dn({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Nl[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Ln(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return Vt(t)&&Vt(e)&&Vt(i)?Fn({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!Vt(t)||!Vt(e)||!Vt(i))return null;var a=Dn({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Ln(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!Vt(t)||!Vt(e)||!Vt(i))return null;var a=function(o){return{h:In(o.h),s:St(o.s,0,100),v:St(o.v,0,100),a:St(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Un(a)},"hsv"]]},Hn=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},Xl=function(s){return typeof s=="string"?Hn(s.trim(),wi.string):typeof s=="object"&&s!==null?Hn(s,wi.object):[null,void 0]},Ti=function(s,t){var e=ze(s);return{h:e.h,s:St(e.s+100*t,0,100),l:e.l,a:e.a}},Ai=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Nn=function(s,t){var e=ze(s);return{h:e.h,s:e.s,l:St(e.l+100*t,0,100),a:e.a}},Pi=function(){function s(t){this.parsed=Xl(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return ot(Ai(this.rgba),2)},s.prototype.isDark=function(){return Ai(this.rgba)<.5},s.prototype.isLight=function(){return Ai(this.rgba)>=.5},s.prototype.toHex=function(){return t=Si(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Es(ot(255*n)):"","#"+Es(e)+Es(i)+Es(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return Si(this.rgba)},s.prototype.toRgbString=function(){return t=Si(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return On(ze(this.rgba))},s.prototype.toHslString=function(){return t=On(ze(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Gn(this.rgba),{h:ot(t.h),s:ot(t.s),v:ot(t.v),a:ot(t.a,3)};var t},s.prototype.invert=function(){return Ot({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),Ot(Ti(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ot(Ti(this.rgba,-t))},s.prototype.grayscale=function(){return Ot(Ti(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Ot(Nn(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Ot(Nn(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?Ot({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ot(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=ze(this.rgba);return typeof t=="number"?Ot({h:t,s:e.s,l:e.l,a:e.a}):ot(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Ot(t).toHex()},s}(),Ot=function(s){return s instanceof Pi?s:new Pi(s)},zn=[],Yl=function(s){s.forEach(function(t){zn.indexOf(t)<0&&(t(Pi,wi),zn.push(t))})};function Kl(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var g=(o=l,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));g<u&&(u=g,d=p)}return d}},t.string.push([function(a){var o=a.toLowerCase(),h=o==="transparent"?"#0000":e[o];return h?new s(h).toRgb():null},"name"])}Yl([Kl]);const Ae=class vs{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof vs)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._normalize(t),this._value=this._cloneSource(t))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,a)=>n===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=vs._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=vs.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Ot(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof vs||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};Ae.shared=new Ae,Ae._temp=new Ae,Ae.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let j=Ae;const ql={cullArea:null,cullable:!1,cullableChildren:!0};function Wn(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}const Zl={allowChildren:!0,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}Wn(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a<r.length;++a)this.emit("childRemoved",r[a],this,a),r[a].emit("removed",this);return r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||N(W,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)}};class Cs{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Ei{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}}class Jl{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Ei(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const $=new Jl;class Ql{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return $.get(i.maskClass,t)}return t}returnMaskEffect(t){$.return(t)}}const Ci=new Ql;O.handleByList(b.MaskEffect,Ci._effectClasses);const tu={_maskEffect:null,_filterEffect:null,effects:[],addEffect(s){if(this.effects.indexOf(s)!==-1)return;this.effects.push(s),this.effects.sort((i,r)=>i.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Ci.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ci.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Cs);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Cs),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},eu={label:null,get name(){return N(W,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){N(W,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,!0,e);return e}},Vn=new I;class pt{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Vn,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Y);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Vn,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=a*t+h*e+l,_=o*t+c*e+u;m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*i+h*e+l,_=o*i+c*e+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*t+h*r+l,_=o*t+c*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=a*i+h*r+l,_=o*i+c*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a,b:o,c:h,d:c,tx:l,ty:u}=t;let d=a*e+h*i+l,f=o*e+c*i+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+h*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new pt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let g=e;g<i;g+=2){const m=t[g],_=t[g+1],x=c*m+u*_+f,y=l*m+d*_+p;n=x<n?x:n,a=y<a?y:a,o=x>o?x:o,h=y>h?y:h}this.minX=n,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}const jt=new Ei(I),$t=new Ei(pt);function Mi(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=jt.get().identity(),i=Ms(s,r)):i=I.IDENTITY,jn(s,e,i,t),r&&jt.return(r),e.isValid||e.set(0,0,0,0),e}function jn(s,t,e,i){var o,h;if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=jt.get(),r.appendFrom(s.localTransform,e));const n=t,a=!!s.effects.length;if(a&&(t=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{s.addBounds&&(t.matrix=r,s.addBounds(t));for(let c=0;c<s.children.length;c++)jn(s.children[c],t,r,i)}if(a){for(let c=0;c<s.effects.length;c++)(h=(o=s.effects[c]).addBounds)==null||h.call(o,t);n.addBounds(t,I.IDENTITY),$t.return(t)}i||jt.return(r)}function Ms(s,t){const e=s.parent;return e&&(Ms(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}let Bi=0;const $n=500;function D(...s){Bi!==$n&&(Bi++,Bi===$n?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}function Ri(s,t,e){return t.clear(),e||(e=I.IDENTITY),Xn(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function Xn(s,t,e,i,r){var h,c;let n;if(r)n=jt.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const l=s.localTransform;n=jt.get(),n.appendFrom(l,e)}const a=t,o=!!s.effects.length;if(o&&(t=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,s.addBounds(t));const l=s.children;for(let u=0;u<l.length;u++)Xn(l[u],t,n,i,!1)}if(o){for(let l=0;l<s.effects.length;l++)(c=(h=s.effects[l]).addLocalBounds)==null||c.call(h,t,i);a.addBounds(t,I.IDENTITY),$t.return(t)}jt.return(n)}function Yn(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],n=(r.uid&255)<<24|r._didChangeId&16777215;t.data[t.index]!==n&&(t.data[t.index]=n,t.didChange=!0),t.index++,r.children.length&&Yn(r,t)}return t.didChange}const su=new I,iu={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new pt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didChangeId>>12&&(s.didChange=!0,s.data[0]=this._didChangeId>>12),Yn(this,s),s.didChange&&Ri(this,s.localBounds,su),s.localBounds},getBounds(s,t){return Mi(this,s,t||new pt)}},ru={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},nu={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(au))}};function au(s,t){return s._zIndex-t._zIndex}const ou={getGlobalPosition(s=new X,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){if(!e){this.updateLocalTransform();const i=Ms(this,new I);return i.append(this.localTransform),i.apply(s,t)}return this.worldTransform.apply(s,t)},toLocal(s,t,e,i){if(t&&(s=t.toGlobal(s,e,i)),!i){this.updateLocalTransform();const r=Ms(this,new I);return r.append(this.localTransform),r.applyInverse(s,e)}return this.worldTransform.applyInverse(s,e)}};class Kn{constructor(){this.uid=et("instructionSet"),this.instructions=[],this.instructionSize=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class hu{constructor(t){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new I,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Kn,this._onRenderContainers=[],this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender()}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}}function cu(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const ki=new ft(null),Ii=new ft(null),Fi=new ft(null,1,1),Gi=1,qn=2,Bs=4;class z extends gt{constructor(t={}){var e,i;super(),this.uid=et("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new I,this.relativeGroupTransform=new I,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ft(this,0,0),this._scale=Fi,this._pivot=Ii,this._skew=ki,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didChangeId=0,this._didLocalTransformChangeId=-1,cu(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(r=>this.addChild(r)),this.effects=[],(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(z.prototype,Object.getOwnPropertyDescriptors(t))}addChild(...t){if(this.allowChildren||N(W,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0];if(e.parent===this)return this.children.splice(this.children.indexOf(e),1),this.children.push(e),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),e;e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e.didViewUpdate=!1,e._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didChangeId+=4096,e._zIndex!==0&&e.depthOfChildModified(),e}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didChangeId+=4096,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didChangeId++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){if(this.renderGroup&&t===!1)throw new Error("[Pixi] cannot undo a render group just yet");t&&this.enableRenderGroup()}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t&&t.removeChild(this),this.renderGroup=new hu(this),t&&t.addChild(this),this._updateIsSimple(),this.groupTransform=I.IDENTITY}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new I),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Il}set angle(t){this.rotation=t*Fl}get pivot(){return this._pivot===Ii&&(this._pivot=new ft(this,0,0)),this._pivot}set pivot(t){this._pivot===Ii&&(this._pivot=new ft(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ki&&(this._skew=new ft(this,0,0)),this._skew}set skew(t){this._skew===ki&&(this._skew=new ft(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Fi&&(this._scale=new ft(this,1,1)),this._scale}set scale(t){this._scale===Fi&&(this._scale=new ft(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();let r,n;typeof t!="object"?(r=t,n=e??t):(r=t.width,n=t.height??t.width),r!==void 0&&this._setWidth(r,i.width),n!==void 0&&this._setHeight(n,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){if((this._didLocalTransformChangeId&15)===this._didChangeId)return;this._didLocalTransformChangeId=this._didChangeId;const t=this.localTransform,e=this._scale,i=this._pivot,r=this._position,n=e._x,a=e._y,o=i._x,h=i._y;t.a=this._cx*n,t.b=this._sx*n,t.c=this._cy*a,t.d=this._sy*a,t.tx=r._x-(o*t.a+h*t.c),t.ty=r._y-(o*t.b+h*t.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Gi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=j.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Gi,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=qn,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?1:0;(this.localDisplayStatus&2)>>1!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Bs,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?1:0;(this.localDisplayStatus&4)>>2!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Bs,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Bs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r<e.length;++r)e[r].destroy(t)}}z.mixin(Zl),z.mixin(ou),z.mixin(ru),z.mixin(iu),z.mixin(tu),z.mixin(eu),z.mixin(nu),z.mixin(ql);class wt extends z{constructor(t=M.EMPTY){t instanceof M&&(t={texture:t});const{texture:e=M.EMPTY,anchor:i,roundPixels:r,width:n,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this._sourceBoundsDirty=!0,this._roundPixels=0,this._anchor=new ft({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n&&(this.width=n),a&&(this.height=a)}static from(t,e=!1){return t instanceof M?new wt(t):new wt(M.from(t,e))}set texture(t){t||(t=M.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didChangeId+=4096,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){Ps(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width)}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){let i,r;typeof t!="object"?(i=t,r=e??t):(i=t.width,r=t.height??t.width),i!==void 0&&this._setWidth(i,this._texture.orig.width),r!==void 0&&this._setHeight(r,this._texture.orig.height)}}const lu=new pt;function Zn(s,t,e){const i=lu;s.measurable=!0,Mi(s,e,i),t.addBoundsMask(i),s.measurable=!1}function Jn(s,t,e){const i=$t.get();s.measurable=!0;const r=jt.get().identity(),n=Qn(s,e,r);Ri(s,i,n),s.measurable=!1,t.addBoundsMask(i),jt.return(r),$t.return(i)}function Qn(s,t,e){return s?(s!==t&&(Qn(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(D("Mask bounds, renderable is not inside the root container"),e)}class ta{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof wt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){Zn(this.mask,t,e)}addLocalBounds(t,e){Jn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof wt}}ta.extension=b.MaskEffect;class ea{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}ea.extension=b.MaskEffect;class sa{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Zn(this.mask,t,e)}addLocalBounds(t,e){Jn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof z}}sa.extension=b.MaskEffect;let ia={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};const L={get(){return ia},set(s){ia=s}};class Pe extends ut{constructor(t){t.resource||(t.resource=L.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}}Pe.extension=b.TextureSource;class Ee extends ut{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=L.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0),t.resource=e,D("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap}}Ee.extension=b.TextureSource;var de=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(de||{});class Ui{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const ra=class vt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ui(null,null,1/0),this.deltaMS=1/vt.targetFPMS,this.elapsedMS=1/vt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=de.NORMAL){return this._addListener(new Ui(t,e,i))}addOnce(t,e,i=de.NORMAL){return this._addListener(new Ui(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*vt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,vt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!vt._shared){const t=vt._shared=new vt;t.autoStart=!0,t._protected=!0}return vt._shared}static get system(){if(!vt._system){const t=vt._system=new vt;t.autoStart=!0,t._protected=!0}return vt._system}};ra.targetFPMS=.06;let ht=ra,Di;async function na(){return Di??(Di=(async()=>{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Di}const Rs=class pl extends ut{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...pl.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ht.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await na(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ht.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ht.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ht.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||globalThis.VideoFrame&&t instanceof VideoFrame}};Rs.extension=b.TextureSource,Rs.defaultOptions={...ut.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},Rs.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ks=Rs;const Mt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class uu{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||D(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Mt(t);let r;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.test(e)){r=c.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&D("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){D(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const K=new uu,Oi=[];O.handleByList(b.TextureSource,Oi);function du(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<Oi.length;r++){const n=Oi[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function fu(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&K.has(i))return K.get(i);const n=new M({source:du(r)});return n.on("destroy",()=>{K.has(i)&&K.remove(i)}),t||K.set(i,n),n}function pu(s,t=!1){return typeof s=="string"?K.get(s):s instanceof ut?new M({source:s}):fu(s,t)}M.from=pu,O.add(ta,ea,sa,ks,Ee,Pe,vi);var te=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(te||{});function Bt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function We(s){return s.split("?")[0].split("#")[0]}function mu(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gu(s,t,e){return s.replace(new RegExp(mu(t),"g"),e)}function _u(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o<s.length)a=s.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(r===o-1||n===1))if(r!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const mt={toPosix(s){return gu(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Bt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(Bt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=We(this.toPosix(t??L.get().getBaseUrl())),r=We(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?mt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Bt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=_u(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Bt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(Bt(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Bt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){Bt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Bt(s),t&&Bt(t),s=We(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){Bt(s),s=We(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){Bt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=We(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function aa(s,t,e,i,r){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?aa(s.replace(i[e],o),t,e+1,i,r):r.push(s.replace(i[e],o))}}function xu(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");r.push(a)}),aa(s,r,0,e,i)}else i.push(s);return i}const Is=s=>!Array.isArray(s);class Ce{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Mt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&D("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&D(`[Resolver] already has key: ${n} overwriting`)},Mt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=Mt(a).map(f=>typeof f=="string"?xu(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let g={};if(typeof p!="object"){g.src=p;for(let m=0;m<this._parsers.length;m++){const _=this._parsers[m];if(_.test(p)){g=_.parse(p);break}}}else o=p.data??o,h=p.format??h,c=p.loadParser??c,g={...g,...p};if(!u)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:u,data:o,format:h,loadParser:c}),d.push(g)})}),u.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=Is(t);t=Mt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Is(t);t=Mt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=mt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??yu(t.src),t}}Ce.RETINA_PREFIX=/@([0-9\.]+)x/;function yu(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Li=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},oa=class Ss{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof M?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ss.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Ss.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],a=n.frame;if(a){let o=null,h=null;const c=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,l=new Y(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);n.rotated?o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new Y(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new Y(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[r]=new M({source:this.textureSource,frame:o,orig:l,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ss.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ss.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};oa.BATCH_SIZE=1e3;let Hi=oa;const bu=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function ha(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=mt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=ha([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const vu={extension:b.Asset,cache:{test:s=>s instanceof Hi,getCacheableAssets:(s,t)=>ha(s,t,!1)},resolver:{test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&bu.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=Ce.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:b.LoadParser,priority:te.Normal},async testParse(s,t){return mt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=mt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof M)a=i;else{const u=Li(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Hi(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=Li(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};O.add(vu);class Ve{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ve.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new X,this.page=new X,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var Ni=/iPhone/i,ca=/iPod/i,la=/iPad/i,ua=/\biOS-universal(?:.+)Mac\b/i,zi=/\bAndroid(?:.+)Mobile\b/i,da=/Android/i,Me=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Fs=/Silk/i,Xt=/Windows Phone/i,fa=/\bWindows(?:.+)ARM\b/i,pa=/BlackBerry/i,ma=/BB10/i,ga=/Opera Mini/i,_a=/\b(CriOS|Chrome)(?:.+)Mobile/i,xa=/Mobile(?:.+)Firefox\b/i,ya=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function Su(s){return function(t){return t.test(s)}}function ba(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var r=Su(e),n={apple:{phone:r(Ni)&&!r(Xt),ipod:r(ca),tablet:!r(Ni)&&(r(la)||ya(t))&&!r(Xt),universal:r(ua),device:(r(Ni)||r(ca)||r(la)||r(ua)||ya(t))&&!r(Xt)},amazon:{phone:r(Me),tablet:!r(Me)&&r(Fs),device:r(Me)||r(Fs)},android:{phone:!r(Xt)&&r(Me)||!r(Xt)&&r(zi),tablet:!r(Xt)&&!r(Me)&&!r(zi)&&(r(Fs)||r(da)),device:!r(Xt)&&(r(Me)||r(Fs)||r(zi)||r(da))||r(/\bokhttp\b/i)},windows:{phone:r(Xt),tablet:r(fa),device:r(Xt)||r(fa)},other:{blackberry:r(pa),blackberry10:r(ma),opera:r(ga),firefox:r(xa),chrome:r(_a),device:r(pa)||r(ma)||r(ga)||r(xa)||r(_a)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const wu=(ba.default??ba)(globalThis.navigator),Tu=9,Gs=100,Au=0,Pu=0,va=2,Sa=1,Eu=-1e3,Cu=-1e3,Mu=2;class wa{constructor(t,e=wu){this._mobileInfo=e,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook();const i=document.createElement("div");i.style.width=`${Gs}px`,i.style.height=`${Gs}px`,i.style.position="absolute",i.style.top=`${Au}px`,i.style.left=`${Pu}px`,i.style.zIndex=va.toString(),this._div=i,this._renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width=`${Sa}px`,t.style.height=`${Sa}px`,t.style.position="absolute",t.style.top=`${Eu}px`,t.style.left=`${Cu}px`,t.style.zIndex=Mu.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(t=this._renderer.view.canvas.parentNode)==null||t.appendChild(this._div))}_deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(t=this._div.parentNode)==null||t.removeChild(this._div))}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){this.debug=(t==null?void 0:t.debug)??this.debug,this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas))return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);const{x:e,y:i,width:r,height:n}=this._renderer.view.canvas.getBoundingClientRect(),{width:a,height:o,resolution:h}=this._renderer,c=r/a*h,l=n/o*h;let u=this._div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${a}px`,u.style.height=`${o}px`;for(let d=0;d<this._children.length;d++){const f=this._children[d];if(f._renderId!==this._renderId)f._accessibleActive=!1,Wn(this._children,d,1),this._div.removeChild(f._accessibleDiv),this._pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(u.style.left=`${(g.tx+p.x*g.a)*c}px`,u.style.top=`${(g.ty+p.y*g.d)*l}px`,u.style.width=`${p.width*g.a*c}px`,u.style.height=`${p.height*g.d*l}px`):(p=f.getBounds().rectangle,this._capHitArea(p),u.style.left=`${p.x*c}px`,u.style.top=`${p.y*l}px`,u.style.width=`${p.width*c}px`,u.style.height=`${p.height*l}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle||""),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint||"")),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle||"",u.tabIndex=f.tabIndex,this.debug&&this._updateDebugHTML(u))}}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||(e=document.createElement("button"),e.style.width=`${Gs}px`,e.style.height=`${Gs}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=va.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{container:i}=t.target,r=this._renderer.events.rootBoundary,n=Object.assign(new Ve(r),{target:i});r.rootTarget=this._renderer.lastObjectRendered,e.forEach(a=>r.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Tu&&this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}wa.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};const Bu={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1},Wi=Object.create(null),Ta=Object.create(null);function Us(s,t){let e=Ta[s];return e===void 0&&(Wi[t]===void 0&&(Wi[t]=1),Ta[s]=e=Wi[t]++),e}let Be;function Aa(){return(!Be||Be!=null&&Be.isContextLost())&&(Be=L.get().createCanvas().getContext("webgl",{})),Be}let Ds;function Ru(){if(!Ds){Ds="mediump";const s=Aa();s&&s.getShaderPrecisionFormat&&(Ds=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Ds}function ku(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
        
        #ifdef GL_ES // This checks if it is WebGL1
        #define in varying
        #define finalColor gl_FragColor
        #define texture texture2D
        #endif
        ${s}
        `):`
        
        #ifdef GL_ES // This checks if it is WebGL1
        #define in attribute
        #define out varying
        #endif
        ${s}
        `}function Iu(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Fu(s,t){return t?`#version 300 es
${s}`:s}const Gu={},Uu={};function Du(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Gu:Uu;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
${s}`}function Ou(s,t){return t?s.replace("#version 300 es",""):s}const Vi={stripVersion:Ou,ensurePrecision:Iu,addProgramDefines:ku,setProgramName:Du,insertVersion:Fu},ji=Object.create(null),Pa=class _n{constructor(t){t={..._n.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ru()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(Vi).forEach(a=>{const o=i[a];r=Vi[a](r,o,!0),n=Vi[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=Us(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return ji[e]||(ji[e]=new _n(t)),ji[e]}};Pa.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let je=Pa;const Ea={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function $e(s){return Ea[s]??Ea.float32}const Lu={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Hu({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=Lu[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:$e(h).stride,offset:0,instance:!1,start:0}}}}return e}function $i(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="<uniform>",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],g=f.match(o).reduce((m,_)=>{const[x,y]=_.split(":");return m[x.trim()]=y.trim(),m},{});return g?{name:p,members:g}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var Xe=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Xe||{});function Nu({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Xe.VERTEX|Xe.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Xe.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Xe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function zu({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Wu(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const Xi=Object.create(null);class Re{constructor(t){var o,h;this._layoutKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=$i(e.source);this.structsAndGroups=c}else{const c=$i(i.source),l=$i(e.source);this.structsAndGroups=Wu(c,l)}this.layout=r??zu(this.structsAndGroups),this.gpuLayout=n??Nu(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Us(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Hu(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Xi[e]||(Xi[e]=new Re(t)),Xi[e]}}const Ca=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>"],Vu=Ca.reduce((s,t)=>(s[t]=!0,s),{});function ju(s,t){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ma=class ml{constructor(t,e){this._touched=0,this.uid=et("uniform"),this._resourceType="uniformGroup",this._resourceId=et("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...ml.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Vu[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Ca.join(", ")}`);n.value??(n.value=ju(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Us(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ma.defaultOptions={ubo:!1,isStatic:!1};let _t=Ma;class Yt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Lt=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Lt||{});class Tt extends gt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Lt.WEBGPU),i&&(a|=Lt.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&o)for(const c in o)for(const l in o[c]){const u=o[c][l];h[u]={group:c,binding:l,name:u}}else if(e&&r&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else if(n){if(e){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else{o={},r={99:new Yt},this._ownedBindGroups.push(r[99]);let c=0;for(const l in n)h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++}r={};for(const c in n){const l=c;let u=n[c];!u.source&&!u._resourceType&&(u=new _t(u));const d=h[l];d&&(r[d.group]||(r[d.group]=new Yt,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(u,d.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Yt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=Re.from(e)),i&&(a=je.from(i)),new Tt({gpuProgram:n,glProgram:a,...r})}}const $u={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8},Yi=0,Ki=1,qi=2,Zi=3,Ji=4,Qi=5,tr=class gl{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Yi)}set blend(t){!!(this.data&1<<Yi)!==t&&(this.data^=1<<Yi)}get offsets(){return!!(this.data&1<<Ki)}set offsets(t){!!(this.data&1<<Ki)!==t&&(this.data^=1<<Ki)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<qi)}set culling(t){!!(this.data&1<<qi)!==t&&(this.data^=1<<qi)}get depthTest(){return!!(this.data&1<<Zi)}set depthTest(t){!!(this.data&1<<Zi)!==t&&(this.data^=1<<Zi)}get depthMask(){return!!(this.data&1<<Qi)}set depthMask(t){!!(this.data&1<<Qi)!==t&&(this.data^=1<<Qi)}get clockwiseFrontFace(){return!!(this.data&1<<Ji)}set clockwiseFrontFace(t){!!(this.data&1<<Ji)!==t&&(this.data^=1<<Ji)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=$u[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new gl;return t.depthTest=!1,t.blend=!0,t}};tr.default2d=tr.for2d();let Kt=tr;const Ba=class xn extends Tt{constructor(t){t={...xn.defaultOptions,...t},super(t),this.enabled=!0,this._state=Kt.for2d(),this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.addResource("uTexture",0,1)}apply(t,e,i,r){t.applyFilter(this,e,i,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=Re.from(e)),i&&(a=je.from(i)),new xn({gpuProgram:n,glProgram:a,...r})}};Ba.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let Xu=Ba;const er=[];O.handleByNamedList(b.Environment,er);async function Yu(s){if(s)for(let t=0;t<er.length;t++){const e=er[t];if(e.value.test()){await e.value.load();return}}}let Ye;function Ra(){if(typeof Ye=="boolean")return Ye;try{Ye=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Ye=!1}return Ye}var sr={exports:{}};sr.exports=Os,sr.exports.default=Os;function Os(s,t,e){e=e||2;var i=t&&t.length,r=i?t[0]*e:s.length,n=ka(s,0,r,e,!0),a=[];if(!n||n.next===n.prev)return a;var o,h,c,l,u,d,f;if(i&&(n=Qu(s,t,n,e)),s.length>80*e){o=c=s[0],h=l=s[1];for(var p=e;p<r;p+=e)u=s[p],d=s[p+1],u<o&&(o=u),d<h&&(h=d),u>c&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return Ke(n,a,e,o,h,f,0),a}function ka(s,t,e,i,r){var n,a;if(r===nr(s,t,e,i)>0)for(n=t;n<e;n+=i)a=Ga(n,s[n],s[n+1],a);else for(n=e-i;n>=t;n-=i)a=Ga(n,s[n],s[n+1],a);return a&&Ls(a,a.next)&&(Ze(a),a=a.next),a}function fe(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(Ls(e,e.next)||st(e.prev,e,e.next)===0)){if(Ze(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ke(s,t,e,i,r,n,a){if(s){!a&&n&&rd(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?qu(s,i,r,n):Ku(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),Ze(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Zu(fe(s),t,e),Ke(s,t,e,i,r,n,2)):a===2&&Ju(s,t,e,i,r,n):Ke(fe(s),t,e,i,r,n,1);break}}}}function Ku(s){var t=s.prev,e=s,i=s.next;if(st(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=r<n?r<a?r:a:n<a?n:a,u=o<h?o<c?o:c:h<c?h:c,d=r>n?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&ke(r,o,n,h,a,c,p.x,p.y)&&st(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function qu(s,t,e,i){var r=s.prev,n=s,a=s.next;if(st(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=o<h?o<c?o:c:h<c?h:c,p=l<u?l<d?l:d:u<d?u:d,g=o>h?o>c?o:c:h>c?h:c,m=l>u?l>d?l:d:u>d?u:d,_=ir(f,p,t,e,i),x=ir(g,m,t,e,i),y=s.prevZ,v=s.nextZ;y&&y.z>=_&&v&&v.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&ke(o,l,h,u,c,d,y.x,y.y)&&st(y.prev,y,y.next)>=0||(y=y.prevZ,v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&ke(o,l,h,u,c,d,v.x,v.y)&&st(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&ke(o,l,h,u,c,d,y.x,y.y)&&st(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=g&&v.y>=p&&v.y<=m&&v!==r&&v!==a&&ke(o,l,h,u,c,d,v.x,v.y)&&st(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Zu(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!Ls(r,n)&&Ia(r,i,i.next,n)&&qe(r,n)&&qe(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Ze(i),Ze(i.next),i=s=n),i=i.next}while(i!==s);return fe(i)}function Ju(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&od(a,o)){var h=Fa(a,o);a=fe(a,a.next),h=fe(h,h.next),Ke(a,t,e,i,r,n,0),Ke(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Qu(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n<a;n++)o=t[n]*i,h=n<a-1?t[n+1]*i:s.length,c=ka(s,o,h,i,!1),c===c.next&&(c.steiner=!0),r.push(ad(c));for(r.sort(td),n=0;n<r.length;n++)e=ed(r[n],e);return e}function td(s,t){return s.x-t.x}function ed(s,t){var e=sd(s,t);if(!e)return t;var i=Fa(e,s);return fe(i,i.next),fe(e,e.next)}function sd(s,t){var e=t,i=s.x,r=s.y,n=-1/0,a;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=i&&o>n&&(n=o,a=e.x<e.next.x?e:e.next,o===i))return a}e=e.next}while(e!==t);if(!a)return null;var h=a,c=a.x,l=a.y,u=1/0,d;e=a;do i>=e.x&&e.x>=c&&i!==e.x&&ke(r<l?i:n,r,c,l,r<l?n:i,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(i-e.x),qe(e,s)&&(d<u||d===u&&(e.x>a.x||e.x===a.x&&id(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function id(s,t){return st(s.prev,s,t.prev)<0&&st(t.next,s,s.next)<0}function rd(s,t,e,i){var r=s;do r.z===0&&(r.z=ir(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,nd(r)}function nd(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t<c&&(o++,i=i.nextZ,!!i);t++);for(h=c;o>0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function ir(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function ad(s){var t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function ke(s,t,e,i,r,n,a,o){return(r-a)*(t-o)>=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function od(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!hd(s,t)&&(qe(s,t)&&qe(t,s)&&cd(s,t)&&(st(s.prev,s,t.prev)||st(s,t.prev,t))||Ls(s,t)&&st(s.prev,s,s.next)>0&&st(t.prev,t,t.next)>0)}function st(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Ls(s,t){return s.x===t.x&&s.y===t.y}function Ia(s,t,e,i){var r=Ns(st(s,t,e)),n=Ns(st(s,t,i)),a=Ns(st(e,i,s)),o=Ns(st(e,i,t));return!!(r!==n&&a!==o||r===0&&Hs(s,e,t)||n===0&&Hs(s,i,t)||a===0&&Hs(e,s,i)||o===0&&Hs(e,t,i))}function Hs(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Ns(s){return s>0?1:s<0?-1:0}function hd(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Ia(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function qe(s,t){return st(s.prev,s,s.next)<0?st(s,t,s.next)>=0&&st(s,s.prev,t)>=0:st(s,t,s.prev)<0||st(s,s.next,t)<0}function cd(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function Fa(s,t){var e=new rr(s.i,s.x,s.y),i=new rr(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Ga(s,t,e,i){var r=new rr(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ze(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function rr(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Os.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(nr(s,0,n,e));if(r)for(var o=0,h=t.length;o<h;o++){var c=t[o]*e,l=o<h-1?t[o+1]*e:s.length;a-=Math.abs(nr(s,c,l,e))}var u=0;for(o=0;o<i.length;o+=3){var d=i[o]*e,f=i[o+1]*e,p=i[o+2]*e;u+=Math.abs((s[d]-s[p])*(s[f+1]-s[d+1])-(s[d]-s[f])*(s[p+1]-s[d+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function nr(s,t,e,i){for(var r=0,n=t,a=e-i;n<e;n+=i)r+=(s[a]-s[n])*(s[n+1]+s[a+1]),a=n;return r}Os.flatten=function(s){for(var t=s[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,r=0;r<s.length;r++){for(var n=0;n<s[r].length;n++)for(var a=0;a<t;a++)e.vertices.push(s[r][n][a]);r>0&&(i+=s[r-1].length,e.holes.push(i))}return e};var ld=sr.exports;const ud=_i(ld);var xt=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(xt||{});class Ua{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](t,e,i,r,n,a,o,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const dd=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Da=class _l extends gt{constructor(t){super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name;const e=[...dd,...t.runners??[]];this._addRunners(...e),this._addSystems(t.systems),this._addPipes(t.renderPipes,t.renderPipeAdaptors),this._unsafeEvalCheck()}async init(t={}){for(const e in this._systemsHash)t={...this._systemsHash[e].constructor.defaultOptions,...t};t={..._l.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let e=0;e<this.runners.init.items.length;e++)await this.runners.init.items[e].init(t);this._initOptions=t}render(t,e){let i=t;if(i instanceof z&&(i={container:i},e&&(N(W,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor=this.background.colorRgba),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:j.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(t,e,i){this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=xt.ALL);const{clear:i,clearColor:r,target:n}=t;j.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,j.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Ua(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[a];this.renderPipes[a]=new n(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ra())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Da.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let zs=Da,Ws;function fd(s){return Ws!==void 0||(Ws=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??zs.defaultOptions.failIfMajorPerformanceCaveat};try{if(!L.get().getWebGLRenderingContext())return!1;let r=L.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),Ws}let Vs;async function pd(s={}){return Vs!==void 0||(Vs=await(async()=>{if(!L.get().getNavigator().gpu)return!1;try{return await(await navigator.gpu.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Vs}const Oa=["webgl","webgpu","canvas"];async function md(s){let t=[];s.preference?(t.push(s.preference),Oa.forEach(n=>{n!==s.preference&&t.push(n)})):t=Oa.slice();let e;await Yu(s.manageImports??!0);let i={};for(let n=0;n<t.length;n++){const a=t[n];if(a==="webgpu"&&await pd()){const{WebGPURenderer:o}=await Promise.resolve().then(()=>Tg);e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&fd(s.failIfMajorPerformanceCaveat??zs.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await Promise.resolve().then(()=>ng);e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}class La{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}La.extension=b.Application;class Ha{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,de.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ht.shared:new ht,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Ha.extension=b.Application;class gd{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const _d={extension:b.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof M),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function Na(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const xd={extension:{type:b.DetectionParser,priority:1},test:async()=>Na("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},za=["png","jpg","jpeg"],yd={extension:{type:b.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...za],remove:async s=>s.filter(t=>!za.includes(t))},bd="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ar(s){return bd?!1:document.createElement("video").canPlayType(s)!==""}const vd={extension:{type:b.DetectionParser,priority:0},test:async()=>ar("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},Sd={extension:{type:b.DetectionParser,priority:0},test:async()=>ar("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},wd={extension:{type:b.DetectionParser,priority:0},test:async()=>ar("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Td={extension:{type:b.DetectionParser,priority:0},test:async()=>Na("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class Ad{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||D(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];if(c.load&&((a=c.test)!=null&&a.call(c,t,e,this))){n=c;break}}if(!n)return D(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let h=0;h<this.parsers.length;h++){const c=this.parsers[h];c.parse&&c.parse&&await((o=c.testParse)==null?void 0:o.call(c,r,e,this))&&(r=await c.parse(r,e,this)||r,i.parser=c)}return r})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=Is(t),a=Mt(t,c=>({alias:[c],src:c})),o=a.length,h=a.map(async c=>{const l=mt.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}.
${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=Mt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=mt.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&D(`[Assets] loadParser name conflict "${e.name}"`):D("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ie(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function Fe(s,t){const e=s.split("?")[0],i=mt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Pd=".json",Ed="application/json",Cd={extension:{type:b.LoadParser,priority:te.Low},name:"loadJson",test(s){return Ie(s,Ed)||Fe(s,Pd)},async load(s){return await(await L.get().fetch(s)).json()}},Md=".txt",Bd="text/plain",Rd={name:"loadTxt",extension:{type:b.LoadParser,priority:te.Low},test(s){return Ie(s,Bd)||Fe(s,Md)},async load(s){return await(await L.get().fetch(s)).text()}},kd=["normal","bold","100","200","300","400","500","600","700","800","900"],Id=[".ttf",".otf",".woff",".woff2"],Fd=["font/ttf","font/otf","font/woff","font/woff2"],Gd=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Ud(s){const t=mt.extname(s),r=mt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(Gd)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Dd=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Od(s){return Dd.test(s)?s:encodeURI(s)}const Ld={extension:{type:b.LoadParser,priority:te.Low},name:"loadWebFont",test(s){return Ie(s,Fd)||Fe(s,Id)},async load(s,t){var i,r,n;const e=L.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Ud(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>kd.includes(l)))??["normal"],c=t.data??{};for(let l=0;l<h.length;l++){const u=h[l],d=new FontFace(o,`url(${Od(s)})`,{...c,weight:u});await d.load(),e.add(d),a.push(d)}return K.set(`${o}-and-url`,{url:s,fontFaces:a}),a.length===1?a[0]:a}return D("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>{K.remove(t.family),L.get().getFontFaceSet().delete(t)})}};var Hd=zd,or={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Nd=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function zd(s){var t=[];return s.replace(Nd,function(e,i,r){var n=i.toLowerCase();for(r=Vd(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==or[n])return r.unshift(i),t.push(r);if(r.length<or[n])throw new Error("malformed path data");t.push([i].concat(r.splice(0,or[n])))}}),t}var Wd=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Vd(s){var t=s.match(Wd);return t?t.map(Number):[]}const jd=_i(Hd);function $d(s,t){const e=jd(s),i=[];let r=null,n=0,a=0;for(let o=0;o<e.length;o++){const h=e[o],c=h[0],l=h;switch(c){case"M":n=l[1],a=l[2],t.moveTo(n,a);break;case"m":n+=l[1],a+=l[2],t.moveTo(n,a);break;case"H":n=l[1],t.lineTo(n,a);break;case"h":n+=l[1],t.lineTo(n,a);break;case"V":a=l[1],t.lineTo(n,a);break;case"v":a+=l[1],t.lineTo(n,a);break;case"L":n=l[1],a=l[2],t.lineTo(n,a);break;case"l":n+=l[1],a+=l[2],t.lineTo(n,a);break;case"C":n=l[5],a=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],n,a);break;case"c":t.bezierCurveTo(n+l[1],a+l[2],n+l[3],a+l[4],n+l[5],a+l[6]),n+=l[5],a+=l[6];break;case"S":n=l[3],a=l[4],t.bezierCurveToShort(l[1],l[2],n,a);break;case"s":t.bezierCurveToShort(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"Q":n=l[3],a=l[4],t.quadraticCurveTo(l[1],l[2],n,a);break;case"q":t.quadraticCurveTo(n+l[1],a+l[2],n+l[3],a+l[4]),n+=l[3],a+=l[4];break;case"T":n=l[1],a=l[2],t.quadraticCurveToShort(n,a);break;case"t":n+=l[1],a+=l[2],t.quadraticCurveToShort(n,a);break;case"A":n=l[6],a=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"a":n+=l[6],a+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],n,a);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:D(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class hr{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new hr(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return h<a+o&&h>a-o}getBounds(t){return t=t||new Y,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class cr{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new cr(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(){return new Y(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Xd(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const g=s-f,m=t-p;return g*g+m*m}class Je{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.closePath=!0}clone(){const t=this.points.slice(),e=new Je(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,a=r-1;n<r;a=n++){const o=this.points[n*2],h=this.points[n*2+1],c=this.points[a*2],l=this.points[a*2+1];h>e!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const r=i/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;h<o;h+=2){const c=a[h],l=a[h+1],u=a[(h+2)%a.length],d=a[(h+3)%a.length];if(Xd(t,e,c,l,u,d)<=n)return!0}return!1}getBounds(t){t=t||new Y;const e=this.points;let i=1/0,r=-1/0,n=1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=2){const c=e[o],l=e[o+1];i=c<i?c:i,r=c>r?c:r,n=l<n?l:n,a=l>a?l:a}return t.x=i,t.width=r-i,t.y=n,t.height=a-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const js=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class lr{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new Y,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new lr(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,g=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=g-c&&e<=g+c)&&t>=l&&t<=l+d?!0:t<l&&e<u&&js(t,e,l,u,h,c)||t>p-h&&e<u&&js(t,e,p-h,u,h,c)||t>p-h&&e>g-h&&js(t,e,p-h,g-h,h,c)||t<l&&e>g-h&&js(t,e,l,g-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}var V=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(V||{});class Rt extends gt{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=et("buffer"),this._resourceType="buffer",this._resourceId=et("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&V.STATIC)}set static(t){t?this.descriptor.usage|=V.STATIC:this.descriptor.usage&=~V.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=et("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Wa(s,t){if(!(s instanceof Rt)){let e=t?V.INDEX:V.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=V.INDEX|V.COPY_DST):(s=new Float32Array(s),e=V.VERTEX|V.COPY_DST)),s=new Rt({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Yd(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,a=1/0,o=-1/0,h=-1/0;const c=r.BYTES_PER_ELEMENT,l=(i.offset||0)/c,u=(i.stride||2*4)/c;for(let d=l;d<r.length;d+=u){const f=r[d],p=r[d+1];f>o&&(o=f),p>h&&(h=p),f<n&&(n=f),p<a&&(a=p)}return e.minX=n,e.minY=a,e.maxX=o,e.maxY=h,e}function Kd(s){return(s instanceof Rt||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Wa(s.buffer,!1),s}class $s extends gt{constructor(t){const{attributes:e,indexBuffer:i,topology:r}=t;super(),this.uid=et("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new pt,this._boundsDirty=!0,this.attributes=e,this.buffers=[],this.instanceCount=t.instanceCount||1;for(const n in e){const a=e[n]=Kd(e[n]);this.buffers.indexOf(a.buffer)===-1&&(this.buffers.push(a.buffer),a.buffer.on("update",this.onBufferUpdate,this),a.buffer.on("change",this.onBufferUpdate,this))}i&&(this.indexBuffer=Wa(i,!0),this.buffers.push(this.indexBuffer)),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Yd(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const qd=new Float32Array(1),Zd=new Uint32Array(1);class Va extends $s{constructor(){const e=new Rt({data:qd,label:"attribute-batch-buffer",usage:V.VERTEX|V.COPY_DST,shrinkToFit:!1}),i=new Rt({data:Zd,label:"index-batch-buffer",usage:V.INDEX|V.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0,location:1},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4,location:3},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4,location:0},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4,location:2}},indexBuffer:i})}}let Xs=null;function Ht(){if(Xs)return Xs;const s=Aa();return Xs=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Xs}const ja={};function ur(s,t){let e=0;for(let i=0;i<t;i++)e=e*31+s[i].uid>>>0;return ja[e]||Jd(s,e)}let dr=0;function Jd(s,t){const e={};let i=0;dr||(dr=Ht());for(let n=0;n<dr;n++){const a=n<s.length?s[n]:M.EMPTY.source;e[i++]=a.source,e[i++]=a.style}const r=new Yt(e);return ja[t]=r,r}class $a{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function fr(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const Qd={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ct=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(ct||{});function Xa(s,t){return t.alphaMode==="no-premultiply-alpha"&&Qd[s]||s}class Ya{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class Ka{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}let Qe=0;const qa=class xl{constructor(t={}){this.uid=et("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],this._batchPool=[],this._batchPoolIndex=0,this._textureBatchPool=[],this._textureBatchPoolIndex=0,t={...xl.defaultOptions,...t};const{vertexSize:e,indexSize:i}=t;this.attributeBuffer=new $a(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(i),this._maxTextures=Ht()}begin(){this.batchIndex=0,this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0,this._batchPoolIndex=0,this._textureBatchPoolIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t.indexStart=this.indexSize,t.location=this.attributeSize,t.batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.vertexSize*this._vertexSize}checkAndUpdateTexture(t,e){const i=t.batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t.textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0,t.packAttributes(this.attributeBuffer.float32View,this.attributeBuffer.uint32View,t.location,t.textureId)}break(t){const e=this._elements;let i=this._textureBatchPool[this._textureBatchPoolIndex++]||new Ya;if(i.clear(),!e[this.elementStart])return;const r=e[this.elementStart];let n=Xa(r.blendMode,r.texture._source);this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,o=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,l=this._batchIndexStart,u="startBatch",d=this._batchPool[this._batchPoolIndex++]||new Ka;const f=this._maxTextures;for(let p=this.elementStart;p<this.elementSize;++p){const g=e[p];e[p]=null;const _=g.texture._source,x=Xa(g.blendMode,_),y=n!==x;if(_._batchTick===Qe&&!y){g.textureId=_._textureBindLocation,c+=g.indexSize,g.packAttributes(a,o,g.location,g.textureId),g.packIndex(h,g.indexStart,g.location/this._vertexSize),g.batch=d;continue}_._batchTick=Qe,(i.count>=f||y)&&(this._finishBatch(d,l,c-l,i,n,t,u),u="renderBatch",l=c,n=x,i=this._textureBatchPool[this._textureBatchPoolIndex++]||new Ya,i.clear(),d=this._batchPool[this._batchPoolIndex++]||new Ka,++Qe),g.textureId=_._textureBindLocation=i.count,i.ids[_.uid]=i.count,i.textures[i.count++]=_,g.batch=d,c+=g.indexSize,g.packAttributes(a,o,g.location,g.textureId),g.packIndex(h,g.indexStart,g.location/this._vertexSize)}i.count>0&&(this._finishBatch(d,l,c-l,i,n,t,u),l=c,++Qe),this.elementStart=this.elementSize,this._batchIndexStart=l,this._batchIndexSize=c}_finishBatch(t,e,i,r,n,a,o){t.gpuBindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=i,++Qe,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new $a(e);fr(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else fr(e.buffer,r.buffer);this.indexBuffer=r}destroy(){for(let t=0;t<this.batches.length;t++)this.batches[t].destroy();this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t].batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};qa.defaultOptions={vertexSize:4,indexSize:6};let Za=qa;function tf(s,t,e,i,r,n,a,o=null){let h=0;e*=t,r*=n;const c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty;for(;h<a;){const g=s[e],m=s[e+1];i[r]=c*g+u*m+f,i[r+1]=l*g+d*m+p,r+=n,e+=t,h++}}function ef(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++}function Ja(s,t,e,i,r){const n=t.a,a=t.b,o=t.c,h=t.d,c=t.tx,l=t.ty;e=e||0,i=i||2,r=r||s.length/i-e;let u=e*i;for(let d=0;d<r;d++){const f=s[u],p=s[u+1];s[u]=n*f+o*p+c,s[u+1]=a*f+h*p+l,u+=i}}function sf(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}class pr{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}packIndex(t,e,i){const r=this.geometryData.indices;for(let n=0;n<this.indexSize;n++)t[e++]=r[n+this.indexOffset]+i-this.vertexOffset}packAttributes(t,e,i,r){const n=this.geometryData,a=this.renderable,o=n.vertices,h=n.uvs,c=this.vertexOffset*2,l=(this.vertexOffset+this.vertexSize)*2,u=this.color,d=u>>16|u&65280|(u&255)<<16;if(this.applyTransform){const f=sf(d,a.groupColor)+(this.alpha*a.groupAlpha*255<<24),p=a.groupTransform,g=r<<16|this.roundPixels&65535,m=p.a,_=p.b,x=p.c,y=p.d,v=p.tx,w=p.ty;for(let C=c;C<l;C+=2){const E=o[C],P=o[C+1];t[i]=m*E+x*P+v,t[i+1]=_*E+y*P+w,t[i+2]=h[C],t[i+3]=h[C+1],e[i+4]=f,e[i+5]=g,i+=6}}else{const f=d+(this.alpha*255<<24);for(let p=c;p<l;p+=2)t[i]=o[p],t[i+1]=o[p+1],t[i+2]=h[p],t[i+3]=h[p+1],e[i+4]=f,e[i+5]=r<<16,i+=6}}get vertSize(){return this.vertexSize}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.vertexOffset=this.vertexOffset,t.vertexSize=this.vertexSize,t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const mr={build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const v=s;e=v.x,i=v.y,a=o=v.radius,r=n=0}else if(s.type==="ellipse"){const v=s;e=v.x,i=v.y,a=v.halfWidth,o=v.halfHeight,r=n=0}else{const v=s,w=v.width/2,C=v.height/2;e=v.x+w,i=v.y+C,a=o=Math.max(0,Math.min(v.radius,Math.min(w,C))),r=w-a,n=C-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,g=n,m=e+p,_=e-p,x=i+g;if(t[l++]=m,t[l++]=x,t[--u]=x,t[--u]=_,n){const v=i-g;t[d++]=_,t[d++]=v,t[--f]=v,t[--f]=m}for(let v=1;v<h;v++){const w=Math.PI/2*(v/h),C=r+Math.cos(w)*a,E=n+Math.sin(w)*o,P=e+C,S=e-C,A=i+E,Q=i-E;t[l++]=P,t[l++]=A,t[--u]=A,t[--u]=S,t[d++]=S,t[d++]=Q,t[--f]=Q,t[--f]=P}p=r,g=n+o,m=e+p,_=e-p,x=i+g;const y=i-g;return t[l++]=m,t[l++]=x,t[--f]=y,t[--f]=m,r&&(t[l++]=_,t[l++]=x,t[--f]=y,t[--f]=_),t},triangulate(s,t,e,i,r,n){if(s.length===0)return;let a=0,o=0;for(let l=0;l<s.length;l+=2)a+=s[l],o+=s[l+1];a/=s.length/2,o/=s.length/2;let h=i;t[h*e]=a,t[h*e+1]=o;const c=h++;for(let l=0;l<s.length;l+=2)t[h*e]=s[l],t[h*e+1]=s[l+1],l>0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},rf=1e-4,Qa=1e-4;function nf(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const a=s[i],o=s[i+1];e+=(a-r)*(o+n),r=a,n=o}return e<0?-1:1}function to(s,t,e,i,r,n,a,o){const h=s-e*r,c=t-i*r,l=s+e*n,u=t+i*n;let d,f;a?(d=i,f=-e):(d=-i,f=e);const p=h+d,g=c+f,m=l+d,_=u+f;return o.push(p,g),o.push(m,_),2}function pe(s,t,e,i,r,n,a,o){const h=e-s,c=i-t;let l=Math.atan2(h,c),u=Math.atan2(r-s,n-t);o&&l<u?l+=Math.PI*2:!o&&l>u&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),g=Math.sqrt(h*h+c*c),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/m;if(d+=_,o){a.push(s,t),a.push(e,i);for(let x=1,y=d;x<m;x++,y+=_)a.push(s,t),a.push(s+Math.sin(y)*g,t+Math.cos(y)*g);a.push(s,t),a.push(r,n)}else{a.push(e,i),a.push(s,t);for(let x=1,y=d;x<m;x++,y+=_)a.push(s+Math.sin(y)*g,t+Math.cos(y)*g),a.push(s,t);a.push(r,n),a.push(s,t)}return m*2}function af(s,t,e,i,r,n,a,o,h){const c=rf;if(s.length===0)return;const l=t;let u=l.alignment;if(t.alignment!==.5){let Z=nf(s);u=(u-.5)*Z+.5}const d=new X(s[0],s[1]),f=new X(s[s.length-2],s[s.length-1]),p=i,g=Math.abs(d.x-f.x)<c&&Math.abs(d.y-f.y)<c;if(p){s=s.slice(),g&&(s.pop(),s.pop(),f.set(s[s.length-2],s[s.length-1]));const Z=(d.x+f.x)*.5,oe=(f.y+d.y)*.5;s.unshift(Z,oe),s.push(Z,oe)}const m=r,_=s.length/2;let x=s.length;const y=m.length/2,v=l.width/2,w=v*v,C=l.miterLimit*l.miterLimit;let E=s[0],P=s[1],S=s[2],A=s[3],Q=0,Ct=0,F=-(P-A),B=E-S,q=0,rt=0,bt=Math.sqrt(F*F+B*B);F/=bt,B/=bt,F*=v,B*=v;const gs=u,G=(1-gs)*2,U=gs*2;p||(l.cap==="round"?x+=pe(E-F*(G-U)*.5,P-B*(G-U)*.5,E-F*G,P-B*G,E+F*U,P+B*U,m,!0)+2:l.cap==="square"&&(x+=to(E,P,F,B,G,U,!0,m))),m.push(E-F*G,P-B*G),m.push(E+F*U,P+B*U);for(let Z=1;Z<_-1;++Z){E=s[(Z-1)*2],P=s[(Z-1)*2+1],S=s[Z*2],A=s[Z*2+1],Q=s[(Z+1)*2],Ct=s[(Z+1)*2+1],F=-(P-A),B=E-S,bt=Math.sqrt(F*F+B*B),F/=bt,B/=bt,F*=v,B*=v,q=-(A-Ct),rt=S-Q,bt=Math.sqrt(q*q+rt*rt),q/=bt,rt/=bt,q*=v,rt*=v;const oe=S-E,_s=P-A,xs=S-Q,ys=Ct-A,hl=oe*xs+_s*ys,pi=_s*xs-ys*oe,bs=pi<0;if(Math.abs(pi)<.001*Math.abs(hl)){m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),hl>=0&&(l.join==="round"?x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-rt*G,m,!1)+4:x+=2,m.push(S-q*U,A-rt*U),m.push(S+q*G,A+rt*G));continue}const cl=(-F+E)*(-B+A)-(-F+S)*(-B+P),ll=(-q+Q)*(-rt+A)-(-q+S)*(-rt+Ct),mi=(oe*ll-xs*cl)/pi,gi=(ys*cl-_s*ll)/pi,gn=(mi-S)*(mi-S)+(gi-A)*(gi-A),be=S+(mi-S)*G,ve=A+(gi-A)*G,Se=S-(mi-S)*U,we=A-(gi-A)*U,px=Math.min(oe*oe+_s*_s,xs*xs+ys*ys),ul=bs?G:U,mx=px+ul*ul*w;gn<=mx?l.join==="bevel"||gn/w>C?(bs?(m.push(be,ve),m.push(S+F*U,A+B*U),m.push(be,ve),m.push(S+q*U,A+rt*U)):(m.push(S-F*G,A-B*G),m.push(Se,we),m.push(S-q*G,A-rt*G),m.push(Se,we)),x+=2):l.join==="round"?bs?(m.push(be,ve),m.push(S+F*U,A+B*U),x+=pe(S,A,S+F*U,A+B*U,S+q*U,A+rt*U,m,!0)+4,m.push(be,ve),m.push(S+q*U,A+rt*U)):(m.push(S-F*G,A-B*G),m.push(Se,we),x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-rt*G,m,!1)+4,m.push(S-q*G,A-rt*G),m.push(Se,we)):(m.push(be,ve),m.push(Se,we)):(m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),l.join==="round"?bs?x+=pe(S,A,S+F*U,A+B*U,S+q*U,A+rt*U,m,!0)+2:x+=pe(S,A,S-F*G,A-B*G,S-q*G,A-rt*G,m,!1)+2:l.join==="miter"&&gn/w<=C&&(bs?(m.push(Se,we),m.push(Se,we)):(m.push(be,ve),m.push(be,ve)),x+=2),m.push(S-q*G,A-rt*G),m.push(S+q*U,A+rt*U),x+=2)}E=s[(_-2)*2],P=s[(_-2)*2+1],S=s[(_-1)*2],A=s[(_-1)*2+1],F=-(P-A),B=E-S,bt=Math.sqrt(F*F+B*B),F/=bt,B/=bt,F*=v,B*=v,m.push(S-F*G,A-B*G),m.push(S+F*U,A+B*U),p||(l.cap==="round"?x+=pe(S-F*(G-U)*.5,A-B*(G-U)*.5,S-F*G,A-B*G,S+F*U,A+B*U,m,!1)+2:l.cap==="square"&&(x+=to(S,A,F,B,G,U,!1,m)));const fx=Qa*Qa;for(let Z=y;Z<x+y-2;++Z)E=m[Z*2],P=m[Z*2+1],S=m[(Z+1)*2],A=m[(Z+1)*2+1],Q=m[(Z+2)*2],Ct=m[(Z+2)*2+1],!(Math.abs(E*(A-Ct)+S*(Ct-P)+Q*(P-A))<fx)&&o.push(Z,Z+1,Z+2)}function eo(s,t,e,i,r,n,a){const o=ud(s,t,2);if(!o)return;for(let c=0;c<o.length;c+=3)n[a++]=o[c]+r,n[a++]=o[c+1]+r,n[a++]=o[c+2]+r;let h=r*i;for(let c=0;c<s.length;c+=2)e[h]=s[c],e[h+1]=s[c+1],h+=i}const of=[],gr={rectangle:{build(s,t){const e=s,i=e.x,r=e.y,n=e.width,a=e.height;return n>=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},polygon:{build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return t},triangulate(s,t,e,i,r,n){eo(s,of,t,e,i,r,n)}},triangle:{build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},circle:mr,ellipse:mr,roundedRectangle:mr},hf=new Y;function cf(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")lf(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const a=n.action==="stroke",o=n.data.path.shapePath,h=n.data.style,c=n.data.hole;a&&c&&so(c.shapePath,h,null,!0,i,e),so(o,h,c,a,i,e)}}}function lf(s,t,e){const{vertices:i,uvs:r,indices:n}=e,a=n.length,o=i.length/2,h=[],c=gr.rectangle,l=hf,u=s.image;l.x=s.dx,l.y=s.dy,l.width=s.dw,l.height=s.dh;const d=s.transform;c.build(l,h),d&&Ja(h,d),c.triangulate(h,i,2,o,n,a);const f=u.uvs;r.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=$.get(pr);p.indexOffset=a,p.indexSize=n.length-a,p.vertexOffset=o,p.vertexSize=i.length/2-o,p.color=s.style,p.alpha=s.alpha,p.texture=u,p.geometryData=e,t.push(p)}function so(s,t,e,i,r,n){const{vertices:a,uvs:o,indices:h}=n,c=s.shapePrimitives.length-1;s.shapePrimitives.forEach(({shape:l,transform:u},d)=>{const f=h.length,p=a.length/2,g=[],m=gr[l.type];if(m.build(l,g),u&&Ja(g,u),i){const v=l.closePath??!0;af(g,t,!1,v,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const v=[],w=g.slice();uf(e.shapePath).forEach(E=>{v.push(w.length/2),w.push(...E)}),eo(w,v,a,2,p,h,f)}else m.triangulate(g,a,2,p,h,f);const _=o.length/2,x=t.texture;if(x!==M.WHITE){const v=t.matrix;u&&v.append(u.clone().invert()),tf(a,2,p,o,_,2,a.length/2-p,v)}else ef(o,_,2,a.length/2-p);const y=$.get(pr);y.indexOffset=f,y.indexSize=h.length-f,y.vertexOffset=p,y.vertexSize=a.length/2-p,y.color=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=n,r.push(y)})}function uf(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i<t.length;i++){const r=t[i].shape,n=[];gr[r.type].build(r,n),e.push(n)}return e}class df{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class ff{constructor(){this.geometry=new Va,this.instructions=new Kn}init(){this.instructions.reset()}}const _r=class yn{constructor(){this._activeBatchers=[],this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){yn.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??yn.defaultOptions.bezierSmoothness}prerender(){this._returnActiveBatchers()}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),cf(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_returnActiveBatchers(){for(let t=0;t<this._activeBatchers.length;t++)$.return(this._activeBatchers[t]);this._activeBatchers.length=0}_initContextRenderData(t){const e=$.get(ff),{batches:i,geometryData:r}=this._gpuContextHash[t.uid],n=r.vertices.length,a=r.indices.length;for(let l=0;l<i.length;l++)i[l].applyTransform=!1;const o=$.get(Za);this._activeBatchers.push(o),o.ensureAttributeBuffer(n),o.ensureIndexBuffer(a),o.begin();for(let l=0;l<i.length;l++){const u=i[l];o.add(u)}o.finish(e.instructions);const h=e.geometry;h.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),h.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const c=o.batches;for(let l=0;l<c.length;l++){const u=c[l];u.bindGroup=ur(u.textures.textures,u.textures.count)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new df;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&($.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{$.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};_r.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"graphicsContext"},_r.defaultOptions={bezierSmoothness:.5};let xr=_r;const pf=8,Ys=11920929e-14,mf=1;function io(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??xr.defaultOptions.bezierSmoothness));let d=(mf-u)/1;return d*=d,gf(t,e,i,r,n,a,o,h,s,d),s}function gf(s,t,e,i,r,n,a,o,h,c){yr(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function yr(s,t,e,i,r,n,a,o,h,c,l){if(l>pf)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,g=(r+a)/2,m=(n+o)/2,_=(u+f)/2,x=(d+p)/2,y=(f+g)/2,v=(p+m)/2,w=(_+y)/2,C=(x+v)/2;if(l>0){let E=a-s,P=o-t;const S=Math.abs((e-a)*P-(i-o)*E),A=Math.abs((r-a)*P-(n-o)*E);if(S>Ys&&A>Ys){if((S+A)*(S+A)<=c*(E*E+P*P)){h.push(w,C);return}}else if(S>Ys){if(S*S<=c*(E*E+P*P)){h.push(w,C);return}}else if(A>Ys){if(A*A<=c*(E*E+P*P)){h.push(w,C);return}}else if(E=w-(s+a)/2,P=C-(t+o)/2,E*E+P*P<=c){h.push(w,C);return}}yr(s,t,u,d,_,x,w,C,h,c,l+1),yr(w,C,y,v,g,m,a,o,h,c,l+1)}const _f=8,xf=11920929e-14,yf=1;function bf(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??xr.defaultOptions.bezierSmoothness));let l=(yf-c)/1;return l*=l,vf(t,e,i,r,n,a,s,l),s}function vf(s,t,e,i,r,n,a,o){br(a,s,t,e,i,r,n,o,0),a.push(r,n)}function br(s,t,e,i,r,n,a,o,h){if(h>_f)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let g=n-t,m=a-e;const _=Math.abs((i-n)*m-(r-a)*g);if(_>xf){if(_*_<=o*(g*g+m*m)){s.push(f,p);return}}else if(g=f-(t+n)/2,m=p-(e+a)/2,g*g+m*m<=o){s.push(f,p);return}br(s,t,e,c,l,f,p,o,h+1),br(s,f,p,u,d,n,a,o,h+1)}function ro(s,t,e,i,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;u<o+1;u++){const d=Math.cos(l),f=Math.sin(l),p=t+d*i,g=e+f*i;s.push(p,g),l+=c}}function Sf(s,t,e,i,r,n){const a=s[s.length-2],h=s[s.length-1]-e,c=a-t,l=r-e,u=i-t,d=Math.abs(h*u-c*l);if(d<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const f=h*h+c*c,p=l*l+u*u,g=h*l+c*u,m=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=m*g/f,y=_*g/p,v=m*u+_*c,w=m*l+_*h,C=c*(_+x),E=h*(_+x),P=u*(m+y),S=l*(m+y),A=Math.atan2(E-w,C-v),Q=Math.atan2(S-w,P-v);ro(s,v+t,w+e,n,A,Q,c*l>u*h)}const ts=Math.PI*2,vr={centerX:0,centerY:0,ang1:0,ang2:0},Sr=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function wf(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const no=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Tf=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),g=Math.pow(l,2),m=Math.pow(u,2);let _=f*p-f*m-p*g;_<0&&(_=0),_/=f*m+p*g,_=Math.sqrt(_)*(a===o?-1:1);const x=_*r/n*u,y=_*-n/r*l,v=c*x-h*y+(s+e)/2,w=h*x+c*y+(t+i)/2,C=(l-x)/r,E=(u-y)/n,P=(-l-x)/r,S=(-u-y)/n,A=no(1,0,C,E);let Q=no(C,E,P,S);o===0&&Q>0&&(Q-=ts),o===1&&Q<0&&(Q+=ts),d.centerX=v,d.centerY=w,d.ang1=A,d.ang2=Q};function Af(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*ts/360),u=Math.cos(o*ts/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),Tf(t,e,i,r,n,a,h,c,l,u,d,f,vr);let{ang1:g,ang2:m}=vr;const{centerX:_,centerY:x}=vr;let y=Math.abs(m)/(ts/4);Math.abs(1-y)<1e-7&&(y=1);const v=Math.max(Math.ceil(y),1);m/=v;let w=s[s.length-2],C=s[s.length-1];const E={x:0,y:0};for(let P=0;P<v;P++){const S=wf(g,m),{x:A,y:Q}=Sr(S[0],n,a,u,l,_,x,E),{x:Ct,y:F}=Sr(S[1],n,a,u,l,_,x,E),{x:B,y:q}=Sr(S[2],n,a,u,l,_,x,E);io(s,w,C,A,Q,Ct,F,B,q),w=B,C=q,g+=m}}function Pf(s,t,e){const i=(a,o)=>{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a<t.length;a++){const o=t[a%t.length],h=o.radius??e;if(h<=0){r(a,o),n=o;continue}const c=t[(a+1)%t.length],l=i(o,n),u=i(o,c);if(l.len<1e-4||u.len<1e-4){r(a,o),n=o;continue}let d=Math.asin(l.nx*u.ny-l.ny*u.nx),f=1,p=!1;l.nx*u.nx-l.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const g=d/2;let m,_=Math.abs(Math.cos(g)*h/Math.sin(g));_>Math.min(l.len/2,u.len/2)?(_=Math.min(l.len/2,u.len/2),m=Math.abs(_*Math.sin(g)/Math.cos(g))):m=h;const x=o.x+u.nx*_+-u.ny*m*f,y=o.y+u.ny*_+u.nx*m*f,v=Math.atan2(l.ny,l.nx)+Math.PI/2*f,w=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(x+Math.cos(v)*m,y+Math.sin(v)*m),s.arc(x,y,m,v,w,p),n=o}}function Ef(s,t,e,i){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o<a;o++){const h=t[(o+1)%a],c=h.radius??e;if(c<=0){o===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const l=t[o],u=t[(o+2)%a],d=r(l,h);let f;if(d<1e-4)f=h;else{const m=Math.min(d/2,c);f=n(h,l,m/d)}const p=r(u,h);let g;if(p<1e-4)g=h;else{const m=Math.min(p/2,c);g=n(h,u,m/p)}o===0?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),s.quadraticCurveTo(h.x,h.y,g.x,g.y,i)}}const Cf=new Y;class Mf{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new pt,this._graphicsPath2D=t}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,a){this._ensurePoly(!1);const o=this._currentPoly.points;return ro(o,t,e,i,r,n,a),this}arcTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly.points;return Sf(a,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,a,o){const h=this._currentPoly.points;return Af(h,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,a,o){this._ensurePoly();const h=this._currentPoly;return io(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,a,o),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const a=this._currentPoly;return bf(this._currentPoly.points,a.lastX,a.lastY,t,e,i,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));for(let i=0;i<t.instructions.length;i++){const r=t.instructions[i];this[r.action](...r.data)}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,r,n){return this.drawShape(new Y(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new hr(t,e,i),r),this}poly(t,e,i){const r=new Je(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,r,n=0,a){r=Math.max(r|0,3);const o=-1*Math.PI/2+n,h=Math.PI*2/r,c=[];for(let l=0;l<r;l++){const u=l*h+o;c.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(c,!0,a),this}roundPoly(t,e,i,r,n,a=0,o){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,a);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const f=d*l+c,p=t+i*Math.cos(f),g=e+i*Math.sin(f),m=f+Math.PI+u,_=f-Math.PI-u,x=p+n*Math.cos(m),y=g+n*Math.sin(m),v=p+n*Math.cos(_),w=g+n*Math.sin(_);d===0?this.moveTo(x,y):this.lineTo(x,y),this.quadraticCurveTo(p,g,v,w,o)}return this.closePath()}roundShape(t,e,i=!1,r){return t.length<3?this:(i?Ef(this,t,e,r):Pf(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const a=Math.min(i,r)/2,o=Math.min(a,Math.max(-a,n)),h=t+i,c=e+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(t,e+u).arcTo(t+l,e+l,t+u,e,u).lineTo(h-u,e).arcTo(h-l,e+l,h,e+u,u).lineTo(h,c-u).arcTo(h-l,c-l,t+i-u,c,u).lineTo(t+u,c).arcTo(t+l,c-l,t,c-u,u).closePath()}chamferRect(t,e,i,r,n,a){if(n<=0)return this.rect(t,e,i,r);const o=Math.min(n,Math.min(i,r)/2),h=t+i,c=e+r,l=[t+o,e,h-o,e,h,e+o,h,c-o,h-o,c,t+o,c,t,c-o,t,e+o];for(let u=l.length-1;u>=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new cr(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new lr(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Je,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Je,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(Cf);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class Ge{constructor(t){this.instructions=[],this.uid=et("graphicsPath"),this._dirty=!0,typeof t=="string"?$d(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Mf(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,r,n){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(X.shared);let h=0,c=0;if(!a||a.action!=="bezierCurveTo")h=o.x,c=o.y;else{h=a.data[2],c=a.data[3];const l=o.x,u=o.y;h=l+(l-h),c=u+(u-c)}return this.instructions.push({action:"bezierCurveTo",data:[h,c,t,e,i,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(X.shared);let a=0,o=0;if(!r||r.action!=="quadraticCurveTo")a=n.x,o=n.y;else{a=r.data[0],o=r.data[1];const h=n.x,c=n.y;a=h+(h-a),o=c+(c-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=!0,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,r]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,r,n,a,o){n=n||r/2;const h=-1*Math.PI/2+a,c=i*2,l=Math.PI*2/c,u=[];for(let d=0;d<c;d++){const f=d%2?n:r,p=d*l+h;u.push(t+f*Math.cos(p),e+f*Math.sin(p))}return this.poly(u,!0,o),this}clone(t=!1){const e=new Ge;if(!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty;let h=0,c=0,l=0,u=0,d=0,f=0,p=0,g=0;for(let m=0;m<this.instructions.length;m++){const _=this.instructions[m],x=_.data;switch(_.action){case"moveTo":case"lineTo":h=x[0],c=x[1],x[0]=e*h+r*c+a,x[1]=i*h+n*c+o;break;case"bezierCurveTo":l=x[0],u=x[1],d=x[2],f=x[3],h=x[4],c=x[5],x[0]=e*l+r*u+a,x[1]=i*l+n*u+o,x[2]=e*d+r*f+a,x[3]=i*d+n*f+o,x[4]=e*h+r*c+a,x[5]=i*h+n*c+o;break;case"quadraticCurveTo":l=x[0],u=x[1],h=x[2],c=x[3],x[0]=e*l+r*u+a,x[1]=i*l+n*u+o,x[2]=e*h+r*c+a,x[3]=i*h+n*c+o;break;case"arcToSvg":h=x[5],c=x[6],p=x[0],g=x[1],x[0]=e*p+r*g,x[1]=i*p+n*g,x[5]=e*h+r*c+a,x[6]=i*h+n*c+o;break;case"circle":x[4]=es(x[3],t);break;case"rect":x[4]=es(x[4],t);break;case"ellipse":x[8]=es(x[8],t);break;case"roundRect":x[5]=es(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=es(x[2],t);break;default:D("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function es(s,t){return s?s.prepend(t):t.clone()}function Bf(s,t){if(typeof s=="string"){const i=document.createElement("div");i.innerHTML=s.trim(),s=i.querySelector("svg")}const e={context:t,path:new Ge};return ao(s,e,null,null),t}function ao(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:a}=Rf(s);n&&e?e={...e,...n}:n&&(e=n),a&&i?i={...i,...a}:a&&(i=a),t.context.fillStyle=e,t.context.strokeStyle=i;let o,h,c,l,u,d,f,p,g,m,_,x,y,v,w,C,E;switch(s.nodeName.toLowerCase()){case"path":v=s.getAttribute("d"),w=new Ge(v),t.context.path(w),e&&t.context.fill(),i&&t.context.stroke();break;case"circle":f=lt(s,"cx",0),p=lt(s,"cy",0),g=lt(s,"r",0),t.context.ellipse(f,p,g,g),e&&t.context.fill(),i&&t.context.stroke();break;case"rect":o=lt(s,"x",0),h=lt(s,"y",0),C=lt(s,"width",0),E=lt(s,"height",0),m=lt(s,"rx",0),_=lt(s,"ry",0),m||_?t.context.roundRect(o,h,C,E,m||_):t.context.rect(o,h,C,E),e&&t.context.fill(),i&&t.context.stroke();break;case"ellipse":f=lt(s,"cx",0),p=lt(s,"cy",0),m=lt(s,"rx",0),_=lt(s,"ry",0),t.context.beginPath(),t.context.ellipse(f,p,m,_),e&&t.context.fill(),i&&t.context.stroke();break;case"line":c=lt(s,"x1",0),l=lt(s,"y1",0),u=lt(s,"x2",0),d=lt(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,l),t.context.lineTo(u,d),i&&t.context.stroke();break;case"polygon":y=s.getAttribute("points"),x=y.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(x,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":y=s.getAttribute("points"),x=y.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(x,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let P=0;P<r.length;P++)ao(r[P],t,e,i)}function lt(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function Rf(s){const t=s.getAttribute("style"),e={},i={};let r=!1,n=!1;if(t){const a=t.split(";");for(let o=0;o<a.length;o++){const h=a[o],[c,l]=h.split(":");switch(c){case"stroke":l!=="none"&&(e.color=j.shared.setValue(l).toNumber(),n=!0);break;case"stroke-width":e.width=Number(l);break;case"fill":l!=="none"&&(r=!0,i.color=j.shared.setValue(l).toNumber());break;case"fill-opacity":i.alpha=Number(l);break;case"stroke-opacity":e.alpha=Number(l);break;case"opacity":i.alpha=Number(l),e.alpha=Number(l);break}}}else{const a=s.getAttribute("stroke");a&&a!=="none"&&(n=!0,e.color=j.shared.setValue(a).toNumber(),e.width=lt(s,"stroke-width",1));const o=s.getAttribute("fill");o&&o!=="none"&&(r=!0,i.color=j.shared.setValue(o).toNumber())}return{strokeStyle:n?e:null,fillStyle:r?i:null}}const oo=class bn{constructor(t,e,i,r){this.uid=et("fillGradient"),this.type="linear",this.gradientStops=[],this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:j.shared.setValue(e).toHex()}),this}buildLinearGradient(){const t=bn.defaultTextureSize,{gradientStops:e}=this,i=L.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,bn.defaultTextureSize,1);for(let g=0;g<e.length;g++){const m=e[g];n.addColorStop(m.offset,m.color)}r.fillStyle=n,r.fillRect(0,0,t,t),this.texture=new M({source:new Ee({resource:i,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:a,y0:o,x1:h,y1:c}=this,l=new I,u=h-a,d=c-o,f=Math.sqrt(u*u+d*d),p=Math.atan2(d,u);l.translate(-a,-o),l.scale(1/t,1/t),l.rotate(-p),l.scale(256/f,1),this.transform=l}};oo.defaultTextureSize=256;let wr=oo;const ho={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class co{constructor(t,e){this.uid=et("fillPattern"),this.transform=new I,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=ho[e].addressModeU,t.source.style.addressModeV=ho[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height)}}function ee(s,t){var a;if(s==null)return null;let e,i;if(s!=null&&s.fill?(i=s.fill,e={...t,...s}):(i=s,e=t),j.isColorLike(i)){const o=j.shared.setValue(i??0);return{...e,color:o.toNumber(),alpha:o.alpha===1?e.alpha:o.alpha,texture:M.WHITE}}else if(i instanceof co){const o=i;return{...e,color:16777215,texture:o.texture,matrix:o.transform,fill:e.fill??null}}else if(i instanceof wr){const o=i;return o.buildLinearGradient(),{...e,color:16777215,texture:o.texture,matrix:o.transform}}const r={...t,...s};if(r.texture){if(r.texture!==M.WHITE){const h=((a=r.matrix)==null?void 0:a.invert())||new I;h.scale(1/r.texture.frame.width,1/r.texture.frame.height),r.matrix=h}const o=r.texture.source.style;o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat")}const n=j.shared.setValue(r.color);return r.alpha*=n.alpha,r.color=n.toNumber(),r.matrix=r.matrix?r.matrix.clone():null,r}const kf=new X,lo=new I,Tr=class zt extends gt{constructor(){super(...arguments),this.uid=et("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Ge,this._transform=new I,this._fillStyle={...zt.defaultFillStyle},this._strokeStyle={...zt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new pt,this._boundsDirty=!0}clone(){const t=new zt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=ee(t,zt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ee(t,zt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ee(t,zt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ee(t,zt.defaultStrokeStyle),this}texture(t,e,i,r,n,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?j.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Ge,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(N(W,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ee(t,zt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(X.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ee(t,zt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,r,n,a),this}arcTo(t,e,i,r,n){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}arcToSvg(t,e,i,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*a+h.c*o+h.tx,h.b*a+h.d*o+h.ty),this}bezierCurveTo(t,e,i,r,n,a,o){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*a+h.tx,h.b*n+h.d*a+h.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=a,this):(this._activePath.moveTo(n,a),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*r+a.tx,a.b*i+a.d*r+a.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,a),this}roundPoly(t,e,i,r,n,a){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,a),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,a){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,a),this}star(t,e,i,r,n=0,a=0){return this._tick++,this._activePath.star(t,e,i,r,n,a,this._transform.clone()),this}svg(t){return this._tick++,Bf(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,a){return t instanceof I?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,a),this)}transform(t,e,i,r,n,a){return t instanceof I?(this._transform.append(t),this):(lo.set(t,e,i,r,n,a),this._transform.append(lo),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.data,a=n.style.width/2,o=n.path.bounds;t.addFrame(o.minX-a,o.minY-a,o.maxX+a,o.maxY+a)}}return t}containsPoint(t){var r;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let n=0;n<e.length;n++){const a=e[n],o=a.data,h=o.path;if(!a.action||!h)continue;const c=o.style,l=h.shapePath.shapePrimitives;for(let u=0;u<l.length;u++){const d=l[u].shape;if(!c||!d)continue;const f=l[u].transform,p=f?f.applyInverse(t,kf):t;a.action==="fill"?i=d.contains(p.x,p.y):i=d.strokeContains(p.x,p.y,c.width);const g=o.hole;if(g){const m=(r=g.shapePath)==null?void 0:r.shapePrimitives;if(m)for(let _=0;_<m.length;_++)m[_].shape.contains(p.x,p.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(i),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(i)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Tr.defaultFillStyle={color:16777215,alpha:1,texture:M.WHITE,matrix:null,fill:null},Tr.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:M.WHITE,matrix:null,fill:null};let se=Tr;function Ar(s,t=1){var i;const e=(i=Ce.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function Pr(s,t,e){s.label=e,s._sourceOrigin=e;const i=new M({source:s,label:e}),r=()=>{delete t.promiseCache[e],K.has(e)&&K.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(D("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(D("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const If=".svg",Ff="image/svg+xml",Gf={extension:{type:b.LoadParser,priority:te.Low},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return Ie(s,Ff)||Fe(s,If)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Df(s):Uf(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Uf(s,t,e,i){var m,_,x;const n=await(await L.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((m=t.data)==null?void 0:m.resolution)||Ar(s),u=((_=t.data)==null?void 0:_.width)??o.width,d=((x=t.data)==null?void 0:x.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,g=new Ee({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return Pr(g,e,s)}async function Df(s){const e=await(await L.get().fetch(s)).text(),i=new se;return i.svg(e),i}const Of=`(function () {
    'use strict';

    const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
    async function checkImageBitmap() {
      try {
        if (typeof createImageBitmap !== "function")
          return false;
        const response = await fetch(WHITE_PNG);
        const imageBlob = await response.blob();
        const imageBitmap = await createImageBitmap(imageBlob);
        return imageBitmap.width === 1 && imageBitmap.height === 1;
      } catch (e) {
        return false;
      }
    }
    void checkImageBitmap().then((result) => {
      self.postMessage(result);
    });

})();
`;let Ue=null,Er=class{constructor(){Ue||(Ue=URL.createObjectURL(new Blob([Of],{type:"application/javascript"}))),this.worker=new Worker(Ue)}};Er.revokeObjectURL=function(){Ue&&(URL.revokeObjectURL(Ue),Ue=null)};const Lf=`(function () {
    'use strict';

    async function loadImageBitmap(url) {
      const response = await fetch(url);
      if (!response.ok) {
        throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
      }
      const imageBlob = await response.blob();
      const imageBitmap = await createImageBitmap(imageBlob);
      return imageBitmap;
    }
    self.onmessage = async (event) => {
      try {
        const imageBitmap = await loadImageBitmap(event.data.data[0]);
        self.postMessage({
          data: imageBitmap,
          uuid: event.data.uuid,
          id: event.data.id
        }, [imageBitmap]);
      } catch (e) {
        self.postMessage({
          error: e,
          uuid: event.data.uuid,
          id: event.data.id
        });
      }
    };

})();
`;let De=null;class uo{constructor(){De||(De=URL.createObjectURL(new Blob([Lf],{type:"application/javascript"}))),this.worker=new Worker(De)}}uo.revokeObjectURL=function(){De&&(URL.revokeObjectURL(De),De=null)};let fo=0,Cr;class Hf{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Er;e.addEventListener("message",i=>{e.terminate(),Er.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Cr===void 0&&(Cr=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Cr&&(this._createdWorkers++,t=new uo().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[fo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:fo++,id:i})}}const po=new Hf,Nf=[".jpeg",".jpg",".png",".webp",".avif"],zf=["image/jpeg","image/png","image/webp","image/avif"];async function Wf(s){const t=await L.get().fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const mo={name:"loadTextures",extension:{type:b.LoadParser,priority:te.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ie(s,zf)||Fe(s,Nf)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await po.isImageBitmapSupported()?i=await po.loadImageBitmap(s):i=await Wf(s):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new Ee({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||Ar(s),...t.data});return Pr(r,e,s)},unload(s){s.destroy(!0)}},go=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Vf=go.map(s=>`video/${s.substring(1)}`);function jf(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Xf(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function $f(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function Xf(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Yf={name:"loadVideo",extension:{type:b.LoadParser},config:null,test(s){const t=Ie(s,Vf),e=Fe(s,go);return t||e},async load(s,t,e){var h,c;const i={...ks.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ar(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await na(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),jf(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=ks.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new ks({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await $f(r),l(Pr(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},_o={extension:b.ResolveParser,test:mo.test,parse:s=>{var t;return{resolution:parseFloat(((t=Ce.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},Kf={extension:b.ResolveParser,test:s=>Ce.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:_o.parse};class qf{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ce,this.loader=new Ad,this.cache=K,this._backgroundLoader=new gd(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){D("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=Is(t),r=Mt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return K.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=K.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(a=>{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),K.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=Mt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Mt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{K.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const kt=new qf;O.handleByList(b.LoadParser,kt.loader.parsers).handleByList(b.ResolveParser,kt.resolver.parsers).handleByList(b.CacheParser,kt.cache.parsers).handleByList(b.DetectionParser,kt.detections),O.add(_d,yd,xd,Td,vd,Sd,wd,Cd,Rd,Ld,Gf,mo,Yf,_o,Kf);const xo={loader:b.LoadParser,resolver:b.ResolveParser,cache:b.CacheParser,detection:b.DetectionParser};O.handle(b.Asset,s=>{const t=s.ref;Object.entries(xo).filter(([e])=>!!t[e]).forEach(([e,i])=>O.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(xo).filter(e=>!!t[e]).forEach(e=>O.remove(t[e]))});class Zf{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this._tickerAdded||!this.domElement||(ht.system.add(this._tickerUpdate,this,de.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ht.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}}const ie=new Zf;class Ks extends Ve{constructor(){super(...arguments),this.client=new X,this.movement=new X,this.offset=new X,this.global=new X,this.screen=new X}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,n,a,o,h,c,l,u,d,f,p,g){throw new Error("Method not implemented.")}}class It extends Ks{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Oe extends Ks{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Oe.DOM_DELTA_PIXEL=0,Oe.DOM_DELTA_LINE=1,Oe.DOM_DELTA_PAGE=2;const Jf=2048,Qf=new X,ss=new X;class tp{constructor(t){this.dispatch=new gt,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,r)=>i.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else D(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ie.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[r](this.rootTarget,this.rootTarget.eventMode,Qf.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=i.length-1;r<n;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)r.forEach(a=>{t.currentTarget=i[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<Jf&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ie.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let u=l.length-1;u>=0;u--){const d=l[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,r,n,a||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),c=t.isInteractive();return c&&c&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,i)&&r(t,i)?c?[t]:[]:null}hitTestRecursive(t,e,i,r,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ie.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children,c=i;for(let l=h.length-1;l>=0;l--){const u=h[l],d=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,c,r,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=t.isInteractive();return(d.length>0||f)&&d.push(t),d}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&r(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.includeInBuild||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,ss),!t.hitArea.contains(ss.x,ss.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const r=t.effects[i];if(r.containsPoint&&!r.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,ss),t.containsPoint(ss)):!1}notifyTarget(t,e){var n,a;e=e??t.type;const i=`on${e}`;(a=(n=t.currentTarget)[i])==null||a.call(n,t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var h,c;if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(((h=r.overTargets)==null?void 0:h.length)>0&&n!==e.target){const l=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,l,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const l=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,l);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(u)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(c=e.target)==null?void 0:c.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(a=i.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const h=i.button===2;this.notifyTarget(i,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete r.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const c=o.button===2;this.dispatchEvent(o,c?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof It)){D("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let n=i;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof Oe)){D("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(It);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(Oe);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(It);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof It&&e instanceof It&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Ks&&e instanceof Ks&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,n=i.length;r<n&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const ep=1,sp={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Mr=class vn{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new tp(null),ie.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new It(null),this._rootWheelEvent=new Oe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...vn.defaultEventFeatures},{set:(e,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[i]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{canvas:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,vn._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const n=e[i],a=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ie.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this._normalizeToPointerData(t);for(let n=0,a=r.length;n<a;n++){const o=this._bootstrapEvent(this._rootPointerEvent,r[n]);o.type+=i,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,ie.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ie.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;ie.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(i-r.top)*(this.domElement.height/r.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=ep),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=sp[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Mr.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1},Mr.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let yo=Mr;const ip={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(s){this.eventMode=s?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??yo.defaultEventMode},set eventMode(s){this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;s=i?`${s}capture`:s;const o=typeof t=="function"?t:t.handleEvent,h=this;r&&r.addEventListener("abort",()=>{h.off(s,o,a)}),n?h.once(s,o,a):h.on(s,o,a)},removeEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,r)},dispatchEvent(s){if(!(s instanceof Ve))throw new Error("Container cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};let rp=0;class np{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,i){const r=new ut({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!0});return new M({source:r,label:`texturePool_${rp++}`})}getOptimalTexture(t,e,i=1,r){let n=Math.ceil(t*i-1e-6),a=Math.ceil(e*i-1e-6);n=Te(n),a=Te(a);const o=(n<<17)+(a<<1)+(r?1:0);this._texturePool[o]||(this._texturePool[o]=[]);let h=this._texturePool[o].pop();return h||(h=this.createTexture(n,a,r)),h.source._resolution=i,h.source.width=n/i,h.source.height=a/i,h.source.pixelWidth=n,h.source.pixelHeight=a,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=o,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t){const e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this._texturePool={}}}const At=new np;class bo{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}bo.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const ap=new I;function op(s,t){return t.clear(),vo(s,t),t.isValid||t.set(0,0,0,0),s.renderGroup?t.applyMatrix(s.renderGroup.localTransform):t.applyMatrix(s.parentRenderGroup.worldTransform),t}function vo(s,t){if(s.localDisplayStatus!==7||!s.measurable)return;const e=!!s.effects.length;let i=t;if((s.renderGroup||e)&&(i=$t.get().clear()),s.boundsArea)t.addRect(s.boundsArea,s.worldTransform);else{if(s.renderPipeId){const n=s.bounds;i.addFrame(n.minX,n.minY,n.maxX,n.maxY,s.groupTransform)}const r=s.children;for(let n=0;n<r.length;n++)vo(r[n],i)}if(e){let r=!1;for(let n=0;n<s.effects.length;n++)s.effects[n].addBounds&&(r||(r=!0,i.applyMatrix(s.parentRenderGroup.worldTransform)),s.effects[n].addBounds(i,!0));r&&(i.applyMatrix(s.parentRenderGroup.worldTransform.copyTo(ap).invert()),t.addBounds(i,s.relativeGroupTransform)),t.addBounds(i),$t.return(i)}else s.renderGroup&&(t.addBounds(i,s.relativeGroupTransform),$t.return(i))}function hp(s,t){t.clear();const e=t.matrix;for(let i=0;i<s.length;i++){const r=s[i];r.globalDisplayStatus<7||(t.matrix=r.worldTransform,r.addBounds(t))}return t.matrix=e,t}const cp=new $s({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),location:0,format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class So{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new _t({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Yt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var f;const e=this.renderer,i=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const r=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,i.length===0){r.skip=!0;return}const n=r.bounds;t.renderables?hp(t.renderables,n):t.filterEffect.filterArea?(n.clear(),n.addRect(t.filterEffect.filterArea),n.applyMatrix(t.container.worldTransform)):op(t.container,n);const a=e.renderTarget.rootRenderTarget.colorTexture.source;let o=a._resolution,h=0,c=a.antialias,l=!1,u=!1;for(let p=0;p<i.length;p++){const g=i[p];if(o=Math.min(o,g.resolution),h+=g.padding,g.antialias!=="inherit"&&(g.antialias==="on"?c=!0:c=!1),!!!(g.compatibleRenderers&e.type)){u=!1;break}if(g.blendRequired&&!(((f=e.backBuffer)==null?void 0:f.useBackBuffer)??!0)){D("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=!1;break}u=g.enabled||u,l=l||g.blendRequired}if(!u){r.skip=!0;return}const d=e.renderTarget.rootViewPort;if(n.scale(o).fitBounds(0,d.width,0,d.height).scale(1/o).pad(h).ceil(),!n.isPositive){r.skip=!0;return}r.skip=!1,r.bounds=n,r.blendRequired=l,r.container=t.container,r.filterEffect=t.filterEffect,r.previousRenderSurface=e.renderTarget.renderSurface,r.inputTexture=At.getOptimalTexture(n.width,n.height,o,c),e.renderTarget.bind(r.inputTexture,!0),e.globalUniforms.push({offset:n})}pop(){const t=this.renderer;this._filterStackIndex--;const e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;const i=e.inputTexture,r=e.bounds;let n=M.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){const o=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(h,r,o)}e.backTexture=n;const a=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),a.length===1)a[0].apply(this,i,e.previousRenderSurface,!1),At.returnTexture(i);else{let o=e.inputTexture,h=At.getOptimalTexture(r.width,r.height,o.source._resolution,!1),c=0;for(c=0;c<a.length-1;++c){a[c].apply(this,o,h,!0);const u=o;o=h,h=u}a[c].apply(this,o,e.previousRenderSurface,!1),At.returnTexture(o),At.returnTexture(h)}e.blendRequired&&At.returnTexture(n)}getBackTexture(t,e,i){const r=t.colorTexture.source._resolution,n=At.getOptimalTexture(e.width,e.height,r,!1);let a=e.minX,o=e.minY;i&&(a-=i.minX,o-=i.minY),a=Math.floor(a*r),o=Math.floor(o*r);const h=Math.ceil(e.width*r),c=Math.ceil(e.height*r);return this.renderer.renderTarget.copyToTexture(t,n,{x:a,y:o},{width:h,height:c},{x:0,y:0}),n}applyFilter(t,e,i,r){const n=this.renderer,a=this._filterStack[this._filterStackIndex],o=a.bounds,h=X.shared,l=a.previousRenderSurface===i;let u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,d=this._filterStackIndex-1;for(;d>0&&this._filterStack[d].skip;)--d;d>0&&(u=this._filterStack[d].inputTexture.source._resolution);const f=this._filterGlobalUniforms,p=f.uniforms,g=p.uOutputFrame,m=p.uInputSize,_=p.uInputPixel,x=p.uInputClamp,y=p.uGlobalFrame,v=p.uOutputTexture;if(l){let E=this._filterStackIndex;for(;E>0;){E--;const P=this._filterStack[this._filterStackIndex-1];if(!P.skip){h.x=P.bounds.minX,h.y=P.bounds.minY;break}}g[0]=o.minX-h.x,g[1]=o.minY-h.y}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,m[0]=e.source.width,m[1]=e.source.height,m[2]=1/m[0],m[3]=1/m[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],x[0]=.5*_[2],x[1]=.5*_[3],x[2]=e.frame.width*m[2]-.5*_[2],x[3]=e.frame.height*m[3]-.5*_[3];const w=this.renderer.renderTarget.rootRenderTarget.colorTexture;y[0]=h.x*u,y[1]=h.y*u,y[2]=w.source.width*u,y[3]=w.source.height*u;const C=this.renderer.renderTarget.getRenderTarget(i);if(n.renderTarget.bind(i,!!r),i instanceof M?(v[0]=i.frame.width,v[1]=i.frame.height):(v[0]=C.width,v[1]=C.height),v[2]=C.isRoot?-1:1,f.update(),n.renderPipes.uniformBatch){const E=n.renderPipes.uniformBatch.getUboResource(f);this._globalFilterBindGroup.setResource(E,0)}else this._globalFilterBindGroup.setResource(f,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:cp,shader:t,state:t._state,topology:"triangle-list"}),n.type===Lt.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new pt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(t,e){const i=this._activeFilterData,r=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(I.shared);return n.invert(),r.prepend(n),r.scale(1/e.texture.frame.width,1/e.texture.frame.height),r.translate(e.anchor.x,e.anchor.y),r}}So.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};var lp=`in vec2 vMaskCoord;
in vec2 vTextureCoord;

uniform sampler2D uTexture;
uniform sampler2D uMaskTexture;

uniform float uAlpha;
uniform vec4 uMaskClamp;

out vec4 finalColor;

void main(void)
{
    float clip = step(3.5,
        step(uMaskClamp.x, vMaskCoord.x) +
        step(uMaskClamp.y, vMaskCoord.y) +
        step(vMaskCoord.x, uMaskClamp.z) +
        step(vMaskCoord.y, uMaskClamp.w));

    // TODO look into why this is needed
    float npmAlpha = uAlpha; 
    vec4 original = texture(uTexture, vTextureCoord);
    vec4 masky = texture(uMaskTexture, vMaskCoord);
    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);

    original *= (alphaMul * masky.r * uAlpha * clip);

    finalColor = original;
}
`,up=`in vec2 aPosition;

out vec2 vTextureCoord;
out vec2 vMaskCoord;


uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;

vec4 filterVertexPosition(  vec2 aPosition )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
       
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord(  vec2 aPosition )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

vec2 getFilterCoord( vec2 aPosition )
{
    return  ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}   

void main(void)
{
    gl_Position = filterVertexPosition(aPosition);
    vTextureCoord = filterTextureCoord(aPosition);
    vMaskCoord = getFilterCoord(aPosition);
}
`,wo=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,  
};

struct MaskUniforms {
  uFilterMatrix:mat3x3<f32>,
  uMaskClamp:vec4<f32>,
  uAlpha:f32,
};


@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) filterUv : vec2<f32>,
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}

fn getSize() -> vec2<f32>
{

  
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
   getFilterCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) filterUv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var maskClamp = filterUniforms.uMaskClamp;

     var clip = step(3.5,
        step(maskClamp.x, filterUv.x) +
        step(maskClamp.y, filterUv.y) +
        step(filterUv.x, maskClamp.z) +
        step(filterUv.y, maskClamp.w));

    var mask = textureSample(uMaskTexture, uSampler, filterUv);
    var source = textureSample(uTexture, uSampler, uv);
    
    var npmAlpha = 0.0;

    var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a);

    var a = (alphaMul * mask.r) * clip;

    return vec4(source.rgb, source.a) * a;
}`;class dp extends Xu{constructor(t){const{sprite:e,...i}=t,r=new kn(e.texture),n=new _t({uFilterMatrix:{value:new I,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"}}),a=Re.from({vertex:{source:wo,entryPoint:"mainVertex"},fragment:{source:wo,entryPoint:"mainFragment"}}),o=je.from({vertex:up,fragment:lp,name:"mask-filter"});super({...i,gpuProgram:a,glProgram:o,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=r}apply(t,e,i,r){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,r)}}class is extends z{constructor(t){t instanceof se&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.canBundle=!0,this.renderPipeId="graphics",this._roundPixels=0,e?this._context=e:this._context=this._ownedContext=new se,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}onViewUpdate(){if(this._didChangeId+=4096,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new is(this._context.clone()):(this._ownedContext=null,new is(this._context))}lineStyle(t,e,i){N(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){N(W,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){N(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==se.defaultStrokeStyle.width||t.color!==se.defaultStrokeStyle.color||t.alpha!==se.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return N(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return N(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return N(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return N(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return N(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return N(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const To=class yl extends $s{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(N(W,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...yl.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Rt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:V.VERTEX|V.COPY_DST}),h=new Rt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:V.VERTEX|V.COPY_DST}),c=new Rt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:V.INDEX|V.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};To.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Br=To;class rs extends wt{constructor(t,e=!0){super(t[0]instanceof M?t[0]:t[0].texture),this._textures=null,this._durations=null,this._autoUpdate=e,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=t}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ht.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ht.shared.add(this.update,this,de.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<r||this.animationSpeed<0&&this.currentFrame>r)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(M.from(t[i]));return new rs(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(M.from(t[i]));return new rs(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof M)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(ht.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ht.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class fp extends z{constructor(t,e){const{text:i,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this.resolution=null,this._didTextUpdate=!0,this._roundPixels=0,this._bounds=new pt,this._boundsDirty=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new ft({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o&&(this.width=o),h&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){let i,r;typeof t!="object"?(i=t,r=e??t):(i=t.width,r=t.height??t.width),i!==void 0&&this._setWidth(i,this.bounds.width),r!==void 0&&this._setHeight(r,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.maxX,i=this.bounds.maxY,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._didChangeId+=4096,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function pp(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(N(W,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}const mp=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function qs(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!mp.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Rr={willReadFrequently:!0},Ft=class R{static get experimentalLetterSpacingSupported(){let t=R._experimentalLetterSpacingSupported;if(t!==void 0){const e=L.get().getCanvasRenderingContext2D().prototype;t=R._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=R._canvas,r=e.wordWrap){var x;const n=`${t}:${e.styleKey}`;if(R._measurementCache[n])return R._measurementCache[n];const a=qs(e),o=R.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=R.__context;h.font=a;const l=(r?R._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let y=0;y<l.length;y++){const v=R._measureText(l[y],e.letterSpacing,h);u[y]=v,d=Math.max(d,v)}const f=((x=e._stroke)==null?void 0:x.width)||0;let p=d+f;e.dropShadow&&(p+=e.dropShadow.distance);const g=e.lineHeight||o.fontSize+f;let m=Math.max(g,o.fontSize+f*2)+(l.length-1)*(g+e.leading);return e.dropShadow&&(m+=e.dropShadow.distance),new R(t,e,p,m,l,u,g+e.leading,d,o)}static _measureText(t,e,i){let r=!1;R.experimentalLetterSpacingSupported&&(R.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(R.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=R._canvas){const r=i.getContext("2d",Rr);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=R._collapseSpaces(l),d=R._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,g=R._tokenize(t);for(let m=0;m<g.length;m++){let _=g[m];if(R._isNewline(_)){if(!d){o+=R._addLine(a),f=!u,a="",n=0;continue}_=" "}if(u){const y=R.isBreakingSpace(_),v=R.isBreakingSpace(a[a.length-1]);if(y&&v)continue}const x=R._getFromCache(_,c,h,r);if(x>p)if(a!==""&&(o+=R._addLine(a),a="",n=0),R.canBreakWords(_,e.breakWords)){const y=R.wordWrapSplit(_);for(let v=0;v<y.length;v++){let w=y[v],C=w,E=1;for(;y[v+E];){const S=y[v+E];if(!R.canBreakChars(C,S,_,v,e.breakWords))w+=S;else break;C=S,E++}v+=E-1;const P=R._getFromCache(w,c,h,r);P+n>p&&(o+=R._addLine(a),f=!1,a="",n=0),a+=w,n+=P}}else{a.length>0&&(o+=R._addLine(a),a="",n=0);const y=m===g.length-1;o+=R._addLine(_,!y),f=!1,a="",n=0}else x+n>p&&(f=!1,o+=R._addLine(a),a="",n=0),(a.length>0||!R.isBreakingSpace(_)||f)&&(a+=_,n+=x)}return o+=R._addLine(a,!1),o}static _addLine(t,e=!0){return t=R._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=R._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!R.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:R._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:R._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],a=t[r+1];if(R.isBreakingSpace(n,a)||R._isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return R.graphemeSegmenter(t)}static measureFont(t){if(R._fonts[t])return R._fonts[t];const e=R._context;e.font=t;const i=e.measureText(R.METRICS_STRING+R.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return R._fonts[t]=r,r}static clearMetrics(t=""){t?delete R._fonts[t]:R._fonts={}}static get _canvas(){if(!R.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",Rr);if(i!=null&&i.measureText)return R.__canvas=e,e;t=L.get().createCanvas()}catch{t=L.get().createCanvas()}t.width=t.height=10,R.__canvas=t}return R.__canvas}static get _context(){return R.__context||(R.__context=R._canvas.getContext("2d",Rr)),R.__context}};Ft.METRICS_STRING="|ÉqÅ",Ft.BASELINE_SYMBOL="M",Ft.BASELINE_MULTIPLIER=1.4,Ft.HEIGHT_MULTIPLIER=2,Ft.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})(),Ft.experimentalLetterSpacing=!1,Ft._fonts={},Ft._newlines=[10,13],Ft._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ft._measurementCache={};let Gt=Ft;const Ao=["_fontFamily","_fontStyle","_fontSize","_fontVariant","_fontWeight","_breakWords","_align","_leading","_letterSpacing","_lineHeight","_textBaseline","_whiteSpace","_wordWrap","_wordWrapWidth","_padding","_cssOverrides","_trim"];function Po(s){const t=[];let e=0;for(let i=0;i<Ao.length;i++){const r=Ao[i];t[e++]=s[r]}return e=Eo(s._fill,t,e),e=gp(s._stroke,t,e),t.join("-")}function Eo(s,t,e){var i;return s&&(t[e++]=s.color,t[e++]=s.alpha,t[e++]=(i=s.fill)==null?void 0:i.uid),e}function gp(s,t,e){return s&&(e=Eo(s,t,e),t[e++]=s.width,t[e++]=s.alignment,t[e++]=s.cap,t[e++]=s.join,t[e++]=s.miterLimit),e}const kr=class Ne extends gt{constructor(t={}){super(),_p(t);const e={...Ne.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow={...Ne.defaultDropShadow,...t}:this._dropShadow=t?{...Ne.defaultDropShadow}:null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._fill=ee(t===0?"black":t,se.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._stroke=ee(t,se.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Po(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Ne.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Ne({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var i,r,n,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}};kr.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},kr.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let me=kr;function _p(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=me.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){N(W,"strokeThickness is now a part of stroke");const e=t.stroke;s.stroke={color:e,width:t.strokeThickness}}if(Array.isArray(t.fill)){N(W,"gradient fill is now a fill pattern: `new FillGradient(...)`");const e=new wr(0,0,0,s.fontSize*1.7),i=t.fill.map(r=>j.shared.setValue(r).toNumber());i.forEach((r,n)=>{const a=t.fillGradientStops[n]??n/i.length;e.addColorStop(a,r)}),s.fill={fill:e}}}class Zs extends fp{constructor(...t){const e=pp(t,"Text");super(e,me),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._style.padding,i=this._anchor,r=Gt.measureText(this._text,this._style),{width:n,height:a}=r;t.minX=-i._x*n-e,t.maxX=t.minX+n+e*2,t.minY=-i._y*a-e,t.maxY=t.minY+a+e*2}}class xp{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=L.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Te(t),e=Te(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const{width:e,height:i}=t.canvas,r=(e<<17)+(i<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const qt=new xp;function Js(s,t){if(s.texture===M.WHITE&&!s.fill)return j.shared.setValue(s.color).toHex();if(s.fill){if(s.fill instanceof co){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(I.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof wr){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,j.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(I.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return D("FillStyle not recognised",s),"red"}class Co extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return N(W,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return N(W,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return N(W,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return N(W,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const e in this.chars)this.chars[e].texture.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}function Mo(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),a=r[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,h=a;o<=h;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}class Bo extends Co{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=4,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const e=t,i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=M.WHITE,i._fill.fill=null);const r=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const n=qs(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/r):i.fontSize=this.baseRenderedFontSize=r,this._style=i,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,this.fontMetrics=Gt.measureFont(n),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(t){var g,m;const e=Mo(t).filter(_=>!this._currentChars.includes(_)).filter((_,x,y)=>y.indexOf(_)===x);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let _=0;_<e.length;_++){const x=e[_],y=Gt.measureText(x,o,r,!1);y.lineHeight=y.height;const v=d*y.width*l,w=y.height*l,C=v+u*2,E=w+u*2;if(p=!1,x!==`
`&&x!=="\r"&&x!=="	"&&x!==" "&&(p=!0,f=Math.ceil(Math.max(E,f))),h+C>512&&(c+=f,f=E,h=0,c+f>512)){a.update();const S=this._nextPage();r=S.canvasAndContext.canvas,n=S.canvasAndContext.context,a=S.texture.source,c=0}const P=v/l-(((g=o.dropShadow)==null?void 0:g.distance)??0)-(((m=o._stroke)==null?void 0:m.width)??0);if(this.chars[x]={id:x.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:P,kerning:{}},p){this._drawGlyph(n,y,h+u,c+u,l,o);const S=a.width*l,A=a.height*l,Q=new Y(h/S*a.width,c/A*a.height,C/S*a.width,E/A*a.height);this.chars[x].texture=new M({source:a,frame:Q}),h+=Math.ceil(C)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let a=0;a<this._currentChars.length;a++){const o=this._currentChars[a];let h=i[n];h||(h=i[n]=e.measureText(n).width);let c=i[o];c||(c=i[o]=e.measureText(o).width);let l=e.measureText(n+o).width,u=l-(h+c);u&&(this.chars[n].kerning[o]=u),l=e.measureText(n+o).width,u=l-(h+c),u&&(this.chars[o].kerning[n]=u)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=qt.getOptimalCanvasAndContext(512,512,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new M({source:new Ee({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload"})}),n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=qs(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=(r==null?void 0:r.width)??0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=Js(r,t)),e._fill&&(t.fillStyle=Js(e._fill,t)),e.dropShadow){const a=e.dropShadow,o=j.shared.setValue(a.color).toArray(),h=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,r,n,a){const o=e.text,h=e.fontProperties,c=a._stroke,l=((c==null?void 0:c.width)??0)*n,u=i+l/2,d=r-l/2,f=h.descent*n,p=e.lineHeight*n;a.stroke&&l&&t.strokeText(o,u,d+p-f),a._fill&&t.fillText(o,u,d+p-f)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];qt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}}function Ro(s,t,e){const i={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=e.baseLineOffset;let r=i.lines[0],n=null,a=!0;const o={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=f=>{const p=r.width;for(let g=0;g<o.index;g++){const m=f.positions[g];r.chars.push(f.chars[g]),r.charPositions.push(m+p)}r.width+=f.width,a=!1,o.width=0,o.index=0,o.chars.length=0},c=()=>{let f=r.chars.length-1,p=r.chars[f];for(;p===" ";)r.width-=e.chars[p].xAdvance,p=r.chars[--f];i.width=Math.max(i.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(r),i.height+=e.lineHeight},l=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*l,d=t.wordWrapWidth*l;for(let f=0;f<s.length+1;f++){let p;const g=f===s.length;g||(p=s[f]);const m=e.chars[p]||e.chars[" "];if(/(?:\s)/.test(p)||p==="\r"||p===`
`||g){if(!a&&t.wordWrap&&r.width+o.width-u>d?(c(),h(o),g||r.charPositions.push(0)):(o.start=r.width,h(o),g||r.charPositions.push(0)),p==="\r"||p===`
`)r.width!==0&&c();else if(!g){const v=m.xAdvance+(m.kerning[n]||0)+u;r.width+=v,r.spaceWidth=v,r.spacesIndex.push(r.charPositions.length),r.chars.push(p)}}else{const y=m.kerning[n]||0,v=m.xAdvance+y+u;o.positions[o.index++]=o.width+y,o.chars.push(p),o.width+=v}n=p}return c(),t.align==="center"?yp(i):t.align==="right"?bp(i):t.align==="justify"&&vp(i),i}function yp(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function bp(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function vp(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let r=0,n=i.spacesIndex[r++],a=0;const o=i.spacesIndex.length,c=(t-i.width)/o;for(let l=0;l<i.charPositions.length;l++)l===n&&(n=i.spacesIndex[r++],a+=c),i.charPositions[l]+=a}}class Sp{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var a;let i=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&(i+=e._fill.fill.uid,r=!1),!K.has(i)){const o=new Bo({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});o.once("destroy",()=>K.remove(i)),K.set(i,o)}const n=K.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e){const i=this.getFont(t,e);return Ro([...t],e,i)}measureText(t,e){return this.getLayout(t,e)}install(...t){var c,l,u,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},N(W,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof me?r:new me(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new Bo({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Mo(e.chars);return o.ensureCharacters(h.join("")),K.set(`${i}-bitmap`,o),o.once("destroy",()=>K.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=K.get(e);i&&(K.remove(e),i.destroy())}}const Ir=new Sp;function wp(s){const t=s._stroke,e=s._fill,r=[`div { ${[`color: ${j.shared.setValue(e.color).toHex()}`,`font-size: ${s.fontSize}px`,`font-family: ${s.fontFamily}`,`font-weight: ${s.fontWeight}`,`font-style: ${s.fontStyle}`,`font-variant: ${s.fontVariant}`,`letter-spacing: ${s.letterSpacing}px`,`text-align: ${s.align}`,`padding: ${s.padding}px`,`white-space: ${s.whiteSpace==="pre"&&s.wordWrap?"pre-wrap":s.whiteSpace}`,...s.lineHeight?[`line-height: ${s.lineHeight}px`]:[],...s.wordWrap?[`word-wrap: ${s.breakWords?"break-all":"break-word"}`,`max-width: ${s.wordWrapWidth}px`]:[],...t?[Io(t)]:[],...s.dropShadow?[ko(s.dropShadow)]:[],...s.cssOverrides].join(";")} }`];return Tp(s.tagStyles,r),r.join(" ")}function ko(s){const t=j.shared.setValue(s.color).setAlpha(s.alpha).toHexa(),e=Math.round(Math.cos(s.angle)*s.distance),i=Math.round(Math.sin(s.angle)*s.distance),r=`${e}px ${i}px`;return s.blur>0?`text-shadow: ${r} ${s.blur}px ${t}`:`text-shadow: ${r} ${t}`}function Io(s){return[`-webkit-text-stroke-width: ${s.width}px`,`-webkit-text-stroke-color: ${j.shared.setValue(s.color).toHex()}`,`text-stroke-width: ${s.width}px`,`text-stroke-color: ${j.shared.setValue(s.color).toHex()}`,"paint-order: stroke"].join(";")}const Fo={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Go={fill:s=>`color: ${j.shared.setValue(s).toHex()}`,breakWords:s=>`word-wrap: ${s?"break-all":"break-word"}`,stroke:Io,dropShadow:ko};function Tp(s,t){for(const e in s){const i=s[e],r=[];for(const n in i)Go[n]?r.push(Go[n](i[n])):Fo[n]&&r.push(Fo[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${r.join(";")} }`)}}class Fr extends me{constructor(t={}){super(t),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=t.cssOverrides),this.tagStyles=t.tagStyles??{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Po(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Fr({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=wp(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){typeof t!="string"&&typeof t!="number"&&D("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=t}set stroke(t){t&&typeof t!="string"&&typeof t!="number"&&D("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=t}}const Uo="http://www.w3.org/2000/svg",Do="http://www.w3.org/1999/xhtml";class Oo{constructor(){this.svgRoot=document.createElementNS(Uo,"svg"),this.foreignObject=document.createElementNS(Uo,"foreignObject"),this.domElement=document.createElementNS(Do,"div"),this.styleElement=document.createElementNS(Do,"style"),this.image=new Image;const{foreignObject:t,svgRoot:e,styleElement:i,domElement:r}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(r)}}let Lo;function Ap(s,t,e,i){i=i||Lo||(Lo=new Oo);const{domElement:r,styleElement:n,svgRoot:a}=i;r.innerHTML=`<style>${t.cssStyle}</style><div>${s}</div>`,r.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(a);const o=r.getBoundingClientRect();a.remove();const h=Gt.measureFont(t.fontStyle).descent;return{width:o.width,height:o.height+h}}function Ho(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else D(`${i} placement hook does not exist in shader`)}}const Pp=/\{\{(.*?)\}\}/g;function No(s){var i;const t={};return(((i=s.match(Pp))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function zo(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Wo(s,t,e=!1){const i=[];zo(t,i),s.forEach(o=>{o.header&&zo(o.header,i)});const r=i;e&&r.sort();const n=r.map((o,h)=>`       @location(${h}) ${o},`).join(`
`);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
${n}
`),a}function Vo(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Ep(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Cp(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Mp(s,t){const e=[];Vo(t,e),s.forEach(h=>{h.header&&Vo(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
`),n=e.sort().map(h=>`       var ${Cp(h)};`).join(`
`),a=`return VSOutput(
                ${e.sort().map(h=>` ${Ep(h)}`).join(`,
`)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
${r}
`),o=o.replace("{{start}}",`
${n}
`),o=o.replace("{{return}}",`
${a}
`),o}function jo(s,t){let e=s;for(const i in t){const r=t[i];r.join(`
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
${r.join(`
`)}
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const re=Object.create(null),Gr=new Map;let Bp=0;function Rp({template:s,bits:t}){const e=$o(s,t);if(re[e])return re[e];const{vertex:i,fragment:r}=Ip(s,t);return re[e]=Xo(i,r,t),re[e]}function kp({template:s,bits:t}){const e=$o(s,t);return re[e]||(re[e]=Xo(s.vertex,s.fragment,t)),re[e]}function Ip(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=Wo(e,s.vertex,!0);r=Mp(e,r);const n=Wo(i,s.fragment,!0);return{vertex:r,fragment:n}}function $o(s,t){return t.map(e=>(Gr.has(e)||Gr.set(e,Bp++),Gr.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Xo(s,t,e){const i=No(s),r=No(t);return e.forEach(n=>{Ho(n.vertex,i,n.name),Ho(n.fragment,r,n.name)}),{vertex:jo(s,i),fragment:jo(t,r)}}const Fp=`
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        var position = aPosition;
        var uv = aUV;

        {{start}}
        
        vColor = vec4<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
       
        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`,Gp=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;
   
    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {
        
        {{start}}

        var outColor:vec4<f32>;
      
        {{main}}
        
        return outColor * vColor;
      };
`,Up=`
    in vec2 aPosition;
    in vec2 aUV;

    out vec4 vColor;
    out vec2 vUV;

    {{header}}

    void main(void){

        mat3 worldTransformMatrix = uWorldTransformMatrix;
        mat3 modelMatrix = mat3(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        vec2 position = aPosition;
        vec2 uv = aUV;
        
        {{start}}
        
        vColor = vec4(1.);
        
        {{main}}
        
        vUV = uv;
        
        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;

        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);

        vColor *= uWorldColorAlpha;

        {{end}}
    }
`,Dp=`
   
    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {
        
        {{start}}

        vec4 outColor;
      
        {{main}}
        
        finalColor = outColor * vColor;
    }
`,Op={name:"global-uniforms-bit",vertex:{header:`
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `}},Lp={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}};function ns({bits:s,name:t}){const e=Rp({template:{fragment:Gp,vertex:Fp},bits:[Op,...s]});return Re.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function as({bits:s,name:t}){return new je({name:t,...kp({template:{vertex:Up,fragment:Dp},bits:[Lp,...s]})})}const Ur={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},Dr={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}},Or={};function Hp(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
`)}function Np(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push("  default:{"):t.push(`  case ${e}:{`),t.push(`      outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push("      break;}");t.push("}")}return t.join(`
`)}function Lr(s){return Or[s]||(Or[s]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;
    
                ${Hp(Ht())}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);
    
                ${Np(Ht())}
            `}}),Or[s]}const Hr={};function zp(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(`	outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Nr(s){return Hr[s]||(Hr[s]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;
              
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;
    
                uniform sampler2D uTextures[${s}];
              
            `,main:`
    
                ${zp(Ht())}
            `}}),Hr[s]}const os={name:"round-pixels-bit",vertex:{header:`
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> 
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},hs={name:"round-pixels-bit",vertex:{header:`   
            vec2 roundPixels(vec2 position, vec2 targetSize)
            {       
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},Yo={};function zr(s){let t=Yo[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=Yo[s]=new _t({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class Ko{constructor(){this._didUpload=!1,this._tempState=Kt.for2d()}init(t){const e=Ht(),i=as({name:"batch",bits:[Dr,Nr(e),hs]});this._shader=new Tt({glProgram:i,resources:{batchSamplers:zr(e)}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const i=t.renderer;i.shader.bind(this._shader,this._didUpload),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,this._shader.glProgram)}execute(t,e){const i=t.renderer;this._didUpload=!0,this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const r=e.textures.textures;for(let n=0;n<r.length;n++)i.texture.bind(r[n],n);i.geometry.draw("triangle-list",e.size,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}Ko.extension={type:[b.WebGLPipesAdaptor],name:"batch"};const Qs=Kt.for2d();class qo{init(){const t=ns({name:"batch",bits:[Ur,Lr(Ht()),os]});this._shader=new Tt({gpuProgram:t,groups:{}})}start(t,e){const i=t.renderer,r=i.encoder,n=this._shader.gpuProgram;this._geometry=e,r.setGeometry(e),Qs.blendMode="normal",i.pipeline.getPipeline(e,n,Qs);const a=i.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,a,n)}execute(t,e){const i=this._shader.gpuProgram,r=t.renderer,n=r.encoder;if(!e.bindGroup){const h=e.textures;e.bindGroup=ur(h.textures,h.count)}Qs.blendMode=e.blendMode;const a=r.bindGroup.getBindGroup(e.bindGroup,i,1),o=r.pipeline.getPipeline(this._geometry,i,Qs);e.bindGroup._touch(r.textureGC.count),n.setPipeline(o),n.renderPassEncoder.setBindGroup(1,a),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}destroy(){this._shader.destroy(!0),this._shader=null}}qo.extension={type:[b.WebGPUPipesAdaptor],name:"batch"};class Zo{constructor(t,e){this.state=Kt.for2d(),this._batches=Object.create(null),this._geometries=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init(this)}buildStart(t){if(!this._batches[t.uid]){const e=new Za;this._batches[t.uid]=e,this._geometries[e.uid]=new Va}this._activeBatch=this._batches[t.uid],this._activeGeometry=this._geometries[this._activeBatch.uid],this._activeBatch.begin()}addToBatch(t){this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){const e=this._activeBatch,i=this._activeGeometry;e.finish(t),i.indexBuffer.setDataWithSize(e.indexBuffer,e.indexSize,!0),i.buffers[0].setDataWithSize(e.attributeBuffer.float32View,e.attributeSize,!1)}upload(t){const e=this._batches[t.uid],i=this._geometries[e.uid];e.dirty&&(e.dirty=!1,i.buffers[0].update(e.attributeSize*4))}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=this._geometries[e.uid];this._adaptor.start(this,i)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor.destroy(),this._adaptor=null;for(const t in this._batches)this._batches[t].destroy();this._batches=null;for(const t in this._geometries)this._geometries[t].destroy();this._geometries=null}}Zo.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};const cs={name:"local-uniform-bit",vertex:{header:`

            struct LocalUniforms {
                uTransformMatrix:mat3x3<f32>,
                uColor:vec4<f32>,
                uRound:f32,
            }

            @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `}},Wp={...cs,vertex:{...cs.vertex,header:cs.vertex.header.replace("group(1)","group(2)")}},Wr={name:"local-uniform-bit",vertex:{header:`

            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix = uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `}},Vp={name:"texture-bit",vertex:{header:`

        struct TextureUniforms {
            uTextureMatrix:mat3x3<f32>,
        }

        @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
        `,main:`
            uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
            @group(2) @binding(0) var uTexture: texture_2d<f32>;
            @group(2) @binding(1) var uSampler: sampler;

         
        `,main:`
            outColor = textureSample(uTexture, uSampler, vUV);
        `}},jp={name:"texture-bit",vertex:{header:`
            uniform mat3 uTextureMatrix;
        `,main:`
            uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
        uniform sampler2D uTexture;

         
        `,main:`
            outColor = texture(uTexture, vUV);
        `}};function $p(s,t){const e=s.root,i=s.instructionSet;i.reset(),t.batch.buildStart(i),t.blendMode.buildStart(),t.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),Jo(e,i,t,!0),t.batch.buildEnd(i),t.blendMode.buildEnd(i)}function ti(s,t,e){s.globalDisplayStatus<7||!s.includeInBuild||(s.sortableChildren&&s.sortChildren(),s.isSimple?Xp(s,t,e):Jo(s,t,e,!1))}function Xp(s,t,e){if(s.renderPipeId&&(e.blendMode.setBlendMode(s,s.groupBlendMode,t),s.didViewUpdate=!1,e[s.renderPipeId].addRenderable(s,t)),!s.renderGroup){const i=s.children,r=i.length;for(let n=0;n<r;n++)ti(i[n],t,e)}}function Jo(s,t,e,i){if(!i&&s.renderGroup)e.renderGroup.addRenderGroup(s.renderGroup,t);else{for(let a=0;a<s.effects.length;a++){const o=s.effects[a];e[o.pipe].push(o,s,t)}const r=s.renderPipeId;r&&(e.blendMode.setBlendMode(s,s.groupBlendMode,t),s.didViewUpdate=!1,e[r].addRenderable(s,t));const n=s.children;if(n.length)for(let a=0;a<n.length;a++)ti(n[a],t,e);for(let a=s.effects.length-1;a>=0;a--){const o=s.effects[a];e[o.pipe].pop(o,s,t)}}}const Yp=new pt;class Kp extends Cs{constructor(){super(),this.filters=[new dp({sprite:new wt(M.EMPTY)})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}}class Qo{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const r=this._renderer;if(r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,ti(n,i,r.renderPipes),n.includeInBuild=!1}r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const r=$.get(Kp);if(i){t.mask.mask.measurable=!0;const n=Mi(t.mask.mask,!0,Yp);t.mask.mask.measurable=!1,n.ceil();const a=At.getOptimalTexture(n.width,n.height,1,!1);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer,filterTexture:a})}else r.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const r=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const r=this._activeMaskStage.pop();i&&At.returnTexture(r.filterTexture),$.return(r.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Qo.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"};class th{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const a=this._colorStack[this._colorStackIndex];a!==this._currentColor&&(this._currentColor=a,i.add({renderPipeId:"colorMask",colorMask:a,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const a=n[this._colorStackIndex-1];a!==this._currentColor&&(this._currentColor=a,i.add({renderPipeId:"colorMask",colorMask:a,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}th.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"colorMask"};class eh{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var r;const n=t,a=this._renderer;a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const h=this._maskHash.get(n);h.instructionsStart=i.instructionSize,ti(o,i,a.renderPipes),o.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const c=i.instructionSize-h.instructionsStart-1;h.instructionsLength=c;const l=a.renderTarget.renderTarget.uid;(r=this._maskStackHash)[l]??(r[l]=0)}pop(t,e,i){const r=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(r.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});const a=this._maskHash.get(t);for(let o=0;o<a.instructionsLength;o++)i.instructions[i.instructionSize++]=i.instructions[a.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,r=i.renderTarget.renderTarget.uid;let n=(e=this._maskStackHash)[r]??(e[r]=0);t.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(ct.RENDERING_MASK_ADD,n),n++,i.colorMask.setMask(0)):t.action==="pushMaskEnd"?(i.stencil.setStencilMode(ct.MASK_ACTIVE,n),i.colorMask.setMask(15)):t.action==="popMaskBegin"?(i.colorMask.setMask(0),n!==0?i.stencil.setStencilMode(ct.RENDERING_MASK_REMOVE,n):(i.renderTarget.clear(null,xt.STENCIL),i.stencil.setStencilMode(ct.DISABLED,n)),n--):t.action==="popMaskEnd"&&(i.stencil.setStencilMode(ct.MASK_ACTIVE,n),i.colorMask.setMask(15)),this._maskStackHash[r]=n}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}eh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"stencilMask"};var ei=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(ei||{});class qp{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class sh{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;if(this._boundBufferBases[e]!==t){const r=this.getGlBuffer(t);this._boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,r.buffer)}}bindBufferRange(t,e,i){const{_gl:r}=this;i=i||0;const n=this.getGlBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const r=t.data;if(i.byteLength>=t.data.byteLength)e.bufferSubData(i.type,0,r,0,t._updateSize/r.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&V.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;i.byteLength=r.byteLength,e.bufferData(i.type,r,n)}return i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],r=this._gl;e||r.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=ei.ARRAY_BUFFER;t.descriptor.usage&V.INDEX?i=ei.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&V.UNIFORM&&(i=ei.UNIFORM_BUFFER);const r=new qp(e.createBuffer(),i);return this._gpuBuffers[t.uid]=r,t.on("destroy",this.onBufferDestroy,this),r}}sh.extension={type:[b.WebGLSystem],name:"buffer"};const Vr=class bl{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){if(t={...bl.defaultOptions,...t},t.context)this.initFromContext(t.context);else{const e=this._renderer.background.alpha<1,i=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:i,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof L.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const r=this._renderer.view.canvas;if(t===2&&(i=r.getContext("webgl2",e)),!i&&(i=r.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...e,drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")};else{this.extensions={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var e;const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(e=this.extensions.loseContext)==null||e.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&D("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const i=this.supports,r=this.webGLVersion===2,n=this.extensions;i.uint32Indices=r||!!n.uint32ElementIndex,i.uniformBufferObject=r,i.vertexArrayObject=r||!!n.vertexArrayObject,i.srgbTextures=r||!!n.srgb,i.nonPowOf2wrapping=r,i.nonPowOf2mipmaps=r,i.msaa=r,i.uint32Indices||D("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Vr.extension={type:[b.WebGLSystem],name:"context"},Vr.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let Zp=Vr;function ih(s,t){for(const e in s.attributes){const i=s.attributes[e],r=t[e];r?(i.location??(i.location=r.location),i.format??(i.format=r.format),i.offset??(i.offset=r.offset),i.instance??(i.instance=r.instance)):D(`Attribute ${e} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}Jp(s)}function Jp(s){const{buffers:t,attributes:e}=s,i={},r={};for(const n in t){const a=t[n];i[a.uid]=0,r[a.uid]=0}for(const n in e){const a=e[n];i[a.buffer.uid]+=$e(a.format).stride}for(const n in e){const a=e[n];a.stride??(a.stride=i[a.buffer.uid]),a.start??(a.start=r[a.buffer.uid]),r[a.buffer.uid]+=$e(a.format).stride}}var jr=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(jr||{}),rh=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(rh||{}),H=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(H||{});const nh={uint8x2:H.UNSIGNED_BYTE,uint8x4:H.UNSIGNED_BYTE,sint8x2:H.BYTE,sint8x4:H.BYTE,unorm8x2:H.UNSIGNED_BYTE,unorm8x4:H.UNSIGNED_BYTE,snorm8x2:H.BYTE,snorm8x4:H.BYTE,uint16x2:H.UNSIGNED_SHORT,uint16x4:H.UNSIGNED_SHORT,sint16x2:H.SHORT,sint16x4:H.SHORT,unorm16x2:H.UNSIGNED_SHORT,unorm16x4:H.UNSIGNED_SHORT,snorm16x2:H.SHORT,snorm16x4:H.SHORT,float16x2:H.HALF_FLOAT,float16x4:H.HALF_FLOAT,float32:H.FLOAT,float32x2:H.FLOAT,float32x3:H.FLOAT,float32x4:H.FLOAT,uint32:H.UNSIGNED_INT,uint32x2:H.UNSIGNED_INT,uint32x3:H.UNSIGNED_INT,uint32x4:H.UNSIGNED_INT,sint32:H.INT,sint32x2:H.INT,sint32x3:H.INT,sint32x4:H.INT};function Qp(s){return nh[s]??nh.float32}const tm={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ah{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=r=>e.bindVertexArrayOES(r),t.deleteVertexArray=r=>e.deleteVertexArrayOES(r));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(r,n,a,o)=>{i.drawArraysInstancedANGLE(r,n,a,o)},t.drawElementsInstanced=(r,n,a,o,h)=>{i.drawElementsInstancedANGLE(r,n,a,o,h)},t.vertexAttribDivisor=(r,n)=>i.vertexAttribDivisorANGLE(r,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const r=this.getVao(t,e);this._activeVao!==r&&(this._activeVao=r,i.bindVertexArray(r)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.updateBuffer(r)}}checkCompatibility(t,e){const i=t.attributes,r=e._attributeData;for(const n in r)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,r=e._attributeData,n=["g",t.uid];for(const a in i)r[a]&&n.push(a,r[a].location);return n.join("-")}getVao(t,e){var i;return((i=this._geometryVaoHash[t.uid])==null?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const r=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const a=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const o=this._geometryVaoHash[t.uid];let h=o[a];if(h)return o[e._key]=h,h;ih(t,e._attributeData);const c=t.buffers;h=r.createVertexArray(),r.bindVertexArray(h);for(let l=0;l<c.length;l++){const u=c[l];n.bind(u)}return this.activateVao(t,e),o[e._key]=h,o[a]=h,r.bindVertexArray(null),h}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],r=this.gl;if(i){if(e)for(const n in i)this._activeVao!==i[n]&&this.unbind(),r.deleteVertexArray(i[n]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const r in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[r])}this._geometryVaoHash[i]=null}}activateVao(t,e){var o;const i=this._renderer.gl,r=this._renderer.buffer,n=t.attributes;t.indexBuffer&&r.bind(t.indexBuffer);let a=null;for(const h in n){const c=n[h],l=c.buffer,u=r.getGlBuffer(l),d=e._attributeData[h];if(d){a!==u&&(r.bind(l),a=u);const f=c.location;i.enableVertexAttribArray(f);const p=$e(c.format),g=Qp(c.format);if(((o=d.format)==null?void 0:o.substring(1,4))==="int"?i.vertexAttribIPointer(f,p.size,g,c.stride,c.offset):i.vertexAttribPointer(f,p.size,g,p.normalised,c.stride,c.offset),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,1);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,r){const{gl:n}=this._renderer,a=this._activeGeometry,o=tm[a.topology||t];if(r||(r=a.instanceCount),a.indexBuffer){const h=a.indexBuffer.data.BYTES_PER_ELEMENT,c=h===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;r>1?n.drawElementsInstanced(o,e||a.indexBuffer.data.length,c,(i||0)*h,r):n.drawElements(o,e||a.indexBuffer.data.length,c,(i||0)*h)}else r>1?n.drawArraysInstanced(o,i||0,e||a.getSize(),r):n.drawArrays(o,i||0,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ah.extension={type:[b.WebGLSystem],name:"geometry"};const em=new $s({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),$r=class vl{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}={...vl.defaultOptions,...t};this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(D("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Kt.for2d();const r=new je({vertex:`
                attribute vec2 aPosition;
                out vec2 vUv;

                void main() {
                    gl_Position = vec4(aPosition, 0.0, 1.0);

                    vUv = (aPosition + 1.0) / 2.0;

                    // flip dem UVs
                    vUv.y = 1.0 - vUv.y;
                }`,fragment:`
                in vec2 vUv;
                out vec4 finalColor;

                uniform sampler2D uTexture;

                void main() {
                    finalColor = texture(uTexture, vUv);
                }`,name:"big-triangle"});this._bigTriangleShader=new Tt({glProgram:r,resources:{uTexture:M.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:em,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new M({source:new ut({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};$r.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1},$r.defaultOptions={useBackBuffer:!1};let sm=$r;class oh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}oh.extension={type:[b.WebGLSystem],name:"colorMask"};class hh{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:r,state:n,skipSync:a,topology:o,size:h,start:c,instanceCount:l}=t;e.shader.bind(r,a),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(o,h,c,l??i.instanceCount)}destroy(){this._renderer=null}}hh.extension={type:[b.WebGLSystem],name:"encoder"};class im{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ge=[];ge[ct.NONE]=void 0,ge[ct.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ge[ct.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ge[ct.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ge[ct.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class ch{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ct.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=ct.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ct.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,n=ge[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===ct.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,r.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}ch.extension={type:[b.WebGLSystem],name:"stencil"};class lh{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ra())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new Rt({data:new Float32Array(e.layout.size/4),usage:V.UNIFORM|V.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const r=Object.keys(t.uniformStructures).map(o=>t.uniformStructures[o]),n=this._adaptor.createUboElements(r),a=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:a}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const r=this.getUniformGroupData(t);return t.buffer||(t.buffer=new Rt({data:new Float32Array(r.layout.size/4),usage:V.UNIFORM|V.COPY_DST})),e||(e=t.buffer.data),i||(i=0),r.syncFunction(t.uniforms,e,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const uh={f32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"mat2x2<f32>":16*2,"mat3x3<f32>":16*3,"mat4x4<f32>":16*4};function rm(s){const t=s.map(n=>({data:n,offset:0,size:0}));let e=0,i=0,r=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=uh[a.data.type],!e)throw new Error(`Unknown type ${a.data.type}`);if(a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.size=e,i%e!==0&&i<16){const o=i%e%16;i+=o,r+=o}i+e>16?(r=Math.ceil(r/16)*16,a.offset=r,r+=e,i=e):(a.offset=r,i+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}const _e=[{type:"mat3x3<f32>",test:s=>s.value.a!==void 0,ubo:`
            var matrix = uv[name].toArray(true);
            data[offset] = matrix[0];
            data[offset + 1] = matrix[1];
            data[offset + 2] = matrix[2];
            data[offset + 4] = matrix[3];
            data[offset + 5] = matrix[4];
            data[offset + 6] = matrix[5];
            data[offset + 8] = matrix[6];
            data[offset + 9] = matrix[7];
            data[offset + 10] = matrix[8];
        `,uniform:` 
            gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
        `},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.width!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
            data[offset + 2] = v.width;
            data[offset + 3] = v.height;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
                cv[0] = v.x;
                cv[1] = v.y;
                cv[2] = v.width;
                cv[3] = v.height;
                gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
            }
        `},{type:"vec2<f32>",test:s=>s.type==="vec2<f32>"&&s.size===1&&s.value.x!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y) {
                cv[0] = v.x;
                cv[1] = v.y;
                gl.uniform2f(ud[name].location, v.x, v.y);
            }
        `},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
            data[offset + 3] = v.alpha;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                cv[3] = v.alpha;
                gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
            }
        `},{type:"vec3<f32>",test:s=>s.type==="vec3<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
            }
        `}];function dh(s,t,e,i){const r=[`
        var v = null;
        var v2 = null;
        var t = 0;
        var index = 0;
        var name = null;
        var arrayOffset = null;
    `];let n=0;for(let o=0;o<s.length;o++){const h=s[o],c=h.data.name;let l=!1,u=0;for(let d=0;d<_e.length;d++)if(_e[d].test(h.data)){u=h.offset/4,r.push(`name = "${c}";`,`offset += ${u-n};`,_e[d][t]||_e[d].ubo),l=!0;break}if(!l)if(h.data.size>1)u=h.offset/4,r.push(e(h,u-n));else{const d=i[h.data.type];u=h.offset/4,r.push(`
                    v = uv.${c};
                    offset += ${u-n};
                    ${d};
                `)}n=u}const a=r.join(`
`);return new Function("uv","data","offset",a)}function Le(s,t){return`
        for (let i = 0; i < ${s*t}; i++) {
            data[offset + (((i / ${s})|0) * 4) + (i % ${s})] = v[i];
        }
    `}const fh={f32:`
        data[offset] = v;`,i32:`
        data[offset] = v;`,"vec2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];`,"vec3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];`,"vec4<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];`,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 4] = v[2];
        data[offset + 5] = v[3];`,"mat3x3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 4] = v[3];
        data[offset + 5] = v[4];
        data[offset + 6] = v[5];
        data[offset + 8] = v[6];
        data[offset + 9] = v[7];
        data[offset + 10] = v[8];`,"mat4x4<f32>":`
        for (let i = 0; i < 16; i++) {
            data[offset + i] = v[i];
        }`,"mat3x2<f32>":Le(3,2),"mat4x2<f32>":Le(4,2),"mat2x3<f32>":Le(2,3),"mat4x3<f32>":Le(4,3),"mat2x4<f32>":Le(2,4),"mat3x4<f32>":Le(3,4)},nm={...fh,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];
    `};function am(s,t){const e=Math.max(uh[s.data.type]/16,1),i=s.data.value.length/s.data.size,r=(4-i%4)%4;return`
        v = uv.${s.data.name};
        offset += ${t};

        arrayOffset = offset;

        t = 0;

        for(var i=0; i < ${s.data.size*e}; i++)
        {
            for(var j = 0; j < ${i}; j++)
            {
                data[arrayOffset++] = v[t++];
            }
            ${r!==0?`arrayOffset += ${r};`:""}
        }
    `}function om(s){return dh(s,"uboStd40",am,fh)}class ph extends lh{constructor(){super({createUboElements:rm,generateUboSync:om})}}ph.extension={type:[b.WebGLSystem],name:"ubo"};class hm{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Y}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Y}copyToTexture(t,e,i,r,n){const a=this._renderTargetSystem,o=this._renderer,h=a.getGpuRenderTarget(t),c=o.gl;return this.finishRenderPass(t),c.bindFramebuffer(c.FRAMEBUFFER,h.resolveTargetFramebuffer),o.texture.bind(e,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,n.x,n.y,i.x,i.y,r.width,r.height),e}startRenderPass(t,e=!0,i,r){const n=this._renderTargetSystem,a=t.colorTexture,o=n.getGpuRenderTarget(t);let h=r.y;t.isRoot&&(h=a.pixelHeight-r.height),t.colorTextures.forEach(u=>{this._renderer.texture.unbind(u)});const c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;(l.x!==r.x||l.y!==h||l.width!==r.width||l.height!==r.height)&&(l.x=r.x,l.y=h,l.width=r.width,l.height=r.height,c.viewport(r.x,h,r.width,r.height)),!o.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const i=this._renderTargetSystem.getGpuRenderTarget(t);if(!i.msaa)return;const r=this._renderer.gl;r.bindFramebuffer(r.FRAMEBUFFER,i.resolveTargetFramebuffer),r.bindFramebuffer(r.READ_FRAMEBUFFER,i.framebuffer),r.blitFramebuffer(0,0,i.width,i.height,0,0,i.width,i.height,r.COLOR_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,i.framebuffer)}initGpuRenderTarget(t){const e=this._renderer,i=e.gl,r=new im;return t.colorTexture.resource===e.gl.canvas?(r.framebuffer=null,r):(this._initColor(t,r),i.bindFramebuffer(i.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const r=this._renderTargetSystem;typeof e=="boolean"&&(e=e?xt.ALL:xt.NONE);const n=this._renderer.gl;if(e&xt.COLOR){i??(i=r.defaultClearColor);const a=this._clearColorCache,o=i;(a[0]!==o[0]||a[1]!==o[1]||a[2]!==o[2]||a[3]!==o[3])&&(a[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],n.clearColor(o[0],o[1],o[2],o[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const i=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,i),t.stencil&&this._resizeStencil(i)}_initColor(t,e){const i=this._renderer,r=i.gl,n=r.createFramebuffer();if(e.resolveTargetFramebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,o)=>{const h=a.source;h.antialias&&(i.context.supports.msaa?e.msaa=!0:D("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(h,0);const l=i.texture.getGlSource(h).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+o,3553,l,0)}),e.msaa){const a=r.createFramebuffer();e.framebuffer=a,r.bindFramebuffer(r.FRAMEBUFFER,a),t.colorTextures.forEach((o,h)=>{const c=r.createRenderbuffer();e.msaaRenderBuffer[h]=c})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((r,n)=>{n!==0&&r.source.resize(i.width,i.height,i._resolution)}),e.msaa){const r=this._renderer,n=r.gl,a=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,a),t.colorTextures.forEach((o,h)=>{const c=o.source;r.texture.bindSource(c,0);const u=r.texture.getGlSource(c).internalFormat,d=e.msaaRenderBuffer[h];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,c.pixelWidth,c.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+h,n.RENDERBUFFER,d)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}}function cm(s,t,e,i,r,n){const a=n?1:-1;return s.identity(),s.a=1/i*2,s.d=a*(1/r*2),s.tx=-1-t*s.a,s.ty=-a-e*s.d,s}const ls=new Map;function mh(s,t){if(!ls.has(s)){const e=new M({source:new Pe({resource:s,...t})}),i=()=>{ls.get(s)===e&&ls.delete(s)};e.once("destroy",i),e.source.once("destroy",i),ls.set(s,e)}return ls.get(s)}function lm(s){const t=s.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}const gh=class Sl{constructor(t={}){if(this.uid=et("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...Sl.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new ut({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof M||t.depthStencilTexture instanceof ut?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ut({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,r=!1){this.dirtyId++,this.colorTextures.forEach((n,a)=>{r&&a===0||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};gh.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Xr=gh;class _h{constructor(t){this.rootViewPort=new Y,this.viewport=new Y,this.onRenderTargetChange=new Ua("onRenderTargetChange"),this.projectionMatrix=new I,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:r}){this._renderTargetStack.length=0,this.push(t,e,i,r),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=lm(this.rootRenderTarget)}bind(t,e=!0,i,r){const n=this.getRenderTarget(t),a=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const o=this.getGpuRenderTarget(n);(n.pixelWidth!==o.width||n.pixelHeight!==o.height)&&(this.adaptor.resizeGpuRenderTarget(n),o.width=n.pixelWidth,o.height=n.pixelHeight);const h=n.colorTexture,c=this.viewport,l=h.pixelWidth,u=h.pixelHeight;if(!r&&t instanceof M&&(r=t.frame),r){const d=h._resolution;c.x=r.x*d+.5|0,c.y=r.y*d+.5|0,c.width=r.width*d+.5|0,c.height=r.height*d+.5|0}else c.x=0,c.y=0,c.width=l,c.height=u;return cm(this.projectionMatrix,0,0,c.width/h.resolution,c.height/h.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,c),a&&this.onRenderTargetChange.emit(n),n}clear(t,e=xt.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=xt.ALL,i,r){const n=this.bind(t,e,i,r);return this._renderTargetStack.push({renderTarget:n,frame:r}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,i,r,n){i.x<0&&(r.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(r.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:a,pixelHeight:o}=t;return r.width=Math.min(r.width,a-i.x),r.height=Math.min(r.height,o-i.y),this.adaptor.copyToTexture(t,e,i,r,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Pe.test(t)&&(t=mh(t).source),t instanceof Xr?e=t:t instanceof ut&&(e=new Xr({colorTextures:[t]}),Pe.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy();const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}}class xh extends _h{constructor(t){super(t),this.adaptor=new hm,this.adaptor.init(t,this)}}xh.extension={type:[b.WebGLSystem],name:"renderTarget"};class Yr extends gt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=et("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=et("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=et("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function um(s,t){const e=[],i=[`
        var g = s.groups;
        var sS = r.shader;
        var p = s.glProgram;
        var ugS = r.uniformGroup;
        var resources;
    `];let r=!1,n=0,a=0;const o=t._getProgramData(s.glProgram);for(const c in s.groups){const l=s.groups[c];e.push(`
            resources = g[${c}].resources;
        `);for(const u in l.resources){const d=l.resources[u];if(d instanceof _t)d.ubo?e.push(`
                        sS.bindUniformBlock(
                            resources[${u}],
                            sS._uniformBindMap[${c}[${u}],
                            ${n++}
                        );
                    `):e.push(`
                        ugS.updateUniformGroup(resources[${u}], p, sD);
                    `);else if(d instanceof Yr)e.push(`
                    sS.bindUniformBlock(
                        resources[${u}],
                        sS._uniformBindMap[${c}[${u}],
                        ${n++}
                    );
                `);else if(d instanceof ut){const f=s._uniformBindMap[c][u],p=o.uniformData[f];p&&(r||(r=!0,i.push(`
                        var tS = r.texture;
                        `)),t._gl.uniform1i(p.location,a),e.push(`
                        tS.bind(resources[${u}], ${a});
                    `),a++)}}}const h=[...i,...e].join(`
`);return new Function("r","s","sD",h)}class dm{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function yh(s,t,e){const i=s.createShader(t);return s.shaderSource(i,e),s.compileShader(i),i}function Kr(s){const t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function bh(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Kr(2*t);case"bvec3":return Kr(3*t);case"bvec4":return Kr(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let si=null;const vh={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},fm={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Sh(s,t){if(!si){const e=Object.keys(vh);si={};for(let i=0;i<e.length;++i){const r=e[i];si[s[r]]=vh[r]}}return si[t]}function pm(s,t){const e=Sh(s,t);return fm[e]||"float32"}function mm(s,t,e=!1){const i={},r=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let a=0;a<r;a++){const o=t.getActiveAttrib(s,a);if(o.name.startsWith("gl_"))continue;const h=pm(t,o.type);i[o.name]={location:0,format:h,stride:$e(h).stride,offset:0,instance:!1,start:0}}const n=Object.keys(i);if(e){n.sort((a,o)=>a>o?1:-1);for(let a=0;a<n.length;a++)i[n[a]].location=a,t.bindAttribLocation(s,a,n[a]);t.linkProgram(s)}else for(let a=0;a<n.length;a++)i[n[a]].location=t.getAttribLocation(s,n[a]);return i}function gm(s,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r<i;r++){const n=t.getActiveUniformBlockName(s,r),a=t.getUniformBlockIndex(s,n),o=t.getActiveUniformBlockParameter(s,r,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:a,size:o}}return e}function _m(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const n=t.getActiveUniform(s,r),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),h=Sh(t,n.type);e[a]={name:a,index:r,type:h,size:n.size,isArray:o,value:bh(h,n.size)}}return e}function wh(s,t){const e=s.getShaderSource(t).split(`
`).map((c,l)=>`${l}: ${c}`),i=s.getShaderInfoLog(t),r=i.split(`
`),n={},a=r.map(c=>parseFloat(c.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(c=>c&&!n[c]?(n[c]=!0,!0):!1),o=[""];a.forEach(c=>{e[c-1]=`%c${e[c-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
`);o[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function xm(s,t,e,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||wh(s,e),s.getShaderParameter(i,s.COMPILE_STATUS)||wh(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}function ym(s,t){const e=yh(s,s.VERTEX_SHADER,t.vertex),i=yh(s,s.FRAGMENT_SHADER,t.fragment),r=s.createProgram();s.attachShader(r,e),s.attachShader(r,i);const n=t.transformFeedbackVaryings;n&&(typeof s.transformFeedbackVaryings!="function"?D("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||xm(s,r,e,i),t._attributeData=mm(r,s,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=_m(r,s),t._uniformBlockData=gm(r,s),s.deleteShader(e),s.deleteShader(i);const a={};for(const h in t._uniformData){const c=t._uniformData[h];a[h]={location:s.getUniformLocation(r,h),value:bh(c.type,c.size)}}return new dm(r,a)}const ii={textureCount:0,blockIndex:0};class Th{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;ii.textureCount=0,ii.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),i(this._renderer,t,ii)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ii)}bindUniformBlock(t,e,i=0){const r=this._renderer.buffer,n=this._getProgramData(this._activeProgram),a=t._bufferResource;a&&this._renderer.ubo.updateUniformGroup(t),r.updateBuffer(t.buffer);let o=this._boundUniformsIdsToIndexHash[t.uid];if(o===void 0){const l=this._nextIndex++%this._maxBindings,u=this._boundIndexToUniformsHash[l];u&&(this._boundUniformsIdsToIndexHash[u.uid]=void 0),o=this._boundUniformsIdsToIndexHash[t.uid]=l,this._boundIndexToUniformsHash[l]=t,a?r.bindBufferRange(t.buffer,l,t.offset):r.bindBufferBase(t.buffer,l)}const h=this._gl,c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==o&&(n.uniformBlockBindings[i]=o,h.uniformBlockBinding(n.program,c,o))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=ym(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return um(t,e)}}Th.extension={type:[b.WebGLSystem],name:"shader"};const bm={f32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1f(location, v);
        }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2f(location, v[0], v[1]);
        }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3f(location, v[0], v[1], v[2]);
        }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4f(location, v[0], v[1], v[2], v[3]);
        }`,i32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,u32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1ui(location, v);
        }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2ui(location, v[0], v[1]);
        }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3ui(location, v[0], v[1], v[2]);
        }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
        }`,bool:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},vm={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function Sm(s,t){const e=[`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
        var name = null;
    `];for(const i in s.uniforms){if(!t[i]){s.uniforms[i]instanceof _t?s.uniforms[i].ubo?e.push(`
                        renderer.shader.bindUniformBlock(uv.${i}, "${i}");
                    `):e.push(`
                        renderer.shader.updateUniformGroup(uv.${i});
                    `):s.uniforms[i]instanceof Yr&&e.push(`
                        renderer.shader.bindBufferResource(uv.${i}, "${i}");
                    `);continue}const r=s.uniformStructures[i];let n=!1;for(let a=0;a<_e.length;a++){const o=_e[a];if(r.type===o.type&&o.test(r)){e.push(`name = "${i}";`,_e[a].uniform),n=!0;break}}if(!n){const o=(r.size===1?bm:vm)[r.type].replace("location",`ud["${i}"].location`);e.push(`
            cu = ud["${i}"];
            cv = cu.value;
            v = uv["${i}"];
            ${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
`))}class Ah{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const r=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==r.uniformDirtyGroups[t.uid])&&(r.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(r.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){var i;return((i=this._uniformGroupSyncHash[t._signature])==null?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),r=this._getSignature(t,e._uniformData,"u");return this._cache[r]||(this._cache[r]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[r],i[e._key]}_generateUniformsSync(t,e){return Sm(t,e)}_getSignature(t,e,i){const r=t.uniforms,n=[`${i}-`];for(const a in r)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Ah.extension={type:[b.WebGLSystem],name:"uniformGroup"};function wm(s){const t={};return t.normal=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t.add=[s.ONE,s.ONE],t.multiply=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.screen=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t["screen-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.erase=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t}const Tm=0,Am=1,Pm=2,Em=3,Cm=4,Mm=5,Ph=class Sn{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Tm]=this.setBlend,this.map[Am]=this.setOffset,this.map[Pm]=this.setCullFace,this.map[Em]=this.setDepthTest,this.map[Cm]=this.setFrontFace,this.map[Mm]=this.setDepthMask,this.checks=[],this.defaultState=Kt.for2d()}contextChange(t){this.gl=t,this.blendModesMap=wm(t),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(Sn._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Sn._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Ph.extension={type:[b.WebGLSystem],name:"state"};let Bm=Ph;class Rm{constructor(t){this.target=rh.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=H.UNSIGNED_BYTE,this.internalFormat=jr.RGBA,this.format=jr.RGBA,this.samplerType=0}}const km={id:"buffer",upload(s,t,e){t.width===s.width||t.height===s.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,s.width,s.height,t.format,t.type,s.resource):e.texImage2D(t.target,0,t.internalFormat,s.width,s.height,0,t.format,t.type,s.resource),t.width=s.width,t.height=s.height}},Im={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Fm={id:"compressed",upload(s,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=s.pixelWidth,r=s.pixelHeight;const n=!!Im[s.format];for(let a=0;a<s.resource.length;a++){const o=s.resource[a];n?e.compressedTexImage2D(e.TEXTURE_2D,a,t.internalFormat,i,r,0,o):e.texImage2D(e.TEXTURE_2D,a,t.internalFormat,i,r,0,t.format,t.type,o),i=Math.max(i>>1,1),r=Math.max(r>>1,1)}}},Eh={id:"image",upload(s,t,e,i){const r=s.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);const n=t.width,a=t.height,o=s.pixelWidth,h=s.pixelHeight,c=s.resourceWidth,l=s.resourceHeight;c<o||l<h?((n!==o||a!==h)&&e.texImage2D(t.target,0,t.internalFormat,o,h,0,t.format,t.type,null),i===2?e.texSubImage2D(e.TEXTURE_2D,0,0,0,c,l,t.format,t.type,s.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,s.resource)):n===o||a===h?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,s.resource):i===2?e.texImage2D(t.target,0,t.internalFormat,o,h,0,t.format,t.type,s.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,s.resource),t.width=o,t.height=h}},Gm={id:"video",upload(s,t,e,i){if(!s.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Eh.upload(s,t,e,i)}},Ch={linear:9729,nearest:9728},Um={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},qr={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Dm={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Mh(s,t,e,i,r,n,a,o){const h=n;if(!o||s.addressModeU!=="repeat"||s.addressModeV!=="repeat"||s.addressModeW!=="repeat"){const c=qr[a?"clamp-to-edge":s.addressModeU],l=qr[a?"clamp-to-edge":s.addressModeV],u=qr[a?"clamp-to-edge":s.addressModeW];t[r](h,t.TEXTURE_WRAP_S,c),t[r](h,t.TEXTURE_WRAP_T,l),t.TEXTURE_WRAP_R&&t[r](h,t.TEXTURE_WRAP_R,u)}if((!o||s.magFilter!=="linear")&&t[r](h,t.TEXTURE_MAG_FILTER,Ch[s.magFilter]),e){if(!o||s.mipmapFilter!=="linear"){const c=Um[s.minFilter][s.mipmapFilter];t[r](h,t.TEXTURE_MIN_FILTER,c)}}else t[r](h,t.TEXTURE_MIN_FILTER,Ch[s.minFilter]);if(i&&s.maxAnisotropy>1){const c=Math.min(s.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[r](h,i.TEXTURE_MAX_ANISOTROPY_EXT,c)}s.compare&&t[r](h,t.TEXTURE_COMPARE_FUNC,Dm[s.compare])}function Om(s){return{r8unorm:s.RED,r8snorm:s.RED,r8uint:s.RED,r8sint:s.RED,r16uint:s.RED,r16sint:s.RED,r16float:s.RED,rg8unorm:s.RG,rg8snorm:s.RG,rg8uint:s.RG,rg8sint:s.RG,r32uint:s.RED,r32sint:s.RED,r32float:s.RED,rg16uint:s.RG,rg16sint:s.RG,rg16float:s.RG,rgba8unorm:s.RGBA,"rgba8unorm-srgb":s.RGBA,rgba8snorm:s.RGBA,rgba8uint:s.RGBA,rgba8sint:s.RGBA,bgra8unorm:s.RGBA,"bgra8unorm-srgb":s.RGBA,rgb9e5ufloat:s.RGB,rgb10a2unorm:s.RGBA,rg11b10ufloat:s.RGB,rg32uint:s.RG,rg32sint:s.RG,rg32float:s.RG,rgba16uint:s.RGBA,rgba16sint:s.RGBA,rgba16float:s.RGBA,rgba32uint:s.RGBA,rgba32sint:s.RGBA,rgba32float:s.RGBA,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT,depth24plus:s.DEPTH_COMPONENT,"depth24plus-stencil8":s.DEPTH_STENCIL,depth32float:s.DEPTH_COMPONENT,"depth32float-stencil8":s.DEPTH_STENCIL}}function Lm(s,t){let e={},i=s.RGBA;return s instanceof L.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":s.SRGB8_ALPHA8,"bgra8unorm-srgb":s.SRGB8_ALPHA8},i=s.RGBA8),{r8unorm:s.R8,r8snorm:s.R8_SNORM,r8uint:s.R8UI,r8sint:s.R8I,r16uint:s.R16UI,r16sint:s.R16I,r16float:s.R16F,rg8unorm:s.RG8,rg8snorm:s.RG8_SNORM,rg8uint:s.RG8UI,rg8sint:s.RG8I,r32uint:s.R32UI,r32sint:s.R32I,r32float:s.R32F,rg16uint:s.RG16UI,rg16sint:s.RG16I,rg16float:s.RG16F,rgba8unorm:s.RGBA,...e,rgba8snorm:s.RGBA8_SNORM,rgba8uint:s.RGBA8UI,rgba8sint:s.RGBA8I,bgra8unorm:i,rgb9e5ufloat:s.RGB9_E5,rgb10a2unorm:s.RGB10_A2,rg11b10ufloat:s.R11F_G11F_B10F,rg32uint:s.RG32UI,rg32sint:s.RG32I,rg32float:s.RG32F,rgba16uint:s.RGBA16UI,rgba16sint:s.RGBA16I,rgba16float:s.RGBA16F,rgba32uint:s.RGBA32UI,rgba32sint:s.RGBA32I,rgba32float:s.RGBA32F,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT16,depth24plus:s.DEPTH_COMPONENT24,"depth24plus-stencil8":s.DEPTH24_STENCIL8,depth32float:s.DEPTH_COMPONENT32F,"depth32float-stencil8":s.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function Hm(s){return{r8unorm:s.UNSIGNED_BYTE,r8snorm:s.BYTE,r8uint:s.UNSIGNED_BYTE,r8sint:s.BYTE,r16uint:s.UNSIGNED_SHORT,r16sint:s.SHORT,r16float:s.HALF_FLOAT,rg8unorm:s.UNSIGNED_BYTE,rg8snorm:s.BYTE,rg8uint:s.UNSIGNED_BYTE,rg8sint:s.BYTE,r32uint:s.UNSIGNED_INT,r32sint:s.INT,r32float:s.FLOAT,rg16uint:s.UNSIGNED_SHORT,rg16sint:s.SHORT,rg16float:s.HALF_FLOAT,rgba8unorm:s.UNSIGNED_BYTE,"rgba8unorm-srgb":s.UNSIGNED_BYTE,rgba8snorm:s.BYTE,rgba8uint:s.UNSIGNED_BYTE,rgba8sint:s.BYTE,bgra8unorm:s.UNSIGNED_BYTE,"bgra8unorm-srgb":s.UNSIGNED_BYTE,rgb9e5ufloat:s.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:s.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:s.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:s.UNSIGNED_INT,rg32sint:s.INT,rg32float:s.FLOAT,rgba16uint:s.UNSIGNED_SHORT,rgba16sint:s.SHORT,rgba16float:s.HALF_FLOAT,rgba32uint:s.UNSIGNED_INT,rgba32sint:s.INT,rgba32float:s.FLOAT,stencil8:s.UNSIGNED_BYTE,depth16unorm:s.UNSIGNED_SHORT,depth24plus:s.UNSIGNED_INT,"depth24plus-stencil8":s.UNSIGNED_INT_24_8,depth32float:s.FLOAT,"depth32float-stencil8":s.FLOAT_32_UNSIGNED_INT_24_8_REV}}const Nm=4;class Bh{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:Eh,buffer:km,video:Gm,compressed:Fm},this._useSeparateSamplers=!1,this._renderer=t}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Lm(t,this._renderer.context.extensions),this._mapFormatToType=Hm(t),this._mapFormatToFormat=Om(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null);for(let e=0;e<16;e++)this.bind(M.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t=t||M.EMPTY.source;const r=this.getGlSource(t);i.bindTexture(r.target,r.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const r=this._getGlSampler(t);this._boundSamplers[e]!==r&&(this._boundSamplers[e]=r,i.bindSampler(e,r))}unbind(t){const e=t.source,i=this._boundTextures,r=this._gl;for(let n=0;n<i.length;n++)if(i[n]===e){this._activateLocation(n);const a=this.getGlSource(e);r.bindTexture(a.target,null),i[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new Rm(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const r=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(r))+1}return this._glTextures[t.uid]=i,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,r=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=t,Mh(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Mh(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:r}=this.getPixels(t),n=L.get().createCanvas();n.width=i,n.height=r;const a=n.getContext("2d");if(a){const o=a.createImageData(i,r);o.data.set(e),a.putImageData(o,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,r=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),a=new Uint8Array(Nm*r*n),o=this._renderer,h=o.renderTarget.getRenderTarget(t),c=o.renderTarget.getGpuRenderTarget(h),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),r,n,l.RGBA,l.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:r,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}Bh.extension={type:[b.WebGLSystem],name:"texture"};class Rh{init(){const t=new _t({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),e=Ht(),i=as({name:"graphics",bits:[Dr,Nr(e),Wr,hs]});this.shader=new Tt({glProgram:i,resources:{localUniforms:t,batchSamplers:zr(e)}})}execute(t,e){const i=e.context,r=i.customShader||this.shader,n=t.renderer,a=n.graphicsContext,{geometry:o,instructions:h}=a.getContextRenderData(i);r.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(r),n.geometry.bind(o,r.glProgram);const c=h.instructions;for(let l=0;l<h.instructionSize;l++){const u=c[l];if(u.size){for(let d=0;d<u.textures.textures.length;d++)n.texture.bind(u.textures.textures[d],d);n.geometry.draw("triangle-list",u.size,u.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Rh.extension={type:[b.WebGLPipesAdaptor],name:"graphics"};class kh{init(){const t=as({name:"mesh",bits:[Wr,jp,hs]});this._shader=new Tt({glProgram:t,resources:{uTexture:M.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(t,e){const i=t.renderer;let r=e._shader;if(r){if(!r.glProgram){D("Mesh shader has no glProgram",e.shader);return}}else{r=this._shader;const n=e.texture,a=n.source;r.resources.uTexture=a,r.resources.uSampler=a.style,r.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}r.groups[100]=i.globalUniforms.bindGroup,r.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}kh.extension={type:[b.WebGLPipesAdaptor],name:"mesh"};class Ih{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Ih.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"};function Fh(s,t){const e=s.instructionSet,i=e.instructions;for(let r=0;r<e.instructionSize;r++){const n=i[r];t[n.renderPipeId].execute(n)}}class Gh{constructor(t){this._renderer=t}addRenderGroup(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&(this._renderer.globalUniforms.push({worldTransformMatrix:t.worldTransform,worldColor:t.worldColorAlpha}),Fh(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}}Gh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"};function Uh(s,t=[]){t.push(s);for(let e=0;e<s.renderGroupChildren.length;e++)Uh(s.renderGroupChildren[e],t);return t}function zm(s,t,e){const i=s>>16&255,r=s>>8&255,n=s&255,a=t>>16&255,o=t>>8&255,h=t&255,c=i+(a-i)*e,l=r+(o-r)*e,u=n+(h-n)*e;return(c<<16)+(l<<8)+u}const Zr=16777215;function Dh(s,t){return s===Zr||t===Zr?s+t-Zr:zm(s,t,.5)}const Wm=new z;function Oh(s,t=!1){Vm(s);const e=s.childrenToUpdate,i=s.updateTick++;for(const r in e){const n=e[r],a=n.list,o=n.index;for(let h=0;h<o;h++){const c=a[h];c.parentRenderGroup===s&&Lh(c,i,0)}n.index=0}if(t)for(let r=0;r<s.renderGroupChildren.length;r++)Oh(s.renderGroupChildren[r],t)}function Vm(s){const t=s.root;let e;if(s.renderGroupParent){const i=s.renderGroupParent;s.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),s.worldColor=Dh(t.groupColor,i.worldColor),e=t.groupAlpha*i.worldAlpha}else s.worldTransform.copyFrom(t.localTransform),s.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,s.worldAlpha=e,s.worldColorAlpha=s.worldColor+((e*255|0)<<24)}function Lh(s,t,e){if(t===s.updateTick)return;s.updateTick=t,s.didChange=!1;const i=s.localTransform;s.updateLocalTransform();const r=s.parent;if(r&&!r.renderGroup?(e=e|s._updateFlags,s.relativeGroupTransform.appendFrom(i,r.relativeGroupTransform),e&&Hh(s,r,e)):(e=s._updateFlags,s.relativeGroupTransform.copyFrom(i),e&&Hh(s,Wm,e)),!s.renderGroup){const n=s.children,a=n.length;for(let h=0;h<a;h++)Lh(n[h],t,e);const o=s.parentRenderGroup;s.renderPipeId&&!o.structureDidChange&&o.updateRenderable(s)}}function Hh(s,t,e){if(e&Gi){s.groupColor=Dh(s.localColor,t.groupColor);let i=s.localAlpha*t.groupAlpha;i=i<0?0:i>1?1:i,s.groupAlpha=i,s.groupColorAlpha=s.groupColor+((i*255|0)<<24)}e&qn&&(s.groupBlendMode=s.localBlendMode==="inherit"?t.groupBlendMode:s.localBlendMode),e&Bs&&(s.globalDisplayStatus=s.localDisplayStatus&t.globalDisplayStatus),s._updateFlags=0}function jm(s,t){const{list:e,index:i}=s.childrenRenderablesToUpdate;let r=!1;for(let n=0;n<i;n++){const a=e[n];if(r=t[a.renderPipeId].validateRenderable(a),r)break}return s.structureDidChange=r,r}const $m=new I;class Nh{constructor(t){this._renderer=t}render({container:t,transform:e}){t.isRenderGroup=!0;const i=t.parent,r=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,a=Uh(t.renderGroup,[]);let o=$m;e&&(o=o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const h=n.renderPipes;for(let c=0;c<a.length;c++){const l=a[c];l.runOnRender(),l.instructionSet.renderPipes=h,l.structureDidChange||jm(l,h),Oh(l),l.structureDidChange?(l.structureDidChange=!1,$p(l,h)):Xm(l),l.childrenRenderablesToUpdate.index=0,n.renderPipes.batch.upload(l.instructionSet)}n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Fh(t.renderGroup,h),h.uniformBatch&&h.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=i,t.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}}Nh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"};function Xm(s){const{list:t,index:e}=s.childrenRenderablesToUpdate;for(let i=0;i<e;i++){const r=t[i];r.didViewUpdate&&s.updateRenderable(r)}}class Jr{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(t,e,i,r){const n=this.renderable,a=this.texture,o=n.groupTransform,h=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,p=this.bounds,g=p.maxX,m=p.minX,_=p.maxY,x=p.minY,y=a.uvs,v=n.groupColorAlpha,w=r<<16|this.roundPixels&65535;t[i+0]=h*m+l*x+d,t[i+1]=u*x+c*m+f,t[i+2]=y.x0,t[i+3]=y.y0,e[i+4]=v,e[i+5]=w,t[i+6]=h*g+l*x+d,t[i+7]=u*x+c*g+f,t[i+8]=y.x1,t[i+9]=y.y1,e[i+10]=v,e[i+11]=w,t[i+12]=h*g+l*_+d,t[i+13]=u*_+c*g+f,t[i+14]=y.x2,t[i+15]=y.y2,e[i+16]=v,e[i+17]=w,t[i+18]=h*m+l*_+d,t[i+19]=u*_+c*m+f,t[i+20]=y.x3,t[i+21]=y.y3,e[i+22]=v,e[i+23]=w}packIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class zh{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,i=this._getGpuSprite(t);return i.texture._source!==e._source?!i.batcher.checkAndUpdateTexture(i,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];$.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.bounds=t.bounds,e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=$.get(Jr);return e.renderable=t,e.texture=t._texture,e.bounds=t.bounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t._didSpriteUpdate=!1,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)$.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}zh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"};const Qr=class wl{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new j(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...wl.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Qr.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0},Qr.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Ym=Qr;const us={};O.handle(b.BlendMode,s=>{if(!s.name)throw new Error("BlendMode extension must have a name property");us[s.name]=s.ref},s=>{delete us[s.name]});class Wh{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,i){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!us[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!us[e]){D(`Unable to assign BlendMode: '${e}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let i=this._filterHash[e];i||(i=this._filterHash[e]=new Cs,i.filters=[new us[e]]);const r={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=r.renderables,t.add(r)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Wh.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"};const tn={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},en=class Tl{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof z||t instanceof M?{target:t,...e}:{...e,...t}}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Tl.defaultImageOptions);const{format:e,quality:i}=t,r=this.canvas(t);if(r.toBlob!==void 0)return new Promise((n,a)=>{r.toBlob(o=>{if(!o){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>n(h.result),h.onerror=a,h.readAsDataURL(o)},tn[e],i)});if(r.toDataURL!==void 0)return r.toDataURL(tn[e],i);if(r.convertToBlob!==void 0){const n=await r.convertToBlob({type:tn[e],quality:i});return new Promise((a,o)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=o,h.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof M)return i.texture.generateCanvas(e);const r=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(r);return r.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,r=e instanceof M?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(r);return e instanceof z&&r.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof M?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),i=document.createElement("a");i.download=t.filename??"image.png",i.href=e.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){const e=t.width??200;t=this._normalizeOptions(t);const i=this.canvas(t),r=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const n=["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};en.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"extract"},en.defaultImageOptions={format:"png",quality:1};let Km=en;class qm extends M{static create(t){return new M({source:new ut(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Zm=new Y,Jm=new pt,Qm=[0,0,0,0];class Vh{constructor(t){this._renderer=t}generateTexture(t){var c;t instanceof z&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,r=t.target;let n=t.clearColor;n?n=Array.isArray(n)&&n.length===4?n:j.shared.setValue(n).toArray():n=Qm;const a=((c=t.frame)==null?void 0:c.copyTo(Zm))||Ri(r,Jm).rectangle;a.width=Math.max(a.width,1/e)|0,a.height=Math.max(a.height,1/e)|0;const o=qm.create({...t.textureSourceOptions,width:a.width,height:a.height,resolution:e,antialias:i}),h=I.shared.translate(-a.x,-a.y);return this._renderer.render({container:r,transform:h,target:o,clearColor:n}),o}destroy(){this._renderer=null}}Vh.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGenerator"};function ri(s,t,e){const i=(s>>24&255)/255;t[e++]=(s&255)/255*i,t[e++]=(s>>8&255)/255*i,t[e++]=(s>>16&255)/255*i,t[e++]=i}class jh{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:r,offset:n}){const a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new I,worldColor:4294967295,offset:new X},h={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||a.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:r||o.worldColor,offset:n||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);const l=c.uniforms;l.uProjectionMatrix=h.projectionMatrix,l.uResolution=h.resolution,l.uWorldTransformMatrix.copyFrom(h.worldTransformMatrix),l.uWorldTransformMatrix.tx-=h.offset.x,l.uWorldTransformMatrix.ty-=h.offset.y,ri(h.worldColor,l.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new Yt,this._activeBindGroups.push(u),u.setResource(c,0)),h.bindGroup=u,this._currentGlobalUniformData=h}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Lt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new _t({uProjectionMatrix:{value:new I,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new I,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}jh.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"};let $h=!1;const Xh="8.1.5";function tg(s){if(!$h){if(L.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c  %c  %c  %c  %c PixiJS %c v${Xh} (${s}) http://www.pixijs.com/

`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Xh} - ${s} - http://www.pixijs.com/`);$h=!0}}class sn{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Lt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),tg(e)}}}sn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2},sn.defaultOptions={hello:!1};const rn=class Al{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t={...Al.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};rn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"},rn.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:60*60,textureGCCheckCountMax:600};let Yh=rn;O.add(Yh);const nn=class Pl{get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t={...Pl.defaultOptions,...t},t.view&&(N(W,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new Y(0,0,t.width,t.height),this.canvas=t.canvas||L.get().createCanvas(),this.antialias=!!t.antialias,this.texture=mh(this.canvas,t),this.renderTarget=new Xr({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.autoDensity&&(this.canvas.style.width=`${this.texture.width}px`,this.canvas.style.height=`${this.texture.height}px`),this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height,this.autoDensity&&(this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`)}destroy(t=!1){(typeof t=="boolean"?t:!!(t!=null&&t.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};nn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0},nn.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Kh=[Ym,jh,sn,nn,Nh,Yh,Vh,Km],qh=[Wh,Zo,zh,Gh,Qo,eh,th,Ih],eg=[...Kh,ph,sm,Zp,sh,Bh,xh,ah,Ah,Th,hh,Bm,ch,oh],sg=[...qh],ig=[Ko,kh,Rh],Zh=[],Jh=[],Qh=[];O.handleByNamedList(b.WebGLSystem,Zh),O.handleByNamedList(b.WebGLPipes,Jh),O.handleByNamedList(b.WebGLPipesAdaptor,Qh),O.add(...eg,...sg,...ig);class rg extends zs{constructor(){const t={name:"webgl",type:Lt.WEBGL,systems:Zh,renderPipes:Jh,renderPipeAdaptors:Qh};super(t)}}const ng=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:rg},Symbol.toStringTag,{value:"Module"}));class tc{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){const r=this._gpu.device,n=e.layout[i],a=[],o=this._renderer;for(const l in n){const u=t.resources[l]??t.resources[n[l]];let d;if(u._resourceType==="uniformGroup"){const f=u;o.ubo.updateUniformGroup(f);const p=f.buffer;d={buffer:o.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(u._resourceType==="buffer"){const f=u;d={buffer:o.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(u._resourceType==="bufferResource"){const f=u;d={buffer:o.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(u._resourceType==="textureSampler"){const f=u;d=o.texture.getGpuSampler(f)}else if(u._resourceType==="textureSource"){const f=u;d=o.texture.getGpuSource(f).createView({})}a.push({binding:n[l],resource:d})}const h=o.shader.getProgramData(e).bindGroups[i],c=r.createBindGroup({layout:h,entries:a});return this._hash[t._key]=c,c}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}tc.extension={type:[b.WebGPUSystem],name:"bindGroup"};class ec{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(fr(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,this._managedBuffers.push(t),e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}ec.extension={type:[b.WebGPUSystem],name:"buffer"};class ag{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}}class sc{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}sc.extension={type:[b.WebGPUSystem],name:"colorMask"};class an{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=this._createDeviceAndAdaptor(t).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),r=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:r}}destroy(){this.gpu=null,this._renderer=null}}an.extension={type:[b.WebGPUSystem],name:"device"},an.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class ic{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,r){const n=this._renderer.pipeline.getPipeline(t,e,i,r);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const r=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,r)}setGeometry(t){for(const e in t.attributes){const i=t.attributes[e];this._setVertexBuffer(i.location,i.buffer)}t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const r=t.groups[i];e||this._syncBindGroup(r),this.setBindGroup(i,r,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:r,topology:n,size:a,start:o,instanceCount:h,skipSync:c}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,r,n),this.setGeometry(e),this._setShaderBindGroups(i,c),e.indexBuffer?this.renderPassEncoder.drawIndexed(a||e.indexBuffer.data.length,h||e.instanceCount,o||0):this.renderPassEncoder.draw(a||e.getSize(),h||e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i={...this._boundVertexBuffer},r=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in n)this.setBindGroup(o,n[o],null);this._setIndexBuffer(r)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}ic.extension={type:[b.WebGPUSystem],name:"encoder",priority:1};class rc{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ct.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const r=this._renderer;r.pipeline.setStencilMode(t),r.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}rc.extension={type:[b.WebGPUSystem],name:"stencil"};const ni={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function og(s){const t=s.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const r=t[i];let n=ni[r.data.type].size;const a=ni[r.data.type].align;if(!ni[r.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(n=Math.max(n,a)*r.data.size),e=Math.ceil(e/a)*a,r.size=n,r.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function hg(s,t){const{size:e,align:i}=ni[s.data.type],r=(i-e)/4;return`
         v = uv.${s.data.name};
         ${t!==0?`offset += ${t};`:""}

         arrayOffset = offset;

         t = 0;

         for(var i=0; i < ${s.data.size*(e/4)}; i++)
         {
             for(var j = 0; j < ${e/4}; j++)
             {
                 data[arrayOffset++] = v[t++];
             }
             ${r!==0?`arrayOffset += ${r};`:""}
         }
     `}function cg(s){return dh(s,"uboWgsl",hg,nm)}class nc extends lh{constructor(){super({createUboElements:og,generateUboSync:cg})}}nc.extension={type:[b.WebGPUSystem],name:"ubo"};const ne=128;class ac{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new ag({minUniformOffsetAlignment:ne});const e=256/ne;for(let i=0;i<e;i++){let r=V.UNIFORM|V.COPY_DST;i===0&&(r|=V.COPY_SRC),this._buffers.push(new Rt({data:this._batchBuffer.data,usage:r}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,r=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,r/4),this._bindGroupHash[t.uid]=this._getBindGroup(r/ne),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/ne)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ne)}getArrayBufferResource(t){const i=this._batchBuffer.addGroup(t)/ne;return this._getBufferResource(i)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Yr({buffer:e,offset:(t/2|0)*256,size:ne})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Yt({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){const n=this._buffers[r];i.copyBufferToBuffer(t.getGPUBuffer(e),ne,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}ac.extension={type:[b.WebGPUPipes],name:"uniformBatch"};const lg={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function ug(s,t,e,i,r){return s<<24|t<<16|e<<10|i<<5|r}function dg(s,t,e,i){return e<<6|s<<3|i<<1|t}class oc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(ct.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=ge[t],this._updatePipeHash())}setPipeline(t,e,i,r){const n=this.getPipeline(t,e,i);r.setPipeline(n)}getPipeline(t,e,i,r){t._layoutKey||(ih(t,e.attributeData),this._generateBufferKey(t)),r=r||t.topology;const n=ug(t._layoutKey,e._layoutKey,i.data,i._blendModeId,lg[r]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,r),this._pipeCache[n])}_createPipeline(t,e,i,r){const n=this._gpu.device,a=this._createVertexBufferLayouts(t),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===ct.RENDERING_MASK_ADD?0:this._colorMask;const h=this._renderer.shader.getProgramData(e).pipeline,c={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:r,cullMode:i.cullMode},layout:h,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),n.createRenderPipeline(c)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const r=Object.keys(t.attributes).sort();for(let a=0;a<r.length;a++){const o=t.attributes[r[a]];e[i++]=o.location,e[i++]=o.offset,e[i++]=o.format,e[i++]=o.stride}const n=e.join("");return t._layoutKey=Us(n,"geometry"),t._layoutKey}_createVertexBufferLayouts(t){if(this._bufferLayoutsCache[t._layoutKey])return this._bufferLayoutsCache[t._layoutKey];const e=[];return t.buffers.forEach(i=>{const r={arrayStride:0,stepMode:"vertex",attributes:[]},n=r.attributes;for(const a in t.attributes){const o=t.attributes[a];o.buffer===i&&(r.arrayStride=o.stride,r.stepMode=o.instance?"instance":"vertex",n.push({shaderLocation:o.location,offset:o.offset,format:o.format}))}n.length&&e.push(r)}),this._bufferLayoutsCache[t._layoutKey]=e,e}_updatePipeHash(){const t=dg(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}oc.extension={type:[b.WebGPUSystem],name:"pipeline"};class fg{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class pg{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,r,n){const a=this._renderer,o=this._getGpuColorTexture(t),h=a.texture.getGpuSource(e.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:h,origin:n},r),e}startRenderPass(t,e=!0,i,r){const a=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);a.descriptor=o,this._renderer.pipeline.setRenderTarget(a),this._renderer.encoder.beginRenderPass(a),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?xt.ALL:xt.NONE);const r=this._renderTargetSystem,n=r.getGpuRenderTarget(t),a=t.colorTextures.map((c,l)=>{const u=n.contexts[l];let d,f;u?d=u.getCurrentTexture().createView():d=this._renderer.texture.getGpuSource(c).createView({mipLevelCount:1}),n.msaaTextures[l]&&(f=d,d=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e&xt.COLOR?"clear":"load";return i??(i=r.defaultClearColor),{view:d,resolveTarget:f,clearValue:i,storeOp:"store",loadOp:p}});let o;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const c=e&xt.STENCIL?"clear":"load",l=e&xt.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:c,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:a,depthStencilAttachment:o}}clear(t,e=!0,i,r){if(!e)return;const{gpu:n,encoder:a}=this._renderer,o=n.device;if(a.commandEncoder===null){const c=o.createCommandEncoder(),l=this.getDescriptor(t,e,i),u=c.beginRenderPass(l);u.setViewport(r.x,r.y,r.width,r.height,0,1),u.end();const d=c.finish();o.queue.submit([d])}else this.startRenderPass(t,e,i,r)}initGpuRenderTarget(t){t.isRoot=!0;const e=new fg;return t.colorTextures.forEach((i,r)=>{if(Pe.test(i.resource)){const n=i.resource.getContext("webgpu"),a=i.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:a})}catch(o){console.error(o)}e.contexts[r]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new ut({width:0,height:0,sampleCount:4});e.msaaTextures[r]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,r)=>{const n=e.msaaTextures[r];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class hc extends _h{constructor(t){super(t),this.adaptor=new pg,this.adaptor.init(t,this)}}hc.extension={type:[b.WebGPUSystem],name:"renderTarget"};class cc{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),r={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(r)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}cc.extension={type:[b.WebGPUSystem],name:"shader"};const Pt={};Pt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Pt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Pt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Pt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Pt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Pt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Pt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Pt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Pt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Pt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class lc{constructor(){this.defaultState=new Kt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Pt[t.blendMode]||Pt.normal}]}destroy(){this.gpu=null}}lc.extension={type:[b.WebGPUSystem],name:"state"};const mg={type:"image",upload(s,t,e){const i=s.resource,r=(s.pixelWidth|0)*(s.pixelHeight|0),n=i.byteLength/r;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:s.pixelHeight,bytesPerRow:s.pixelHeight*n},{width:s.pixelWidth,height:s.pixelHeight,depthOrArrayLayers:1})}},uc={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},gg={blockBytes:4,blockWidth:1,blockHeight:1},_g={type:"compressed",upload(s,t,e){let i=s.pixelWidth,r=s.pixelHeight;const n=uc[s.format]||gg;for(let a=0;a<s.resource.length;a++){const o=s.resource[a],h=Math.ceil(i/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:a},o,{offset:0,bytesPerRow:h},{width:Math.ceil(i/n.blockWidth)*n.blockWidth,height:Math.ceil(r/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),r=Math.max(r>>1,1)}}},dc={type:"image",upload(s,t,e){const i=s.resource;if(!i)return;const r=Math.min(t.width,s.resourceWidth||s.pixelWidth),n=Math.min(t.height,s.resourceHeight||s.pixelHeight),a=s.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:a},{width:r,height:n})}},xg={type:"video",upload(s,t,e){dc.upload(s,t,e)}};class yg{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
                        var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
                        vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));

                        struct VertexOutput {
                        @builtin(position) position : vec4<f32>,
                        @location(0) texCoord : vec2<f32>,
                        };

                        @vertex
                        fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
                        var output : VertexOutput;
                        output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
                        output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
                        return output;
                        }

                        @group(0) @binding(0) var imgSampler : sampler;
                        @group(0) @binding(1) var img : texture_2d<f32>;

                        @fragment
                        fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
                        return textureSample(img, imgSampler, texCoord);
                        }
                    `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const r=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const h={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(h)}const a=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let h=0;h<r;++h){let c=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),l=n?1:0;for(let u=1;u<t.mipLevelCount;++u){const d=i.createView({baseMipLevel:l++,mipLevelCount:1,dimension:"2d",baseArrayLayer:h,arrayLayerCount:1}),f=a.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),p=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:c}]});f.setPipeline(e),f.setBindGroup(0,p),f.draw(3,1,0,0),f.end(),c=d}}if(!n){const h={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:r};for(let c=1;c<t.mipLevelCount;++c)a.copyTextureToTexture({texture:i,mipLevel:c-1},{texture:t,mipLevel:c},h),h.width=Math.ceil(h.width/2),h.height=Math.ceil(h.height/2)}return this.device.queue.submit([a.finish()]),n||i.destroy(),t}}class fc{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:dc,buffer:mg,video:xg,compressed:_g},this._renderer=t}contextChange(t){this._gpu=t}initSource(t){if(t.autoGenerateMipmaps){const h=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(h))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=uc[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,a={label:t.label,size:{width:r,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpu.device.createTexture(a);return this._gpuSources[t.uid]=o,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new yg(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]??this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source,i=e.uid;return this._bindGroupHash[i]=new Yt({0:e,1:e.style}),this._bindGroupHash[i]}getTextureView(t){const e=t.source;return this._textureViewHash[e.uid]??this._createTextureView(e)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),r=L.get().createCanvas();r.width=t.source.pixelWidth,r.height=t.source.pixelHeight;const n=r.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:r.width,height:r.height}),e.gpu.device.queue.submit([i.finish()]),r}getPixels(t){const e=this.generateCanvas(t),i=qt.getOptimalCanvasAndContext(e.width,e.height),r=i.context;r.drawImage(e,0,0);const{width:n,height:a}=e,o=r.getImageData(0,0,n,a),h=new Uint8ClampedArray(o.data.buffer);return qt.returnCanvasAndContext(i),{pixels:h,width:n,height:a}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}fc.extension={type:[b.WebGPUSystem],name:"texture"};class pc{init(){const t=new _t({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),e=ns({name:"graphics",bits:[Ur,Lr(Ht()),Wp,os]});this.shader=new Tt({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const i=e.context,r=i.customShader||this.shader,n=t.renderer,a=n.graphicsContext,{geometry:o,instructions:h}=a.getContextRenderData(i),c=n.encoder;c.setPipelineFromGeometryProgramAndState(o,r.gpuProgram,t.state),c.setGeometry(o);const l=n.globalUniforms.bindGroup;c.setBindGroup(0,l,r.gpuProgram);const u=n.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);c.setBindGroup(2,u,r.gpuProgram);const d=h.instructions;for(let f=0;f<h.instructionSize;f++){const p=d[f];if(r.groups[1]=p.bindGroup,!p.gpuBindGroup){const g=p.textures;p.bindGroup=ur(g.textures,g.count),p.gpuBindGroup=n.bindGroup.getBindGroup(p.bindGroup,r.gpuProgram,1)}c.setBindGroup(1,p.bindGroup,r.gpuProgram),c.renderPassEncoder.drawIndexed(p.size,1,p.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}pc.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"};class mc{init(){const t=ns({name:"mesh",bits:[cs,Vp,os]});this._shader=new Tt({gpuProgram:t,resources:{uTexture:M.EMPTY._source,uSampler:M.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(t,e){const i=t.renderer;let r=e._shader;if(!r)r=this._shader,r.resources.uTexture=e.texture.source,r.resources.uSampler=e.texture.source.style,r.resources.textureUniforms.uniforms.uTextureMatrix=e.texture.textureMatrix.mapCoord;else if(!r.gpuProgram){D("Mesh shader has no gpuProgram",e.shader);return}const n=r.gpuProgram;if(n.autoAssignGlobalUniforms&&(r.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const a=t.localUniforms;r.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(a,!0)}i.encoder.draw({geometry:e._geometry,shader:r,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}mc.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"};const bg=[...Kh,nc,ic,an,ec,fc,hc,cc,lc,oc,sc,rc,tc],vg=[...qh,ac],Sg=[qo,mc,pc],gc=[],_c=[],xc=[];O.handleByNamedList(b.WebGPUSystem,gc),O.handleByNamedList(b.WebGPUPipes,_c),O.handleByNamedList(b.WebGPUPipesAdaptor,xc),O.add(...bg,...vg,...Sg);class wg extends zs{constructor(){const t={name:"webgpu",type:Lt.WEBGPU,systems:gc,renderPipes:_c,renderPipeAdaptors:xc};super(t)}}const Tg=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:wg},Symbol.toStringTag,{value:"Module"}));class yc{constructor(t,e){this.state=Kt.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,i=!!this._graphicsBatchesHash[t.uid],r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||i!==r.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let i=0;i<e.length;i++){const r=e[i];r.batcher.updateElement(r)}}destroyRenderable(t){this._graphicsBatchesHash[t.uid]&&this._removeBatchForRenderable(t.uid)}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const a=n.resources.localUniforms.uniforms;a.uTransformMatrix=t.groupTransform,a.uRound=e._roundPixels|t._roundPixels,ri(t.groupColorAlpha,a.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(t.context);e&&this._removeBatchForRenderable(t.uid),i.isBatchable&&this._initBatchesForRenderable(t),t.batched=i.isBatchable}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,r=this._getBatchesForRenderable(t);for(let n=0;n<r.length;n++){const a=r[n];i.addToBatch(a,e)}}_getBatchesForRenderable(t){return this._graphicsBatchesHash[t.uid]||this._initBatchesForRenderable(t)}_initBatchesForRenderable(t){const e=t.context,i=this.renderer.graphicsContext.getGpuContext(e),r=this.renderer._roundPixels|t._roundPixels,n=i.batches.map(a=>{const o=$.get(pr);return a.copyTo(o),o.renderable=t,o.roundPixels=r,o});return this._graphicsBatchesHash[t.uid]===void 0&&t.on("destroyed",()=>{this.destroyRenderable(t)}),this._graphicsBatchesHash[t.uid]=n,n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{$.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}yc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"graphics"};const bc=class El extends Br{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(N(W,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...El.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;u<e;u++){const d=u%this.verticesX,f=u/this.verticesX|0;i.push(d*h,f*c),r.push(d/a,f/o)}const l=a*o;for(let u=0;u<l;u++){const d=u%a,f=u/a|0,p=f*this.verticesX+d,g=f*this.verticesX+d+1,m=(f+1)*this.verticesX+d,_=(f+1)*this.verticesX+d+1;n.push(p,g,m,g,_,m)}this.buffers[0].data=new Float32Array(i),this.buffers[1].data=new Float32Array(r),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};bc.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Ag=bc;class on{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null}packIndex(t,e,i){const r=this.geometry.indices;for(let n=0;n<r.length;n++)t[e++]=r[n]+i}packAttributes(t,e,i,r){const n=this.mesh,a=this.geometry,o=n.groupTransform,h=r<<16|this.roundPixels&65535,c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty,g=a.positions,m=a.getBuffer("aUV"),_=m.data;let x=_;const y=this.texture.textureMatrix;y.isSimple||(x=this._transformedUvs,(this._textureMatrixUpdateId!==y._updateID||this._uvUpdateId!==m._updateID)&&((!x||x.length<_.length)&&(x=this._transformedUvs=new Float32Array(_.length)),this._textureMatrixUpdateId=y._updateID,this._uvUpdateId=m._updateID,y.multiplyUvs(_,x)));const v=n.groupColorAlpha;for(let w=0;w<g.length;w+=2){const C=g[w],E=g[w+1];t[i]=c*C+u*E+f,t[i+1]=l*C+d*E+p,t[i+2]=x[w],t[i+3]=x[w+1],e[i+4]=v,e[i+5]=h,i+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class vc{constructor(t,e){this.localUniforms=new _t({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Yt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,r=t.batched;if(e.batched=r,i!==r)return!0;if(r){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const a=this._getBatchableMesh(t),o=t.texture;if(a.texture._source!==o._source&&a.texture._source!==o._source)return!a.batcher.checkAndUpdateTexture(a,o)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,{batched:r}=this._getMeshData(t);if(r){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,i.addToBatch(n)}else i.break(e),e.add({renderPipeId:"mesh",mesh:t})}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e.batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&($.return(e),this._gpuBatchableMeshHash[t.uid]=null)}execute({mesh:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),ri(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,i;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(i=t._geometry.positions)==null?void 0:i.length},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=$.get(on);return e.mesh=t,e.texture=t._texture,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e.mesh=t,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&$.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}vc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"mesh"};const Sc=class Cl extends Ag{constructor(t={}){t={...Cl.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,i=this.width>e?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};Sc.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Pg=Sc;class wc{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,i=this._getGpuSprite(t);return i.texture._source!==e._source?!i.batcher.checkAndUpdateTexture(i,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];$.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new on;return e.geometry=new Pg,e.mesh=t,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}wc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"nineSliceSprite"};const Eg={name:"tiling-bit",vertex:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`
            uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;

            position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
        `},fragment:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`

            var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
            coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
            var unclamped = coord;
            coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);

            var bias = 0.;

            if(unclamped.x == coord.x && unclamped.y == coord.y)
            {
                bias = -32.;
            } 

            outColor = textureSampleBias(uTexture, uSampler, coord, bias);
        `}},Cg={name:"tiling-bit",vertex:{header:`
            uniform mat3 uTextureTransform;
            uniform vec4 uSizeAnchor;
        
        `,main:`
            uv = (uTextureTransform * vec3(aUV, 1.0)).xy;

            position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
        `},fragment:{header:`
            uniform sampler2D uTexture;
            uniform mat3 uMapCoord;
            uniform vec4 uClampFrame;
            uniform vec2 uClampOffset;
        `,main:`

        vec2 coord = vUV + ceil(uClampOffset - vUV);
        coord = (uMapCoord * vec3(coord, 1.0)).xy;
        vec2 unclamped = coord;
        coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
        
        outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
    
        `}};let hn,cn;class Mg extends Tt{constructor(){hn??(hn=ns({name:"tiling-sprite-shader",bits:[cs,Eg,os]})),cn??(cn=as({name:"tiling-sprite-shader",bits:[Wr,Cg,hs]}));const t=new _t({uMapCoord:{value:new I,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new I,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:cn,gpuProgram:hn,resources:{localUniforms:new _t({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:M.EMPTY.source,uSampler:M.EMPTY.source.style}})}updateUniforms(t,e,i,r,n,a){const o=this.resources.tilingUniforms,h=a.width,c=a.height,l=a.textureMatrix,u=o.uniforms.uTextureTransform;u.set(i.a*h/t,i.b*h/e,i.c*c/t,i.d*c/e,i.tx/t,i.ty/e),u.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=u,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=r,o.uniforms.uSizeAnchor[3]=n,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class Bg extends Br{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function Rg(s,t){const e=s.anchor.x,i=s.anchor.y;t[0]=-e*s.width,t[1]=-i*s.height,t[2]=(1-e)*s.width,t[3]=-i*s.height,t[4]=(1-e)*s.width,t[5]=(1-i)*s.height,t[6]=-e*s.width,t[7]=(1-i)*s.height}function kg(s,t,e,i){let r=0;const n=s.length/t,a=i.a,o=i.b,h=i.c,c=i.d,l=i.tx,u=i.ty;for(e*=t;r<n;){const d=s[e],f=s[e+1];s[e]=a*d+h*f+l,s[e+1]=o*d+c*f+u,e+=t,r++}}function Ig(s,t){const e=s.texture,i=e.frame.width,r=e.frame.height;let n=0,a=0;s._applyAnchorToTexture&&(n=s.anchor.x,a=s.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-a,t[5]=t[7]=1-a;const o=I.shared;o.copyFrom(s._tileTransform.matrix),o.tx/=s.width,o.ty/=s.height,o.invert(),o.scale(s.width/i,s.height/r),kg(t,2,0,o)}const ai=new Bg;class Tc{constructor(t){this._tilingSpriteDataHash=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const r=e.canBatch;if(r&&r===i){const{batchableMesh:n}=e;if(n.texture._source!==t.texture._source)return!n.batcher.checkAndUpdateTexture(n,t.texture)}return i!==r}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const r=this._getTilingSpriteData(t),{geometry:n,canBatch:a}=r;if(a){r.batchableMesh||(r.batchableMesh=new on);const o=r.batchableMesh;t._didTilingSpriteUpdate&&(t._didTilingSpriteUpdate=!1,this._updateBatchableMesh(t),o.geometry=n,o.mesh=t,o.texture=t._texture),o.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(o)}else i.break(e),r.shader||(r.shader=new Mg),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,ri(t.groupColorAlpha,i.uColor,0),this._renderer.encoder.draw({geometry:ai,shader:e,state:Kt.default2d})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:r}=e;t._didTilingSpriteUpdate&&this._updateBatchableMesh(t),r.batcher.updateElement(r)}else if(t._didTilingSpriteUpdate){const{shader:r}=e;r.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}t._didTilingSpriteUpdate=!1}destroyRenderable(t){var i;const e=this._getTilingSpriteData(t);e.batchableMesh=null,(i=e.shader)==null||i.destroy(),this._tilingSpriteDataHash[t.uid]=null}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new Br({indices:ai.indices,positions:ai.positions.slice(),uvs:ai.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:!0,renderable:t,geometry:e},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,r=t.texture.source.style;r.addressMode!=="repeat"&&(r.addressMode="repeat",r.update()),Ig(t,i.uvs),Rg(t,i.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let r=!0;return this._renderer.type===Lt.WEBGL&&(r=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(r||i.source.isPowerOfTwo),e.canBatch}}Tc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"tilingSprite"};const ln={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const d=t[u].match(/^[a-z]+/gm)[0],f=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const g in f){const m=f[g].split("="),_=m[0],x=m[1].replace(/"/gm,""),y=parseFloat(x),v=isNaN(y)?x:y;p[_]=v}e[d].push(p)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[a]=e.distanceField??[];a&&(i.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const o=e.page;for(let u=0;u<o.length;u++)i.pages.push({id:parseInt(o[u].id,10)||0,file:o[u].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const c=e.char;for(let u=0;u<c.length;u++){const d=c[u],f=parseInt(d.id,10);let p=d.letter??d.char??String.fromCharCode(f);p==="space"&&(p=" "),h[f]=p,i.chars[p]={id:f,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const l=e.kerning||[];for(let u=0;u<l.length;u++){const d=parseInt(l[u].first,10),f=parseInt(l[u].second,10),p=parseInt(l[u].amount,10);i.chars[h[f]].kerning[h[d]]=p}return i}},Ac={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],r=s.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),a=s.getElementsByTagName("char"),o=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let c=0;c<n.length;c++)t.pages.push({id:parseInt(n[c].getAttribute("id"),10)||0,file:n[c].getAttribute("file")});const h={};t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let c=0;c<a.length;c++){const l=a[c],u=parseInt(l.getAttribute("id"),10);let d=l.getAttribute("letter")??l.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),h[u]=d,t.chars[d]={id:u,page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xOffset:parseInt(l.getAttribute("xoffset"),10),yOffset:parseInt(l.getAttribute("yoffset"),10),xAdvance:parseInt(l.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<o.length;c++){const l=parseInt(o[c].getAttribute("first"),10),u=parseInt(o[c].getAttribute("second"),10),d=parseInt(o[c].getAttribute("amount"),10);t.chars[h[u]].kerning[h[l]]=d}return t}},Pc={test(s){return typeof s=="string"&&s.includes("<font>")?Ac.test(L.get().parseXML(s)):!1},parse(s){return Ac.parse(L.get().parseXML(s))}};class Ec extends Co{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new Y(a.x+o.x,a.y+o.y,a.width,a.height),l=new M({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Ir.install(t)}static uninstall(t){Ir.uninstall(t)}}const Fg=[".xml",".fnt"],Gg={extension:b.CacheParser,test:s=>s instanceof Ec,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Ug={extension:{type:b.LoadParser,priority:te.Normal},test(s){return Fg.includes(mt.extname(s).toLowerCase())},async testParse(s){return ln.test(s)||Pc.test(s)},async parse(s,t,e){const i=ln.test(s)?ln.parse(s):Pc.parse(s),{src:r}=t,{pages:n}=i,a=[];for(let l=0;l<n.length;++l){const u=n[l].file;let d=mt.join(mt.dirname(r),u);d=Li(d,r),a.push(d)}const o=await e.load(a),h=a.map(l=>o[l]);return new Ec({data:i,textures:h},r)},async load(s,t){return await(await L.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}},Dg={name:"local-uniform-msdf-bit",vertex:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32,
                uRound:f32,
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `},fragment:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
         `,main:` 
            outColor = vColor * calculateMSDFAlpha(outColor, localUniforms.uDistance);
        `}},Og={name:"local-uniform-msdf-bit",vertex:{header:`
            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix *= uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `},fragment:{header:`
            uniform float uDistance;
         `,main:` 
            outColor = vColor * calculateMSDFAlpha(outColor, uDistance);
        `}},Lg={name:"msdf-bit",fragment:{header:`
            fn calculateMSDFAlpha(msdfColor:vec4<f32>, distance:f32) -> f32 {
                
                // MSDF
                var median = msdfColor.r + msdfColor.g + msdfColor.b -
                    min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                    max(msdfColor.r, max(msdfColor.g, msdfColor.b));
            
                // SDF
                median = min(median, msdfColor.a);

                var screenPxDistance = distance * (median - 0.5);
                var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                return alpha;
            }
        `}},Hg={name:"msdf-bit",fragment:{header:`
            float calculateMSDFAlpha(vec4 msdfColor, float distance) {
                
                // MSDF
                float median = msdfColor.r + msdfColor.g + msdfColor.b -
                                min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                                max(msdfColor.r, max(msdfColor.g, msdfColor.b));
               
                // SDF
                median = min(median, msdfColor.a);
            
                float screenPxDistance = distance * (median - 0.5);
                float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
           
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                return alpha;
            }
        `}};class Ng extends Tt{constructor(){const t=new _t({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=Ht(),i=ns({name:"sdf-shader",bits:[Ur,Lr(e),Dg,Lg,os]}),r=as({name:"sdf-shader",bits:[Dr,Nr(e),Og,Hg,hs]});super({glProgram:r,gpuProgram:i,resources:{localUniforms:t,batchSamplers:zr(e)}})}}class Cc{constructor(t){this._gpuBitmapText={},this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Mc(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){$.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);Mc(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){var f;const{context:i}=e,r=Ir.getFont(t.text,t._style);i.clear(),r.distanceField.type!=="none"&&(i.customShader||(this._sdfShader||(this._sdfShader=new Ng),i.customShader=this._sdfShader));const n=Array.from(t.text),a=t._style;let o=(((f=a._stroke)==null?void 0:f.width)||0)/2;o+=r.baseLineOffset;const h=Ro(n,a,r);let c=0;const l=a.padding,u=h.scale;i.translate(-t._anchor._x*h.width-l,-t._anchor._y*(h.height+h.offsetY)-l).scale(u,u);const d=a._fill.color;for(let p=0;p<h.lines.length;p++){const g=h.lines[p];for(let m=0;m<g.charPositions.length;m++){const _=n[c++],x=r.chars[_];x!=null&&x.texture&&i.texture(x.texture,d||"black",Math.round(g.charPositions[m]+x.xOffset),Math.round(o+x.yOffset))}o+=r.lineHeight}}_getGpuBitmapText(t){return this._gpuBitmapText[t.uid]||this.initGpuText(t)}initGpuText(t){const e=$.get(is);return this._gpuBitmapText[t.uid]=e,this._updateContext(t,e),t.on("destroyed",()=>{this.destroyRenderable(t)}),this._gpuBitmapText[t.uid]}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,r=K.get(`${i}-bitmap`),{a:n,b:a,c:o,d:h}=t.groupTransform,c=Math.sqrt(n*n+a*a),l=Math.sqrt(o*o+h*h),u=(Math.abs(c)+Math.abs(l))/2,d=r.baseRenderedFontSize/t._style.fontSize,f=t.resolution??this._renderer.resolution,p=u*r.distanceField.range*(1/d)*f;e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){var t;for(const e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,(t=this._sdfShader)==null||t.destroy(!0),this._sdfShader=null,this._renderer=null}}Cc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"bitmapText"};function Mc(s,t){t.groupTransform=s.groupTransform,t.groupColorAlpha=s.groupColorAlpha,t.groupColor=s.groupColor,t.groupBlendMode=s.groupBlendMode,t.globalDisplayStatus=s.globalDisplayStatus,t.groupTransform=s.groupTransform,t.localDisplayStatus=s.localDisplayStatus,t.groupAlpha=s.groupAlpha,t._roundPixels=s._roundPixels}class Bc{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==i}addRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(i)}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.htmlText.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).catch(a=>{console.error(a)}),t._didTextUpdate=!1;const n=t._style.padding;Ps(r.bounds,t._anchor,r.texture,n)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=t._getKey();this._renderer.htmlText.decreaseReferenceCount(e.currentKey),e.generatingTexture=!0,e.currentKey=i;const r=t.resolution??this._renderer.resolution,n=await this._renderer.htmlText.getManagedTexture(t.text,r,t._style,t._getKey()),a=e.batchableSprite;a.texture=e.texture=n,e.generatingTexture=!1,e.textureNeedsUploading=!0,t.onViewUpdate();const o=t._style.padding;Ps(a.bounds,t._anchor,a.texture,o)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:M.EMPTY,currentKey:"--",batchableSprite:$.get(Jr),textureNeedsUploading:!1,generatingTexture:!1},i=e.batchableSprite;return i.renderable=t,i.texture=M.EMPTY,i.bounds={minX:0,maxX:1,minY:0,maxY:0},i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Bc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"htmlText"};function zg(){const{userAgent:s}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(s)}const Wg=new pt;function Rc(s,t,e,i){const r=Wg;r.minX=0,r.minY=0,r.maxX=s.width/i|0,r.maxY=s.height/i|0;const n=At.getOptimalTexture(r.width,r.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=s,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}function Vg(s,t){const e=t.fontFamily,i=[],r={},n=/font-family:([^;"\s]+)/g,a=s.match(n);function o(h){r[h]||(i.push(h),r[h]=!0)}if(Array.isArray(e))for(let h=0;h<e.length;h++)o(e[h]);else o(e);a&&a.forEach(h=>{const c=h.split(":")[1].trim();o(c)});for(const h in t.tagStyles){const c=t.tagStyles[h].fontFamily;o(c)}return i}async function jg(s){const e=await(await L.get().fetch(s)).blob(),i=new FileReader;return await new Promise((n,a)=>{i.onloadend=()=>n(i.result),i.onerror=a,i.readAsDataURL(e)})}async function kc(s,t){const e=await jg(t);return`@font-face {
        font-family: "${s.fontFamily}";
        src: url('${e}');
        font-weight: ${s.fontWeight};
        font-style: ${s.fontStyle};
    }`}const oi=new Map;async function $g(s,t,e){const i=s.filter(r=>K.has(`${r}-and-url`)).map((r,n)=>{if(!oi.has(r)){const{url:a}=K.get(`${r}-and-url`);n===0?oi.set(r,kc(t,a)):oi.set(r,kc({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:r},a))}return oi.get(r)});return(await Promise.all(i)).join(`
`)}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 un{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(Oo),n=Vg(t,i),a=await $g(n,i,Fr.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=Rc(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){At.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}un.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"htmlText"},un.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class Ic{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;Ps(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(Jr)};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}}Ic.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};function Fc(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 Gc(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&&Fc(a,e,h);)++h;if(h===i)return Y.EMPTY;for(;Fc(a,e,l);)--l;for(;Gc(a,e,o,h,l);)++o;for(;Gc(a,e,c,h,l);)--c;return++c,++l,new Y(o/t,h/t,(c-o)/t,(l-h)/t)}class Uc{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=Rc(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),At.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,C,E;const{canvas:n,context:a}=r,o=qs(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,rt=B.alpha;a.shadowColor=j.shared.setValue(q).setAlpha(rt).toRgbaString();const bt=B.blur*i,gs=B.distance*i;a.shadowBlur=bt,a.shadowOffsetX=Math.cos(B.angle)*gs,a.shadowOffsetY=Math.sin(B.angle)*gs+Q}else a.globalAlpha=((v=e._fill)==null?void 0:v.alpha)??1,a.fillStyle=e._fill?Js(e._fill,a):null,(w=e._stroke)!=null&&w.width&&(a.strokeStyle=Js(e._stroke,a)),a.shadowColor="black";let Ct=(l-f.fontSize)/2;l-f.fontSize<0&&(Ct=0);const F=((C=e._stroke)==null?void 0:C.width)??0;for(let B=0;B<c.length;B++)m=F/2,_=F/2+B*l+f.ascent+Ct,e.align==="right"?m+=d-u[B]:e.align==="center"&&(m+=(d-u[B])/2),(E=e._stroke)!=null&&E.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}}Uc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"canvasText"},O.add(Ml,Bl);const ae=.02*1e3,Dc=s=>s.name=="jump",Oc=s=>s.name=="color",Lc=s=>s.name=="grow",Hc=s=>s.name=="dash",Nc=s=>s.name=="sprite",zc=s=>s.name=="add_jump_hits",Wc=s=>s.name=="resurrect";function hi(s){"@babel/helpers - typeof";return hi=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},hi(s)}var Zg=/^\s+/,Jg=/\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=Qg(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=Kc(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=jc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString: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.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+r+"%)":"hsva("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=Vc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Vc(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 $c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return i_(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:m_[$c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Xc(this._r,this._g,this._b,this._a),i=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=k(t);i="#"+Xc(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(o_,arguments)},brighten:function(){return this._applyModification(h_,arguments)},darken:function(){return this._applyModification(c_,arguments)},desaturate:function(){return this._applyModification(r_,arguments)},saturate:function(){return this._applyModification(n_,arguments)},greyscale:function(){return this._applyModification(a_,arguments)},spin:function(){return this._applyModification(l_,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(f_,arguments)},complement:function(){return this._applyCombination(u_,arguments)},monochromatic:function(){return this._applyCombination(p_,arguments)},splitcomplement:function(){return this._applyCombination(d_,arguments)},triad:function(){return this._applyCombination(Yc,[3])},tetrad:function(){return this._applyCombination(Yc,[4])}},k.fromRatio=function(s,t){if(hi(s)=="object"){var e={};for(var i in s)s.hasOwnProperty(i)&&(i==="a"?e[i]=s[i]:e[i]=ds(s[i]));s=e}return k(s,t)};function Qg(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=y_(s)),hi(s)=="object"&&(Zt(s.r)&&Zt(s.g)&&Zt(s.b)?(t=t_(s.r,s.g,s.b),a=!0,o=String(s.r).substr(-1)==="%"?"prgb":"rgb"):Zt(s.h)&&Zt(s.s)&&Zt(s.v)?(i=ds(s.s),r=ds(s.v),t=s_(s.h,i,r),a=!0,o="hsv"):Zt(s.h)&&Zt(s.s)&&Zt(s.l)&&(i=ds(s.s),n=ds(s.l),t=e_(s.h,i,n),a=!0,o="hsl"),s.hasOwnProperty("a")&&(e=s.a)),e=Kc(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 t_(s,t,e){return{r:J(s,255)*255,g:J(t,255)*255,b:J(e,255)*255}}function Vc(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 e_(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 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,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 s_(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 $c(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 i_(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(qc(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 Xc(s,t,e,i){var r=[Ut(qc(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 r_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s-=t/100,e.s=ci(e.s),k(e)}function n_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s+=t/100,e.s=ci(e.s),k(e)}function a_(s){return k(s).desaturate(100)}function o_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l+=t/100,e.l=ci(e.l),k(e)}function h_(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 c_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l-=t/100,e.l=ci(e.l),k(e)}function l_(s,t){var e=k(s).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,k(e)}function u_(s){var t=k(s).toHsl();return t.h=(t.h+180)%360,k(t)}function Yc(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 d_(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 f_(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 p_(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=b_(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 dn=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"},m_=k.hexNames=g_(dn);function g_(s){var t={};for(var e in s)s.hasOwnProperty(e)&&(t[s[e]]=e);return t}function Kc(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function J(s,t){__(s)&&(s="100%");var e=x_(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 ci(s){return Math.min(1,Math.max(0,s))}function yt(s){return parseInt(s,16)}function __(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function x_(s){return typeof s=="string"&&s.indexOf("%")!=-1}function Ut(s){return s.length==1?"0"+s:""+s}function ds(s){return s<=1&&(s=s*100+"%"),s}function qc(s){return Math.round(parseFloat(s)*255).toString(16)}function Zc(s){return yt(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 Zt(s){return!!Dt.CSS_UNIT.exec(s)}function y_(s){s=s.replace(Zg,"").replace(Jg,"").toLowerCase();var t=!1;if(dn[s])s=dn[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:yt(e[1]),g:yt(e[2]),b:yt(e[3]),a:Zc(e[4]),format:t?"name":"hex8"}:(e=Dt.hex6.exec(s))?{r:yt(e[1]),g:yt(e[2]),b:yt(e[3]),format:t?"name":"hex"}:(e=Dt.hex4.exec(s))?{r:yt(e[1]+""+e[1]),g:yt(e[2]+""+e[2]),b:yt(e[3]+""+e[3]),a:Zc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=Dt.hex3.exec(s))?{r:yt(e[1]+""+e[1]),g:yt(e[2]+""+e[2]),b:yt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function b_(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 fs=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-fs.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?fs.Bounce.In(s*2)*.5:fs.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}}}}),ps=function(){return performance.now()},v_=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=ps()),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}}},S_=function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s}(),fn=new v_,xe=function(){function s(t,e){e===void 0&&(e=fn),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=fs.Linear.None,this._interpolationFunction=He.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=S_.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=ps()),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=ps()),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=ps()),!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=fn),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=fs.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=ps()),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=fn;Nt.getAll.bind(Nt),Nt.removeAll.bind(Nt),Nt.add.bind(Nt),Nt.remove.bind(Nt),Nt.update.bind(Nt);class Jt{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 w_{constructor(){T(this,"timers",[])}add(t,e){this.timers.push(new Jt(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 pn=new w_;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 Jc=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 kt.load(e.image),r=new Hi(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 rs(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 rs(h);c.texture.source.scaleMode="nearest",a[o.name]=c}n.name&&(r[n.name]=a)}return r}}const li=new A_;var ye={},Qc={},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 E_=function(t,e){return function(i,r,n,a){e(i,r,n)&&a(i,t,r,n)}};Qt.conditional=E_;var C_=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=C_;var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.readBits=nt.readArray=nt.readUnsigned=nt.readString=nt.peekBytes=nt.readBytes=nt.peekByte=nt.readByte=nt.buildStream=void 0;var M_=function(t){return{data:t,pos:0}};nt.buildStream=M_;var tl=function(){return function(t){return t.data[t.pos++]}};nt.readByte=tl;var B_=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};nt.peekByte=B_;var ui=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};nt.readBytes=ui;var R_=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};nt.peekBytes=R_;var k_=function(t){return function(e){return Array.from(ui(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};nt.readString=k_;var I_=function(t){return function(e){var i=ui(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};nt.readUnsigned=I_;var F_=function(t,e){return function(i,r,n){for(var a=typeof e=="function"?e(i,r,n):e,o=ui(t),h=new Array(a),c=0;c<a;c++)h[c]=o(i);return h}};nt.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=tl()(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},{})}};nt.readBits=U_,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var t=Qt,e=nt,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}(Qc);var di={};Object.defineProperty(di,"__esModule",{value:!0}),di.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};di.deinterlace=D_;var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.lzw=void 0;var O_=function(t,e,i){var r=4096,n=-1,a=i,o,h,c,l,u,d,f,C,p,g,w,m,E,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,C,E,P,S,A;for(w=C=E=P=S=A=0,g=0;g<a;){if(P===0){if(C<l){w+=e[A]<<C,C+=8,A++;continue}if(p=w&c,w>>=l,C-=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,E=p;continue}for(d=p,p==o&&(v[P++]=E,p=f);p>h;)v[P++]=y[p],p=x[p];E=y[p]&255,v[P++]=E,o<r&&(x[o]=f,y[o]=E,o++,!(o&c)&&o<r&&(l++,c+=o)),f=d}P--,_[S++]=v[P],g++}for(g=S;g<a;g++)_[g]=0;return _};fi.lzw=O_,Object.defineProperty(ye,"__esModule",{value:!0});var el=ye.decompressFrames=ye.decompressFrame=sl=ye.parseGIF=void 0,L_=V_(Qc),H_=Qt,N_=nt,z_=di,W_=fi;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)},sl=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},il=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=il;var X_=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return il(i,t.gct,e)})};el=ye.decompressFrames=X_;const ms=class extends wt{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({},ms.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=sl(s);e(i);const r=el(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({},ms.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:C,top:E}}=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,C,E);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 ms(n,{width:p,height:g,...t})}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ht.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ht.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/ht.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?(ht.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ht.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 ms([...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 mn=ms;mn.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=>mt.extname(s)===".gif",load:async(s,t)=>{const i=await(await L.get().fetch(s)).arrayBuffer();return mn.fromBuffer(i,t==null?void 0:t.data)},unload:async s=>{s.destroy()}}};O.add(Y_);const rl={};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=rl[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=mn.fromBuffer(a),rl[t]=i;break}case"image/png":{i=wt.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 Jt(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 Zs({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,"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;(i=this.timer)==null||i.tick(),(r=this.showTween)==null||r.update(),(n=this.hideTween)==null||n.update(),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){var e,i;this.isChecking=!1,(e=this.hideTween)==null||e.stop(),(i=this.showTween)==null||i.stop(),t&&(this.beforeShow(),this.show(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 is;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 Jt(1e4,()=>{var n;(n=this.hideTween)==null||n.start()})}),this.showTween.start()}}class Z_{constructor(){T(this,"text",new Zs({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(it.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);it.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 Jt(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 wt(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))},nl={fontFamily:"Custom Font",fontSize:14,fill:"white",align:"center",stroke:{width:4,color:"black",join:"round"}};class ex{constructor(){T(this,"container",new z);T(this,"killText",new Zs({text:void 0,style:nl}));T(this,"killSprite");T(this,"jumpText",new Zs({text:void 0,style:nl}));T(this,"jumpSprite");T(this,"kills",0);T(this,"jumps",0);this.container.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=kt.get(t),i=wt.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.container.removeChildren();for(const n of t)n.position.set(r,0),r+=n.width+e,this.container.addChild(n)}update(t){this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.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 al{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);this.container.addChild(this.name.text),this.container.addChild(this.info.container),this.container.addChild(this.emoteSpitter.container),this.container.addChild(this.message.container),this.container.sortableChildren=!0}get screenBounds(){return{left:this.offset,right:it.renderer.width-this.offset}}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 Jt(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:it.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 Jt(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 Jt((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,Jc.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 li.getSpriteData(t);if(!e)return;this.sprite&&this.container.removeChild(this.sprite.container),this.state.sprite=t;const i=li.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 Jt(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=it.renderer.height,this.animationState==dt.Fall&&(this.setAnimationState(dt.Land),this.landTimer=new Jt(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.container.position.y-this.info.container.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>it.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=kt.get(t),n=li.createAnimatedSprite(t,r);n&&(it.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=()=>{it.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=kt.get(e);this.sprite=wt.from(i)}isOnGround(t){return t>it.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=it.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,"viewerArray",[]);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 al;if(this.addViewer(t,r),it.settings.maxEvotars&&this.viewerArray.length>it.settings.maxEvotars){const n=this.viewerArray.shift(),a=n!=null?this.viewers[n]:void 0;n&&a&&this.deleteViewer(n,a)}return await r.setProps(e),r.spawn(i),this.recentEvotarActivity[t]=performance.now(),r}async processRaid(t){if(!it.settings.fallingRaiders)return;const e=1/t.viewers.count*5e3;let i=t.viewers.count;it.settings.maxEvotars&&(i=Math.min(i,it.settings.maxEvotars));for(let o=0;o<t.viewers.count;o++){const h=new al;await h.setProps({isAnonymous:!0,zIndex:-1,sprite:t.viewers.sprite,color:new j(t.broadcaster.info.color)}),pn.add(e*o,()=>{this.addRaider(h),h.spawn({isFalling:!0})}),pn.add(o*e+6e4,()=>{this.despawnRaider(h)})}const r=this.viewers[t.broadcaster.id],n={...this.prepareEvotarProps(t.broadcaster.info.displayName,t.broadcaster.info.color,t.broadcaster.info.sprite),scale:2,isImmortal:!0},a=async()=>{await this.spawnViewerEvotar(t.broadcaster.id,n,{isFalling:!0,positionX:.5})};this.recentEvotarActivity[t.broadcaster.id]=performance.now(),r?r.despawn({onComplete:()=>{a()}}):a()}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(it.settings.showAnonymousEvotars){for(const e of t)if(!this.viewers[e.userId]){const r={name:e.name,isAnonymous:!this.hasActivity(e.userId),sprite:"default"};await this.spawnViewerEvotar(e.userId,r,{})}}}doAction(t,e){if(Dc(t)&&e.jump({velocityX:t.data.velocityX,velocityY:t.data.velocityY}),Hc(t)&&e.dash({force:t.data.force}),Oc(t)){const i=k(t.data.color);i&&i.isValid()&&e.setUserProps({color:new j(t.data.color)})}Lc(t)&&e.scale({value:t.data.scale,duration:t.data.duration}),Nc(t)&&e.setSprite(t.data.sprite),zc(t)&&e.addJumpHit(t.data.count),Wc(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);e?(await e.setProps(i),this.doAction(t,e)):await this.spawnViewerEvotar(t.userId,i,{onComplete:()=>{const r=this.viewers[t.userId];r&&this.doAction(t,r)}})}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=it.settings.fallingEvotars?!this.hasActivity(t.userId):!1;i=await this.spawnViewerEvotar(t.userId,e,{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){it.stage.addChild(t.container),this.tombstones.push(t)}deleteTombStone(t){it.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,this.viewerArray.push(t)}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){li.initialize(e.spriteLoaderFn),Jc.initialize(e.sounds),e.font&&await kt.load({src:e.font,data:{family:"Custom Font"}});for(const i in e.assets)kt.add({alias:i,src:e.assets[i]});await kt.load(["skull","weight","poof","rip1","rip2"]),this.ticker=new ht,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(){pn.tick(),Et.update(),this.renderer.render(this.stage)}}const it=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){it.updateSettings(t)}async run(){if(this.isRendered)return;this.isRendered=!0,await(async()=>{await it.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,it.update()),requestAnimationFrame(n)}})()}}O.add(wa),z.mixin(Bu),O.add(La),O.add(Ha),O.add(yo),z.mixin(ip),O.add(yc),O.add(xr),O.add(vc),O.add(Uc),O.add(Ic),O.add(Cc,Ug,Gg),O.add(un),O.add(Bc),O.add(Tc),O.add(wc),O.add(So),O.add(bo);const ux=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),dx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));at.Evotars=lx,at.isAddJumpHitsUserActionEntity=zc,at.isColorUserActionEntity=Oc,at.isDashUserActionEntity=Hc,at.isGrowUserActionEntity=Lc,at.isJumpUserActionEntity=Dc,at.isResurrectUserActionEntity=Wc,at.isSpriteUserActionEntity=Nc,Object.defineProperty(at,Symbol.toStringTag,{value:"Module"})});