const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-B7E4lTU2.js","assets/webworkerAll-BTHTV2vQ.js","assets/colorToUniform-BrndAOXx.js","assets/WebGPURenderer-BBLdxcb9.js","assets/SharedSystems-Bu8-b11f.js","assets/WebGLRenderer-B6t6FMSV.js"])))=>i.map(i=>d[i]); var Ua=Object.defineProperty;var Na=(i,t,e)=>t in i?Ua(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var g=(i,t,e)=>Na(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const Oa="modulepreload",Wa=function(i){return"/"+i},en={},mi=function(t,e,s){let n=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"));n=Promise.allSettled(e.map(h=>{if(h=Wa(h),h in en)return;en[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const d=document.createElement("link");if(d.rel=l?"stylesheet":Oa,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var G=(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))(G||{});const as=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},ei=(i,t)=>as(i).priority??t,dt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var r,a;const s=this._addHandlers,n=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&((a=r[i])==null||a.forEach(o=>t(o)),delete r[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(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,a)=>ei(a.value,e)-ei(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ei(r,e)-ei(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})}},Ha={extension:{type:G.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await mi(()=>import("./browserAll-B7E4lTU2.js"),__vite__mapDeps([0,1,2]))}},$a={extension:{type:G.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await mi(()=>import("./webworkerAll-BTHTV2vQ.js"),__vite__mapDeps([1,2]))}};class pt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new pt(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 Gs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var nr={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new n(c,d||h,f),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],p]:h._events[m].push(p):(h._events[m]=p,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,p=d.length,m=new Array(p);fJt[i],uY:i=>te[i],vX:i=>ee[i],vY:i=>ie[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>os[i][t],sub:(i,t)=>os[i][j.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?j.S:j.N:Math.abs(t)*2<=Math.abs(i)?i>0?j.E:j.W:t>0?i>0?j.SE:j.SW:i>0?j.NE:j.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const n=rr[j.inv(t)];n.tx=e,n.ty=s,i.append(n)}},si=[new ht,new ht,new ht,new ht];class I{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}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 I(0,0,0,0)}clone(){return new I(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<=l&&e>=c&&e<=d&&!(t>f&&tm&&et.right?t.right:this.right)<=k)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=s||a<=r)return!1;const o=si[0].set(t.left,t.top),h=si[1].set(t.left,t.bottom),l=si[2].set(t.right,t.top),c=si[3].set(t.right,t.bottom);if(l.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(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=s||Math.min(o.x,h.x,l.x,c.x)>=n||Math.max(o.y,h.y,l.y,c.y)<=r||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const f=d*(h.y-o.y),p=d*(o.x-h.x),m=f*s+p*r,y=f*n+p*r,x=f*s+p*a,w=f*n+p*a;if(Math.max(m,y,x,w)<=f*o.x+p*o.y||Math.min(m,y,x,w)>=f*c.x+p*c.y)return!1;const _=d*(o.y-l.y),b=d*(l.x-o.x),S=_*s+b*r,A=_*n+b*r,F=_*s+b*a,P=_*n+b*a;return!(Math.max(S,A,F,P)<=_*o.x+b*o.y||Math.min(S,A,F,P)>=_*c.x+b*c.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),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=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=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new I,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ri={default:-1};function nt(i="default"){return Ri[i]===void 0&&(Ri[i]=-1),++Ri[i]}const sn={},W="8.0.0",Qa="8.3.4";function N(i,t,e=3){if(sn[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))),sn[t]=!0}const ar=()=>{};function nn(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 rn(i){return!(i&i-1)&&!!i}function Ja(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const an=Object.create(null);function to(i){const t=an[i];return t===void 0&&(an[i]=nt("resource")),t}const or=class hr extends gt{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){N(W,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=to(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};or.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let eo=or;const lr=class cr extends gt{constructor(t={}){super(),this.options=t,this.uid=nt("textureSource"),this._resourceType="textureSource",this._resourceId=nt("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={...cr.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 eo(Ja(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=nt("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 n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("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=rn(this.pixelWidth)&&rn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};lr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Nt=lr;class ks extends Nt{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}}ks.extension=G.TextureSource;const on=new H;class io{constructor(t,e){this.mapCoord=new H,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 n=0;nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new I);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=hn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,l=r.d,c=r.tx,d=r.ty;let f=this.minX,p=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,w=o*t+l*e+d;xm&&(m=x),w>y&&(y=w),x=a*s+h*e+c,w=o*s+l*e+d,xm&&(m=x),w>y&&(y=w),x=a*t+h*n+c,w=o*t+l*n+d,xm&&(m=x),w>y&&(y=w),x=a*s+h*n+c,w=o*s+l*n+d,xm&&(m=x),w>y&&(y=w),this.minX=f,this.minY=p,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?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=a*e+h*r+c,p=o*e+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=a*n+h*r+c,p=o*n+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),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 Et(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,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,d=n.c,f=n.d,p=n.tx,m=n.ty;for(let y=e;yo?_:o,h=b>h?b:h}this.minX=r,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 no={grad:.9,turn:360,rad:360/(2*Math.PI)},Ft=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},wt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},dr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},ln=function(i){return{r:wt(i.r,0,255),g:wt(i.g,0,255),b:wt(i.b,0,255),a:wt(i.a)}},Fi=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},ro=/^#([0-9a-f]{3,8})$/i,ni=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ur=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),a=r-Math.min(t,e,s),o=a?r===t?(e-s)/a:r===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},fr=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),a=s*(1-e),o=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:n}},cn=function(i){return{h:dr(i.h),s:wt(i.s,0,100),l:wt(i.l,0,100),a:wt(i.a)}},dn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},un=function(i){return fr((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},Oe=function(i){return{h:(t=ur(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},ao=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ho=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(i){var t=ro.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?at(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?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ho.exec(i)||lo.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:ln({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=ao.exec(i)||oo.exec(i);if(!t)return null;var e,s,n=cn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(no[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return un(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Ft(t)&&Ft(e)&&Ft(s)?ln({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=cn({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return un(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=function(o){return{h:dr(o.h),s:wt(o.s,0,100),v:wt(o.v,0,100),a:wt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return fr(a)},"hsv"]]},fn=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,a=(r=t.a)<1?ni(at(255*r)):"","#"+ni(e)+ni(s)+ni(n)+a;var t,e,s,n,r,a},i.prototype.toRgb=function(){return Fi(this.rgba)},i.prototype.toRgbString=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return dn(Oe(this.rgba))},i.prototype.toHslString=function(){return t=dn(Oe(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=ur(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Gt({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),Gt(Li(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Gt(Li(this.rgba,-t))},i.prototype.grayscale=function(){return Gt(Li(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Gt(pn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Gt(pn(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"?Gt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Oe(this.rgba);return typeof t=="number"?Gt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Gt(t).toHex()},i}(),Gt=function(i){return i instanceof ls?i:new ls(i)},gn=[],uo=function(i){i.forEach(function(t){gn.indexOf(t)<0&&(t(ls,hs),gn.push(t))})};function fo(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 n in e)s[e[n]]=n;var r={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,f="black";if(!r.length)for(var p in e)r[p]=new i(e[p]).toRgb();for(var m in e){var y=(o=c,h=r[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));yr===e[a]);if(t!==null&&e!==null){const r=Object.keys(t),a=Object.keys(e);return r.length!==a.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}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,n]=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(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,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,n,r]=De._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,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,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}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,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=De.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Gt(t);a.isValid()&&({r:e,g:s,b:n,a:r}=a.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,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((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof De||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}};me.shared=new me;me._temp=new me;me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=me;const po={cullArea:null,cullable:!1,cullableChildren:!0};class Bs{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 go{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 Bs(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 zt=new go;function mo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}mo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);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||N(W,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const n=i.parent.children.indexOf(i);if(i.parent===this&&n===t)return i;n!==-1&&i.parent.children.splice(n,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 n=this.renderGroup||this.parentRenderGroup;n&&(n.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 mn{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-n.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),cs.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=cs.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var r;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new mn);i=i;const e=(i==null?void 0:i.length)>0,s=((r=t.filters)==null?void 0:r.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(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 mn),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},_o={label:null,get name(){return N(W,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){N(W,"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(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(tt.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||N(W,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n1){for(let n=0;n-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=zt.get(Po,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),zt.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 H),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*Xa}set angle(t){this.rotation=t*ja}get pivot(){return this._pivot===Ni&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===Ni&&(this._pivot=new pt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Oi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Oi&&(this._scale=new pt(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,n=this._pivot,r=this._position,a=s._x,o=s._y,h=n._x,l=n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=r._x-(h*e.a+l*e.c),e.ty=r._y-(h*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=yn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Y.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=yn,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|=ko,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|=Wi,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|=Wi,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|=Wi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends vi{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:s,roundPixels:n,width:r,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 pt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof z?new $(t):new $(z.from(t,e))}set texture(t){t||(t=z.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(){so(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:n,height:r}=e.orig;s.maxX=-t._x*n,s.minX=s.maxX+n,s.maxY=-t._y*r,s.minY=s.maxY+r}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 Bo=new Et;function _r(i,t,e){const s=Bo;i.measurable=!0,pr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function br(i,t,e){const s=xe.get();i.measurable=!0;const n=Ut.get().identity(),r=Sr(i,e,n);mr(i,s,r),i.measurable=!1,t.addBoundsMask(s),Ut.return(n),xe.return(s)}function Sr(i,t,e){return i?(i!==t&&(Sr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class vr{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 $),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){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $}}vr.extension=G.MaskEffect;class Cr{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"}}Cr.extension=G.MaskEffect;class Tr{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){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tt}}Tr.extension=G.MaskEffect;const Io={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 wn=Io;const J={get(){return wn},set(i){wn=i}};class Ar extends Nt{constructor(t){t.resource||(t.resource=J.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 n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}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"))}}Ar.extension=G.TextureSource;class Ce extends Nt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=J.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,st("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=G.TextureSource;var yi=(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))(yi||{});class Hi{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}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 Mr=class mt{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 Hi(null,null,1/0),this.deltaMS=1/mt.targetFPMS,this.elapsedMS=1/mt.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=yi.NORMAL){return this._addListener(new Hi(t,e,s))}addOnce(t,e,s=yi.NORMAL){return this._addListener(new Hi(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 r=t-this._lastFrame|0;if(r{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 n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),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 r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),$i}const Ci=class Gr extends Nt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Gr.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=It.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 Pr(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,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&&(It.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||(It.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ci.extension=G.TextureSource;Ci.defaultOptions={...Nt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ci.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let fi=Ci;const Ct=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Eo{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||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=Ct(t);let n;for(let h=0;h{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const q=new Eo,ds=[];dt.handleByList(G.TextureSource,ds);function kr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n{q.has(s)&&q.remove(s)}),t||q.set(s,r),r}function Fo(i,t=!1){return typeof i=="string"?q.get(i):i instanceof Nt?new z({source:i}):Ro(i,t)}z.from=Fo;Nt.from=kr;dt.add(vr,Cr,Tr,fi,Ce,Ar,ks);var Xt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Xt||{});function St(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ie(i){return i.split("?")[0].split("#")[0]}function Lo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Do(i,t,e){return i.replace(new RegExp(Lo(t),"g"),e)}function zo(i,t){let e="",s=0,n=-1,r=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("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=o,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,o)}`:e=i.slice(n+1,o),s=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const xt={toPosix(i){return Do(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){St(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(St(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ie(this.toPosix(t??J.get().getBaseUrl())),n=Ie(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?xt.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(St(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=zo(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return St(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 n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(St(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),a=i;i=i.slice(r.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){s=o;break}}else n=!1;return s===-1?e?"/":this.isUrl(a)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){St(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){St(i),t&&St(t),i=Ie(this.toPosix(i));let e=0,s=-1,n=!0,r;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(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){St(i),i=Ie(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}s===-1&&(n=!1,s=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){St(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Ie(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||o===-1||c===0||c===1&&r===o-1&&r===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,r),t.base=i.slice(1,o)):(t.name=i.slice(a,r),t.base=i.slice(a,o)),t.ext=i.slice(r,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Br(i,t,e,s,n){const r=t[e];for(let a=0;a{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Br(i,n,0,e,s)}else s.push(i);return s}const wi=i=>!Array.isArray(i);class Te{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 Ct(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&st("[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 n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);s.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},Ct(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=Ct(a).map(p=>typeof p=="string"?Uo(p):Array.isArray(p)?p:[p]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[];c.forEach(p=>{p.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x{this._assetMap[p]=f})})}resolveBundle(t){const e=wi(t);t=Ct(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(n,h)]=l}s[n]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=wi(t);t=Ct(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const l=r.filter(c=>c[o]?c[o]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;er.params.format.includes(s.format));if(n)return n}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:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??No(t.src),t}}Te.RETINA_PREFIX=/@([0-9\.]+)x/;function No(i){return i.split(".").pop().split("?").shift().split("#").shift()}const us=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Ir=class ze{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?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<=ze.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ze.BATCH_SIZE;for(;e-t{this._batchIndex*ze.BATCH_SIZE{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[n]=t.textures[n]}),!e){const n=xt.dirname(i[0]);t.linkedSheets.forEach((r,a)=>{const o=Er([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(s,o)})}return s}const Wo={extension:G.Asset,cache:{test:i=>i instanceof _i,getCacheableAssets:(i,t)=>Er(i,t,!1)},resolver:{extension:{type:G.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Oo.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Te.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:G.LoadParser,priority:Xt.Normal,name:"spritesheetLoader"},async testParse(i,t){return xt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,c;const{texture:s,imageFilename:n}=(t==null?void 0:t.data)??{};let r=xt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(s instanceof z)a=s;else{const d=us(r+(n??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new _i(a.source,i);await o.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=r+p;(c=t.data)!=null&&c.ignoreMultiPack||(m=us(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);o.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==p))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};dt.add(Wo);const Vi=Object.create(null),_n=Object.create(null);function Is(i,t){let e=_n[i];return e===void 0&&(Vi[t]===void 0&&(Vi[t]=1),_n[i]=e=Vi[t]++),e}let he;function Rr(){return(!he||he!=null&&he.isContextLost())&&(he=J.get().createCanvas().getContext("webgl",{})),he}let ri;function Ho(){if(!ri){ri="mediump";const i=Rr();i&&i.getShaderPrecisionFormat&&(ri=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ri}function $o(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 Vo(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float; ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Yo(i,t){return t?`#version 300 es ${i}`:i}const Xo={},jo={};function qo(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Xo:jo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`} ${i}`}function Ko(i,t){return t?i.replace("#version 300 es",""):i}const Yi={stripVersion:Ko,ensurePrecision:Vo,addProgramDefines:$o,setProgramName:qo,insertVersion:Yo},Xi=Object.create(null),Fr=class fs{constructor(t){t={...fs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ho()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Yi).forEach(a=>{const o=s[a];n=Yi[a](n,o,!0),r=Yi[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Is(`${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 Xi[e]||(Xi[e]=new fs(t)),Xi[e]}};Fr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Lr=Fr;const bn={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 Zo(i){return bn[i]??bn.float32}const Qo={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 Jo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const r=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=Qo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Zo(h).stride,offset:0,instance:!1,start:0}}}}return e}function ji(i){var d,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=i.match(t))==null?void 0:d.map(p=>({group:parseInt(p.match(e)[1],10),binding:parseInt(p.match(s)[1],10),name:p.match(n)[2],isUniform:p.match(n)[1]==="",type:p.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=i.match(a))==null?void 0:f.map(p=>{const m=p.match(h)[1],y=p.match(o).reduce((x,w)=>{const[_,b]=w.split(":");return x[_.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:p})=>l.some(m=>m.type===p)))??[];return{groups:l,structs:c}}var Ue=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ue||{});function th({groups:i}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),r=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:n,groups:r}}const qi=Object.create(null);class Ti{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const l=ji(e.source);this.structsAndGroups=l}else{const l=ji(s.source),c=ji(e.source);this.structsAndGroups=ih(l,c)}this.layout=n??eh(this.structsAndGroups),this.gpuLayout=r??th(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=Is(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Jo(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 qi[e]||(qi[e]=new Ti(t)),qi[e]}}const Dr=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],sh=Dr.reduce((i,t)=>(i[t]=!0,i),{});function nh(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 zr=class Ur{constructor(t,e){this._touched=0,this.uid=nt("uniform"),this._resourceType="uniformGroup",this._resourceId=nt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Ur.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!sh[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Dr.join(", ")}`);r.value??(r.value=nh(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Is(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};zr.defaultOptions={ubo:!1,isStatic:!1};let Nr=zr;class pi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,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 n,r;const s=this.resources[e];t!==s&&(s&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.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 n=t[s];(e=n.off)==null||e.call(n,"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 ps=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(ps||{});class Es extends gt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=ps.WEBGPU),s&&(a|=ps.WEBGL)),this.compatibleRenderers=a;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const c in o[l]){const d=o[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&n&&!o){const l=e.structsAndGroups.groups;o={},l.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},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 l=0;for(const c in r)h[c]||(n[99]||(n[99]=new pi,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},o[99]=o[99]||{},o[99][l]=c,l++);for(const c in r){const d=c;let f=r[c];!f.source&&!f._resourceType&&(f=new Nr(f));const p=h[d];p&&(n[p.group]||(n[p.group]=new pi,this._ownedBindGroups.push(n[p.group])),n[p.group].setResource(f,p.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.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(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...n}=t;let r,a;return e&&(r=Ti.from(e)),s&&(a=Lr.from(s)),new Es({gpuProgram:r,glProgram:a,...n})}}const gs=[];dt.handleByNamedList(G.Environment,gs);async function rh(i){if(!i)for(let t=0;t80*e){o=l=i[0],h=c=i[1];for(var m=e;ml&&(l=d),f>c&&(c=f);p=Math.max(l-o,c-h),p=p!==0?32767/p:0}return $e(r,a,e,o,h,p,0),a}function Or(i,t,e,s,n){var r,a;if(n===ys(i,t,e,s)>0)for(r=t;r=t;r-=s)a=Sn(r,i[r],i[r+1],a);return a&&Mi(a,a.next)&&(Ye(a),a=a.next),a}function ae(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Mi(e,e.next)||K(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function $e(i,t,e,s,n,r,a){if(i){!a&&r&&mh(i,s,n,r);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,r?hh(i,s,n,r):oh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=lh(ae(i),t,e),$e(i,t,e,s,n,r,2)):a===2&&ch(i,t,e,s,n,r):$e(ae(i),t,e,s,n,r,1);break}}}}function oh(i){var t=i.prev,e=i,s=i.next;if(K(t,e,s)>=0)return!1;for(var n=t.x,r=e.x,a=s.x,o=t.y,h=e.y,l=s.y,c=nr?n>a?n:a:r>a?r:a,p=o>h?o>l?o:l:h>l?h:l,m=s.next;m!==t;){if(m.x>=c&&m.x<=f&&m.y>=d&&m.y<=p&&ue(n,o,r,h,a,l,m.x,m.y)&&K(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function hh(i,t,e,s){var n=i.prev,r=i,a=i.next;if(K(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,l=a.x,c=n.y,d=r.y,f=a.y,p=oh?o>l?o:l:h>l?h:l,x=c>d?c>f?c:f:d>f?d:f,w=ms(p,m,t,e,s),_=ms(y,x,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=w&&S&&S.z<=_;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=p&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=w;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=_;){if(S.x>=p&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function lh(i,t,e){var s=i;do{var n=s.prev,r=s.next.next;!Mi(n,r)&&Wr(n,s,s.next,r)&&Ve(n,r)&&Ve(r,n)&&(t.push(n.i/e|0),t.push(s.i/e|0),t.push(r.i/e|0),Ye(s),Ye(s.next),s=i=r),s=s.next}while(s!==i);return ae(s)}function ch(i,t,e,s,n,r){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&wh(a,o)){var h=Hr(a,o);a=ae(a,a.next),h=ae(h,h.next),$e(a,t,e,s,n,r,0),$e(h,t,e,s,n,r,0);return}o=o.next}a=a.next}while(a!==i)}function dh(i,t,e,s){var n=[],r,a,o,h,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){var o=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>r&&(r=o,a=e.x=e.x&&e.x>=l&&s!==e.x&&ue(na.x||e.x===a.x&&gh(a,e)))&&(a=e,d=f)),e=e.next;while(e!==h);return a}function gh(i,t){return K(i.prev,i,t.prev)<0&&K(t.next,i,i.next)<0}function mh(i,t,e,s){var n=i;do n.z===0&&(n.z=ms(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,xh(n)}function xh(i){var t,e,s,n,r,a,o,h,l=1;do{for(e=i,i=null,r=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)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(a>1);return i}function ms(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|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 yh(i){var t=i,e=i;do(t.x=(i-a)*(r-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(s-o)}function wh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!_h(i,t)&&(Ve(i,t)&&Ve(t,i)&&bh(i,t)&&(K(i.prev,i,t.prev)||K(i,t.prev,t))||Mi(i,t)&&K(i.prev,i,i.next)>0&&K(t.prev,t,t.next)>0)}function K(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mi(i,t){return i.x===t.x&&i.y===t.y}function Wr(i,t,e,s){var n=oi(K(i,t,e)),r=oi(K(i,t,s)),a=oi(K(e,s,i)),o=oi(K(e,s,t));return!!(n!==r&&a!==o||n===0&&ai(i,e,t)||r===0&&ai(i,s,t)||a===0&&ai(e,i,s)||o===0&&ai(e,t,s))}function ai(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 oi(i){return i>0?1:i<0?-1:0}function _h(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&&Wr(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ve(i,t){return K(i.prev,i,i.next)<0?K(i,t,i.next)>=0&&K(i,i.prev,t)>=0:K(i,t,i.prev)<0||K(i,i.next,t)<0}function bh(i,t){var e=i,s=!1,n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Hr(i,t){var e=new xs(i.i,i.x,i.y),s=new xs(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function Sn(i,t,e,s){var n=new xs(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ye(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 xs(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}Ai.deviation=function(i,t,e,s){var n=t&&t.length,r=n?t[0]*e:i.length,a=Math.abs(ys(i,0,r,e));if(n)for(var o=0,h=t.length;o0&&(s+=i[n-1].length,e.holes.push(s))}return e};var Sh=Rs.exports;const vh=Gs(Sh);var $r=(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))($r||{});class Ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,f=c.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 n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=s[a];this.renderPipes[a]=new r(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(!ah())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Vr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Xr=Vr,hi;function Ah(i){return hi!==void 0||(hi=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Xr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!J.get().getWebGLRenderingContext())return!1;let n=J.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const a=n.getExtension("WEBGL_lose_context");a&&a.loseContext()}return n=null,r}catch{return!1}})()),hi}let li;async function Mh(i={}){return li!==void 0||(li=await(async()=>{const t=J.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),li}const vn=["webgl","webgpu","canvas"];async function Ph(i){let t=[];i.preference?(t.push(i.preference),vn.forEach(r=>{r!==i.preference&&t.push(r)})):t=vn.slice();let e,s={};for(let r=0;r{const{WebGPURenderer:h}=await import("./WebGPURenderer-BBLdxcb9.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&Ah(i.failIfMajorPerformanceCaveat??Xr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await mi(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-B6t6FMSV.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 n=new e;return await n.init(s),n}const jr="8.4.0";class qr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,jr)}static destroy(){}}qr.extension=G.Application;class Gh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,jr)}destroy(){this._renderer=null}}Gh.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"initHook",priority:-10};const Kr=class ws{constructor(...t){this.stage=new tt,t[0]!==void 0&&N(W,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Ph(t),ws._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return N(W,"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=ws._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kr._plugins=[];let Zr=Kr;dt.handleByList(G.Application,Zr._plugins);dt.add(qr);class Qr extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return N(W,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return N(W,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return N(W,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return N(W,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){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 Jr=class _s{constructor(t,e,s,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=_s.defaultTextureSize,{gradientStops:e}=this,s=J.get().createCanvas();s.width=t,s.height=t;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,_s.defaultTextureSize,1);for(let y=0;y`${n.offset}-${n.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}`}};Jr.defaultTextureSize=256;let Xe=Jr;const Cn={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 Pi{constructor(t,e){this.uid=nt("fillPattern"),this.transform=new H,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Cn[e].addressModeU,t.source.style.addressModeV=Cn[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 kh=Ih,Ki={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Bh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Ih(i){var t=[];return i.replace(Bh,function(e,s,n){var r=s.toLowerCase();for(n=Rh(n),r=="m"&&n.length>2&&(t.push([s].concat(n.splice(0,2))),r="l",s=s=="m"?"l":"L");;){if(n.length==Ki[r])return n.unshift(s),t.push(n);if(n.length0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},s.push(n))}return t}class Fs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Fs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(n*n+r*r);return ha-o}getBounds(t){return t=t||new I,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 Ls{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Ls(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,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=s/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,f=e-this.y,p=d*d/(o*o)+f*f/(h*h),m=d*d/(l*l)+f*f/(c*c);return p>1&&m<=1}getBounds(t){return t=t||new I,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 Dh(i,t,e,s,n,r){const a=i-e,o=t-s,h=n-e,l=r-s,c=a*h+o*l,d=h*h+l*l;let f=-1;d!==0&&(f=c/d);let p,m;f<0?(p=e,m=s):f>1?(p=n,m=r):(p=e+f*h,m=s+f*l);const y=i-p,x=t-m;return y*y+x*x}class We{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;ne!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const n=s/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hn?l:n,r=ca?c:a}return t.x=s,t.width=n-s,t.y=r,t.height=a-r,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 ci=(i,t,e,s,n,r)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Ds{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t=t||new I,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ds(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 n=t-(this.x+s),r=e-(this.y+s);const a=s*s;if(n*n+r*r<=a||(n=t-(this.x+this.width-s),n*n+r*r<=a)||(r=e-(this.y+this.height-s),n*n+r*r<=a)||(n=t-(this.x+s),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,s){const{x:n,y:r,width:a,height:o,radius:h}=this,l=s/2,c=n+h,d=r+h,f=a-h*2,p=o-h*2,m=n+a,y=r+o;return(t>=n-l&&t<=n+l||t>=m-l&&t<=m+l)&&e>=d&&e<=d+p||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+f?!0:tm-h&&em-h&&e>y-h&&ci(t,e,m-h,y-h,h,l)||ty-h&&ci(t,e,c,y-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const zh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Uh(i){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return ea[e]||Wh(i,t,e)}let Zi=0;function Wh(i,t,e){const s={};let n=0;Zi||(Zi=ta());for(let a=0;a0){const a=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const Hh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $h=(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))($h||{});function Mn(i,t){return t.alphaMode==="no-premultiply-alpha"&&Hh[i]||i}class Vh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?ia[--bs]:new Yh}function Gn(i){ia[bs++]=i}let Re=0;const sa=class gi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],gi.defaultOptions.maxTextures=gi.defaultOptions.maxTextures??ta(),t={...gi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Tn(s*4),this.indexBuffer=new Uint16Array(n),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,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,f="startBatch";const p=this.maxTextures;for(let m=this.elementStart;m=p||b)&&(this._finishBatch(s,d,c-d,n,a,t,f),f="renderBatch",d=c,a=_,s=Pn(),n=s.textures,n.clear(),++Re),y._textureId=w._textureBindLocation=n.count,n.ids[w.uid]=n.count,n.textures[n.count++]=w,y._batch=s,c+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(l,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,l,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,c-d,n,a,t,f),d=c,++Re),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=s,++Re,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 Tn(e);An(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 n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r(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))(it||{});class Vt extends gt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("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:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.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 n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=p),m>h&&(h=m),pe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kh=new Float32Array(1),Zh=new Uint32Array(1);class Qh extends ra{constructor(){const e=new Vt({data:Kh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new Vt({data:Zh,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:s})}}function kn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${s} placement hook does not exist in shader`)}}const Jh=/\{\{(.*?)\}\}/g;function Bn(i){var s;const t={};return(((s=i.match(Jh))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function In(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function En(i,t,e=!1){const s=[];In(t,s),i.forEach(o=>{o.header&&In(o.header,s)});const n=s;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${r} `),a}function Rn(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function tl(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function el(i){const t=/@.*?\s+/g;return i.replace(t,"")}function il(i,t){const e=[];Rn(t,e),i.forEach(h=>{h.header&&Rn(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`, `),r=e.sort().map(h=>` var ${el(h)};`).join(` `),a=`return VSOutput( ${e.sort().map(h=>` ${tl(h)}`).join(`, `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",` ${n} `),o=o.replace("{{start}}",` ${r} `),o=o.replace("{{return}}",` ${a} `),o}function Fn(i,t){let e=i;for(const s in t){const n=t[s];n.join(` `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${n.join(` `)} //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),Qi=new Map;let sl=0;function nl({template:i,bits:t}){const e=aa(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=al(i,t);return $t[e]=oa(s,n,t),$t[e]}function rl({template:i,bits:t}){const e=aa(i,t);return $t[e]||($t[e]=oa(i.vertex,i.fragment,t)),$t[e]}function al(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let n=En(e,i.vertex,!0);n=il(e,n);const r=En(s,i.fragment,!0);return{vertex:n,fragment:r}}function aa(i,t){return t.map(e=>(Qi.has(e)||Qi.set(e,sl++),Qi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function oa(i,t,e){const s=Bn(i),n=Bn(t);return e.forEach(r=>{kn(r.vertex,s,r.name),kn(r.fragment,n,r.name)}),{vertex:Fn(i,s),fragment:Fn(t,n)}}const ol=` @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}} }; `,hl=` @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; }; `,ll=` 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}} } `,cl=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,dl={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},ul={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function fl({bits:i,name:t}){const e=nl({template:{fragment:hl,vertex:ol},bits:[dl,...i]});return Ti.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function pl({bits:i,name:t}){return new Lr({name:t,...rl({template:{vertex:ll,fragment:cl},bits:[ul,...i]})})}const gl={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},ml={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Ji={};function xl(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 yl(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; ${xl(i)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${yl(i)} `}}),Ji[i]}const ts={};function _l(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; } `}},vl={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; } `}},Ln={};function Cl(i){let t=Ln[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s>16&255,s=i>>8&255,n=i&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=s*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const kl=new H;class da{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?Gl(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)||kl}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 je={extension:{type:G.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,n=r=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=i,A=S.width/2,F=S.height/2;e=S.x+A,s=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(A,F))),n=A-a,r=F-o}if(!(a>=0&&o>=0&&n>=0&&r>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,t;let c=0,d=h*4+(n?2:0)+2,f=d,p=l,m=n+a,y=r,x=e+m,w=e-m,_=s+y;if(t[c++]=x,t[c++]=_,t[--d]=_,t[--d]=w,r){const S=s-y;t[f++]=w,t[f++]=S,t[--p]=S,t[--p]=x}for(let S=1;S0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Bl={...je,extension:{...je.extension,name:"ellipse"}},Il={...je,extension:{...je.extension,name:"roundedRectangle"}},El=1e-4,zn=1e-4;function Rl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];sd&&(d+=Math.PI*2);let f=c;const p=d-c,m=Math.abs(p),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,w=p/x;if(f+=w,o){a.push(i,t),a.push(e,s);for(let _=1,b=f;_=0&&(c.join==="round"?_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4:_+=2,x.push(v-X*D,T-et*D),x.push(v+X*B,T+et*B));continue}const Qs=(-L+P)*(-E+T)-(-L+v)*(-E+k),Js=(-X+Z)*(-et+T)-(-X+v)*(-et+Rt),Je=(Wt*Js-Ge*Qs)/Qe,ti=(ke*Qs-Pe*Js)/Qe,Ii=(Je-v)*(Je-v)+(ti-T)*(ti-T),jt=v+(Je-v)*B,qt=T+(ti-T)*B,Kt=v-(Je-v)*D,Zt=T-(ti-T)*D,Da=Math.min(Wt*Wt+Pe*Pe,Ge*Ge+ke*ke),tn=Be?B:D,za=Da+tn*tn*A;Ii<=za?c.join==="bevel"||Ii/A>F?(Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),x.push(v-X*B,T-et*B),x.push(Kt,Zt)),_+=2):c.join==="round"?Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+4,x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4,x.push(v-X*B,T-et*B),x.push(Kt,Zt)):(x.push(jt,qt),x.push(Kt,Zt)):(x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),c.join==="round"?Be?_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+2:_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+2:c.join==="miter"&&Ii/A<=F&&(Be?(x.push(Kt,Zt),x.push(Kt,Zt)):(x.push(jt,qt),x.push(jt,qt)),_+=2),x.push(v-X*B,T-et*B),x.push(v+X*D,T+et*D),_+=2)}P=i[(w-2)*2],k=i[(w-2)*2+1],v=i[(w-1)*2],T=i[(w-1)*2+1],L=-(k-T),E=P-v,bt=Math.sqrt(L*L+E*E),L/=bt,E/=bt,L*=S,E*=S,x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),m||(c.cap==="round"?_+=Qt(v-L*(B-D)*.5,T-E*(B-D)*.5,v-L*B,T-E*B,v+L*D,T+E*D,x,!1)+2:c.cap==="square"&&(_+=Un(v,T,L,E,B,D,!1,x)));const La=zn*zn;for(let V=b;V<_+b-2;++V)P=x[V*2],k=x[V*2+1],v=x[(V+1)*2],T=x[(V+1)*2+1],Z=x[(V+2)*2],Rt=x[(V+2)*2+1],!(Math.abs(P*(T-Rt)+v*(Rt-k)+Z*(k-T))=0&&a>=0&&(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+a,t[6]=s,t[7]=n+a),t},triangulate(i,t,e,s,n,r){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;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Ul={extension:{type:G.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,n,r){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;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Gi={};dt.handleByMap(G.ShapeBuilder,Gi);dt.add(zl,Dl,Ul,je,Bl,Il);const Nl=new I;function Ol(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 n=0;n{const p=h.length,m=a.length/2,y=[],x=Gi[c.type];if(x.build(c,y),d&&ca(y,d),s){const S=c.closePath??!0;Fl(y,t,!1,S,a,2,m,h)}else if(e&&l===f){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],A=y.slice();Hl(e.shapePath).forEach(P=>{S.push(A.length/2),A.push(...P)}),ua(A,S,a,2,m,h,p)}else x.triangulate(y,a,2,m,h,p);const w=o.length/2,_=t.texture;if(_!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Ml(a,2,m,o,w,2,a.length/2-m,S))}else Pl(o,w,2,a.length/2-m);const b=zt.get(da);b.indexOffset=p,b.indexSize=h.length-p,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=_,b.geometryData=r,n.push(b)})}function Hl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s{zt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};zs.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"graphicsContext"};zs.defaultOptions={bezierSmoothness:.5};let fa=zs;const Yl=8,di=11920929e-14,Xl=1;function pa(i,t,e,s,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??fa.defaultOptions.bezierSmoothness));let f=(Xl-d)/1;return f*=f,jl(t,e,s,n,r,a,o,h,i,f),i}function jl(i,t,e,s,n,r,a,o,h,l){vs(i,t,e,s,n,r,a,o,h,l,0),h.push(a,o)}function vs(i,t,e,s,n,r,a,o,h,l,c){if(c>Yl)return;const d=(i+e)/2,f=(t+s)/2,p=(e+n)/2,m=(s+r)/2,y=(n+a)/2,x=(r+o)/2,w=(d+p)/2,_=(f+m)/2,b=(p+y)/2,S=(m+x)/2,A=(w+b)/2,F=(_+S)/2;if(c>0){let P=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*P),T=Math.abs((n-a)*k-(r-o)*P);if(v>di&&T>di){if((v+T)*(v+T)<=l*(P*P+k*k)){h.push(A,F);return}}else if(v>di){if(v*v<=l*(P*P+k*k)){h.push(A,F);return}}else if(T>di){if(T*T<=l*(P*P+k*k)){h.push(A,F);return}}else if(P=A-(i+a)/2,k=F-(t+o)/2,P*P+k*k<=l){h.push(A,F);return}}vs(i,t,d,f,w,_,A,F,h,l,c+1),vs(A,F,b,S,y,x,a,o,h,l,c+1)}const ql=8,Kl=11920929e-14,Zl=1;function Ql(i,t,e,s,n,r,a,o){const l=Math.min(.99,Math.max(0,o??fa.defaultOptions.bezierSmoothness));let c=(Zl-l)/1;return c*=c,Jl(t,e,s,n,r,a,i,c),i}function Jl(i,t,e,s,n,r,a,o){Cs(a,i,t,e,s,n,r,o,0),a.push(n,r)}function Cs(i,t,e,s,n,r,a,o,h){if(h>ql)return;const l=(t+s)/2,c=(e+n)/2,d=(s+r)/2,f=(n+a)/2,p=(l+d)/2,m=(c+f)/2;let y=r-t,x=a-e;const w=Math.abs((s-r)*x-(n-a)*y);if(w>Kl){if(w*w<=o*(y*y+x*x)){i.push(p,m);return}}else if(y=p-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){i.push(p,m);return}Cs(i,t,e,l,c,p,m,o,h+1),Cs(i,p,m,d,f,r,a,o,h+1)}function ga(i,t,e,s,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(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 l=h/o,c=n;l*=a?-1:1;for(let d=0;dd*h)}const He=Math.PI*2,es={centerX:0,centerY:0,ang1:0,ang2:0},is=({x:i,y:t},e,s,n,r,a,o,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+a,h.y=c+o,h};function ec(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const On=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},ic=(i,t,e,s,n,r,a,o,h,l,c,d,f)=>{const p=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let w=p*m-p*x-m*y;w<0&&(w=0),w/=p*x+m*y,w=Math.sqrt(w)*(a===o?-1:1);const _=w*n/r*d,b=w*-r/n*c,S=l*_-h*b+(i+e)/2,A=h*_+l*b+(t+s)/2,F=(c-_)/n,P=(d-b)/r,k=(-c-_)/n,v=(-d-b)/r,T=On(1,0,F,P);let Z=On(F,P,k,v);o===0&&Z>0&&(Z-=He),o===1&&Z<0&&(Z+=He),f.centerX=S,f.centerY=A,f.ang1=T,f.ang2=Z};function sc(i,t,e,s,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*He/360),d=Math.cos(o*He/360),f=d*(t-s)/2+c*(e-n)/2,p=-c*(t-s)/2+d*(e-n)/2;if(f===0&&p===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(f,2)/Math.pow(r,2)+Math.pow(p,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),ic(t,e,s,n,r,a,h,l,c,d,f,p,es);let{ang1:y,ang2:x}=es;const{centerX:w,centerY:_}=es;let b=Math.abs(x)/(He/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let A=i[i.length-2],F=i[i.length-1];const P={x:0,y:0};for(let k=0;k{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,f=l/c;return{len:c,nx:d,ny:f}},n=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a0&&(p=-1,m=!0);const y=f/2;let x,w=Math.abs(Math.cos(y)*h/Math.sin(y));w>Math.min(c.len/2,d.len/2)?(w=Math.min(c.len/2,d.len/2),x=Math.abs(w*Math.sin(y)/Math.cos(y))):x=h;const _=o.x+d.nx*w+-d.ny*x*p,b=o.y+d.ny*w+d.nx*x*p,S=Math.atan2(c.ny,c.nx)+Math.PI/2*p,A=Math.atan2(d.ny,d.nx)-Math.PI/2*p;a===0&&i.moveTo(_+Math.cos(S)*x,b+Math.sin(S)*x),i.arc(_,b,x,S,A,m),r=o}}function rc(i,t,e,s){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,l)=>({x:o.x+(h.x-o.x)*l,y:o.y+(h.y-o.y)*l}),a=t.length;for(let o=0;o=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,a)}ellipse(t,e,s,n,r){return this.drawShape(new Ls(t,e,s,n),r),this}roundRect(t,e,s,n,r,a){return this.drawShape(new Ds(t,e,s,n,r),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 We,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 We,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=s;s=r.a*s+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(s,n)}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(_,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!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=ne({...this._originalFill},yt.defaultFillStyle)})),this._fill=ne(t===0?"black":t,yt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...yt.defaultStrokeStyle,...t},()=>{this._stroke=bi({...this._originalStroke},yt.defaultStrokeStyle)})),this._stroke=bi(t,yt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=pc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=de.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new de({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,n,r,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),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.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,n,r)=>(s[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof Xe||t instanceof Pi)}};Ns.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ns.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 O=Ns;function xc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=O.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){N(W,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Y.isColorLike(e))s.color=e;else if(e instanceof Xe||e instanceof Pi)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)){N(W,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=O.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Xe(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Y.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);s.addColorStop(o,r)}),i.fill={fill:s}}}class yc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=J.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=nn(t),e=nn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const jn=new yc,wc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ts(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 n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!wc.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const ss={willReadFrequently:!0},At=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=J.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,n=e.wordWrap){var _;const r=`${t}:${e.styleKey}`;if(M._measurementCache[r])return M._measurementCache[r];const a=Ts(e),o=M.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=M.__context;h.font=a;const c=(n?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let f=0;for(let b=0;b0&&(n?r-=e:r+=(M.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,s=M._canvas){const n=s.getContext("2d",ss);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=M._collapseSpaces(c),f=M._collapseNewlines(c);let p=!d;const m=e.wordWrapWidth+l,y=M._tokenize(t);for(let x=0;xm)if(a!==""&&(o+=M._addLine(a),a="",r=0),M.canBreakWords(w,e.breakWords)){const b=M.wordWrapSplit(w);for(let S=0;Sm&&(o+=M._addLine(a),p=!1,a="",r=0),a+=A,r+=k}}else{a.length>0&&(o+=M._addLine(a),a="",r=0);const b=x===y.length-1;o+=M._addLine(w,!b),p=!1,a="",r=0}else _+r>m&&(p=!1,o+=M._addLine(a),a="",r=0),(a.length>0||!M.isBreakingSpace(w)||p)&&(a+=w,r+=_)}return o+=M._addLine(a,!1),o}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,n){let r=s[t];return typeof r!="number"&&(r=M._measureText(t,e,n)+e,s[t]=r),r}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(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let n=0;n{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]})();At.experimentalLetterSpacing=!1;At._fonts={};At._newlines=[10,13];At._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];At._measurementCache={};let As=At;function qn(i,t){if(i.texture===z.WHITE&&!i.fill)return Y.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Pi){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(n),s}else if(i.fill instanceof Xe){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{s.addColorStop(n.offset,Y.shared.setValue(n.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(H.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return st("FillStyle not recognised",i),"red"}function ya(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e!this._currentChars.includes(w)).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:n,context:r}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,f=o.fontStyle==="italic"?2:1;let p=0,m=!1;for(let w=0;wthis._textureSize&&(l+=p,p=P,h=0,l+p>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const k=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,T=a.height*c,Z=new I(h/v*a.width,l/T*a.height,F/v*a.width,P/T*a.height);this.chars[_].texture=new z({source:a,frame:Z}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return N(W,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let n=0;n{const y=r.width;for(let x=0;x{let m=r.chars.length-1;if(s){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,f=t.letterSpacing*d,p=t.wordWrapWidth*d;for(let m=0;mp?(c(),l(h),x||r.charPositions.push(0)):(h.start=r.width,l(h),x||r.charPositions.push(0)),y==="\r"||y===` `)r.width!==0&&c();else if(!x){const A=w.xAdvance+(w.kerning[a]||0)+f;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=w.kerning[a]||0,A=w.xAdvance+S+f;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=A}a=y}return c(),t.align==="center"?bc(n):t.align==="right"?Sc(n):t.align==="justify"&&vc(n),n}function bc(i){for(let t=0;t50&&st("BitmapText",`You have dynamically created ${ui} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ui--,q.remove(s)}),q.set(s,o)}const r=q.get(s);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e);return _c([...t],e,n,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var l,c,d,f;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(c=t[2])==null?void 0:c.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(f=t[2])==null?void 0:f.skipKerning},N(W,"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 n=e.style,r=n instanceof O?n:new O(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new Kn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ya(e.chars);return o.ensureCharacters(h.join("")),q.set(`${s}-bitmap`,o),o.once("destroy",()=>q.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&(q.remove(e),s.destroy())}}const Zn=new Cc;class ba extends Qr{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=s[a.page],l=new I(a.x+o.x,a.y+o.y,a.width,a.height),c=new z({source:h,frame:l});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?Qn.test(J.get().parseXML(i)):!1},parse(i){return Qn.parse(J.get().parseXML(i))}},Tc=[".xml",".fnt"],Ac={extension:{type:G.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof ba,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Mc={extension:{type:G.LoadParser,priority:Xt.Normal},name:"loadBitmapFont",test(i){return Tc.includes(xt.extname(i).toLowerCase())},async testParse(i){return ns.test(i)||Jn.test(i)},async parse(i,t,e){const s=ns.test(i)?ns.parse(i):Jn.parse(i),{src:n}=t,{pages:r}=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 ba({data:s,textures:l},n)},async load(i,t){return await(await J.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 z),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function Sa(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 kc={extension:{type:G.DetectionParser,priority:1},test:async()=>Sa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},tr=["png","jpg","jpeg"],Bc={extension:{type:G.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...tr],remove:async i=>i.filter(t=>!tr.includes(t))},Ic="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Os(i){return Ic?!1:document.createElement("video").canPlayType(i)!==""}const Ec={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Rc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Fc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Lc={extension:{type:G.DetectionParser,priority:0},test:async()=>Sa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Dc{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 n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h({alias:[l],src:l,data:{}})),o=a.length,h=a.map(async l=>{const c=xt.toAbsolute(l.src);if(!n[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),n[l.src]=await this.promiseCache[c].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[c],delete n[l.src],new Error(`[Loader.load] Failed to load ${c}. ${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=Ct(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=xt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const l=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,l,n,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]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ae(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 Me(i,t){const e=i.split("?")[0],s=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const zc=".json",Uc="application/json",Nc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadJson",test(i){return Ae(i,Uc)||Me(i,zc)},async load(i){return await(await J.get().fetch(i)).json()}},Oc=".txt",Wc="text/plain",Hc={name:"loadTxt",extension:{type:G.LoadParser,priority:Xt.Low,name:"loadTxt"},test(i){return Ae(i,Wc)||Me(i,Oc)},async load(i){return await(await J.get().fetch(i)).text()}},$c=["normal","bold","100","200","300","400","500","600","700","800","900"],Vc=[".ttf",".otf",".woff",".woff2"],Yc=["font/ttf","font/otf","font/woff","font/woff2"],Xc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jc(i){const t=xt.extname(i),n=xt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match(Xc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const qc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kc(i){return qc.test(i)?i:encodeURI(i)}const Zc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadWebFont",test(i){return Ae(i,Yc)||Me(i,Vc)},async load(i,t){var s,n,r;const e=J.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??jc(i),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>$c.includes(c)))??["normal"],l=t.data??{};for(let c=0;c{q.remove(t.family),J.get().getFontFaceSet().delete(t)})}};function Ws(i,t=1){var s;const e=(s=Te.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Hs(i,t,e){i.label=e,i._sourceOrigin=e;const s=new z({source:i,label:e}),n=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(st("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const Qc=".svg",Jc="image/svg+xml",td={extension:{type:G.LoadParser,priority:Xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Ae(i,Jc)||Me(i,Qc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?id(i):ed(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function ed(i,t,e,s){var x,w,_;const r=await(await J.get().fetch(i)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Ws(i),d=((w=t.data)==null?void 0:w.width)??o.width,f=((_=t.data)==null?void 0:_.height)??o.height;h.width=d*c,h.height=f*c,l.drawImage(o,0,0,d*c,f*c);const{parseAsGraphicsContext:p,...m}=t.data,y=new Ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Hs(y,e,i)}async function id(i){const e=await(await J.get().fetch(i)).text(),s=new yt;return s.svg(e),s}const sd=`(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 fe=null,Ms=class{constructor(){fe||(fe=URL.createObjectURL(new Blob([sd],{type:"application/javascript"}))),this.worker=new Worker(fe)}};Ms.revokeObjectURL=function(){fe&&(URL.revokeObjectURL(fe),fe=null)};const nd=`(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 pe=null;class va{constructor(){pe||(pe=URL.createObjectURL(new Blob([nd],{type:"application/javascript"}))),this.worker=new Worker(pe)}}va.revokeObjectURL=function(){pe&&(URL.revokeObjectURL(pe),pe=null)};let er=0,rs;class rd{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 Ms;e.addEventListener("message",s=>{e.terminate(),Ms.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(){rs===void 0&&(rs=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((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});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[er]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:er++,id:s})}}const ir=new rd,ad=[".jpeg",".jpg",".png",".webp",".avif"],od=["image/jpeg","image/png","image/webp","image/avif"];async function hd(i,t){var n;const e=await J.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Ca={name:"loadTextures",extension:{type:G.LoadParser,priority:Xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Ae(i,od)||Me(i,ad)},async load(i,t,e){var r;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ir.isImageBitmapSupported()?s=await ir.loadImageBitmap(i,t):s=await hd(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 n=new Ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ws(i),...t.data});return Hs(n,e,i)},unload(i){i.destroy(!0)}},Ta=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],ld=Ta.map(i=>`video/${i.substring(1)}`);function cd(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=ud(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function dd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(a){r(),e(a)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function ud(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 fd={name:"loadVideo",extension:{type:G.LoadParser,name:"loadVideo"},test(i){const t=Ae(i,ld),e=Me(i,Ta);return t||e},async load(i,t,e){var h,l;const s={...fi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ws(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Pr(),...t.data},n=document.createElement("video"),r={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(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),s.muted===!0&&(n.muted=!0),cd(n,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 c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=fi.MIME_TYPES[c]||`video/${c}`}return a.src=i,o&&(a.type=o),new Promise(c=>{const d=async()=>{const f=new fi({...s,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await dd(n),c(Hs(f,e,i))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(i){i.destroy(!0)}},Aa={extension:{type:G.ResolveParser,name:"resolveTexture"},test:Ca.test,parse:i=>{var t;return{resolution:parseFloat(((t=Te.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},pd={extension:{type:G.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Te.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Aa.parse};class gd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Te,this.loader=new Dc,this.cache=q,this._backgroundLoader=new Pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){st("[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=((r=t.texturePreference)==null?void 0:r.resolution)??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,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=wi(t),n=Ct(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return s?a[n[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 n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(d=>{const f=n[d];return h+=Object.keys(f).length,this._mapLoadToResolve(f,l).then(p=>{r[d]=p})});return await Promise.all(c),s?r[t[0]]:r}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 q.get(t);const e={};for(let s=0;s{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(l=>{r[l]=o}),q.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=Ct(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Ct(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{q.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,n)=>e.indexOf(s)===n),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 Ne=new gd;dt.handleByList(G.LoadParser,Ne.loader.parsers).handleByList(G.ResolveParser,Ne.resolver.parsers).handleByList(G.CacheParser,Ne.cache.parsers).handleByList(G.DetectionParser,Ne.detections);dt.add(Gc,Bc,kc,Lc,Ec,Rc,Fc,Nc,Hc,Zc,td,Ca,fd,Mc,Ac,Aa,pd);const sr={loader:G.LoadParser,resolver:G.ResolveParser,cache:G.CacheParser,detection:G.DetectionParser};dt.handle(G.Asset,i=>{const t=i.ref;Object.entries(sr).filter(([e])=>!!t[e]).forEach(([e,s])=>dt.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(sr).filter(e=>!!t[e]).forEach(e=>dt.remove(t[e]))});class Tt extends vi{constructor(t){t instanceof yt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new yt,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 Tt(this._context.clone()):(this._ownedContext=null,new Tt(this._context))}lineStyle(t,e,s){N(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){N(W,"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(){N(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==yt.defaultStrokeStyle.width||t.color!==yt.defaultStrokeStyle.color||t.alpha!==yt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return N(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return N(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return N(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return N(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return N(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return N(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ma=class Pa extends ra{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(N(W,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Pa.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Vt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),l=new Vt({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:it.INDEX|it.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:l,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}};Ma.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let md=Ma;class we extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:n,...r}=e,[a]=s;super({...r,texture:a instanceof z?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=n??!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&&(It.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(It.shared.add(this.update,this,yi.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,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=s/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&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?(It.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(It.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xd extends vi{constructor(t,e){const{text:s,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=l??!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,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+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 yd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(N(W,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class U extends xd{constructor(...t){const e=yd(t,"Text");super(e,O),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=As.measureText(this._text,this._style),{width:n,height:r}=s;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ga=class ka extends md{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(N(W,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...ka.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=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,l=this.height/o;for(let d=0;de?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(s,r);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()}};Ba.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ce=Ba;const Ea=class Ra extends vi{constructor(t){var d,f,p,m;t instanceof z&&(t={texture:t});const{width:e,height:s,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:l,...c}=t;super({label:"NineSliceSprite",...c}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ce.defaultOptions.leftWidth,this._topHeight=a??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.top)??ce.defaultOptions.topHeight,this._rightWidth=r??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.right)??ce.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ce.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ce.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??ce.defaultOptions.height,this.allowChildren=!1,this.texture=h??Ra.defaultOptions.texture,this.roundPixels=l??!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=z.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}};Ea.defaultOptions={texture:z.EMPTY};let _t=Ea;dt.add(Ha,$a);const R=class R{static async Load(t){return this.text.text=`Loading asset: ${t} (${this.counter}/102)`,this.counter++,await Ne.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 U({text:"Loading textures. This might take a while.",style:new O({fill:3355443,fontSize:50})});t.x=u.app.canvas.width/2,t.y=u.app.canvas.height/2,t.anchor.set(.5,.5),u.app.stage.addChild(t),this.text=new U({text:"",style:new O({fill:3355443,fontSize:50})}),this.text.x=u.app.canvas.width/2,this.text.y=u.app.canvas.height/2+50,this.text.anchor.set(.5,.5),u.app.stage.addChild(this.text),await Promise.all([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/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/background_02.png").then(e=>this.FrameTowerTab=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/frame_yellow.png").then(e=>this.YellowBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=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/fastforward.png").then(e=>this.FastForwardIconTexture=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(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Dt||{}),qe=(i=>(i[i.Basic=0]="Basic",i[i.Circle=1]="Circle",i[i.Electric=2]="Electric",i[i.Buff=3]="Buff",i[i.Strong=4]="Strong",i[i.Rail=5]="Rail",i[i.Trapper=6]="Trapper",i[i.Debuff=7]="Debuff",i))(qe||{});const Q=class Q{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;Q.NotificationManager.Notify("Loaded.","danger");let e=C.Towers[qe.Electric];Q.TowerManager.ToggleChoosingTowerLocation("RESET"),Q.TowerManager.PlaceTower(e,6,10,e.behaviour,!0),Q.GameScene.MissionStats.earnGold(2e3);for(let s=0;s<24;s++)this.GameScene.MissionStats.giveGem(new Ps(s%6),!0)}};g(Q,"app"),g(Q,"GameMaster"),g(Q,"Grid"),g(Q,"WaveManager"),g(Q,"TowerManager"),g(Q,"AnimationManager"),g(Q,"NotificationManager"),g(Q,"DebrisManager"),g(Q,"GameScene"),g(Q,"latestCommit"),g(Q,"latestGemId",0),g(Q,"GridCellSize",64),g(Q,"GridColumns",25),g(Q,"GridRows",17),g(Q,"MouseX",0),g(Q,"MouseY",0);let u=Q;class _d{constructor(){g(this,"currentScene");u.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),u.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),u.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class Mt{constructor(t){g(this,"name",this.constructor.name);g(this,"_container",new tt);g(this,"_events",new gt);g(this,"enabled",!0);g(this,"bb",new I);u.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 ot=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(ot||{});class ut extends Mt{constructor(e,s,n,r=!0){super(!0);g(this,"caption");g(this,"bounds");g(this,"buttonTexture");g(this,"buttonSprite");g(this,"buttonText");g(this,"buttonIcon");n==0&&(this.buttonTexture=C.Button01Texture),n==1&&(this.buttonTexture=C.Button02Texture),this.caption=s,this.enabled=r,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 _t({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 U({text:this.caption,style:new O({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}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class ki{constructor(){g(this,"stage",new tt);g(this,"gui",[]);g(this,"_events",new gt);u.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(C.MainBackground);t.width=u.app.canvas.width,t.height=u.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class bd extends ki{constructor(){super(...arguments);g(this,"currentImg",1);g(this,"sprite")}init(){let e=[null,C.Tutorial01,C.Tutorial02,C.Tutorial03,C.Tutorial04,C.Tutorial05];this.sprite=new $({texture:C.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let s=new ut(new I(250,this.sprite.height+160,120,60),"Back",ot.Button01);s.container.alpha=0,s.onClick=()=>{s.container.alpha==0||this.currentImg==1||(this.currentImg--,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.sprite.texture=e[this.currentImg],this.currentImg==1&&(s.container.alpha=0))};let n=new ut(new I(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ot.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(s.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ut(new I(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ot.Button01);r.onClick=a=>{u.GameMaster.changeScene(new qs)}}}class Pt{constructor(){g(this,"name",this.constructor.name);g(this,"_container",new tt);g(this,"bb",new I);g(this,"_events",new gt)}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.container==null?null:(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 re=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(re||{}),lt=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.GiveEffect="giveEffect",i.Escaped="escaped",i.Moved="moved",i))(lt||{}),Ke=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Ke||{}),_e=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(_e||{}),$s=(i=>(i.GemGivenEvent="gemGivenEvent",i))($s||{}),Vs=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))(Vs||{}),vt=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i.CircleTowerBehaviour="CircleTowerBehaviour",i.ElectricTowerBehaviour="ElectricTowerBehaviour",i.BuffTowerBehaviour="BuffTowerBehaviour",i.StrongTowerBehaviour="StrongTowerBehaviour",i.RailTowerBehaviour="RailTowerBehaviour",i.TrapperTowerBehaviour="TrapperTowerBehaviour",i.DebuffTowerBehaviour="DebuffTowerBehaviour",i))(vt||{});class Sd{constructor(){g(this,"isPlacingTower",!1);g(this,"canPlaceTowers",!0);g(this,"selectedTower",null);g(this,"previewSprite",new $({parent:u.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));g(this,"towers",[]);u.TowerManager=this,u.GameScene.events.on(Ke.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*u.GridCellSize,this.previewSprite.y=t.row*u.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),u.GameScene.events.on(Ke.CellMouseLeave,t=>{this.previewSprite.texture=null,u.Grid.rangePreview.clear()})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,u.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(u.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):C.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 u.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(n=>{n.row==t&&n.column==e&&(s=n)}),s}PlaceTower(t,e,s,n,r){const a=t.texture;if(!u.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return u.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Path&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Restricted){r||u.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Ld(e,s,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,u.GameScene.events.emit(_e.TowerPlacedEvent,t.name,e,s)}else u.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn")}update(t){this.towers.forEach((e,s)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);u.GameScene.events.emit(_e.TowerSoldEvent,e.definition.name,e.row,e.column),u.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(s,1)}else e.update(t)})}}function ct(i,t,e,s){const n=e-i,r=s-t;return Math.atan2(r,n)}class Ys extends Pt{constructor(e,s,n,r,a,o,h,l,c){super();g(this,"deleteMe",!1);g(this,"sprite");g(this,"x");g(this,"y");g(this,"angle");g(this,"speed");g(this,"damage");g(this,"pierce",1);g(this,"timeToLive");g(this,"parent");g(this,"gemResistanceModifications");g(this,"collidedCreepIDs",[]);this.x=e,this.y=s,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new we({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),u.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)&&!this.collidedCreepIDs.find(r=>s.id==r.id)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}}),this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e,s){u.GameScene.events.emit(lt.TakenDamage,e.id,s.damage,s.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let s=this.copyContainerToBB(),n=e.copyContainerToBB();return s.getBounds().intersects(n.getBounds())}}class vd extends Ys{constructor(e,s,n,r,a,o,h,l,c){super(e,s,n,r,a,o,h,l,c);g(this,"visuals",[]);g(this,"counter",0);this.pierce=1e3,this.timeToLive=2e3}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(super.update(e),this.counter==2){this.counter=0;let s=new $({x:this.x,y:this.y,rotation:this.angle,texture:this.sprite.texture,scale:.25});s.anchor.set(.5,.5),this.visuals.push(s),this.visuals.forEach(n=>{if(n.scale==null)return n.destroy();n.width&&n.height&&n.alpha&&(n.width-=4,n.height-=4,n.alpha-=.1,(n.width<=0||n.height<=0||n.alpha<=0)&&n.destroy())}),u.GameScene.stage.addChild(s)}else this.counter++}}class Cd extends Ys{constructor(e,s,n,r,a,o,h,l,c,d,f){super(e,s,n,r,h,l,c,d,f);g(this,"visuals",[]);g(this,"counter",0);g(this,"goalX");g(this,"goalY");this.sprite.scale=.5,this.sprite.rotation=Math.random()*Math.PI*2,this.goalX=a,this.goalY=o}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();be(this.x,this.y,this.goalX,this.goalY)<25?(this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}})):(this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y)}}}class Td extends Pt{constructor(e,s){super();g(this,"deleteMe",!1);g(this,"c");g(this,"oc");g(this,"Lightning");this.c=e,this.oc=s;let n=ct(e.x,e.y,s.x,s.y);this.Lightning=new we({textures:C.SpecialLightning,x:e.x,y:e.y,width:be(this.c.x,this.c.y,this.oc.x,this.oc.y),height:64,scale:1.2,rotation:n}),this.Lightning.anchor.set(0,.5),this.Lightning.play(),u.GameMaster.currentScene.stage.addChild(this.Lightning),u.DebrisManager.CreateDebris(this,30)}destroy(){this.deleteMe=!0,this.container.destroy(),this.Lightning.destroy()}update(){this.deleteMe||(this.Lightning.x=this.c.x,this.Lightning.y=this.c.y,this.Lightning.width=be(this.c.x,this.c.y,this.oc.x,this.oc.y))}}var Xs=(i=>(i.MovingBackwards="MovingBackwards",i.DebuffTowerDebuff="DebuffTowerDebuff",i))(Xs||{});class Ad{constructor(t,e){g(this,"effectEnum");g(this,"durationInMS");g(this,"ticks",0);this.effectEnum=t,this.durationInMS=e}}class Md extends Pt{constructor(e,s,n){super();g(this,"id");g(this,"creepType");g(this,"sprite");g(this,"path");g(this,"stats");g(this,"pathIndex",0);g(this,"speed");g(this,"direction",1);g(this,"healthBarGraphics",new Tt);g(this,"healthBarWidth",50);g(this,"effects",[]);g(this,"health");g(this,"maxHealth");g(this,"escaped",!1);g(this,"died",!1);g(this,"x");g(this,"y");g(this,"dead",!1);this.creepType=e,this.stats=structuredClone(C.Creeps[this.creepType].stats),this.sprite=new we(C.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.tint=C.Creeps[this.creepType].tint,this.sprite.play(),this.id=n,this.container.x=-70,this.container.y=-50,this.sprite.width=u.GridCellSize,this.sprite.height=u.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][0]*u.GridCellSize+u.GridCellSize/2,this.y=s[0][1]*u.GridCellSize+u.GridCellSize/2,u.GameScene.events.on(lt.TakenDamage,(r,a,o)=>{r==this.id&&(this.effects.find(h=>h.effectEnum=="DebuffTowerDebuff")&&(a=a*1.5),this.health-=Math.max(a+a*(o.physical-this.stats.resistance.physical),0),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),u.GameScene.events.on(lt.GiveEffect,(r,a,o)=>{r==this.id&&this.effects.find(h=>h.effectEnum==a)==null&&this.effects.push(new Ad(a,o))}),u.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,n=Math.max(0,e/s),r=this.healthBarWidth,a=10,o=2,h=-r/2,l=-32;this.healthBarGraphics.rect(h-o,l-o,r+o*2,a+o*2),this.healthBarGraphics.fill({color:0});const c=r*n;this.healthBarGraphics.rect(h,l,c,a),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){u.GameScene.events.emit(lt.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(lt.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=this.pathIndex-1!=0?this.path[this.pathIndex-1]:this.path[0];let a=!1;for(let m=this.effects.length-1;m>=0;m--){let y=this.effects[m];if(y.ticks+=e*u.GameScene.gameSpeedMultiplier,y.ticks>=y.durationInMS)this.effects.splice(m,1);else if(y.effectEnum=="MovingBackwards")return a=!0}let o,h,l,c;a?(o=r[0]*u.GridCellSize+u.GridCellSize/2,h=r[1]*u.GridCellSize+u.GridCellSize/2,l=s[0]-r[0],c=r[1]-s[1]):(o=n[0]*u.GridCellSize+u.GridCellSize/2,h=n[1]*u.GridCellSize+u.GridCellSize/2,l=n[0]-s[0],c=n[1]-s[1]),l>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):l<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let d=this.speed*e*l*u.GameScene.gameSpeedMultiplier,f=this.speed*e*c*u.GameScene.gameSpeedMultiplier,p=!1;d>0&&this.x+d>o&&(d=o-this.x,p=!0),d<0&&this.x+d0&&this.y+f>h&&(f=h-this.y,p=!0),f<0&&this.y+f=0;e--){let s=i.projectiles[e];s.deleteMe||i.sold?(s.collidedCreepIDs.forEach(()=>{i.damageDealt+=i.computedDamageToDeal}),s.collidedCreepIDs=[],s.destroy(),i.projectiles.splice(e,1)):s.update(t)}}function Ot(i){let t=0,e=0,s=0,n=0,r=0;if(i.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},i.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,s+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();i.totalGemResistanceModifications.physical+=Number(h.physical.toFixed(2)),i.totalGemResistanceModifications.ice+=Number(h.ice.toFixed(2)),i.totalGemResistanceModifications.fire+=Number(h.fire.toFixed(2)),i.totalGemResistanceModifications.divine+=Number(h.divine.toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number(h.frostfire.toFixed(2))}),i.computedDamageToDeal=i.definition.stats.damage+t,i.computedCooldown=i.definition.stats.cooldown-e,i.computedRange=i.definition.stats.range+s,i.behaviour!=vt.TrapperTowerBehaviour?i.computedTimeToLive=i.definition.stats.timeToLive+n:i.computedTimeToLive=i.definition.stats.timeToLive+n*10,i.computedPierce=i.definition.stats.pierce+r,i.parent.isBuffedBy.length>0&&i.definition.name!=C.Towers[qe.Buff].name){let a=i.parent.isBuffedBy[0];i.computedDamageToDeal+=Number((a.computedDamageToDeal/2).toFixed(1)),i.computedCooldown-=Number((a.computedCooldown/5).toFixed(1)),i.computedRange+=Number((a.computedRange/10).toFixed(1)),i.computedTimeToLive+=Number((a.computedTimeToLive/5).toFixed(1)),i.computedPierce+=Number((a.computedPierce/4).toFixed(1)),i.totalGemResistanceModifications.physical+=Number((a.totalGemResistanceModifications.physical/2).toFixed(2)),i.totalGemResistanceModifications.ice+=Number((a.totalGemResistanceModifications.ice/2).toFixed(2)),i.totalGemResistanceModifications.fire+=Number((a.totalGemResistanceModifications.fire/2).toFixed(2)),i.totalGemResistanceModifications.divine+=Number((a.totalGemResistanceModifications.divine/2).toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number((a.totalGemResistanceModifications.frostfire/2).toFixed(2))}}function Pd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Gd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else if(i.GetCreepsInRange().length>0){i.millisecondsUntilNextShot=i.computedCooldown;let s=i.column*u.GridCellSize+u.GridCellSize/2,n=i.row*u.GridCellSize+u.GridCellSize/2;i.Shoot(ct(s,n,s,n+10)),i.Shoot(ct(s,n,s+10,n)),i.Shoot(ct(s,n,s-10,n)),i.Shoot(ct(s,n,s,n-10)),i.Shoot(ct(s,n,s+10,n+10)),i.Shoot(ct(s,n,s-10,n+10)),i.Shoot(ct(s,n,s-10,n-10)),i.Shoot(ct(s,n,s+10,n-10))}}function kd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{let l=[];h.pierce=0;let c=0;function d(f){if(c>=50){u.GameScene.PauseGame(),u.NotificationManager.Notify("Electric Tower max recursion exceeded! Please tell koneko! (game paused)","danger");return}c++,u.Grid.creeps.forEach(p=>{if(p.id!=o.id){const m=p.x,y=p.y,x=1.5*u.GridCellSize;if(be(f.x,f.y,m,y)_==p.id)!=null)return;l.push(p.id),new Td(f,p),u.GameScene.events.emit(lt.TakenDamage,p.id,Math.round(h.damage/2),h.gemResistanceModifications),d(p)}}})}u.GameScene.events.emit(lt.TakenDamage,o.id,h.damage,h.gemResistanceModifications),l.push(o.id),d(o)}}}}function Bd(i,t){Ot(i)}function Id(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(lt.GiveEffect,o.id,Xs.MovingBackwards,750),u.GameScene.events.emit(lt.TakenDamage,o.id,h.damage/2,h.gemResistanceModifications)}}}}function Ed(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Rd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{if(u.GameScene.roundMode!=Fa.Combat)return;let e=i.column*u.GridCellSize+u.GridCellSize/2,s=i.row*u.GridCellSize+u.GridCellSize/2,n=u.Grid.GetPathCellsInRange(i.row,i.column,i.computedRange);if(n.length>0){let r=Math.floor(Math.random()*n.length),a=n[r],o=a.column*u.GridCellSize+u.GridCellSize/2,h=a.row*u.GridCellSize+u.GridCellSize/2,l=new Y("white");if(i.slottedGems.length>0){let d=new Y(i.slottedGems[0].definition.color);for(let f=1;f0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(lt.GiveEffect,o.id,Xs.DebuffTowerDebuff,5e3),u.GameScene.events.emit(lt.TakenDamage,o.id,h.damage/1.5,h.gemResistanceModifications)}}}}function be(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Ld extends Pt{constructor(e,s,n,r,a){super();g(this,"row");g(this,"column");g(this,"setAsSold",!1);g(this,"sold",!1);g(this,"definition");g(this,"slottedGems",[]);g(this,"damageDealt",0);g(this,"projectiles",[]);g(this,"behaviour");g(this,"sprite");g(this,"millisecondsUntilNextShot");g(this,"graphics",new Tt);g(this,"computedDamageToDeal",0);g(this,"computedCooldown",0);g(this,"computedRange",0);g(this,"computedTimeToLive",0);g(this,"computedPierce",0);g(this,"totalGemResistanceModifications",{fire:0,frostfire:0,divine:0,ice:0,physical:0});g(this,"parent");g(this,"onParentCellEnter",e=>{!u.TowerManager.isPlacingTower&&u.Grid.gridInteractionEnabled&&!u.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});g(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=u.Grid.getCellByRowAndCol(e,s),this.sprite=new $({texture:n,height:u.GridCellSize,width:u.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.computedRange=this.definition.stats.range,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),u.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){this.slottedGems[s]=e,u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];if(s==null||!s)return console.warn("UnslotGem: Gem is null.");u.GameScene.MissionStats.giveGem(s,!0);for(let n=e;nn!=null),u.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return u.Grid.creeps.filter(s=>{const n=s.x,r=s.y,a=this.column*u.GridCellSize+u.GridCellSize/2,o=this.row*u.GridCellSize+u.GridCellSize/2,h=this.computedRange*u.GridCellSize;return be(a,o,n,r)0){let o=new Y(this.slottedGems[0].definition.color);for(let h=1;h{u.Grid.gridInteractionEnabled&&(u.TowerManager.isPlacingTower?u.Grid.onGridCellClicked(s,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseLeave,this)}),u.GameScene.events.on(_e.TowerPlacedEvent,(a,o,h)=>{if(o==this.row&&h==this.column)this.hasTowerPlaced=!0,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&this.isBuffedBy.push(l)}}),u.GameScene.events.on(_e.TowerSoldEvent,(a,o,h)=>{if(console.log(a,o,h),o==this.row&&h==this.column)this.hasTowerPlaced=!1,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&(console.log("REMOVED!"),this.isBuffedBy.splice(this.isBuffedBy.indexOf(l),1),console.log(this.isBuffedBy))}})}showRangePreview(e,s){let n=16777215;e&&(n=16711680),u.Grid.rangePreview.clear(),u.Grid.rangePreview.circle(this.column*u.GridCellSize+u.GridCellSize/2,this.row*u.GridCellSize+u.GridCellSize/2,s*u.GridCellSize),u.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=u.TowerManager.GetTowerByRowAndCol(this.row,this.column);u.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Dt.Path||this.type==Dt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Dt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Dt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Dt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class zd extends Pt{constructor(e,s){super();g(this,"gameMap");g(this,"cells",[]);g(this,"rangePreview");g(this,"creeps",[]);g(this,"gridShown",!1);g(this,"gridInteractionEnabled",!0);this.gameMap=e,u.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=u.GridCellSize*u.GridColumns,this.bb.height=u.GridCellSize*u.GridRows,u.GameMaster.currentScene.stage.addChild(this.container);let n=new $(C.MissionBackgrounds[s]);this.container.addChild(n);for(let r=0;rc.some(d=>d[1]===a&&d[0]===r));h&&(o=Dt.Path);let l=new Dd(o,a,r,h);this.cells.push(l)}this.rangePreview=new Tt({zIndex:10,x:0,y:0,width:u.app.canvas.width,height:u.app.canvas.height}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(s=>{if(s.isPath){e[s.row][s.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=s.row+n,o=s.column+r;a>=0&&a=0&&o{a.isPath&&this.IsCellInRangeOfOtherCell(e,s,n,a)&&r.push(a)}),r}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(lt.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(lt.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(n=>n.row==e&&n.column==s)[0]}onGridCellClicked(e,s){}}class Ud extends Pt{constructor(e,s){super();g(this,"creeps",[]);g(this,"rounds");g(this,"paths");g(this,"ticks",0);g(this,"started",!1);g(this,"internalCreepId",0);g(this,"pathsIndex");g(this,"finished",!1);u.WaveManager=this,this.rounds=e,this.paths=s,this.pathsIndex=0}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1,this.pathsIndex+1==this.paths.length?this.pathsIndex=0:this.pathsIndex++;let s=0;this.rounds[e].waves.forEach(n=>{s+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new Md(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};s+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*u.GameScene.gameSpeedMultiplier,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(re.CreepSpawned,s.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(re.Finished))):s.spawned&&s.creep.update(e)}))}}class Ht extends Mt{constructor(e,s,n,r,a,o,h,l){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);g(this,"frameSprite");g(this,"background");g(this,"towerName");g(this,"iconSprite");g(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=s*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:l}),this.background.width=n,this.background.height=r,this.iconSprite.x=n/2,this.iconSprite.y=r/2,this.iconSprite.width=n/2,this.iconSprite.height=r/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new _t({texture:C.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),u.GameScene.events.on(_e.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{u.GameScene.tooltip.Hide()}}ShowTooltip(){let e;C.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),u.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)}onClick(e){u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower&&u.TowerManager.selectedTower.name!=this.towerName&&(u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower()),u.GameScene.towerPanel.Hide(),u.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,u.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class Nd extends Mt{constructor(e){super(!1);g(this,"bounds");g(this,"towerTabSprite");g(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new _t({texture:C.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 Ht(0,0,70,70,this.container,C.RedBackground,C.Towers[0].name,C.Towers[0].texture)),this.towerButtons.push(new Ht(1,0,70,70,this.container,C.RedBackground,C.Towers[1].name,C.Towers[1].texture)),this.towerButtons.push(new Ht(2,0,70,70,this.container,C.BlueBackground,C.Towers[2].name,C.Towers[2].texture)),this.towerButtons.push(new Ht(3,0,70,70,this.container,C.BlueBackground,C.Towers[3].name,C.Towers[3].texture)),this.towerButtons.push(new Ht(0,1,70,70,this.container,C.GreenBackground,C.Towers[4].name,C.Towers[4].texture)),this.towerButtons.push(new Ht(1,1,70,70,this.container,C.GreenBackground,C.Towers[5].name,C.Towers[5].texture)),this.towerButtons.push(new Ht(2,1,70,70,this.container,C.YellowBackground,C.Towers[6].name,C.Towers[6].texture)),this.towerButtons.push(new Ht(3,1,70,70,this.container,C.YellowBackground,C.Towers[7].name,C.Towers[7].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new I(u.app.canvas.width-360,0,360,u.app.canvas.height),se.ChangeRoundButtonRect=new I(50,u.app.canvas.height-100,310,100)}};g(se,"SidebarRect"),g(se,"ChangeRoundButtonRect"),g(se,"MaximumPlayerNameLength",20);let Yt=se;class Ze extends Mt{constructor(e,s,n,r){super(!0);g(this,"iconSprite");g(this,"background");g(this,"frame");g(this,"i",0);g(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(u.GridCellSize+6)+350,this.background=new $({texture:C.Frame01Texture}),n==null&&!r?a=C.PlusIconTexture:r=="SELL"?a=C.GoldTexture:r=="UPGRADE"?a=C.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=u.GridCellSize,this.background.height=u.GridCellSize,n==null&&!r?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8),this.frame=new $({texture:C.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.level:"",h=new U({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 Od extends Mt{constructor(e){super(!1);g(this,"bounds");g(this,"towerPanel");g(this,"closeBtn");g(this,"vGems",[]);g(this,"showingTower",null);g(this,"isShown",!1);g(this,"titleText");g(this,"damageText");g(this,"totalDamage");g(this,"attackSpeedText");g(this,"fireResDamage");g(this,"iceResDamage");g(this,"frostFireResDamage");g(this,"divineResDamage");g(this,"physicalResDamage");g(this,"sellButton");g(this,"description");this.bounds=e,this.towerPanel=new _t({texture:C.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 ut(new I(-20,-20,60,60),"",ot.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:C.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=u.app.canvas.height/2-u.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),u.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new U({x:this.bounds.width/3,y:50,zIndex:5,style:new O({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new U({x:10,y:100,zIndex:5,style:new O({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new U({x:100,y:100,zIndex:5,style:new O({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new U({x:10,y:130,zIndex:5,style:new O({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new U({x:10,y:170,zIndex:5,style:new O({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new U({x:10,y:190,zIndex:5,style:new O({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new U({x:10,y:210,zIndex:5,style:new O({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new U({x:10,y:230,zIndex:5,style:new O({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new U({x:10,y:250,zIndex:5,style:new O({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.description=new U({x:10,y:270,zIndex:5,style:{fontSize:18,wordWrap:!0,wordWrapWidth:245,fill:65280,fontStyle:"italic",stroke:{color:0,width:2}}}),this.container.addChild(this.description),this.sellButton=new ut(new I(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ot.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let n=0;n{r&&(u.GameScene.tooltip.SetContentGem(r),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},a.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},a.onClick=()=>{u.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),u.GameScene.events.emit(Vs.TowerPanelSelectGem,r,a.i,e),!r&&u.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Ot(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,u.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<1270?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.computedRange)}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.computedCooldown/1e3*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,this.description.text=`"${e.definition.description}"`,this.sellButton.setCaption("Sell for "+e.definition.stats.cost+" gold"),this.sellButton.onClick=()=>{e.Sell(),this.Hide()}}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=Yt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,u.Grid.rangePreview.clear()}}class Wd extends Mt{constructor(e){super(!1);g(this,"bounds");g(this,"gemTabSprite");g(this,"vGems",[]);g(this,"isSelectingGem",!1);g(this,"selectingGemSlotIndex",-1);g(this,"selectingGemTowerObject",null);g(this,"isDragAndDroppingGem",!1);g(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new _t({texture:C.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),u.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),u.GameScene.events.on($s.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,n){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?(u.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=n):(n.UnslotGem(s),this.RebuildInventoryVisual(),u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=u.MouseX-32,this.dragAndDroppingGem.container.y=u.MouseY-32)}isOverlappingGemsmith(e,s,n){let r=e.copyContainerToBB(),a=s.copyContainerToBB(),o=n.x+a.x+u.GameScene.sidebar.container.x,h=n.y+a.y+u.GameScene.sidebar.container.y,l=new I(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],u.GameScene.MissionStats.getInventory().forEach((e,s)=>{let n=new Ze(0,this.container,e),r=10,a=s%4*70+10,o=s;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(u.GameScene.tooltip.SetContentGem(e),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},n.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(u.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=u.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),u.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.sellVGem,u.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;u.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),u.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),u.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.upgradeVGem,u.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())u.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;u.GameScene.MissionStats.hasEnoughGold(d)?(u.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),u.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):u.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(u.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let f=this.dragAndDroppingGem.copyContainerToBB(),p=d.copyContainerToBB(),m=u.GameScene.towerPanel.container.x+p.x,y=u.GameScene.towerPanel.container.y+p.y,x=new I(m,y,p.width,p.height);f.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=u.GameScene.MissionStats.takeGem(e);u.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Hd extends Mt{constructor(e){super(!1);g(this,"bounds");g(this,"sellVGem");g(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:C.BannerGemsmith});this.container.addChild(s);let n=new U({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new O({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new U({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new O({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ze(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ze(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class $d extends Mt{constructor(e){super(!1);g(this,"towerTab");g(this,"gemTab");g(this,"gemsmith");g(this,"bounds");g(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new _t({texture:C.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 I(60,20,this.bounds.width-65,150);this.towerTab=new Nd(s),this.container.addChild(this.towerTab.container);const n=new I(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Wd(n),this.container.addChild(this.gemTab.container);const r=new I(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Hd(r),this.container.addChild(this.gemsmith.container)}}class Vd extends Pt{constructor(e,s){super();g(this,"hp",100);g(this,"gold",0);g(this,"goldEarned",0);g(this,"goldSpent",0);g(this,"damageDealt",0);g(this,"wavesSurvived",0);g(this,"creepsKilled",0);g(this,"goldText");g(this,"healthText");g(this,"waveText");g(this,"inventory",[]);this.hp=e,this.gold=s,this.goldEarned=s,this.container.x=0,this.container.y=20,u.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new U({text:`${this.hp}`,style:new O({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new U({text:`${this.gold}`,style:new O({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new U({text:`0/${u.GameScene.mission.rounds.length}`,style:new O({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(C.HealthTexture),r=new $(C.GoldTexture),a=new $(C.WaveTexture);this.healthText.x=200,this.healthText.y=-15,n.x=160,n.width=36,n.height=32,n.y=-10,this.goldText.x=200,this.goldText.y=20,r.x=150,r.width=56,r.height=56,r.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(n),this.container.addChild(r),this.container.addChild(a),u.GameScene.events.on(re.NewWave,o=>{this.waveText.text=`${o}/${u.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,this.goldEarned+=e}spendGold(e){this.gold-=e,this.goldText.text=this.gold,this.goldSpent+=e}giveGem(e,s){if(this.inventory.length>=32)return u.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||u.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),u.GameScene.events.emit($s.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const s of this.inventory)e.push(s.definition.name);return u.TowerManager.towers.forEach(s=>{s.slottedGems.forEach(n=>{e.push(n.definition.name)})}),this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100+1e3}update(){}}class Yd extends Mt{constructor(e){super(!1);g(this,"bounds");g(this,"tooltipSprite");g(this,"titleText");g(this,"costText");g(this,"damageText");g(this,"gemAmount");g(this,"gemAmountSprite");g(this,"title");g(this,"costSprite");g(this,"damageSprite");g(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new _t({texture:C.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new U({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new O({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:C.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:C.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new U({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 U({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 $({texture:C.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:C.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new U({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 U({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),u.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,n,r){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 ${r} Gem slots.`,this.gemAmountSprite.texture=C.GemAmountIcons[r],this.costText.text=`Costs ${n} 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;let s;e.isMaxLevel()?s="Max level.":s=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${s} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>u.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}}const ft=class ft{static init(){window.addEventListener("keydown",ft.handleKeyDown)}static onKeyPressed(t){return ft.listeners=[...ft.listeners,t],()=>ft.offKey(t)}static offKey(t){const e=ft.listeners.indexOf(t);e>=0&&(ft.listeners=[...ft.listeners.slice(0,e),...ft.listeners.slice(e+1)])}static handleKeyDown(t){if(ft.listeners.length>0)for(let e=ft.listeners.length-1;e>=0&&(ft.listeners[e](t),!t.defaultPrevented);e--);}};g(ft,"listeners",[]);let Se=ft;class Bi extends Mt{constructor(e,s,n){super();g(this,"overlay");g(this,"buttonHeight",65);g(this,"buttonCaptions");g(this,"buttons",[]);g(this,"dialogContent");g(this,"dialogContainer");g(this,"background");g(this,"generated",!1);g(this,"escapeKeyButton");g(this,"enterKeyButton");g(this,"keyboardManagerUnsubscribe");g(this,"onClosed");if(this.buttonCaptions=e,n&&!e.includes(n))throw new Error(`Escape key button "${n}" not found in buttons: ${e}`);if(this.escapeKeyButton=n,s&&!e.includes(s))throw new Error(`Enter key button "${s}" not found in buttons: ${e}`);this.enterKeyButton=s,this.keyboardManagerUnsubscribe=Se.onKeyPressed(this.onKeyPress.bind(this))}show(){return this.generate(),`${Math.round(this.dialogContainer.x)}${Math.round(this.dialogContainer.y)}${Math.round(this.dialogContainer.width)}${Math.round(this.dialogContainer.height)}`,`${Math.round(this.dialogContent.x)}${Math.round(this.dialogContent.y)}${Math.round(this.dialogContent.width)}${Math.round(this.dialogContent.height)}`,new Promise((e,s)=>{u.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new _t({texture:C.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new Tt,this.overlay.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(l=>({caption:l,width:l.length*14+60,height:this.buttonHeight,click:()=>this.close(l)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let s=0;for(const l of e)s>0&&(s+=10),s+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(s,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new I(u.app.canvas.width/2-r/2,u.app.canvas.height/2-a/2,r,a);this.dialogContainer=new tt,this.dialogContainer.x=o.x,this.dialogContainer.y=o.y,this.background.width=r,this.background.height=a,this.dialogContainer.addChild(this.background),this.dialogContent.width0&&(r=s[0]),!n&&s.length>0&&(n=s[s.length-1]);super(s,n,r);g(this,"caption");this.caption=e}createContent(){return new U({text:this.caption,style:new O({fill:16777215,fontSize:24})})}static show(e,s,n=0){return new js(e,s).show()}}const Lt=class Lt{constructor(t){g(this,"missionName");g(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,s)=>s.score-e.score||e.timestamp-s.timestamp)}loadScores(){const t=localStorage.getItem(Lt.STORAGE_KEY_PREFIX+this.missionName);return Lt.parseStoredScores(t)}saveScores(){localStorage.setItem(Lt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,s)=>s.score-e.score),this.scores.length>Lt.MAX_SCORES&&(this.scores.length=Lt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(s=>typeof s.playerName=="string"&&typeof s.score=="number"&&typeof s.timestamp=="number"))return e.map(s=>({playerName:s.playerName,score:s.score,timestamp:s.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};g(Lt,"STORAGE_KEY_PREFIX","highscore_"),g(Lt,"MAX_SCORES",10);let Si=Lt;const Le={Confirm:"OK",Skip:"Skip"};class jd extends Bi{constructor(e,s,n){super([Le.Confirm,Le.Skip],Le.Confirm,Le.Skip);g(this,"dialogCaption");g(this,"playerNameTextInput");g(this,"lost");g(this,"highScore");g(this,"missionStats");this.lost=n,this.highScore=new Si(e),this.missionStats=s}generate(){super.generate(),this.dialogCaption=new U({text:this.lost?"You lost!":"You won!",style:new O({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new _t({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],l=300;for(let f=0;fthis.createText((f+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],l=a.reduce((d,f)=>Math.max(d,f.width),0)+20,c=l+o.reduce((d,f)=>Math.max(d,f.width),0)+20;for(let d=0;d(i[i.Purchase=0]="Purchase",i[i.Combat=1]="Combat",i[i.Misc=2]="Misc",i))(Fa||{});class ve extends ki{constructor(e){super();g(this,"isGameOver",!1);g(this,"mission");g(this,"missionIndex");g(this,"MissionStats");g(this,"roundMode");g(this,"ticker");g(this,"changeRoundButton");g(this,"sidebar");g(this,"tooltip");g(this,"towerPanel");g(this,"isPaused",!1);g(this,"gameSpeedMultiplier",1);g(this,"pauseButton");g(this,"visualGems",[]);g(this,"currentRound",0);g(this,"isWaveManagerFinished",!1);g(this,"playerWon",!1);g(this,"destroyTicker",!1);g(this,"offerGemsSprite");g(this,"dimGraphics",new Tt({x:0,y:0,zIndex:120}));g(this,"windowTitle");u.GameScene=this,this.windowTitle=document.title,C.Missions.forEach((s,n)=>{s.name==e&&(this.mission=s,this.missionIndex=n)})}init(){u.latestGemId=0,new zd(this.mission.gameMap,this.missionIndex),new Sd,new Ud(this.mission.rounds,this.mission.gameMap.paths),u.Grid.onGridCellClicked=(e,s)=>{u.TowerManager.isPlacingTower&&u.TowerManager.PlayerClickOnGrid(e,s)},u.WaveManager.events.on(re.CreepSpawned,e=>{u.Grid.addCreep(e),e.events.on(lt.Escaped,()=>{this.onCreepEscaped(e)})}),u.WaveManager.events.on(re.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(lt.Died,(e,s)=>{this.MissionStats.damageDealt+=e,this.MissionStats.creepsKilled++,this.MissionStats.earnGold(e)}),this.towerPanel=new Od(Yt.SidebarRect),this.sidebar=new $d(Yt.SidebarRect),this.changeRoundButton=new ut(Yt.ChangeRoundButtonRect,"",ot.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),u.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Yd(new I(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:C.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){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=C.FastForwardIconTexture,this.events.emit(re.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Vd(100,75),this.events.on(Vs.TowerPanelSelectGem,(e,s,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return u.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,n)}),this.pauseButton=new ut(new I(5,5,120,80),"",ot.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:C.PauseIconTexture,x:this.pauseButton.container.width/2,y:this.pauseButton.container.height/2,scale:.2}),this.pauseButton.buttonIcon.anchor.set(.5,.5),this.pauseButton.container.addChild(this.pauseButton.buttonIcon)},this.pauseButton.CustomButtonLogic(),this.pauseButton.onClick=()=>{this.isPaused?this.UnpauseGame():(this.ShowPauseDialog(),this.PauseGame())},this.ticker=new It,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(u.MouseX,u.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}u.WaveManager.update(e),u.Grid.update(e),u.TowerManager.update(e),this.isWaveManagerFinished&&u.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=C.PlayIconTexture,this.MissionStats.wavesSurvived++,u.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(u.NotificationManager.Notify("Mission victory!!","reward"),this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){u.Grid.gridInteractionEnabled=!1,u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new _t({width:380,height:150,texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:u.app.canvas.width/2-190,y:u.app.canvas.height/2-75}),u.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new U({x:u.app.canvas.width/4,y:u.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}}});u.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((n,r)=>{let a=new Ps(n,!0),o=new Ze(0,u.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(r+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{u.GameScene.tooltip.SetContentGem(a),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)},o.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},o.onClick=()=>{u.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new Ps(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),u.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}PauseGame(){this.isPaused=!0,this.ticker.stop(),document.title="[PAUSED] "+this.windowTitle}UnpauseGame(){this.isPaused=!1,this.ticker.start(),document.title=this.windowTitle}ShowPauseDialog(){new Kd().show()}async ShowEndgameDialog(e){await new jd(this.mission.name,this.MissionStats,e).show();const r=await new qd(this.mission.name,e,!e&&this.missionIndex+1{u.GameMaster.changeScene(new qs)},C.Missions.forEach((e,s)=>{const n=new ut(new I(u.app.canvas.width/2-150,400+s*70,300,60),e.name,ot.Button01);n.onClick=r=>{u.GameMaster.changeScene(new ve(e.name))}})}}class qs extends ki{init(){this.addMainBackground();const t={caption:"Play",rect:new I(u.app.canvas.width/2-300/2,400+0*70,300,60),texture:ot.Button01},e={caption:"How to play",rect:new I(u.app.canvas.width/2-300/2,400+1*70,300,60),texture:ot.Button01};new I(u.app.canvas.width/2-300/2,400+2*70,300,60),ot.Button01;let s=new U({x:0,y:0,text:"Latest commit: "+u.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(s);const n=new ut(t.rect,t.caption,t.texture,!0);n.onClick=a=>{u.GameMaster.changeScene(new ge)};let r=new ut(e.rect,e.caption,e.texture,!0);r.onClick=a=>{u.GameMaster.changeScene(new bd)}}}class Zd{constructor(){g(this,"finished",!1);g(this,"calledBack",!1);g(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Qd extends Zd{constructor(e,s,n,r){super();g(this,"fadeType");g(this,"fadeTime");g(this,"pixiObject");g(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=n,this.callbackFn=r,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 Jd{constructor(){g(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 tu{constructor(t,e,s,n,r){g(this,"textObj");g(this,"ticksToFadeAway");g(this,"animating",!1);g(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:e=="green"&&(a=65280),this.ticksToFadeAway=r,this.textObj=new U({text:t,style:new O({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),u.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class eu extends Pt{constructor(){super();g(this,"notifications",[]);g(this,"ticks",0);this.bb.x=u.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,u.app.stage.addChild(this.container)}Notify(e,s){let n=0,r=this.notifications.length*32;this.notifications.push(new tu(e,s,n,r,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const n=this.notifications[s];if(n.destroyed){this.notifications.splice(s,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,u.AnimationManager.Animate(new Qd("out",300,n.textObj,()=>{n.destroy()})))}}}class iu{constructor(t,e){g(this,"ticksToDestroyAt");g(this,"debris");this.debris=t,this.ticksToDestroyAt=e}destroy(){this.debris.destroy()}update(t){this.debris instanceof Pt&&this.debris.update(t)}}class su extends Pt{constructor(){super(...arguments);g(this,"ticks",0);g(this,"debris",[])}update(e){this.ticks++;for(let s=this.debris.length-1;s>=0;s--){const n=this.debris[s];this.ticks>=n.ticksToDestroyAt?(n.destroy(),this.debris.splice(s,1)):n.update(e)}}CreateDebris(e,s){s||(s=120),this.debris.push(new iu(e,this.ticks+s))}}(async()=>{const i=new Zr;u.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 r=window.innerWidth,a=window.innerHeight,o=r/i.screen.width,h=a/i.screen.height,l=Math.min(o,h),c=Math.round(i.screen.width*l),d=Math.round(i.screen.height*l),f=(r-c)/2,p=(a-d)/2;i.canvas.style.width=`${c}px`,i.canvas.style.height=`${d}px`,i.canvas.style.marginLeft=`${f}px`,i.canvas.style.marginTop=`${p}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}if(u.latestCommit=await fetch("./latest_commit").then(r=>r.text()),window.addEventListener("resize",t),t(),/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)){let r=new U({text:`Bastion: The Watchers Lament is currently unsupported on mobile. Please play it on your computer instead.`,style:new O({fill:3355443,fontSize:50,textBaseline:"middle"})});r.x=u.app.canvas.width/2,r.y=u.app.canvas.height/2+50,r.anchor.set(.5,.5),u.app.stage.addChild(r);return}await C.LoadAssets(),Yt.init(),Se.init(),new _d,u.AnimationManager=new Jd,u.NotificationManager=new eu,u.DebrisManager=new su,globalThis.Engine=u,It.shared.add(r=>{u.NotificationManager.update(r.elapsedMS),u.AnimationManager.update(r.elapsedMS),u.DebrisManager.update(r.elapsedMS)}),i.canvas.addEventListener("pointermove",function(r){u.MouseX=(r.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,u.MouseY=(r.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),u.GameMaster.changeScene(new qs),new URLSearchParams(location.href).entries().next().value[1]=="game"&&u.GameMaster.changeScene(new ve("The Turn")),u.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":u.TestSuite();let n=!1;window.addEventListener("blur",()=>{u.GameScene&&!u.GameScene.isPaused&&(u.GameScene.PauseGame(),n=!0)}),window.addEventListener("focus",()=>{u.GameScene&&n&&u.GameScene.isPaused&&(n=!1,u.GameScene.UnpauseGame())})})();export{N as $,Xr as A,it as B,tt as C,J as D,G as E,pr as F,Ti as G,Et as H,mn as I,$ as J,Zo as K,ah as L,H as M,nt as N,I as O,ht as P,Ch as Q,ps as R,$h as S,Nt as T,yi as U,yn as V,ko as W,Wi as X,Y,mr as Z,jr as _,z as a,W as a0,Gh as a1,ra as a2,pl as a3,ml as a4,bl as a5,vl as a6,Cl as a7,xe as a8,O as a9,pc as aa,As as ab,da as ac,Mn as ad,ce as ae,md as af,Zn as ag,_c as ah,Tt as ai,q as aj,so as ak,Ts as al,qn as am,fa as an,It as b,gt as c,Vt as d,dt as e,An as f,Oh as g,pi as h,Is as i,$r as j,Ar as k,Nr as l,jn as m,nn as n,fl as o,gl as p,wl as q,mo as r,ta as s,Sl as t,Es as u,Lr as v,st as w,io as x,Al as y,zt as z};