const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-w8xss8gu.js","assets/webworkerAll-tB1Muq8I.js","assets/colorToUniform-D6WiE-Of.js","assets/WebGPURenderer-Co8-REvx.js","assets/SharedSystems-BzpUCeml.js","assets/WebGLRenderer-B1cEC-wN.js"])))=>i.map(i=>d[i]); var Ca=Object.defineProperty;var Ta=(i,t,e)=>t in i?Ca(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var x=(i,t,e)=>Ta(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const Ma="modulepreload",Pa=function(i){return"/"+i},Fs={},ii=function(t,e,s){let r=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(e.map(h=>{if(h=Pa(h),h in Fs)return;Fs[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Ma,c||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((u,f)=>{d.addEventListener("load",u),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};var P=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(P||{});const Ni=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},We=(i,t)=>Ni(i).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ni).forEach(t=>{t.type.forEach(e=>{var s,r;return(r=(s=this._removeHandlers)[e])==null?void 0:r.call(s,t)})}),this},add(...i){return i.map(Ni).forEach(t=>{t.type.forEach(e=>{var n,a;const s=this._addHandlers,r=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,r=this._removeHandlers;if(s[i]||r[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,r[i]=e;const n=this._queue;return n[i]&&((a=n[i])==null||a.forEach(o=>t(o)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(n=>n.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((n,a)=>We(a.value,e)-We(n.value,e)))},s=>{const r=t.findIndex(n=>n.name===s.name);r!==-1&&t.splice(r,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((r,n)=>We(n,e)-We(r,e)))},s=>{const r=t.indexOf(s.ref);r!==-1&&t.splice(r,1)})}},ka={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ii(()=>import("./browserAll-w8xss8gu.js"),__vite__mapDeps([0,1,2]))}},Ga={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ii(()=>import("./webworkerAll-tB1Muq8I.js"),__vite__mapDeps([1,2]))}};class lt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new lt(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 ds(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Or={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,d,u){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,d||h,u),m=e?e+c:c;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],f]:h._events[m].push(f):(h._events[m]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new s:delete h._events[c]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,d;if(this._eventsCount===0)return c;for(d in l=this._events)t.call(l,d)&&c.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,d=this._events[l];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,f=d.length,m=new Array(f);u$t[i],uY:i=>Vt[i],vX:i=>Yt[i],vY:i=>Xt[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Hi[i][t],sub:(i,t)=>Hi[i][V.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?V.S:V.N:Math.abs(t)*2<=Math.abs(i)?i>0?V.E:V.W:t>0?i>0?V.SE:V.SW:i>0?V.NE:V.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=Ur[V.inv(t)];r.tx=e,r.ty=s,i.append(r)}},He=[new ot,new ot,new ot,new ot];class z{constructor(t=0,e=0,s=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),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 z(0,0,0,0)}clone(){return new z(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.y&&e=h&&t<=c&&e>=l&&e<=d&&!(t>u&&tm&&et.right?t.right:this.right)<=k)return!1;const A=this.yt.bottom?t.bottom:this.bottom)>A}const s=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=s||a<=n)return!1;const o=He[0].set(t.left,t.top),h=He[1].set(t.left,t.bottom),c=He[2].set(t.right,t.top),l=He[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===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)<=s||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 u=d*(h.y-o.y),f=d*(o.x-h.x),m=u*s+f*n,y=u*r+f*n,g=u*s+f*a,_=u*r+f*a;if(Math.max(m,y,g,_)<=u*o.x+f*o.y||Math.min(m,y,g,_)>=u*l.x+f*l.y)return!1;const w=d*(o.y-c.y),b=d*(c.x-o.x),S=w*s+b*n,C=w*r+b*n,E=w*s+b*a,M=w*r+b*a;return!(Math.max(S,C,E,M)<=w*o.x+b*o.y||Math.min(S,C,E,M)>=w*l.x+b*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),s=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(s-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const s=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=s-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=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=s-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new z,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const gi={default:-1};function st(i="default"){return gi[i]===void 0&&(gi[i]=-1),++gi[i]}const Rs={},U="8.0.0",za="8.3.4";function O(i,t,e=3){if(Rs[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${i}`):(s=s.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${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${i}`),console.warn(s))),Rs[t]=!0}const Wr=()=>{};function Ls(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Ds(i){return!(i&i-1)&&!!i}function Oa(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const zs=Object.create(null);function Ua(i){const t=zs[i];return t===void 0&&(zs[i]=st("resource")),t}const Nr=class Hr extends ct{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Hr.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){O(U,"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=Ua(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Nr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Wa=Nr;const $r=class Vr extends ct{constructor(t={}){super(),this.options=t,this.uid=st("textureSource"),this._resourceType="textureSource",this._resourceId=st("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={...Vr.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 Wa(Oa(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.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=st("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,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*s),n=Math.round(e*s);return this.width=r/s,this.height=n/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=st("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=Ds(this.pixelWidth)&&Ds(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};$r.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Gt=$r;class us extends Gt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),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}}us.extension=P.TextureSource;const Os=new W;class Na{constructor(t,e){this.mapCoord=new W,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 s=this.mapCoord;for(let r=0;rthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new z);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=Us,this}set(t,e,s,r){this.minX=t,this.minY=e,this.maxX=s,this.maxY=r}addFrame(t,e,s,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,d=n.ty;let u=this.minX,f=this.minY,m=this.maxX,y=this.maxY,g=a*t+h*e+l,_=o*t+c*e+d;gm&&(m=g),_>y&&(y=_),g=a*s+h*e+l,_=o*s+c*e+d,gm&&(m=g),_>y&&(y=_),g=a*t+h*r+l,_=o*t+c*r+d,gm&&(m=g),_>y&&(y=_),g=a*s+h*r+l,_=o*s+c*r+d,gm&&(m=g),_>y&&(y=_),this.minX=u,this.minY=f,this.maxX=m,this.maxY=y}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.maxXthis.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*e+h*n+l,f=o*e+c*n+d,this.minX=uthis.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY,u=a*r+h*n+l,f=o*r+c*n+d,this.minX=uthis.maxX?u:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,r){return this.minXe&&(this.maxX=e),this.minYr&&(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 vt(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,s,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,d=r.c,u=r.d,f=r.tx,m=r.ty;for(let y=e;yo?w:o,h=b>h?b: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}]`}}var $a={grad:.9,turn:360,rad:360/(2*Math.PI)},Ct=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},nt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},pt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},Yr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Ws=function(i){return{r:pt(i.r,0,255),g:pt(i.g,0,255),b:pt(i.b,0,255),a:pt(i.a)}},xi=function(i){return{r:nt(i.r),g:nt(i.g),b:nt(i.b),a:nt(i.a,3)}},Va=/^#([0-9a-f]{3,8})$/i,$e=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Xr=function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=Math.max(t,e,s),a=n-Math.min(t,e,s),o=a?n===t?(e-s)/a:n===e?2+(s-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}},jr=function(i){var t=i.h,e=i.s,s=i.v,r=i.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),a=s*(1-e),o=s*(1-(t-n)*e),h=s*(1-(1-t+n)*e),c=n%6;return{r:255*[s,o,a,a,h,s][c],g:255*[h,s,s,o,a,a][c],b:255*[a,a,h,s,s,o][c],a:r}},Ns=function(i){return{h:Yr(i.h),s:pt(i.s,0,100),l:pt(i.l,0,100),a:pt(i.a)}},Hs=function(i){return{h:nt(i.h),s:nt(i.s),l:nt(i.l),a:nt(i.a,3)}},$s=function(i){return jr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Te=function(i){return{h:(t=Xr(i)).h,s:(r=(200-(e=t.s))*(s=t.v)/100)>0&&r<200?e*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,s,r},Ya=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Xa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ja=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$i={string:[[function(i){var t=Va.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?nt(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?nt(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ja.exec(i)||qa.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Ws({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(i){var t=Ya.exec(i)||Xa.exec(i);if(!t)return null;var e,s,r=Ns({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*($a[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return $s(r)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=r===void 0?1:r;return Ct(t)&&Ct(e)&&Ct(s)?Ws({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,r=i.a,n=r===void 0?1:r;if(!Ct(t)||!Ct(e)||!Ct(s))return null;var a=Ns({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return $s(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,r=i.a,n=r===void 0?1:r;if(!Ct(t)||!Ct(e)||!Ct(s))return null;var a=function(o){return{h:Yr(o.h),s:pt(o.s,0,100),v:pt(o.v,0,100),a:pt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return jr(a)},"hsv"]]},Vs=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=xi(this.rgba),e=t.r,s=t.g,r=t.b,a=(n=t.a)<1?$e(nt(255*n)):"","#"+$e(e)+$e(s)+$e(r)+a;var t,e,s,r,n,a},i.prototype.toRgb=function(){return xi(this.rgba)},i.prototype.toRgbString=function(){return t=xi(this.rgba),e=t.r,s=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+r+", "+n+")":"rgb("+e+", "+s+", "+r+")";var t,e,s,r,n},i.prototype.toHsl=function(){return Hs(Te(this.rgba))},i.prototype.toHslString=function(){return t=Hs(Te(this.rgba)),e=t.h,s=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+r+"%, "+n+")":"hsl("+e+", "+s+"%, "+r+"%)";var t,e,s,r,n},i.prototype.toHsv=function(){return t=Xr(this.rgba),{h:nt(t.h),s:nt(t.s),v:nt(t.v),a:nt(t.a,3)};var t},i.prototype.invert=function(){return _t({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),_t(yi(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),_t(yi(this.rgba,-t))},i.prototype.grayscale=function(){return _t(yi(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),_t(Ys(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),_t(Ys(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?_t({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):nt(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Te(this.rgba);return typeof t=="number"?_t({h:t,s:e.s,l:e.l,a:e.a}):nt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===_t(t).toHex()},i}(),_t=function(i){return i instanceof Vi?i:new Vi(i)},Xs=[],Za=function(i){i.forEach(function(t){Xs.indexOf(t)<0&&(t(Vi,$i),Xs.push(t))})};function Qa(i,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"},s={};for(var r in e)s[e[r]]=r;var n={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=s[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),d=1/0,u="black";if(!n.length)for(var f in e)n[f]=new i(e[f]).toRgb();for(var m in e){var y=(o=l,h=n[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));yn===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,s,r]=this._components;return{r:t,g:e,b:s,a:r}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,r,n]=this._components;return t[0]=e,t[1]=s,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,r]=this._components;return t[0]=e,t[1]=s,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,r,n]=Se._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,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 s=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<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,s,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(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,s,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,s,r,n=255]=t,e/=255,s/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Se.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=_t(t);a.isValid()&&({r:e,g:s,b:r,a:n}=a.rgba,e/=255,s/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,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,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Se||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 Ja={cullArea:null,cullable:!1,cullableChildren:!0};class fs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.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}clear(){this._pool.length=0,this._index=0}}class to{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 fs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const Mt=new to;function eo(i,t,e){const s=i.length;let r;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(r=t;r0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}eo(this.children,i,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||O(U,"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(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const r=i.parent.children.indexOf(i);if(i.parent===this&&r===t)return i;r!==-1&&i.parent.children.splice(r,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class js{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;es.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),Yi.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Yi.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var n;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new js);i=i;const e=(i==null?void 0:i.length)>0,s=((n=t.filters)==null?void 0:n.length)>0,r=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new js),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},no={label:null,get name(){return O(U,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){O(U,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s-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 s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(r)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(at.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||O(U,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r1){for(let r=0;r-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=Mt.get(po,this),this.groupTransform=W.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Mt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new W),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*Ea}set angle(t){this.rotation=t*Fa}get pivot(){return this._pivot===Si&&(this._pivot=new lt(this,0,0)),this._pivot}set pivot(t){this._pivot===Si&&(this._pivot=new lt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===bi&&(this._skew=new lt(this,0,0)),this._skew}set skew(t){this._skew===bi&&(this._skew=new lt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===vi&&(this._scale=new lt(this,1,1)),this._scale}set scale(t){this._scale===vi&&(this._scale=new lt(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 s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.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(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,r=this._pivot,n=this._position,a=s._x,o=s._y,h=r._x,c=r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=n._x-(h*e.a+c*e.c),e.ty=n._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ks,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=J.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=Ks,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|=go,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ai,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ai,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|=Ai,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;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 n=0;n=e.minX&&s<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class H extends oi{constructor(t=L.EMPTY){t instanceof L&&(t={texture:t});const{texture:e=L.EMPTY,anchor:s,roundPixels:r,width:n,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new lt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof L?new H(t):new H(L.from(t,e))}set texture(t){t||(t=L.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._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),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._didViewChangeTick++,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(){Ha(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:r,height:n}=e.orig;s.maxX=-t._x*r,s.minX=s.maxX+r,s.maxY=-t._y*n,s.minY=s.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}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 width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}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){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const xo=new vt;function en(i,t,e){const s=xo;i.measurable=!0,qr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function sn(i,t,e){const s=oe.get();i.measurable=!0;const r=Pt.get().identity(),n=rn(i,e,r);Zr(i,s,n),i.measurable=!1,t.addBoundsMask(s),Pt.return(r),oe.return(s)}function rn(i,t,e){return i?(i!==t&&(rn(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(tt("Mask bounds, renderable is not inside the root container"),e)}class nn{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 H),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){en(this.mask,t,e)}addLocalBounds(t,e){sn(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof H}}nn.extension=P.MaskEffect;class an{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"}}an.extension=P.MaskEffect;class on{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){en(this.mask,t,e)}addLocalBounds(t,e){sn(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof at}}on.extension=P.MaskEffect;const yo={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let Zs=yo;const K={get(){return Zs},set(i){Zs=i}};class hn extends Gt{constructor(t){t.resource||(t.resource=K.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,s=this._resolution){const r=super.resize(t,e,s);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}hn.extension=P.TextureSource;class ce extends Gt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=K.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e,tt("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||globalThis.VideoFrame&&t instanceof VideoFrame}}ce.extension=P.TextureSource;var ri=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(ri||{});class Ci{constructor(t,e=null,s=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,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 ln=class dt{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 Ci(null,null,1/0),this.deltaMS=1/dt.targetFPMS,this.elapsedMS=1/dt.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,s=ri.NORMAL){return this._addListener(new Ci(t,e,s))}addOnce(t,e,s=ri.NORMAL){return this._addListener(new Ci(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.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{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 s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,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(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Ti}const hi=class dn extends Gt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...dn.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=bt.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 cn(),this._load=new Promise((s,r)=>{this.isValid?s(this):(this._resolve=s,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&&(bt.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||(bt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(bt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};hi.extension=P.TextureSource;hi.defaultOptions={...Gt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};hi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Je=hi;const xt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class _o{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||tt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=xt(t);let r;for(let h=0;h{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:s};s.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&&tt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){tt(`[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 Y=new _o,Xi=[];ht.handleByList(P.TextureSource,Xi);function un(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let r=0;r{Y.has(s)&&Y.remove(s)}),t||Y.set(s,n),n}function bo(i,t=!1){return typeof i=="string"?Y.get(i):i instanceof Gt?new L({source:i}):wo(i,t)}L.from=bo;Gt.from=un;ht.add(nn,an,on,Je,ce,hn,us);var Lt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Lt||{});function gt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function ye(i){return i.split("?")[0].split("#")[0]}function So(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vo(i,t,e){return i.replace(new RegExp(So(t),"g"),e)}function Ao(i,t){let e="",s=0,r=-1,n=0,a=-1;for(let o=0;o<=i.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,r=o,n=0;continue}}}else e.length>0?e+=`/${i.slice(r+1,o)}`:e=i.slice(r+1,o),s=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const ut={toPosix(i){return vo(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){gt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(gt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=ye(this.toPosix(t??K.get().getBaseUrl())),r=ye(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?ut.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(gt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Ao(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return gt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=s;else{const r=i[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(gt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,r=!0;const n=this.getProtocol(i),a=i;i=i.slice(n.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!r){s=o;break}}else r=!1;return s===-1?e?"/":this.isUrl(a)?n+i:n:e&&s===1?"//":n+i.slice(0,s)},rootname(i){gt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){gt(i),t&>(t),i=ye(this.toPosix(i));let e=0,s=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(n=i.length-1;n>=0;--n){const h=i.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&&(s=n):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!r){e=n+1;break}}else s===-1&&(r=!1,s=n+1);return s===-1?"":i.slice(e,s)},extname(i){gt(i),i=ye(this.toPosix(i));let t=-1,e=0,s=-1,r=!0,n=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}s===-1&&(r=!1,s=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){gt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=ye(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let r;t.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=i.length-1,l=0;for(;c>=r;--c){if(e=i.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&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,n),t.base=i.slice(1,o)):(t.name=i.slice(a,n),t.base=i.slice(a,o)),t.ext=i.slice(n,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function fn(i,t,e,s,r){const n=t[e];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");r.push(a)}),fn(i,r,0,e,s)}else s.push(i);return s}const ni=i=>!Array.isArray(i);class de{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(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return xt(e||s,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&&tt("[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 s=[];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);s.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));s.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=n=>{this.hasKey(n)&&tt(`[Resolver] already has key: ${n} overwriting`)},xt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=xt(a).map(f=>typeof f=="string"?Co(f):Array.isArray(f)?f:[f]),d=this.getAlias(n);Array.isArray(d)?d.forEach(s):s(d);const u=[];l.forEach(f=>{f.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let g=0;g{this._assetMap[f]=u})})}resolveBundle(t){const e=ni(t);t=xt(t);const s={};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}s[r]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=ni(t);t=xt(t);const s={};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},{});s[r]=this._resolverHash[r]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.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:s,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=ut.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??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??To(t.src),t}}de.RETINA_PREFIX=/@([0-9\.]+)x/;function To(i){return i.split(".").pop().split("?").shift().split("#").shift()}const ji=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},pn=class ve{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof L?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,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<=ve.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ve.BATCH_SIZE;for(;e-t{this._batchIndex*ve.BATCH_SIZE{s[r]=t}),Object.keys(t.textures).forEach(r=>{s[r]=t.textures[r]}),!e){const r=ut.dirname(i[0]);t.linkedSheets.forEach((n,a)=>{const o=mn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(s,o)})}return s}const Po={extension:P.Asset,cache:{test:i=>i instanceof Qs,getCacheableAssets:(i,t)=>mn(i,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),r=e.pop();return s==="json"&&Mo.includes(r)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=de.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:Lt.Normal,name:"spritesheetLoader"},async testParse(i,t){return ut.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var c,l;const{texture:s,imageFilename:r}=(t==null?void 0:t.data)??{};let n=ut.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(s instanceof L)a=s;else{const d=ji(n+(r??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new Qs(a.source,i);await o.parse();const h=(c=i==null?void 0:i.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let m=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(m=ji(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const u=await Promise.all(d);o.linkedSheets=u,u.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==f))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};ht.add(Po);const Mi=Object.create(null),Js=Object.create(null);function ps(i,t){let e=Js[i];return e===void 0&&(Mi[t]===void 0&&(Mi[t]=1),Js[i]=e=Mi[t]++),e}let Qt;function gn(){return(!Qt||Qt!=null&&Qt.isContextLost())&&(Qt=K.get().createCanvas().getContext("webgl",{})),Qt}let Ve;function ko(){if(!Ve){Ve="mediump";const i=gn();i&&i.getShaderPrecisionFormat&&(Ve=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return Ve}function Go(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${i} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${i} `}function Io(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&s!=="highp"&&(r="mediump"),`precision ${r} float; ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Bo(i,t){return t?`#version 300 es ${i}`:i}const Eo={},Fo={};function Ro(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Eo:Fo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`} ${i}`}function Lo(i,t){return t?i.replace("#version 300 es",""):i}const Pi={stripVersion:Lo,ensurePrecision:Io,addProgramDefines:Go,setProgramName:Ro,insertVersion:Bo},ki=Object.create(null),xn=class qi{constructor(t){t={...qi.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ko()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(Pi).forEach(a=>{const o=s[a];r=Pi[a](r,o,!0),n=Pi[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=ps(`${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 ki[e]||(ki[e]=new qi(t)),ki[e]}};xn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let yn=xn;const tr={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 Do(i){return tr[i]??tr.float32}const zo={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Oo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const r=i.indexOf("->",s);if(r!==-1){const n=i.substring(s,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=zo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Do(h).stride,offset:0,instance:!1,start:0}}}}return e}function Gi(i){var d,u;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@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=(d=i.match(t))==null?void 0:d.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(s)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((u=i.match(a))==null?void 0:u.map(f=>{const m=f.match(h)[1],y=f.match(o).reduce((g,_)=>{const[w,b]=_.split(":");return g[w.trim()]=b.trim(),g},{});return y?{name:m,members:y}:null}).filter(({name:f})=>c.some(m=>m.type===f)))??[];return{groups:c,structs:l}}var Ae=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ae||{});function Uo({groups:i}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),n=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:r,groups:n}}const Ii=Object.create(null);class li{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const c=Gi(e.source);this.structsAndGroups=c}else{const c=Gi(s.source),l=Gi(e.source);this.structsAndGroups=No(c,l)}this.layout=r??Wo(this.structsAndGroups),this.gpuLayout=n??Uo(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,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ps(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Oo(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 Ii[e]||(Ii[e]=new li(t)),Ii[e]}}const _n=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Ho=_n.reduce((i,t)=>(i[t]=!0,i),{});function $o(i,t){switch(i){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const wn=class bn{constructor(t,e){this._touched=0,this.uid=st("uniform"),this._resourceType="uniformGroup",this._resourceId=st("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...bn.defaultOptions,...e},this.uniformStructures=t;const s={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Ho[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${_n.join(", ")}`);n.value??(n.value=$o(n.type,n.size)),s[r]=n.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ps(Object.keys(s).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};wn.defaultOptions={ubo:!1,isStatic:!1};let Sn=wn;class ti{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const r=t[s];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const s=this.resources[e];t!==s&&(s&&((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 s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const r=t[s];(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 s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var Ki=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(Ki||{});class ms extends ct{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=Ki.WEBGPU),s&&(a|=Ki.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 d=o[c][l];h[d]={group:c,binding:l,name:d}}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){r={},o={},e&&e.structsAndGroups.groups.forEach(d=>{o[d.group]=o[d.group]||{},o[d.group][d.binding]=d.name,h[d.name]=d});let c=0;for(const l in n)h[l]||(r[99]||(r[99]=new ti,this._ownedBindGroups.push(r[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in n){const d=l;let u=n[l];!u.source&&!u._resourceType&&(u=new Sn(u));const f=h[d];f&&(r[f.group]||(r[f.group]=new ti,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(u,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,s){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new ti,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const r in e){const n=e[r];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.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:s,...r}=t;let n,a;return e&&(n=li.from(e)),s&&(a=yn.from(s)),new ms({gpuProgram:n,glProgram:a,...r})}}const Zi=[];ht.handleByNamedList(P.Environment,Zi);async function Vo(i){if(!i)for(let t=0;t80*e){o=c=i[0],h=l=i[1];for(var m=e;mc&&(c=d),u>l&&(l=u);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return ke(n,a,e,o,h,f,0),a}function vn(i,t,e,s,r){var n,a;if(r===ts(i,t,e,s)>0)for(n=t;n=t;n-=s)a=er(n,i[n],i[n+1],a);return a&&di(a,a.next)&&(Ie(a),a=a.next),a}function Kt(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(di(e,e.next)||X(e.prev,e,e.next)===0)){if(Ie(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function ke(i,t,e,s,r,n,a){if(i){!a&&n&&ih(i,s,r,n);for(var o=i,h,c;i.prev!==i.next;){if(h=i.prev,c=i.next,n?jo(i,s,r,n):Xo(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(c.i/e|0),Ie(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=qo(Kt(i),t,e),ke(i,t,e,s,r,n,2)):a===2&&Ko(i,t,e,s,r,n):ke(Kt(i),t,e,s,r,n,1);break}}}}function Xo(i){var t=i.prev,e=i,s=i.next;if(X(t,e,s)>=0)return!1;for(var r=t.x,n=e.x,a=s.x,o=t.y,h=e.y,c=s.y,l=rn?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,m=s.next;m!==t;){if(m.x>=l&&m.x<=u&&m.y>=d&&m.y<=f&&ie(r,o,n,h,a,c,m.x,m.y)&&X(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function jo(i,t,e,s){var r=i.prev,n=i,a=i.next;if(X(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,d=n.y,u=a.y,f=oh?o>c?o:c:h>c?h:c,g=l>d?l>u?l:u:d>u?d:u,_=Qi(f,m,t,e,s),w=Qi(y,g,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=_&&S&&S.z<=w;){if(b.x>=f&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&ie(o,l,h,d,c,u,b.x,b.y)&&X(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=f&&S.x<=y&&S.y>=m&&S.y<=g&&S!==r&&S!==a&&ie(o,l,h,d,c,u,S.x,S.y)&&X(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=_;){if(b.x>=f&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&ie(o,l,h,d,c,u,b.x,b.y)&&X(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=w;){if(S.x>=f&&S.x<=y&&S.y>=m&&S.y<=g&&S!==r&&S!==a&&ie(o,l,h,d,c,u,S.x,S.y)&&X(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function qo(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!di(r,n)&&An(r,s,s.next,n)&&Ge(r,n)&&Ge(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Ie(s),Ie(s.next),s=i=n),s=s.next}while(s!==i);return Kt(s)}function Ko(i,t,e,s,r,n){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&nh(a,o)){var h=Cn(a,o);a=Kt(a,a.next),h=Kt(h,h.next),ke(a,t,e,s,r,n,0),ke(h,t,e,s,r,n,0);return}o=o.next}a=a.next}while(a!==i)}function Zo(i,t,e,s){var r=[],n,a,o,h,c;for(n=0,a=t.length;n=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<=s&&o>n&&(n=o,a=e.x=e.x&&e.x>=c&&s!==e.x&&ie(ra.x||e.x===a.x&&eh(a,e)))&&(a=e,d=u)),e=e.next;while(e!==h);return a}function eh(i,t){return X(i.prev,i,t.prev)<0&&X(t.next,i,i.next)<0}function ih(i,t,e,s){var r=i;do r.z===0&&(r.z=Qi(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,sh(r)}function sh(i){var t,e,s,r,n,a,o,h,c=1;do{for(e=i,i=null,n=null,a=0;e;){for(a++,s=e,o=0,t=0;t0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(r=e,e=e.nextZ,o--):(r=s,s=s.nextZ,h--),n?n.nextZ=r:i=r,r.prevZ=n,n=r;e=s}n.nextZ=null,c*=2}while(a>1);return i}function Qi(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rh(i){var t=i,e=i;do(t.x=(i-a)*(n-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(s-o)}function nh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!ah(i,t)&&(Ge(i,t)&&Ge(t,i)&&oh(i,t)&&(X(i.prev,i,t.prev)||X(i,t.prev,t))||di(i,t)&&X(i.prev,i,i.next)>0&&X(t.prev,t,t.next)>0)}function X(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function di(i,t){return i.x===t.x&&i.y===t.y}function An(i,t,e,s){var r=Xe(X(i,t,e)),n=Xe(X(i,t,s)),a=Xe(X(e,s,i)),o=Xe(X(e,s,t));return!!(r!==n&&a!==o||r===0&&Ye(i,e,t)||n===0&&Ye(i,s,t)||a===0&&Ye(e,i,s)||o===0&&Ye(e,t,s))}function Ye(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Xe(i){return i>0?1:i<0?-1:0}function ah(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&An(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ge(i,t){return X(i.prev,i,i.next)<0?X(i,t,i.next)>=0&&X(i,i.prev,t)>=0:X(i,t,i.prev)<0||X(i,i.next,t)<0}function oh(i,t){var e=i,s=!1,r=(i.x+t.x)/2,n=(i.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&&(s=!s),e=e.next;while(e!==i);return s}function Cn(i,t){var e=new Ji(i.i,i.x,i.y),s=new Ji(t.i,t.x,t.y),r=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function er(i,t,e,s){var r=new Ji(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function Ie(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ji(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}ci.deviation=function(i,t,e,s){var r=t&&t.length,n=r?t[0]*e:i.length,a=Math.abs(ts(i,0,n,e));if(r)for(var o=0,h=t.length;o0&&(s+=i[r-1].length,e.holes.push(s))}return e};var hh=gs.exports;const lh=ds(hh);var Tn=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(Tn||{});class ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,r,n,a,o,h){const{name:c,items:l}=this;for(let d=0,u=l.length;d{this.runners[e]=new ch(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}_addPipes(t,e){const s=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=s[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(!Yo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Mn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let kn=Mn,je;function uh(i){return je!==void 0||(je=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??kn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!K.get().getWebGLRenderingContext())return!1;let r=K.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}})()),je}let qe;async function fh(i={}){return qe!==void 0||(qe=await(async()=>{const t=K.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),qe}const ir=["webgl","webgpu","canvas"];async function ph(i){let t=[];i.preference?(t.push(i.preference),ir.forEach(n=>{n!==i.preference&&t.push(n)})):t=ir.slice();let e,s={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-Co8-REvx.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&uh(i.failIfMajorPerformanceCaveat??kn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await ii(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-B1cEC-wN.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(s),r}const Gn="8.4.0";class In{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Gn)}static destroy(){}}In.extension=P.Application;class mh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Gn)}destroy(){this._renderer=null}}mh.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const Bn=class es{constructor(...t){this.stage=new at,t[0]!==void 0&&O(U,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await ph(t),es._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return O(U,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=es._plugins.slice(0);s.reverse(),s.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Bn._plugins=[];let En=Bn;ht.handleByList(P.Application,En._plugins);ht.add(In);class Fn extends ct{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.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return O(U,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return O(U,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return O(U,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return O(U,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return O(U,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Rn=class is{constructor(t,e,s,r){this.uid=st("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:J.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=is.defaultTextureSize,{gradientStops:e}=this,s=K.get().createCanvas();s.width=t,s.height=t;const r=s.getContext("2d"),n=r.createLinearGradient(0,0,is.defaultTextureSize,1);for(let y=0;y`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Rn.defaultTextureSize=256;let Be=Rn;const sr={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 ui{constructor(t,e){this.uid=st("fillPattern"),this.transform=new W,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=sr[e].addressModeU,t.source.style.addressModeV=sr[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),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var gh=yh,Bi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},xh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function yh(i){var t=[];return i.replace(xh,function(e,s,r){var n=s.toLowerCase();for(r=wh(r),n=="m"&&r.length>2&&(t.push([s].concat(r.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(r.length==Bi[n])return r.unshift(s),t.push(r);if(r.length0&&(r=s.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:tt(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},s.push(r))}return t}class xs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new xs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(r*r+n*n);return ha-o}getBounds(t){return t=t||new z,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 ys{constructor(t=0,e=0,s=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=r}clone(){return new ys(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return s*=s,r*=r,s+r<=1}strokeContains(t,e,s){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=s/2,o=r-a,h=n-a,c=r+a,l=n+a,d=t-this.x,u=e-this.y,f=d*d/(o*o)+u*u/(h*h),m=d*d/(c*c)+u*u/(l*l);return f>1&&m<=1}getBounds(t){return t=t||new z,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}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 vh(i,t,e,s,r,n){const a=i-e,o=t-s,h=r-e,c=n-s,l=a*h+o*c,d=h*h+c*c;let u=-1;d!==0&&(u=l/d);let f,m;u<0?(f=e,m=s):u>1?(f=r,m=n):(f=e+u*h,m=s+u*c);const y=i-f,g=t-m;return y*y+g*g}class Me{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let r=0,n=e.length;re!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const r=s/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hr?c:r,n=la?l:a}return t.x=s,t.width=r-s,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 Ke=(i,t,e,s,r,n)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class _s{constructor(t=0,e=0,s=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n}getBounds(t){return t=t||new z,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new _s(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 s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let r=t-(this.x+s),n=e-(this.y+s);const a=s*s;if(r*r+n*n<=a||(r=t-(this.x+this.width-s),r*r+n*n<=a)||(n=e-(this.y+this.height-s),r*r+n*n<=a)||(r=t-(this.x+s),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,s){const{x:r,y:n,width:a,height:o,radius:h}=this,c=s/2,l=r+h,d=n+h,u=a-h*2,f=o-h*2,m=r+a,y=n+o;return(t>=r-c&&t<=r+c||t>=m-c&&t<=m+c)&&e>=d&&e<=d+f||(e>=n-c&&e<=n+c||e>=y-c&&e<=y+c)&&t>=l&&t<=l+u?!0:tm-h&&em-h&&e>y-h&&Ke(t,e,m-h,y-h,h,c)||ty-h&&Ke(t,e,l,y-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Ah=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Ch(i){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return Dn[e]||Ph(i,t,e)}let Ei=0;function Ph(i,t,e){const s={};let r=0;Ei||(Ei=Ln());for(let a=0;a0){const a=new Uint8Array(i,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const kh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Gh=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))(Gh||{});function ar(i,t){return t.alphaMode==="no-premultiply-alpha"&&kh[i]||i}class Ih{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?zn[--ss]:new Bh}function hr(i){zn[ss++]=i}let we=0;const On=class ei{constructor(t={}){this.uid=st("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],ei.defaultOptions.maxTextures=ei.defaultOptions.maxTextures??Ln(),t={...ei.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:r}=t;this.attributeBuffer=new rr(s*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,c=this.indexBuffer;let l=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const f=this.maxTextures;for(let m=this.elementStart;m=f||b)&&(this._finishBatch(s,d,l-d,r,a,t,u),u="renderBatch",d=l,a=w,s=or(),r=s.textures,r.clear(),++we),y._textureId=_._textureBindLocation=r.count,r.ids[_.uid]=r.count,r.textures[r.count++]=_,y._batch=s,l+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(s,d,l-d,r,a,t,u),d=l,++we),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=l}_finishBatch(t,e,s,r,n,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=s,++we,this.batches[this.batchIndex++]=t,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),s=new rr(e);nr(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const r=s>65535?new Uint32Array(s):new Uint16Array(s);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(Q||{});class Ft extends ct{constructor(t){let{data:e,size:s}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=st("buffer"),this._resourceType="buffer",this._resourceId=st("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,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&Q.STATIC)}set static(t){t?this.descriptor.usage|=Q.STATIC:this.descriptor.usage&=~Q.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=f),m>h&&(h=m),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Lh=new Float32Array(1),Dh=new Uint32Array(1);class zh extends Wn{constructor(){const e=new Ft({data:Lh,label:"attribute-batch-buffer",usage:Q.VERTEX|Q.COPY_DST,shrinkToFit:!1}),s=new Ft({data:Dh,label:"index-batch-buffer",usage:Q.INDEX|Q.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:s})}}function lr(i,t,e){if(i)for(const s in i){const r=s.toLocaleLowerCase(),n=t[r];if(n){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else tt(`${s} placement hook does not exist in shader`)}}const Oh=/\{\{(.*?)\}\}/g;function cr(i){var s;const t={};return(((s=i.match(Oh))==null?void 0:s.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function dr(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function ur(i,t,e=!1){const s=[];dr(t,s),i.forEach(o=>{o.header&&dr(o.header,s)});const r=s;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 fr(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Uh(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function Wh(i){const t=/@.*?\s+/g;return i.replace(t,"")}function Nh(i,t){const e=[];fr(t,e),i.forEach(h=>{h.header&&fr(h.header,e)});let s=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`, `),n=e.sort().map(h=>` var ${Wh(h)};`).join(` `),a=`return VSOutput( ${e.sort().map(h=>` ${Uh(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 pr(i,t){let e=i;for(const s in t){const r=t[s];r.join(` `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${r.join(` `)} //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Et=Object.create(null),Fi=new Map;let Hh=0;function $h({template:i,bits:t}){const e=Nn(i,t);if(Et[e])return Et[e];const{vertex:s,fragment:r}=Yh(i,t);return Et[e]=Hn(s,r,t),Et[e]}function Vh({template:i,bits:t}){const e=Nn(i,t);return Et[e]||(Et[e]=Hn(i.vertex,i.fragment,t)),Et[e]}function Yh(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let r=ur(e,i.vertex,!0);r=Nh(e,r);const n=ur(s,i.fragment,!0);return{vertex:r,fragment:n}}function Nn(i,t){return t.map(e=>(Fi.has(e)||Fi.set(e,Hh++),Fi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Hn(i,t,e){const s=cr(i),r=cr(t);return e.forEach(n=>{lr(n.vertex,s,n.name),lr(n.fragment,r,n.name)}),{vertex:pr(i,s),fragment:pr(t,r)}}const Xh=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 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(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,jh=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} var finalColor:vec4 = outColor * vColor; {{end}} return finalColor; }; `,qh=` 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}} } `,Kh=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,Zh={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},Qh={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function Jh({bits:i,name:t}){const e=$h({template:{fragment:jh,vertex:Xh},bits:[Zh,...i]});return li.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function tl({bits:i,name:t}){return new yn({name:t,...Vh({template:{vertex:qh,fragment:Kh},bits:[Qh,...i]})})}const el={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},il={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Ri={};function sl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` `)}function rl(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${sl(i)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${rl(i)} `}}),Ri[i]}const Li={};function al(i){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},ll={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; } `}},mr={};function cl(i){let t=mr[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s>16&255,s=i>>8&255,r=i&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=s*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const gl=new W;class Xn{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?ml(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||gl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Ee={extension:{type:P.ShapeBuilder,name:"circle"},build(i,t){let e,s,r,n,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,r=n=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,r=n=0}else{const S=i,C=S.width/2,E=S.height/2;e=S.x+C,s=S.y+E,a=o=Math.max(0,Math.min(S.radius,Math.min(C,E))),r=C-a,n=E-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]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n,t;let l=0,d=h*4+(r?2:0)+2,u=d,f=c,m=r+a,y=n,g=e+m,_=e-m,w=s+y;if(t[l++]=g,t[l++]=w,t[--d]=w,t[--d]=_,n){const S=s-y;t[u++]=_,t[u++]=S,t[--f]=S,t[--f]=g}for(let S=1;S0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},xl={...Ee,extension:{...Ee.extension,name:"ellipse"}},yl={...Ee,extension:{...Ee.extension,name:"roundedRectangle"}},_l=1e-4,xr=1e-4;function wl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,r=i[t-2],n=i[t-1];sd&&(d+=Math.PI*2);let u=l;const f=d-l,m=Math.abs(f),y=Math.sqrt(h*h+c*c),g=(15*m*Math.sqrt(y)/Math.PI>>0)+1,_=f/g;if(u+=_,o){a.push(i,t),a.push(e,s);for(let w=1,b=u;w=0&&(l.join==="round"?w+=Ht(v,A,v-F*G,A-B*G,v-$*G,A-Z*G,g,!1)+4:w+=2,g.push(v-$*R,A-Z*R),g.push(v+$*G,A+Z*G));continue}const Is=(-F+M)*(-B+A)-(-F+v)*(-B+k),Bs=(-$+j)*(-Z+A)-(-$+v)*(-Z+At),Oe=(Bt*Bs-me*Is)/ze,Ue=(ge*Is-pe*Bs)/ze,pi=(Oe-v)*(Oe-v)+(Ue-A)*(Ue-A),Ot=v+(Oe-v)*G,Ut=A+(Ue-A)*G,Wt=v-(Oe-v)*R,Nt=A-(Ue-A)*R,va=Math.min(Bt*Bt+pe*pe,me*me+ge*ge),Es=xe?G:R,Aa=va+Es*Es*C;pi<=Aa?l.join==="bevel"||pi/C>E?(xe?(g.push(Ot,Ut),g.push(v+F*R,A+B*R),g.push(Ot,Ut),g.push(v+$*R,A+Z*R)):(g.push(v-F*G,A-B*G),g.push(Wt,Nt),g.push(v-$*G,A-Z*G),g.push(Wt,Nt)),w+=2):l.join==="round"?xe?(g.push(Ot,Ut),g.push(v+F*R,A+B*R),w+=Ht(v,A,v+F*R,A+B*R,v+$*R,A+Z*R,g,!0)+4,g.push(Ot,Ut),g.push(v+$*R,A+Z*R)):(g.push(v-F*G,A-B*G),g.push(Wt,Nt),w+=Ht(v,A,v-F*G,A-B*G,v-$*G,A-Z*G,g,!1)+4,g.push(v-$*G,A-Z*G),g.push(Wt,Nt)):(g.push(Ot,Ut),g.push(Wt,Nt)):(g.push(v-F*G,A-B*G),g.push(v+F*R,A+B*R),l.join==="round"?xe?w+=Ht(v,A,v+F*R,A+B*R,v+$*R,A+Z*R,g,!0)+2:w+=Ht(v,A,v-F*G,A-B*G,v-$*G,A-Z*G,g,!1)+2:l.join==="miter"&&pi/C<=E&&(xe?(g.push(Wt,Nt),g.push(Wt,Nt)):(g.push(Ot,Ut),g.push(Ot,Ut)),w+=2),g.push(v-$*G,A-Z*G),g.push(v+$*R,A+Z*R),w+=2)}M=i[(_-2)*2],k=i[(_-2)*2+1],v=i[(_-1)*2],A=i[(_-1)*2+1],F=-(k-A),B=M-v,mt=Math.sqrt(F*F+B*B),F/=mt,B/=mt,F*=S,B*=S,g.push(v-F*G,A-B*G),g.push(v+F*R,A+B*R),m||(l.cap==="round"?w+=Ht(v-F*(G-R)*.5,A-B*(G-R)*.5,v-F*G,A-B*G,v+F*R,A+B*R,g,!1)+2:l.cap==="square"&&(w+=yr(v,A,F,B,G,R,!1,g)));const Sa=xr*xr;for(let N=b;N=0&&a>=0&&(t[0]=s,t[1]=r,t[2]=s+n,t[3]=r,t[4]=s+n,t[5]=r+a,t[6]=s,t[7]=r+a),t},triangulate(i,t,e,s,r,n){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},Cl={extension:{type:P.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,r,n){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},fi={};ht.handleByMap(P.ShapeBuilder,fi);ht.add(Al,vl,Cl,Ee,xl,yl);const Tl=new z;function Ml(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r{const f=h.length,m=a.length/2,y=[],g=fi[l.type];if(g.build(l,y),d&&Yn(y,d),s){const S=l.closePath??!0;bl(y,t,!1,S,a,2,m,h)}else if(e&&c===u){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],C=y.slice();kl(e.shapePath).forEach(M=>{S.push(C.length/2),C.push(...M)}),jn(C,S,a,2,m,h,f)}else g.triangulate(y,a,2,m,h,f);const _=o.length/2,w=t.texture;if(w!==L.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),fl(a,2,m,o,_,2,a.length/2-m,S))}else pl(o,_,2,a.length/2-m);const b=Mt.get(Xn);b.indexOffset=f,b.indexSize=h.length-f,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=w,b.geometryData=n,r.push(b)})}function kl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s{Mt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};ws.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};ws.defaultOptions={bezierSmoothness:.5};let qn=ws;const Bl=8,Ze=11920929e-14,El=1;function Kn(i,t,e,s,r,n,a,o,h,c){const d=Math.min(.99,Math.max(0,c??qn.defaultOptions.bezierSmoothness));let u=(El-d)/1;return u*=u,Fl(t,e,s,r,n,a,o,h,i,u),i}function Fl(i,t,e,s,r,n,a,o,h,c){ns(i,t,e,s,r,n,a,o,h,c,0),h.push(a,o)}function ns(i,t,e,s,r,n,a,o,h,c,l){if(l>Bl)return;const d=(i+e)/2,u=(t+s)/2,f=(e+r)/2,m=(s+n)/2,y=(r+a)/2,g=(n+o)/2,_=(d+f)/2,w=(u+m)/2,b=(f+y)/2,S=(m+g)/2,C=(_+b)/2,E=(w+S)/2;if(l>0){let M=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(v>Ze&&A>Ze){if((v+A)*(v+A)<=c*(M*M+k*k)){h.push(C,E);return}}else if(v>Ze){if(v*v<=c*(M*M+k*k)){h.push(C,E);return}}else if(A>Ze){if(A*A<=c*(M*M+k*k)){h.push(C,E);return}}else if(M=C-(i+a)/2,k=E-(t+o)/2,M*M+k*k<=c){h.push(C,E);return}}ns(i,t,d,u,_,w,C,E,h,c,l+1),ns(C,E,b,S,y,g,a,o,h,c,l+1)}const Rl=8,Ll=11920929e-14,Dl=1;function zl(i,t,e,s,r,n,a,o){const c=Math.min(.99,Math.max(0,o??qn.defaultOptions.bezierSmoothness));let l=(Dl-c)/1;return l*=l,Ol(t,e,s,r,n,a,i,l),i}function Ol(i,t,e,s,r,n,a,o){as(a,i,t,e,s,r,n,o,0),a.push(r,n)}function as(i,t,e,s,r,n,a,o,h){if(h>Rl)return;const c=(t+s)/2,l=(e+r)/2,d=(s+n)/2,u=(r+a)/2,f=(c+d)/2,m=(l+u)/2;let y=n-t,g=a-e;const _=Math.abs((s-n)*g-(r-a)*y);if(_>Ll){if(_*_<=o*(y*y+g*g)){i.push(f,m);return}}else if(y=f-(t+n)/2,g=m-(e+a)/2,y*y+g*g<=o){i.push(f,m);return}as(i,t,e,c,l,f,m,o,h+1),as(i,f,m,d,u,n,a,o,h+1)}function Zn(i,t,e,s,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(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let d=0;dd*h)}const Pe=Math.PI*2,Di={centerX:0,centerY:0,ang1:0,ang2:0},zi=({x:i,y:t},e,s,r,n,a,o,h)=>{i*=e,t*=s;const c=r*i-n*t,l=n*i+r*t;return h.x=c+a,h.y=l+o,h};function Wl(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,r=Math.cos(i),n=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*s,y:n+r*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const wr=(i,t,e,s)=>{const r=i*s-t*e<0?-1:1;let n=i*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Nl=(i,t,e,s,r,n,a,o,h,c,l,d,u)=>{const f=Math.pow(r,2),m=Math.pow(n,2),y=Math.pow(l,2),g=Math.pow(d,2);let _=f*m-f*g-m*y;_<0&&(_=0),_/=f*g+m*y,_=Math.sqrt(_)*(a===o?-1:1);const w=_*r/n*d,b=_*-n/r*l,S=c*w-h*b+(i+e)/2,C=h*w+c*b+(t+s)/2,E=(l-w)/r,M=(d-b)/n,k=(-l-w)/r,v=(-d-b)/n,A=wr(1,0,E,M);let j=wr(E,M,k,v);o===0&&j>0&&(j-=Pe),o===1&&j<0&&(j+=Pe),u.centerX=S,u.centerY=C,u.ang1=A,u.ang2=j};function Hl(i,t,e,s,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*Pe/360),d=Math.cos(o*Pe/360),u=d*(t-s)/2+l*(e-r)/2,f=-l*(t-s)/2+d*(e-r)/2;if(u===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const m=Math.pow(u,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);m>1&&(n*=Math.sqrt(m),a*=Math.sqrt(m)),Nl(t,e,s,r,n,a,h,c,l,d,u,f,Di);let{ang1:y,ang2:g}=Di;const{centerX:_,centerY:w}=Di;let b=Math.abs(g)/(Pe/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);g/=S;let C=i[i.length-2],E=i[i.length-1];const M={x:0,y:0};for(let k=0;k{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),d=h/l,u=c/l;return{len:l,nx:d,ny:u}},r=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a0&&(f=-1,m=!0);const y=u/2;let g,_=Math.abs(Math.cos(y)*h/Math.sin(y));_>Math.min(l.len/2,d.len/2)?(_=Math.min(l.len/2,d.len/2),g=Math.abs(_*Math.sin(y)/Math.cos(y))):g=h;const w=o.x+d.nx*_+-d.ny*g*f,b=o.y+d.ny*_+d.nx*g*f,S=Math.atan2(l.ny,l.nx)+Math.PI/2*f,C=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&i.moveTo(w+Math.cos(S)*g,b+Math.sin(S)*g),i.arc(w,b,g,S,C,m),n=o}}function Vl(i,t,e,s){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=2;d-=2)l[d]===l[d-2]&&l[d-1]===l[d-3]&&l.splice(d-1,2);return this.poly(l,!0,a)}ellipse(t,e,s,r,n){return this.drawShape(new ys(t,e,s,r),n),this}roundRect(t,e,s,r,n,a){return this.drawShape(new _s(t,e,s,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new Me,s.points.push(t,e),this._currentPoly=s,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 Me,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=s;s=n.a*s+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(s,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eparseInt(k,10)),t.context.poly(w,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),w=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(w,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=jt({...this._originalFill},ft.defaultFillStyle)})),this._fill=jt(t===0?"black":t,ft.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ft.defaultStrokeStyle,...t},()=>{this._stroke=ai({...this._originalStroke},ft.defaultStrokeStyle)})),this._stroke=ai(t,ft.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=tc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=ee.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new ee({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,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 s,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;(s=this._fill)!=null&&s.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}_createProxy(t,e){return new Proxy(t,{set:(s,r,n)=>(s[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(J.isColorLike(t)||t instanceof Be||t instanceof ui)}};Ss.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ss.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 et=Ss;function sc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=et.defaultDropShadow;i.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){O(U,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(J.isColorLike(e))s.color=e;else if(e instanceof Be||e instanceof ui)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){O(U,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=et.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Be(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>J.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);s.addColorStop(o,n)}),i.fill={fill:s}}}class rc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=K.get().createCanvas();s.width=t,s.height=e;const r=s.getContext("2d");return{canvas:s,context:r}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Ls(t),e=Ls(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 e=t.canvas,{width:s,height:r}=e,n=(s<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Mr=new rc,nc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function os(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let r=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!nc.includes(r)&&(r=`"${r}"`),e[s]=r}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const Oi={willReadFrequently:!0},yt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t!==void 0){const e=K.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,r,n,a,o,h,c){this.text=t,this.style=e,this.width=s,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,s=T._canvas,r=e.wordWrap){var w;const n=`${t}:${e.styleKey}`;if(T._measurementCache[n])return T._measurementCache[n];const a=os(e),o=T.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=T.__context;h.font=a;const l=(r?T._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(l.length);let u=0;for(let b=0;b0&&(r?n-=e:n+=(T.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=T._canvas){const r=s.getContext("2d",Oi);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,d=T._collapseSpaces(l),u=T._collapseNewlines(l);let f=!d;const m=e.wordWrapWidth+c,y=T._tokenize(t);for(let g=0;gm)if(a!==""&&(o+=T._addLine(a),a="",n=0),T.canBreakWords(_,e.breakWords)){const b=T.wordWrapSplit(_);for(let S=0;Sm&&(o+=T._addLine(a),f=!1,a="",n=0),a+=C,n+=k}}else{a.length>0&&(o+=T._addLine(a),a="",n=0);const b=g===y.length-1;o+=T._addLine(_,!b),f=!1,a="",n=0}else w+n>m&&(f=!1,o+=T._addLine(a),a="",n=0),(a.length>0||!T.isBreakingSpace(_)||f)&&(a+=_,n+=w)}return o+=T._addLine(a,!1),o}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,r){let n=s[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,s[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 s=t[e];if(!T.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;r{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();yt.experimentalLetterSpacing=!1;yt._fonts={};yt._newlines=[10,13];yt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];yt._measurementCache={};let hs=yt;function Pr(i,t){if(i.texture===L.WHITE&&!i.fill)return J.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof ui){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(W.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(r),s}else if(i.fill instanceof Be){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{s.addColorStop(r.offset,J.shared.setValue(r.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(W.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return tt("FillStyle not recognised",i),"red"}function ta(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e!this._currentChars.includes(_)).filter((_,w,b)=>b.indexOf(_)===w);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:r,context:n}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*l,u=o.fontStyle==="italic"?2:1;let f=0,m=!1;for(let _=0;_this._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const v=this._nextPage();r=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,c=0}const k=S/l-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[w]={id:w.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(n,b,h+d,c+d,l,o);const v=a.width*l,A=a.height*l,j=new z(h/v*a.width,c/A*a.height,E/v*a.width,M/A*a.height);this.chars[w].texture=new L({source:a,frame:j}),h+=Math.ceil(E)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return O(U,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let r=0;r{const y=n.width;for(let g=0;g{let m=n.chars.length-1;if(s){let y=n.chars[m];for(;y===" ";)n.width-=e.chars[y].xAdvance,y=n.chars[--m]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(n),r.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*d,f=t.wordWrapWidth*d;for(let m=0;mf?(l(),c(h),g||n.charPositions.push(0)):(h.start=n.width,c(h),g||n.charPositions.push(0)),y==="\r"||y===` `)n.width!==0&&l();else if(!g){const C=_.xAdvance+(_.kerning[a]||0)+u;n.width+=C,n.spaceWidth=C,n.spacesIndex.push(n.charPositions.length),n.chars.push(y)}}else{const S=_.kerning[a]||0,C=_.xAdvance+S+u;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=C}a=y}return l(),t.align==="center"?oc(r):t.align==="right"?hc(r):t.align==="justify"&&lc(r),r}function oc(i){for(let t=0;t50&&tt("BitmapText",`You have dynamically created ${Qe} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Qe--,Y.remove(s)}),Y.set(s,o)}const n=Y.get(s);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,s=!0){const r=this.getFont(t,e);return ac([...t],e,r,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var c,l,d,u;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:(d=t[2])==null?void 0:d.padding,skipKerning:(u=t[2])==null?void 0:u.skipKerning},O(U,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof et?r:new et(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new kr({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ta(e.chars);return o.ensureCharacters(h.join("")),Y.set(`${s}-bitmap`,o),o.once("destroy",()=>Y.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=Y.get(e);s&&(Y.remove(e),s.destroy())}}const Gr=new cc;class sa extends Fn{constructor(t,e){super();const{textures:s,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=s[a.page],c=new z(a.x+o.x,a.y+o.y,a.width,a.height),l=new L({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")?Ir.test(K.get().parseXML(i)):!1},parse(i){return Ir.parse(K.get().parseXML(i))}},dc=[".xml",".fnt"],uc={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof sa,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},fc={extension:{type:P.LoadParser,priority:Lt.Normal},name:"loadBitmapFont",test(i){return dc.includes(ut.extname(i).toLowerCase())},async testParse(i){return Ui.test(i)||Br.test(i)},async parse(i,t,e){const s=Ui.test(i)?Ui.parse(i):Br.parse(i),{src:r}=t,{pages:n}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;dh[d.src]);return new sa({data:s,textures:c},r)},async load(i,t){return await(await K.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class pc{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 s=0;sArray.isArray(i)&&i.every(t=>t instanceof L),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((r,n)=>{e[s+(n===0?"":n+1)]=r})}),e}};async function ra(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const gc={extension:{type:P.DetectionParser,priority:1},test:async()=>ra("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},Er=["png","jpg","jpeg"],xc={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Er],remove:async i=>i.filter(t=>!Er.includes(t))},yc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function vs(i){return yc?!1:document.createElement("video").canPlayType(i)!==""}const _c={extension:{type:P.DetectionParser,priority:0},test:async()=>vs("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},wc={extension:{type:P.DetectionParser,priority:0},test:async()=>vs("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},bc={extension:{type:P.DetectionParser,priority:0},test:async()=>vs("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Sc={extension:{type:P.DetectionParser,priority:0},test:async()=>ra("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class vc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||tt(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=ut.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(++s/o)}catch(d){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}. ${d}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const s=xt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=ut.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(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&tt(`[Assets] loadParser name conflict "${e.name}"`):tt("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function ue(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function fe(i,t){const e=i.split("?")[0],s=ut.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Ac=".json",Cc="application/json",Tc={extension:{type:P.LoadParser,priority:Lt.Low},name:"loadJson",test(i){return ue(i,Cc)||fe(i,Ac)},async load(i){return await(await K.get().fetch(i)).json()}},Mc=".txt",Pc="text/plain",kc={name:"loadTxt",extension:{type:P.LoadParser,priority:Lt.Low,name:"loadTxt"},test(i){return ue(i,Pc)||fe(i,Mc)},async load(i){return await(await K.get().fetch(i)).text()}},Gc=["normal","bold","100","200","300","400","500","600","700","800","900"],Ic=[".ttf",".otf",".woff",".woff2"],Bc=["font/ttf","font/otf","font/woff","font/woff2"],Ec=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Fc(i){const t=ut.extname(i),r=ut.basename(i,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(Ec)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Rc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Lc(i){return Rc.test(i)?i:encodeURI(i)}const Dc={extension:{type:P.LoadParser,priority:Lt.Low},name:"loadWebFont",test(i){return ue(i,Bc)||fe(i,Ic)},async load(i,t){var s,r,n;const e=K.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??Fc(i),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>Gc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l{Y.remove(t.family),K.get().getFontFaceSet().delete(t)})}};function As(i,t=1){var s;const e=(s=de.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Cs(i,t,e){i.label=e,i._sourceOrigin=e;const s=new L({source:i,label:e}),r=()=>{delete t.promiseCache[e],Y.has(e)&&Y.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(tt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),s.once("destroy",()=>{i.destroyed||(tt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),s}const zc=".svg",Oc="image/svg+xml",Uc={extension:{type:P.LoadParser,priority:Lt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return ue(i,Oc)||fe(i,zc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Nc(i):Wc(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function Wc(i,t,e,s){var g,_,w;const n=await(await K.get().fetch(i)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||As(i),d=((_=t.data)==null?void 0:_.width)??o.width,u=((w=t.data)==null?void 0:w.height)??o.height;h.width=d*l,h.height=u*l,c.drawImage(o,0,0,d*l,u*l);const{parseAsGraphicsContext:f,...m}=t.data,y=new ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...m});return Cs(y,e,i)}async function Nc(i){const e=await(await K.get().fetch(i)).text(),s=new ft;return s.svg(e),s}const Hc=`(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 re=null,ls=class{constructor(){re||(re=URL.createObjectURL(new Blob([Hc],{type:"application/javascript"}))),this.worker=new Worker(re)}};ls.revokeObjectURL=function(){re&&(URL.revokeObjectURL(re),re=null)};const $c=`(function () { 'use strict'; async function loadImageBitmap(url, alphaMode) { 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(); return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob); } self.onmessage = async (event) => { try { const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]); 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 ne=null;class na{constructor(){ne||(ne=URL.createObjectURL(new Blob([$c],{type:"application/javascript"}))),this.worker=new Worker(ne)}}na.revokeObjectURL=function(){ne&&(URL.revokeObjectURL(ne),ne=null)};let Fr=0,Wi;class Vc{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 ls;e.addEventListener("message",s=>{e.terminate(),ls.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Wi===void 0&&(Wi=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{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 s=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[Fr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Fr++,id:s})}}const Rr=new Vc,Yc=[".jpeg",".jpg",".png",".webp",".avif"],Xc=["image/jpeg","image/png","image/webp","image/avif"];async function jc(i,t){var r;const e=await K.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const aa={name:"loadTextures",extension:{type:P.LoadParser,priority:Lt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return ue(i,Xc)||fe(i,Yc)},async load(i,t,e){var n;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Rr.isImageBitmapSupported()?s=await Rr.loadImageBitmap(i,t):s=await jc(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const r=new ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||As(i),...t.data});return Cs(r,e,i)},unload(i){i.destroy(!0)}},oa=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],qc=oa.map(i=>`video/${i.substring(1)}`);function Kc(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=Qc(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function Zc(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",r),i.load();function s(){n(),t()}function r(a){n(),e(a)}function n(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",r)}})}function Qc(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Jc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(i){const t=ue(i,qc),e=fe(i,oa);return t||e},async load(i,t,e){var h,c;const s={...Je.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||As(i),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await cn(),...t.data},r=document.createElement("video"),n={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const d=n[l];d!==void 0&&r.setAttribute(l,d)}),s.muted===!0&&(r.muted=!0),Kc(r,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const l=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=Je.MIME_TYPES[l]||`video/${l}`}return a.src=i,o&&(a.type=o),new Promise(l=>{const d=async()=>{const u=new Je({...s,resource:r});r.removeEventListener("canplay",d),t.data.preload&&await Zc(r),l(Cs(u,e,i))};r.addEventListener("canplay",d),r.appendChild(a)})},unload(i){i.destroy(!0)}},ha={extension:{type:P.ResolveParser,name:"resolveTexture"},test:aa.test,parse:i=>{var t;return{resolution:parseFloat(((t=de.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},td={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:i=>de.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:ha.parse};class ed{constructor(){this._detections=[],this._initialized=!1,this.resolver=new de,this.loader=new vc,this.cache=Y,this._backgroundLoader=new pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){tt("[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,s=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:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=ni(t),r=xt(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 s?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!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(d=>{const u=r[d];return h+=Object.keys(u).length,this._mapLoadToResolve(u,c).then(f=>{n[d]=f})});return await Promise.all(l),s?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(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Y.get(t);const e={};for(let s=0;s{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),Y.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=xt(t).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=xt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{Y.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,r)=>e.indexOf(s)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Ce=new ed;ht.handleByList(P.LoadParser,Ce.loader.parsers).handleByList(P.ResolveParser,Ce.resolver.parsers).handleByList(P.CacheParser,Ce.cache.parsers).handleByList(P.DetectionParser,Ce.detections);ht.add(mc,xc,gc,Sc,_c,wc,bc,Tc,kc,Dc,Uc,aa,Jc,fc,uc,ha,td);const Lr={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};ht.handle(P.Asset,i=>{const t=i.ref;Object.entries(Lr).filter(([e])=>!!t[e]).forEach(([e,s])=>ht.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(Lr).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class kt extends oi{constructor(t){t instanceof ft&&(t={context:t});const{context:e,roundPixels:s,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ft,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!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)}onViewUpdate(){if(this._didViewChangeTick++,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 kt(this._context.clone()):(this._ownedContext=null,new kt(this._context))}lineStyle(t,e,s){O(U,"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),s&&(r.alpha=s),this.context.strokeStyle=r,this}beginFill(t,e){O(U,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){O(U,"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!==ft.defaultStrokeStyle.width||t.color!==ft.defaultStrokeStyle.color||t.alpha!==ft.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return O(U,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return O(U,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return O(U,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return O(U,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return O(U,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return O(U,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const la=class ca extends Wn{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(O(U,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...ca.defaultOptions,...e};const s=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 Ft({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:Q.VERTEX|Q.COPY_DST}),h=new Ft({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Q.VERTEX|Q.COPY_DST}),c=new Ft({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:Q.INDEX|Q.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}};la.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let id=la;class Fe extends H{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:r,...n}=e,[a]=s;super({...n,texture:a instanceof L?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=r??!0,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=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(bt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(bt.shared.add(this.update,this,ri.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,s=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=s/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+=s;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.currentFramer)&&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 s=0;sthis.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?(bt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(bt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class sd extends oi{constructor(t,e){const{text:s,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new lt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}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){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,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.width,s=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){if(this._didViewChangeTick++,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}:${this._resolution}`}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 rd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(O(U,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class q extends sd{constructor(...t){const e=rd(t,"Text");super(e,et),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=hs.measureText(this._text,this._style),{width:r,height:n}=s;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const da=class ua extends id{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(O(U,"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={...ua.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,s=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let d=0;de?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(s,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,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};fa.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let te=fa;const ma=class ga extends oi{constructor(t){var d,u,f,m;t instanceof L&&(t={texture:t});const{width:e,height:s,leftWidth:r,rightWidth:n,topHeight:a,bottomHeight:o,texture:h,roundPixels:c,...l}=t;super({label:"NineSliceSprite",...l}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=r??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??te.defaultOptions.leftWidth,this._topHeight=a??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.top)??te.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??te.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??te.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??te.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??te.defaultOptions.height,this.allowChildren=!1,this.texture=h??ga.defaultOptions.texture,this.roundPixels=c??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=L.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 originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};ma.defaultOptions={texture:L.EMPTY};let Dt=ma;ht.add(ka,Ga);const D=class D{static async Load(t){return this.text.text="Loading asset: "+t,await Ce.load({src:t})}static async LoadAssets(){if(this.text){console.warn("Do not call GameAssets.LoadAssets() more than once.");return}console.log("Loading Texture Assets");const t=new q({text:"Loading textures. This might take a while.",style:new et({fill:3355443,fontSize:50})});t.x=p.app.canvas.width/2,t.y=p.app.canvas.height/2,t.anchor.set(.5,.5),p.app.stage.addChild(t),this.text=new q({text:"",style:new et({fill:3355443,fontSize:50})}),this.text.x=p.app.canvas.width/2,this.text.y=p.app.canvas.height/2+50,this.text.anchor.set(.5,.5),p.app.stage.addChild(this.text),await Promise.all([this.Load("./aclonica.woff2"),this.Load("./assets/gui/button_01.png").then(e=>this.Button01Texture=e),this.Load("./assets/gui/button_02.png").then(e=>this.Button02Texture=e),this.Load("./assets/gui/button_small.png").then(e=>this.ButtonSmallTexture=e),this.Load("./assets/gui/frame_01.png").then(e=>this.Frame01Texture=e),this.Load("./assets/gui/frame_02.png").then(e=>this.Frame02Texture=e),this.Load("./assets/gui/frame_03.png").then(e=>this.Frame03Texture=e),this.Load("./assets/gui/frame_04.png").then(e=>this.Frame04Texture=e),this.Load("./assets/gui/frame_05.png").then(e=>this.Frame05Texture=e),this.Load("./assets/gui/frame_inv.png").then(e=>this.FrameInventory=e),this.Load("./assets/gui/background_01.png").then(e=>this.FrameBackground=e),this.Load("./assets/gui/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_violet.png").then(e=>this.VioletBackground=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/exclamation.png").then(e=>this.ExclamationIconTexture=e),this.Load("./assets/gui/icons/home.png").then(e=>this.HomeIconTexture=e),this.Load("./assets/gui/icons/hammer.png").then(e=>this.HammerIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s{e.destroy()}),this.currentScene=t,this.currentScene.init()}}class It{constructor(t){x(this,"name",this.constructor.name);x(this,"_container",new at);x(this,"_events",new ct);x(this,"enabled",!0);x(this,"bb",new z);p.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var Zt=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(Zt||{});class le extends It{constructor(e,s,r,n=!0){super(!0);x(this,"caption");x(this,"bounds");x(this,"buttonTexture");x(this,"buttonSprite");x(this,"buttonText");x(this,"buttonIcon");r==0&&(this.buttonTexture=I.Button01Texture),r==1&&(this.buttonTexture=I.Button02Texture),this.caption=s,this.enabled=n,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new Dt({texture:this.buttonTexture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.buttonSprite.x=0,this.buttonSprite.y=0,this.buttonSprite.width=this.bounds.width,this.buttonSprite.height=this.bounds.height,this.container.addChild(this.buttonSprite),this.buttonText=new q({text:this.caption,style:new et({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class zt{constructor(){x(this,"name",this.constructor.name);x(this,"_container",new at);x(this,"bb",new z);x(this,"_events",new ct)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var Tt=(i=>(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Tt||{}),qt=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(qt||{}),St=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.Escaped="escaped",i.Moved="moved",i))(St||{}),Re=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Re||{}),Le=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(Le||{}),Ts=(i=>(i.GemGivenEvent="gemGivenEvent",i))(Ts||{}),Ms=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))(Ms||{});class od extends zt{constructor(e,s,r,n){super();x(this,"type");x(this,"row");x(this,"column");x(this,"isPath",!1);x(this,"g");x(this,"hasTowerPlaced",!1);x(this,"clickDetector");this.type=e,this.row=s,this.column=r,this.isPath=n,this.bb.x=this.column*p.GridCellSize,this.bb.y=this.row*p.GridCellSize,this.bb.width=p.GridCellSize,this.bb.height=p.GridCellSize,p.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new kt({zIndex:99,interactive:!0}),this.g=new kt({zIndex:5}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.container.addChild(this.g),this.clickDetector.on("pointerup",a=>{p.Grid.gridInteractionEnabled&&(p.TowerManager.isPlacingTower?p.Grid.onGridCellClicked(s,r):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!p.Grid.gridInteractionEnabled||p.GameScene.towerPanel.isShown||p.GameScene.events.emit(Re.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!p.Grid.gridInteractionEnabled||p.GameScene.towerPanel.isShown||(p.GameScene.events.emit(Re.CellMouseLeave,this),p.Grid.rangePreview.clear())}),p.GameScene.events.on(Le.TowerPlacedEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!0,p.Grid.rangePreview.clear())}),p.GameScene.events.on(Le.TowerSoldEvent,(a,o,h)=>{o==this.row&&h==this.column&&(this.hasTowerPlaced=!1)})}showRangePreview(e,s){let r=16777215;e&&(r=16711680),p.Grid.rangePreview.clear(),p.Grid.rangePreview.circle(this.column*p.GridCellSize+p.GridCellSize/2,this.row*p.GridCellSize+p.GridCellSize/2,s*p.GridCellSize),p.Grid.rangePreview.fill({color:r,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=p.TowerManager.GetTowerByRowAndCol(this.row,this.column);p.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Tt.Path||this.type==Tt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Tt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Tt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Tt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class hd extends zt{constructor(e,s){super();x(this,"gameMap");x(this,"cells",[]);x(this,"rangePreview");x(this,"creeps",[]);x(this,"gridShown",!1);x(this,"gridInteractionEnabled",!0);this.gameMap=e,p.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=p.GridCellSize*p.GridColumns,this.bb.height=p.GridCellSize*p.GridRows,p.GameMaster.currentScene.stage.addChild(this.container);let r=new H(I.MissionBackgrounds[s]);this.container.addChild(r);for(let n=0;nl.some(d=>d[0]===a&&d[1]===n));h&&(o=Tt.Path);let c=new od(o,a,n,h);this.cells.push(c)}this.rangePreview=new kt({zIndex:10}),this.container.addChild(this.rangePreview)}toggleGrid(e){this.cells.forEach(s=>{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(St.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(St.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(r=>r.row==e&&r.column==s)[0]}onGridCellClicked(e,s){}}class ld extends zt{constructor(e,s,r){super();x(this,"id");x(this,"creepType");x(this,"sprite");x(this,"path");x(this,"stats");x(this,"pathIndex",0);x(this,"speed");x(this,"direction",1);x(this,"healthBarGraphics",new kt);x(this,"healthBarWidth",50);x(this,"health");x(this,"maxHealth");x(this,"escaped",!1);x(this,"died",!1);x(this,"x");x(this,"y");x(this,"dead",!1);this.creepType=e,this.stats=structuredClone(I.Creeps[this.creepType].stats),this.sprite=new Fe(I.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=r,this.container.x=-70,this.container.y=-50,this.sprite.width=p.GridCellSize,this.sprite.height=p.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][1]*p.GridCellSize+p.GridCellSize/2,this.y=s[0][0]*p.GridCellSize+p.GridCellSize/2,p.GameScene.events.on(St.TakenDamage,(n,a)=>{n==this.id&&(this.health-=a,this.UpdateHealthbar())}),p.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,r=e/s,n=this.healthBarWidth*r;this.healthBarGraphics.rect(-this.healthBarWidth/2+3,-32,this.healthBarWidth+4,14),this.healthBarGraphics.fill({color:0}),this.healthBarGraphics.rect(-this.healthBarWidth/2+5,-30,n,10),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){p.GameScene.events.emit(St.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(St.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*p.GridCellSize+p.GridCellSize/2,a=r[0]*p.GridCellSize+p.GridCellSize/2,o=r[1]-s[1],h=r[0]-s[0];o>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):o<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let c=this.speed*e*o,l=this.speed*e*h,d=!1;c>0&&this.x+c>n&&(c=n-this.x,d=!0),c<0&&this.x+c0&&this.y+l>a&&(l=a-this.y,d=!0),l<0&&this.y+l{s+=r.firstCreepSpawnTick,r.creeps.forEach(n=>{const a=new ld(n,this.paths[0],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};console.log("CREAWTASEDASD"),s+=r.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(qt.CreepSpawned,s.creep),console.log("Wave manager creep spawned, ",s,this.ticks),!this.finished&&this.creeps.every(r=>r.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit(qt.Finished))):s.spawned&&s.creep.update(e)}))}}class zr extends It{constructor(e,s,r,n,a,o,h,c){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);x(this,"frameSprite");x(this,"background");x(this,"towerName");x(this,"iconSprite");x(this,"i",0);this.towerName=h,this.container.x=e*r+5,this.container.y=s*n+5,this.background=new H({texture:o}),this.iconSprite=new H({texture:c}),this.background.width=r,this.background.height=n,this.iconSprite.x=r/2,this.iconSprite.y=n/2,this.iconSprite.width=r/2,this.iconSprite.height=n/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new Dt({texture:I.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),p.GameScene.events.on(Le.TowerPlacedEvent,l=>{this.resetTint()}),this.container.onpointermove=l=>{p.Grid.gridInteractionEnabled!=!1&&(p.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=l=>{p.GameScene.tooltip.Hide()}}ShowTooltip(){let e;I.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),p.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),p.GameScene.tooltip.Show(p.MouseX,p.MouseY)}onClick(e){p.Grid.gridInteractionEnabled!=!1&&(p.TowerManager.isPlacingTower&&p.TowerManager.selectedTower.name!=this.towerName&&(p.GameScene.sidebar.towerTab.resetTint(),p.TowerManager.ResetChooseTower()),p.GameScene.towerPanel.Hide(),p.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,p.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class dd extends It{constructor(e){super(!1);x(this,"bounds");x(this,"towerTabSprite");x(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Dt({texture:I.FrameTowerTab,leftWidth:500,topHeight:500,rightWidth:500,bottomHeight:500,roundPixels:!0}),this.towerTabSprite.width=this.bounds.width,this.towerTabSprite.height=this.bounds.height,this.container.addChild(this.towerTabSprite),this.towerButtons.push(new zr(0,0,70,70,this.container,I.RedBackground,"Basic Tower",I.Towers[0].texture)),this.towerButtons.push(new zr(3,1,70,70,this.container,I.GreenBackground,"Circle Tower",I.Towers[1].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new z(p.app.canvas.width-360,0,360,p.app.canvas.height),se.ChangeRoundButtonRect=new z(50,p.app.canvas.height-100,310,100)}};x(se,"SidebarRect"),x(se,"ChangeRoundButtonRect");let Rt=se;function ud(i,t){i.projectiles.forEach(e=>{e.deleteMe?(i.damageDealt+=i.computedDamageToDeal,i.projectiles.splice(i.projectiles.indexOf(e),1),e=null):e.update(t)})}function xa(i){let t=0;i.slottedGems.forEach(e=>{t+=e.currentGemImprovement().damageUp}),i.computedDamageToDeal=i.definition.stats.damage+t}function fd(i,t){i.ticksUntilNextShot%2==0&&xa(i),ud(i,t),i.ticksUntilNextShot>0&&i.ticksUntilNextShot--;let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];i.ticksUntilNextShot==0&&(i.ticksUntilNextShot=i.definition.stats.cooldown,i.Shoot(s))}}class De extends It{constructor(e,s,r,n){super(!0);x(this,"iconSprite");x(this,"background");x(this,"frame");x(this,"i",0);x(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(p.GridCellSize+6)+300,this.background=new H({texture:I.Frame01Texture}),r==null&&!n?a=I.PlusIconTexture:n=="SELL"?a=I.GoldTexture:n=="UPGRADE"?a=I.PlusIconTexture:(a=r.texture,this.gem=r),this.iconSprite=new H({texture:a,zIndex:10}),this.background.width=p.GridCellSize,this.background.height=p.GridCellSize,r==null&&!n?(this.iconSprite.x=p.GridCellSize/2,this.iconSprite.y=p.GridCellSize/2,this.iconSprite.width=p.GridCellSize/2,this.iconSprite.height=p.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):n=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=p.GridCellSize-8,this.iconSprite.height=p.GridCellSize-8):n=="UPGRADE"?(this.iconSprite.x=p.GridCellSize/2,this.iconSprite.y=p.GridCellSize/2,this.iconSprite.width=p.GridCellSize/2,this.iconSprite.height=p.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=p.GridCellSize-8,this.iconSprite.height=p.GridCellSize-8),this.frame=new H({texture:I.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=r?r.id:"",h=new q({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class pd extends It{constructor(e){super(!1);x(this,"bounds");x(this,"towerPanel");x(this,"closeBtn");x(this,"vGems",[]);x(this,"showingTower",null);x(this,"isShown",!1);x(this,"titleText");x(this,"damageText");x(this,"totalDamage");x(this,"attackSpeedText");this.bounds=e,this.towerPanel=new Dt({texture:I.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new le(new z(-20,-20,60,60),"",Zt.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new H({texture:I.XIconTexture,x:this.closeBtn.container.width/2,y:this.closeBtn.container.height/2,scale:.2}),this.closeBtn.buttonIcon.anchor.set(.5,.5),this.closeBtn.container.addChild(this.closeBtn.buttonIcon)},this.closeBtn.onClick=()=>{this.Hide()},this.Hide(),this.closeBtn.CustomButtonLogic(),this.container.y=p.app.canvas.height/2-p.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),p.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new q({x:this.bounds.width/3,y:50,zIndex:5,style:new et({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new q({x:10,y:100,zIndex:5,style:new et({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new q({x:100,y:100,zIndex:5,style:new et({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new q({x:10,y:130,zIndex:5,style:new et({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage)}MakeSlots(e){this.vGems.forEach(r=>{r.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let r=0;r{n&&(p.GameScene.tooltip.SetContentGem(n),p.GameScene.tooltip.Show(p.MouseX,p.MouseY))},a.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},a.onClick=()=>{p.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",n,a.i,r,e),p.GameScene.events.emit(Ms.TowerPanelSelectGem,n,a.i,e),!n&&p.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,xa(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,p.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<900?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.definition.stats.range)}SetContent(e){this.titleText.text=e.definition.name,this.damageText.text="Deals "+e.computedDamageToDeal+" damage",this.totalDamage.text="Damage dealt: "+e.damageDealt+" damage",this.attackSpeedText.x=this.damageText.width+10,this.attackSpeedText.text=` every ${Math.floor(e.definition.stats.cooldown/60)}s`}ShowLeft(){this.towerPanel.x=-100,this.container.x=0,this.container.alpha=1,this.closeBtn.container.x=this.bounds.width-150}ShowRight(){this.towerPanel.x=-10,this.container.x=Rt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=Rt.SidebarRect.x+10,p.Grid.rangePreview.clear()}}class md extends It{constructor(e){super(!1);x(this,"bounds");x(this,"gemTabSprite");x(this,"vGems",[]);x(this,"isSelectingGem",!1);x(this,"selectingGemSlotIndex",-1);x(this,"selectingGemTowerObject",null);x(this,"isDragAndDroppingGem",!1);x(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Dt({texture:I.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite),p.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),p.GameScene.events.on(Ts.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,r){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(p.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=r):(r.UnslotGem(s),this.RebuildInventoryVisual(),p.GameScene.towerPanel.Hide(),p.GameScene.towerPanel.Show(r),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=p.MouseX-32,this.dragAndDroppingGem.container.y=p.MouseY-32)}isOverlappingGemsmith(e,s,r){let n=e.copyContainerToBB(),a=s.copyContainerToBB(),o=r.x+a.x+p.GameScene.sidebar.container.x,h=r.y+a.y+p.GameScene.sidebar.container.y,c=new z(o,h,a.width,a.height);if(n.getBounds().intersects(c)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],p.GameScene.MissionStats.getInventory().forEach((e,s)=>{let r=new De(0,this.container,e),n=10,a=s%4*70+10,o=s;for(;!(o<=3);)n+=66,o-=4;r.container.x=a,r.container.y=n,r.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(p.GameScene.tooltip.SetContentGem(e),p.GameScene.tooltip.Show(p.MouseX,p.MouseY))},r.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},r.container.onpointerdown=()=>{if(p.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=p.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=r,r.container.removeFromParent(),p.GameScene.stage.addChild(r.container),this.pointerMoveEvent()},r.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,p.GameScene.sidebar.gemsmith.sellVGem,p.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;p.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),p.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),p.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,p.GameScene.sidebar.gemsmith.upgradeVGem,p.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())p.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;p.GameScene.MissionStats.hasEnoughGold(d)?(p.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),p.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):p.NotificationManager.Notify("You don't have enough, you need "+d+" gold to upgrade this gem.","warn")}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(p.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let u=this.dragAndDroppingGem.copyContainerToBB(),f=d.copyContainerToBB(),m=p.GameScene.towerPanel.container.x+f.x,y=p.GameScene.towerPanel.container.y+f.y,g=new z(m,y,f.width,f.height);u.getBounds().intersects(g)&&d&&d.gem==null&&(h=d)}),h){let d=p.GameScene.MissionStats.takeGem(e);p.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(r)})}}class gd extends It{constructor(e){super(!1);x(this,"bounds");x(this,"sellVGem");x(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new H({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:I.BannerGemsmith});this.container.addChild(s);let r=new q({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new et({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r);let n=new q({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new et({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n),this.sellVGem=new De(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new De(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class xd extends It{constructor(e){super(!1);x(this,"towerTab");x(this,"gemTab");x(this,"gemsmith");x(this,"bounds");x(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Dt({texture:I.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new z(60,20,this.bounds.width-65,150);this.towerTab=new dd(s),this.container.addChild(this.towerTab.container);const r=new z(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new md(r),this.container.addChild(this.gemTab.container);const n=new z(60,185+r.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new gd(n),this.container.addChild(this.gemsmith.container)}}class Ps{constructor(){x(this,"stage",new at);x(this,"gui",[]);x(this,"_events",new ct);p.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this.gui.forEach(t=>{t.destroy()})}get events(){return this._events}init(){}}class yd extends zt{constructor(e,s){super();x(this,"hp",100);x(this,"gold",0);x(this,"goldText");x(this,"healthText");x(this,"waveText");x(this,"inventory",[]);x(this,"score",0);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,p.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new q({text:`${this.hp}`,style:new et({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new q({text:`${this.gold}`,style:new et({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new q({text:`0/${p.GameScene.mission.rounds.length}`,style:new et({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new H(I.HealthTexture),n=new H(I.GoldTexture),a=new H(I.WaveTexture);this.healthText.x=200,this.healthText.y=-15,r.x=160,r.width=36,r.height=32,r.y=-10,this.goldText.x=200,this.goldText.y=20,n.x=150,n.width=56,n.height=56,n.y=15,this.waveText.x=200,this.waveText.y=55,a.x=155,a.width=46,a.height=32,a.y=65,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(this.waveText),this.container.addChild(r),this.container.addChild(n),this.container.addChild(a),p.GameScene.events.on(qt.NewWave,o=>{this.waveText.text=`${o}/${p.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return p.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||p.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),p.GameScene.events.emit(Ts.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}update(){}}function _d(i,t,e,s){const r=e-i,n=s-t;return Math.atan2(n,r)}class wd extends zt{constructor(e,s,r,n,a,o,h){super();x(this,"deleteMe",!1);x(this,"sprite");x(this,"x");x(this,"y");x(this,"angle");x(this,"speed");x(this,"damage");x(this,"timeToLive",1);x(this,"parent");this.x=e,this.y=s,this.parent=h,this.damage=a,this.sprite=new Fe({textures:r,scale:.25,rotation:n}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.sprite.tint=o,this.container.addChild(this.sprite),p.GameMaster.currentScene.stage.addChild(this.container),this.angle=n,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.timeToLive<=0)return this.destroy();p.Grid.creeps.forEach(s=>{if(!(this.timeToLive<=0)&&s.container&&this.checkCollision(s)){this.timeToLive--,this.onCollide(s);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){p.GameScene.events.emit(St.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let s=this.copyContainerToBB(),r=e.copyContainerToBB();return s.getBounds().intersects(r.getBounds())}}function bd(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Sd extends zt{constructor(e,s,r,n,a){super();x(this,"row");x(this,"column");x(this,"definition");x(this,"slottedGems",[]);x(this,"damageDealt",0);x(this,"projectiles",[]);x(this,"behaviour");x(this,"sprite");x(this,"ticksUntilNextShot");x(this,"graphics",new kt);x(this,"computedDamageToDeal");x(this,"parent");x(this,"onParentCellEnter",e=>{!p.TowerManager.isPlacingTower&&p.Grid.gridInteractionEnabled&&!p.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.definition.stats.range)});x(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0,this.parent=p.Grid.getCellByRowAndCol(e,s),this.sprite=new H({texture:r,height:p.GridCellSize,width:p.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),p.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){console.log("ATTEMPTING TO SLOT ",e,s),this.slottedGems[s]=e,p.GameScene.towerPanel.Hide(),p.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];p.GameScene.MissionStats.giveGem(s,!0);for(let r=e;rr!=null),p.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return p.Grid.creeps.filter(s=>{const r=s.x,n=s.y,a=this.column*p.GridCellSize+p.GridCellSize/2,o=this.row*p.GridCellSize+p.GridCellSize/2,h=this.definition.stats.range*p.GridCellSize;return bd(a,o,r,n){o.definition.type.toString()=="Fire"&&(a=16711680)}),this.projectiles.push(new wd(s,r,this.definition.projectileTextures,n,this.computedDamageToDeal,a,this))}update(e){this.behaviour==ya.BasicTowerBehaviour&&fd(this,e)}destroy(){super.destroy(),this.parent.clickDetector.off("pointerenter",this.onParentCellEnter),this.parent.clickDetector.off("pointerleave",this.onParentCellLeave),this.graphics.destroy()}}var ya=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i))(ya||{});class vd{constructor(){x(this,"isPlacingTower",!1);x(this,"canPlaceTowers",!0);x(this,"selectedTower",null);x(this,"previewSprite",new H({parent:p.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));x(this,"towers",[]);p.TowerManager=this,p.GameScene.events.on(Re.CellMouseOver,t=>{this.isPlacingTower&&(t.checkIfCantPlace()?(t.showRangePreview(!0,this.selectedTower.stats.range),this.previewSprite.tint=16711680):(t.showRangePreview(!1,this.selectedTower.stats.range),this.previewSprite.tint=16777215),this.previewSprite.x=t.column*p.GridCellSize,this.previewSprite.y=t.row*p.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),p.GameScene.events.on(Re.CellMouseLeave,t=>{this.previewSprite.texture=null})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,p.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(p.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):I.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e,console.log(this.selectedTower))}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)return p.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(s=r)}),s}PlaceTower(t,e,s,r,n){const a=t.texture;if(!p.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return p.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&p.Grid.getCellByRowAndCol(e,s).type!=Tt.Path&&p.Grid.getCellByRowAndCol(e,s).type!=Tt.Restricted){n||p.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Sd(e,s,a,t,r);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,p.GameScene.events.emit(Le.TowerPlacedEvent,t.name,e,s)}else p.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn"),console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}class Ad extends It{constructor(e){super(!1);x(this,"bounds");x(this,"tooltipSprite");x(this,"titleText");x(this,"costText");x(this,"damageText");x(this,"gemAmount");x(this,"gemAmountSprite");x(this,"title");x(this,"costSprite");x(this,"damageSprite");x(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new Dt({texture:I.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new q({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new et({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new H({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:I.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new H({texture:I.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new q({x:54,y:26,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"gold",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageText=new q({x:54,y:65,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"red",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageSprite=new H({texture:I.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new H({texture:I.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new q({x:54,y:105,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"white",fontWeight:"bold",stroke:{color:0,width:5}}}),this.gemDescriptionText=new q({x:10,y:20,text:"",style:{fontSize:18,wordWrap:!0,wordWrapWidth:this.tooltipSprite.width-30,fill:"white",fontWeight:"bold",fontStyle:"italic",stroke:{color:0,width:5}}}),this.container.addChild(this.tooltipSprite),this.container.addChild(this.title),this.container.addChild(this.costSprite),this.container.addChild(this.damageSprite),this.container.addChild(this.gemAmountSprite),this.container.addChild(this.costText),this.container.addChild(this.titleText),this.container.addChild(this.damageText),this.container.addChild(this.gemAmount),this.container.addChild(this.gemDescriptionText),p.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,r,n){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${n} Gem slots.`,this.gemAmountSprite.texture=I.GemAmountIcons[n],this.costText.text=`Costs ${r} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name,this.gemDescriptionText.text=`Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>p.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}class _a extends Ps{constructor(e){super();x(this,"isGameOver",!1);x(this,"mission");x(this,"missionIndex");x(this,"MissionStats");x(this,"roundMode");x(this,"ticker");x(this,"changeRoundButton");x(this,"sidebar");x(this,"tooltip");x(this,"towerPanel");x(this,"visualGems",[]);x(this,"currentRound",0);x(this,"isWaveManagerFinished",!1);x(this,"playerWon",!1);x(this,"destroyTicker",!1);x(this,"offerGemsSprite");x(this,"dimGraphics",new kt({x:0,y:0,zIndex:120}));p.GameScene=this,I.Missions.forEach((s,r)=>{s.name==e&&(this.mission=s,this.missionIndex=r)})}init(){new hd(this.mission.gameMap,this.missionIndex),new vd,new cd(this.mission.rounds,this.mission.gameMap.paths),p.Grid.onGridCellClicked=(e,s)=>{p.TowerManager.isPlacingTower&&p.TowerManager.PlayerClickOnGrid(e,s)},p.WaveManager.events.on(qt.CreepSpawned,e=>{p.Grid.addCreep(e),e.events.on(St.Escaped,()=>{this.onCreepEscaped(e)})}),p.WaveManager.events.on(qt.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(St.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new pd(Rt.SidebarRect),this.sidebar=new xd(Rt.SidebarRect),this.changeRoundButton=new le(Rt.ChangeRoundButtonRect,"",Zt.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),p.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Ad(new z(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new H({texture:I.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1)return p.NotificationManager.Notify("Wave is already in progress.","warn");if(this.isGameOver)return p.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=I.ExclamationIconTexture,this.events.emit(qt.NewWave,`${this.currentRound+1}`))},this.MissionStats=new yd(100,200),this.events.on(Ms.TowerPanelSelectGem,(e,s,r)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return p.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,r)}),this.ticker=new bt,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(p.MouseX,p.MouseY),this.tooltip.Hide(),this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start()}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}p.WaveManager.update(e),p.Grid.update(e),p.TowerManager.update(e),this.isWaveManagerFinished&&p.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=I.PlayIconTexture,p.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(p.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=I.HomeIconTexture,this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowScoreScreen(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowScoreScreen(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,p.app.canvas.width,p.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){p.Grid.gridInteractionEnabled=!1,p.GameScene.sidebar.towerTab.resetTint(),p.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new Dt({width:380,height:150,texture:I.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:p.app.canvas.width/2-190,y:p.app.canvas.height/2-75}),p.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new q({x:p.app.canvas.width/4,y:p.app.canvas.height/4,zIndex:this.dimGraphics.zIndex+1,text:"Choose a Gem as your reward for beating this round!",style:{fontSize:40,fill:"orange",fontWeight:"bold",stroke:{color:0,width:5}}});p.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((r,n)=>{let a=new cs(r,!0),o=new De(0,p.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(n+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{p.GameScene.tooltip.SetContentGem(a),p.GameScene.tooltip.Show(p.MouseX,p.MouseY)},o.container.onpointerleave=()=>{p.GameScene.tooltip.Hide()},o.onClick=()=>{p.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new cs(r))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),p.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}ShowScoreScreen(e){console.log(e?"LOSE!":"WIN!")}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?p.WaveManager.start(this.currentRound):p.WaveManager.end()}destroy(){super.destroy(),this.isGameOver=!0,this.destroyTicker=!0,p.GameScene=null}ReturnToMain(){this.destroy(),p.GameMaster.currentScene.stage.removeChildren(),p.GameMaster.changeScene(new wa)}}class wa extends Ps{init(){const t=new le(new z(0,0,300,60),"Back to main",Zt.Button01);t.onClick=e=>{p.GameMaster.changeScene(new ba)},I.Missions.forEach((e,s)=>{const r=new le(new z(p.app.canvas.width/2-150,p.app.canvas.height/5+s*80,300,60),e.name,Zt.Button01);r.onClick=n=>{p.GameMaster.changeScene(new _a(e.name))}})}}class ba extends Ps{init(){const t={caption:"New Game",rect:new z(p.app.canvas.width/2-150,p.app.canvas.height/5+240,300,60),texture:Zt.Button02},e={caption:"Settings",rect:new z(p.app.canvas.width/2-300/2,p.app.canvas.height/5+4*80,300,60),texture:Zt.Button02};let s=new q({x:p.app.canvas.width/2-300/2,y:p.app.canvas.height/5+1*80,text:"BASTION",style:{fill:16755200,fontFamily:"Aclonica",fontSize:100}});s.x=s.x-s.width/5,p.GameMaster.currentScene.stage.addChild(s);let r=new q({x:0,y:0,text:"Latest commit: "+p.latestCommit,style:{fill:0,fontSize:10,fontWeight:"bold"}});p.GameMaster.currentScene.stage.addChild(r);const n=new le(t.rect,t.caption,t.texture,!0);n.onClick=o=>{p.GameMaster.currentScene.stage.removeChild(s),p.GameMaster.currentScene.stage.removeChild(r),p.GameMaster.changeScene(new wa)};let a=new le(e.rect,e.caption,e.texture,!0);a.onClick=o=>{p.NotificationManager.Notify("Not finished.","info")}}}class Cd{constructor(){x(this,"finished",!1);x(this,"calledBack",!1);x(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Td extends Cd{constructor(e,s,r,n){super();x(this,"fadeType");x(this,"fadeTime");x(this,"pixiObject");x(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=r,this.callbackFn=n,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class Md{constructor(){x(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class Pd{constructor(t,e,s,r,n){x(this,"textObj");x(this,"ticksToFadeAway");x(this,"animating",!1);x(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"?a=14047996:e=="gemaward"&&(a=16777215),this.ticksToFadeAway=n,this.textObj=new q({text:t,style:new et({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:r,zIndex:100}),this.textObj.anchor.set(.5,.5),p.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class kd extends zt{constructor(){super();x(this,"notifications",[]);x(this,"ticks",0);this.bb.x=p.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,p.app.stage.addChild(this.container)}Notify(e,s){let r=0,n=this.notifications.length*32;this.notifications.push(new Pd(e,s,r,n,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const r=this.notifications[s];if(r.destroyed){this.notifications.splice(s,1);continue}this.ticks>=r.ticksToFadeAway&&!r.animating&&(r.animating=!0,p.AnimationManager.Animate(new Td("out",300,r.textObj,()=>{r.destroy()})))}}}(async()=>{const i=new En;p.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const s=window.innerWidth,r=window.innerHeight,n=s/i.screen.width,a=r/i.screen.height,o=Math.min(n,a),h=Math.round(i.screen.width*o),c=Math.round(i.screen.height*o),l=(s-h)/2,d=(r-c)/2;i.canvas.style.width=`${h}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${l}px`,i.canvas.style.marginTop=`${d}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}p.latestCommit=await fetch("/latest_commit").then(s=>s.text()),window.addEventListener("resize",t),t(),await I.LoadAssets(),Rt.init(),new ad,p.AnimationManager=new Md,p.NotificationManager=new kd,globalThis.Engine=p,bt.shared.add(s=>{p.NotificationManager.update(s.elapsedMS),p.AnimationManager.update(s.elapsedMS)}),i.canvas.addEventListener("pointermove",function(s){p.MouseX=(s.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,p.MouseY=(s.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),p.GameMaster.changeScene(new ba),new URLSearchParams(location.href).entries().next().value[1]=="game"&&p.GameMaster.changeScene(new _a("Mission 1")),p.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":p.TestSuite()})();export{O as $,kn as A,Q as B,at as C,K as D,P as E,qr as F,li as G,vt as H,js as I,H as J,Do as K,Yo as L,W as M,st as N,z as O,ot as P,ch as Q,Ki as R,Gh as S,Gt as T,ri as U,Ks as V,go as W,Ai as X,J as Y,Zr as Z,Gn as _,L as a,U as a0,mh as a1,Wn as a2,tl as a3,il as a4,ol as a5,ll as a6,cl as a7,oe as a8,et as a9,tc as aa,hs as ab,Xn as ac,ar as ad,te as ae,id as af,Gr as ag,ac as ah,kt as ai,Y as aj,Ha as ak,os as al,Pr as am,qn as an,bt as b,ct as c,Ft as d,ht as e,nr as f,Mh as g,ti as h,ps as i,Tn as j,hn as k,Sn as l,Mr as m,Ls as n,Jh as o,el as p,nl as q,eo as r,Ln as s,hl as t,ms as u,yn as v,tt as w,Na as x,ul as y,Mt as z};