const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-B1wSO3YJ.js","assets/webworkerAll-Bh_VKI4a.js","assets/colorToUniform-Cc9gMCz1.js","assets/WebGPURenderer-CJK8XGjF.js","assets/SharedSystems-Cm-baQDq.js","assets/WebGLRenderer-CzO_3dRU.js"])))=>i.map(i=>d[i]); var da=Object.defineProperty;var fa=(s,t,e)=>t in s?da(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var w=(s,t,e)=>fa(s,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const pa="modulepreload",ga=function(s){return"/"+s},Si={},Ye=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(e.map(h=>{if(h=ga(h),h in Si)return;Si[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":pa,c||(u.as="script"),u.crossOrigin="",u.href=h,o&&u.setAttribute("nonce",o),document.head.appendChild(u),c)return new Promise((d,f)=>{u.addEventListener("load",d),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};var P=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(P||{});const Fs=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Ie=(s,t)=>Fs(s).priority??t,nt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Fs).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Fs).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>Ie(a.value,e)-Ie(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Ie(n,e)-Ie(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},ma={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Ye(()=>import("./browserAll-B1wSO3YJ.js"),__vite__mapDeps([0,1,2]))}},xa={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Ye(()=>import("./webworkerAll-Bh_VKI4a.js"),__vite__mapDeps([1,2]))}};class ot{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ot(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 si(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Pr={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);dLt[s],uY:s=>Gt[s],vX:s=>Wt[s],vY:s=>Ot[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Rs[s][t],sub:(s,t)=>Rs[s][V.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?V.S:V.N:Math.abs(t)*2<=Math.abs(s)?s>0?V.E:V.W:t>0?s>0?V.SE:V.SW:s>0?V.NE:V.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=kr[V.inv(t)];r.tx=e,r.ty=i,s.append(r)}},Re=[new it,new it,new it,new it];class U{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new U(0,0,0,0)}clone(){return new U(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=h&&t<=c&&e>=l&&e<=u&&!(t>d&&tp&&et.right?t.right:this.right)<=k)return!1;const A=this.yt.bottom?t.bottom:this.bottom)>A}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=Re[0].set(t.left,t.top),h=Re[1].set(t.left,t.bottom),c=Re[2].set(t.right,t.top),l=Re[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,m=d*r+f*n,g=d*i+f*a,x=d*r+f*a;if(Math.max(p,m,g,x)<=d*o.x+f*o.y||Math.min(p,m,g,x)>=d*l.x+f*l.y)return!1;const y=u*(o.y-c.y),_=u*(c.x-o.x),b=y*i+_*n,S=y*r+_*n,I=y*i+_*a,M=y*r+_*a;return!(Math.max(b,S,I,M)<=y*o.x+_*o.y||Math.min(b,S,I,M)>=y*l.x+_*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new U,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const os={default:-1};function tt(s="default"){return os[s]===void 0&&(os[s]=-1),++os[s]}const Ci={},O="8.0.0",Ca="8.3.4";function W(s,t,e=3){if(Ci[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${s}`):(i=i.split(` `).splice(e).join(` `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${s}`),console.warn(i))),Ci[t]=!0}const Er=()=>{};function Ti(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Mi(s){return!(s&s-1)&&!!s}function Ta(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Pi=Object.create(null);function Ma(s){const t=Pi[s];return t===void 0&&(Pi[s]=tt("resource")),t}const Br=class Ir extends at{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Ir.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){W(O,"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=Ma(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Br.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Pa=Br;const Fr=class Rr extends at{constructor(t={}){super(),this.options=t,this.uid=tt("textureSource"),this._resourceType="textureSource",this._resourceId=tt("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={...Rr.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 Pa(Ta(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=tt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=tt("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=Mi(this.pixelWidth)&&Mi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Fr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ct=Fr;class ii extends Ct{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ii.extension=P.TextureSource;const ki=new D;class ka{constructor(t,e){this.mapCoord=new D,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;rthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new U);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=Ei,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*t+h*e+l,x=o*t+c*e+u;gp&&(p=g),x>m&&(m=x),g=a*i+h*e+l,x=o*i+c*e+u,gp&&(p=g),x>m&&(m=x),g=a*t+h*r+l,x=o*t+c*r+u,gp&&(p=g),x>m&&(m=x),g=a*i+h*r+l,x=o*i+c*r+u,gp&&(p=g),x>m&&(m=x),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}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?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minXe&&(this.maxX=e),this.minYr&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new bt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let m=e;mo?y:o,h=_>h?_:h}this.minX=n,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var Ba={grad:.9,turn:360,rad:360/(2*Math.PI)},vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},st=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},ut=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Lr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Bi=function(s){return{r:ut(s.r,0,255),g:ut(s.g,0,255),b:ut(s.b,0,255),a:ut(s.a)}},hs=function(s){return{r:st(s.r),g:st(s.g),b:st(s.b),a:st(s.a,3)}},Ia=/^#([0-9a-f]{3,8})$/i,Le=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Gr=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},Wr=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},Ii=function(s){return{h:Lr(s.h),s:ut(s.s,0,100),l:ut(s.l,0,100),a:ut(s.a)}},Fi=function(s){return{h:st(s.h),s:st(s.s),l:st(s.l),a:st(s.a,3)}},Ri=function(s){return Wr((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},xe=function(s){return{h:(t=Gr(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Fa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ra=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,La=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ga=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ls={string:[[function(s){var t=Ia.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?st(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?st(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=La.exec(s)||Ga.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Bi({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Fa.exec(s)||Ra.exec(s);if(!t)return null;var e,i,r=Ii({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Ba[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Ri(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return vt(t)&&vt(e)&&vt(i)?Bi({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=Ii({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Ri(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=function(o){return{h:Lr(o.h),s:ut(o.s,0,100),v:ut(o.v,0,100),a:ut(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Wr(a)},"hsv"]]},Li=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Le(st(255*n)):"","#"+Le(e)+Le(i)+Le(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return hs(this.rgba)},s.prototype.toRgbString=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Fi(xe(this.rgba))},s.prototype.toHslString=function(){return t=Fi(xe(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Gr(this.rgba),{h:st(t.h),s:st(t.s),v:st(t.v),a:st(t.a,3)};var t},s.prototype.invert=function(){return yt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,-t))},s.prototype.grayscale=function(){return yt(ls(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),yt(Gi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),yt(Gi(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?yt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):st(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=xe(this.rgba);return typeof t=="number"?yt({h:t,s:e.s,l:e.l,a:e.a}):st(e.h)},s.prototype.isEqual=function(t){return this.toHex()===yt(t).toHex()},s}(),yt=function(s){return s instanceof Gs?s:new Gs(s)},Wi=[],Oa=function(s){s.forEach(function(t){Wi.indexOf(t)<0&&(t(Gs,Ls),Wi.push(t))})};function Da(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var m=(o=l,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));mn===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=fe._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=fe.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=yt(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof fe||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}};qt.shared=new qt;qt._temp=new qt;qt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Q=qt;const Ua={cullArea:null,cullable:!1,cullableChildren:!0};class ri{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,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class za{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 ri(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const At=new za;function Ha(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}Ha(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||W(O,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class Oi{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;ei.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Ws.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ws.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Oi);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Oi),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Xa={label:null,get name(){return W(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){W(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(rt.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||W(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r1){for(let r=0;r-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._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=At.get(to,this),this.groupTransform=D.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),At.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 D),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*ba}set angle(t){this.rotation=t*wa}get pivot(){return this._pivot===fs&&(this._pivot=new ot(this,0,0)),this._pivot}set pivot(t){this._pivot===fs&&(this._pivot=new ot(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew}set skew(t){this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===ps&&(this._scale=new ot(this,1,1)),this._scale}set scale(t){this._scale===ps&&(this._scale=new ot(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._position,a=i._x,o=i._y,h=r._x,c=r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=n._x-(h*e.a+c*e.c),e.ty=n._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ui,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Q.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Ui,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|=so,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|=gs,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|=gs,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|=gs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let n=0;n=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class dt extends Qe{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:i,roundPixels:r,width:n,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new ot({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof G?new dt(t):new dt(G.from(t,e))}set texture(t){t||(t=G.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(){Ea(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get 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 io=new bt;function Vr(s,t,e){const i=io;s.measurable=!0,Or(s,e,i),t.addBoundsMask(i),s.measurable=!1}function $r(s,t,e){const i=Kt.get();s.measurable=!0;const r=St.get().identity(),n=Xr(s,e,r);Ur(s,i,n),s.measurable=!1,t.addBoundsMask(i),St.return(r),Kt.return(i)}function Xr(s,t,e){return s?(s!==t&&(Xr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(J("Mask bounds, renderable is not inside the root container"),e)}class Yr{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 dt),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){Vr(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}Yr.extension=P.MaskEffect;class jr{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"}}jr.extension=P.MaskEffect;class qr{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){Vr(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof rt}}qr.extension=P.MaskEffect;const ro={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let zi=ro;const j={get(){return zi},set(s){zi=s}};class Kr extends Ct{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,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Kr.extension=P.TextureSource;class te extends Ct{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,J("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}}te.extension=P.TextureSource;var Os=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Os||{});class ms{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Zr=class ht{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 ms(null,null,1/0),this.deltaMS=1/ht.targetFPMS,this.elapsedMS=1/ht.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Os.NORMAL){return this._addListener(new ms(t,e,i))}addOnce(t,e,i=Os.NORMAL){return this._addListener(new ms(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),xs}const Je=class Jr extends Ct{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Jr.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=pe.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 Qr(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(pe.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||(pe.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(pe.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Je.extension=P.TextureSource;Je.defaultOptions={...Ct.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Je.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ve=Je;const gt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class no{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||J(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=gt(t);let r;for(let h=0;h{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&J("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){J(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const $=new no,Ds=[];nt.handleByList(P.TextureSource,Ds);function tn(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r{$.has(i)&&$.remove(i)}),t||$.set(i,n),n}function oo(s,t=!1){return typeof s=="string"?$.get(s):s instanceof Ct?new G({source:s}):ao(s,t)}G.from=oo;Ct.from=tn;nt.add(Yr,jr,qr,Ve,te,Kr,ii);var kt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(kt||{});function pt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function le(s){return s.split("?")[0].split("#")[0]}function ho(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lo(s,t,e){return s.replace(new RegExp(ho(t),"g"),e)}function co(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const lt={toPosix(s){return lo(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){pt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(pt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=le(this.toPosix(t??j.get().getBaseUrl())),r=le(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?lt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(pt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=co(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return pt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(pt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){pt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){pt(s),t&&pt(t),s=le(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){pt(s),s=le(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){pt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=le(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function en(s,t,e,i,r){const n=t[e];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");r.push(a)}),en(s,r,0,e,i)}else i.push(s);return i}const qe=s=>!Array.isArray(s);class ee{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return gt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&J("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&J(`[Resolver] already has key: ${n} overwriting`)},gt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=gt(a).map(f=>typeof f=="string"?uo(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let m={};if(typeof p!="object"){m.src=p;for(let g=0;g{this._assetMap[f]=d})})}resolveBundle(t){const e=qe(t);t=gt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=qe(t);t=gt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=lt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??fo(t.src),t}}ee.RETINA_PREFIX=/@([0-9\.]+)x/;function fo(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Us=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},sn=class ge{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof G?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ge.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ge.BATCH_SIZE;for(;e-t{this._batchIndex*ge.BATCH_SIZE{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=lt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=rn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const go={extension:P.Asset,cache:{test:s=>s instanceof Hi,getCacheableAssets:(s,t)=>rn(s,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&po.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ee.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:kt.Normal,name:"spritesheetLoader"},async testParse(s,t){return lt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=lt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof G)a=i;else{const u=Us(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Hi(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=Us(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};nt.add(go);const ys=Object.create(null),Ni=Object.create(null);function ni(s,t){let e=Ni[s];return e===void 0&&(ys[t]===void 0&&(ys[t]=1),Ni[s]=e=ys[t]++),e}let Ht;function nn(){return(!Ht||Ht!=null&&Ht.isContextLost())&&(Ht=j.get().createCanvas().getContext("webgl",{})),Ht}let Ge;function mo(){if(!Ge){Ge="mediump";const s=nn();s&&s.getShaderPrecisionFormat&&(Ge=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Ge}function xo(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${s} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${s} `}function yo(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float; ${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function _o(s,t){return t?`#version 300 es ${s}`:s}const bo={},wo={};function vo(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?bo:wo;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} ${s}`}function Ao(s,t){return t?s.replace("#version 300 es",""):s}const _s={stripVersion:Ao,ensurePrecision:yo,addProgramDefines:xo,setProgramName:vo,insertVersion:_o},bs=Object.create(null),an=class zs{constructor(t){t={...zs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:mo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(_s).forEach(a=>{const o=i[a];r=_s[a](r,o,!0),n=_s[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=ni(`${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 bs[e]||(bs[e]=new zs(t)),bs[e]}};an.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let on=an;const Vi={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 So(s){return Vi[s]??Vi.float32}const Co={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 To({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=Co[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:So(h).stride,offset:0,instance:!1,start:0}}}}return e}function ws(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],m=f.match(o).reduce((g,x)=>{const[y,_]=x.split(":");return g[y.trim()]=_.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var me=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(me||{});function Mo({groups:s}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const vs=Object.create(null);class ts{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=ws(e.source);this.structsAndGroups=c}else{const c=ws(i.source),l=ws(e.source);this.structsAndGroups=ko(c,l)}this.layout=r??Po(this.structsAndGroups),this.gpuLayout=n??Mo(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ni(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=To(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 vs[e]||(vs[e]=new ts(t)),vs[e]}}const hn=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Eo=hn.reduce((s,t)=>(s[t]=!0,s),{});function Bo(s,t){switch(s){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 ln=class cn{constructor(t,e){this._touched=0,this.uid=tt("uniform"),this._resourceType="uniformGroup",this._resourceId=tt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...cn.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Eo[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${hn.join(", ")}`);n.value??(n.value=Bo(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ni(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};ln.defaultOptions={ubo:!1,isStatic:!1};let un=ln;class $e{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Hs=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Hs||{});class ai extends at{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Hs.WEBGPU),i&&(a|=Hs.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&o)for(const c in o)for(const l in o[c]){const u=o[c][l];h[u]={group:c,binding:l,name:u}}else if(e&&r&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else if(n){r={},o={},e&&e.structsAndGroups.groups.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,h[u.name]=u});let c=0;for(const l in n)h[l]||(r[99]||(r[99]=new $e,this._ownedBindGroups.push(r[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in n){const u=l;let d=n[l];!d.source&&!d._resourceType&&(d=new un(d));const f=h[u];f&&(r[f.group]||(r[f.group]=new $e,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(d,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new $e,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=ts.from(e)),i&&(a=on.from(i)),new ai({gpuProgram:n,glProgram:a,...r})}}const Ns=[];nt.handleByNamedList(P.Environment,Ns);async function Io(s){if(!s)for(let t=0;t80*e){o=c=s[0],h=l=s[1];for(var p=e;pc&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return be(n,a,e,o,h,f,0),a}function dn(s,t,e,i,r){var n,a;if(r===Xs(s,t,e,i)>0)for(n=t;n=t;n-=i)a=$i(n,s[n],s[n+1],a);return a&&ss(a,a.next)&&(ve(a),a=a.next),a}function zt(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(ss(e,e.next)||X(e.prev,e,e.next)===0)){if(ve(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function be(s,t,e,i,r,n,a){if(s){!a&&n&&No(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?Lo(s,i,r,n):Ro(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),ve(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Go(zt(s),t,e),be(s,t,e,i,r,n,2)):a===2&&Wo(s,t,e,i,r,n):be(zt(s),t,e,i,r,n,1);break}}}}function Ro(s){var t=s.prev,e=s,i=s.next;if(X(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=rn?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&Xt(r,o,n,h,a,c,p.x,p.y)&&X(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Lo(s,t,e,i){var r=s.prev,n=s,a=s.next;if(X(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=oh?o>c?o:c:h>c?h:c,g=l>u?l>d?l:d:u>d?u:d,x=Vs(f,p,t,e,i),y=Vs(m,g,t,e,i),_=s.prevZ,b=s.nextZ;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Xt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Xt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Xt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Xt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Go(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!ss(r,n)&&fn(r,i,i.next,n)&&we(r,n)&&we(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),ve(i),ve(i.next),i=s=n),i=i.next}while(i!==s);return zt(i)}function Wo(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Xo(a,o)){var h=pn(a,o);a=zt(a,a.next),h=zt(h,h.next),be(a,t,e,i,r,n,0),be(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Oo(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=i&&o>n&&(n=o,a=e.x=e.x&&e.x>=c&&i!==e.x&&Xt(ra.x||e.x===a.x&&Ho(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function Ho(s,t){return X(s.prev,s,t.prev)<0&&X(t.next,s,s.next)<0}function No(s,t,e,i){var r=s;do r.z===0&&(r.z=Vs(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,Vo(r)}function Vo(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function Vs(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function $o(s){var t=s,e=s;do(t.x=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function Xo(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Yo(s,t)&&(we(s,t)&&we(t,s)&&jo(s,t)&&(X(s.prev,s,t.prev)||X(s,t.prev,t))||ss(s,t)&&X(s.prev,s,s.next)>0&&X(t.prev,t,t.next)>0)}function X(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ss(s,t){return s.x===t.x&&s.y===t.y}function fn(s,t,e,i){var r=Oe(X(s,t,e)),n=Oe(X(s,t,i)),a=Oe(X(e,i,s)),o=Oe(X(e,i,t));return!!(r!==n&&a!==o||r===0&&We(s,e,t)||n===0&&We(s,i,t)||a===0&&We(e,s,i)||o===0&&We(e,t,i))}function We(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Oe(s){return s>0?1:s<0?-1:0}function Yo(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&fn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function we(s,t){return X(s.prev,s,s.next)<0?X(s,t,s.next)>=0&&X(s,s.prev,t)>=0:X(s,t,s.prev)<0||X(s,s.next,t)<0}function jo(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function pn(s,t){var e=new $s(s.i,s.x,s.y),i=new $s(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function $i(s,t,e,i){var r=new $s(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ve(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function $s(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}es.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(Xs(s,0,n,e));if(r)for(var o=0,h=t.length;o0&&(i+=s[r-1].length,e.holes.push(i))}return e};var qo=oi.exports;const Ko=si(qo);var gn=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(gn||{});class Zo{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u{this.runners[e]=new Zo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[a];this.renderPipes[a]=new n(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Fo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};mn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let yn=mn,De;function Jo(s){return De!==void 0||(De=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??yn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let r=j.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),De}let Ue;async function th(s={}){return Ue!==void 0||(Ue=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Ue}const Xi=["webgl","webgpu","canvas"];async function eh(s){let t=[];s.preference?(t.push(s.preference),Xi.forEach(n=>{n!==s.preference&&t.push(n)})):t=Xi.slice();let e,i={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-CJK8XGjF.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&Jo(s.failIfMajorPerformanceCaveat??yn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await Ye(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-CzO_3dRU.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const _n="8.4.0";class bn{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,_n)}static destroy(){}}bn.extension=P.Application;class sh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,_n)}destroy(){this._renderer=null}}sh.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const wn=class Ys{constructor(...t){this.stage=new rt,t[0]!==void 0&&W(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await eh(t),Ys._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return W(O,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Ys._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};wn._plugins=[];let vn=wn;nt.handleByList(P.Application,vn._plugins);nt.add(bn);class An extends at{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 W(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return W(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return W(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return W(O,"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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const Sn=class js{constructor(t,e,i,r){this.uid=tt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Q.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=js.defaultTextureSize,{gradientStops:e}=this,i=j.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,js.defaultTextureSize,1);for(let m=0;m`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Sn.defaultTextureSize=256;let Ae=Sn;const Yi={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 is{constructor(t,e){this.uid=tt("fillPattern"),this.transform=new D,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Yi[e].addressModeU,t.source.style.addressModeV=Yi[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 ih=nh,As={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},rh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function nh(s){var t=[];return s.replace(rh,function(e,i,r){var n=i.toLowerCase();for(r=oh(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==As[n])return r.unshift(i),t.push(r);if(r.length0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:J(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class hi{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new hi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return ha-o}getBounds(t){return t=t||new U,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 li{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new li(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(t){return t=t||new U,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 ch(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const m=s-f,g=t-p;return m*m+g*g}class ye{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;re!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const r=i/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hr?c:r,n=la?l:a}return t.x=i,t.width=r-i,t.y=n,t.height=a-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ze=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class ci{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new U,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ci(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,m=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=m-c&&e<=m+c)&&t>=l&&t<=l+d?!0:tp-h&&ep-h&&e>m-h&&ze(t,e,p-h,m-h,h,c)||tm-h&&ze(t,e,l,m-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const uh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function dh(s){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return Tn[e]||gh(s,t,e)}let Ss=0;function gh(s,t,e){const i={};let r=0;Ss||(Ss=Cn());for(let a=0;a0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const mh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var xh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(xh||{});function Ki(s,t){return t.alphaMode==="no-premultiply-alpha"&&mh[s]||s}class yh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?Mn[--qs]:new _h}function Qi(s){Mn[qs++]=s}let ue=0;const Pn=class Xe{constructor(t={}){this.uid=tt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Xe.defaultOptions.maxTextures=Xe.defaultOptions.maxTextures??Cn(),t={...Xe.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new ji(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,c=this.indexBuffer;let l=this._batchIndexSize,u=this._batchIndexStart,d="startBatch";const f=this.maxTextures;for(let p=this.elementStart;p=f||_)&&(this._finishBatch(i,u,l-u,r,a,t,d),d="renderBatch",u=l,a=y,i=Zi(),r=i.textures,r.clear(),++ue),m._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,m._batch=i,l+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,o,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,o,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,u,l-u,r,a,t,d),u=l,++ue),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=l}_finishBatch(t,e,i,r,n,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=i,++ue,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),i=new ji(e);qi(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(Z||{});class Pt extends at{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=tt("buffer"),this._resourceType="buffer",this._resourceId=tt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&Z.STATIC)}set static(t){t?this.descriptor.usage|=Z.STATIC:this.descriptor.usage&=~Z.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=f),p>h&&(h=p),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Ah=new Float32Array(1),Sh=new Uint32Array(1);class Ch extends En{constructor(){const e=new Pt({data:Ah,label:"attribute-batch-buffer",usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),i=new Pt({data:Sh,label:"index-batch-buffer",usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:i})}}function Ji(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else J(`${i} placement hook does not exist in shader`)}}const Th=/\{\{(.*?)\}\}/g;function tr(s){var i;const t={};return(((i=s.match(Th))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function er(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function sr(s,t,e=!1){const i=[];er(t,i),s.forEach(o=>{o.header&&er(o.header,i)});const r=i;e&&r.sort();const n=r.map((o,h)=>` @location(${h}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${n} `),a}function ir(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Mh(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Ph(s){const t=/@.*?\s+/g;return s.replace(t,"")}function kh(s,t){const e=[];ir(t,e),s.forEach(h=>{h.header&&ir(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, `),n=e.sort().map(h=>` var ${Ph(h)};`).join(` `),a=`return VSOutput( ${e.sort().map(h=>` ${Mh(h)}`).join(`, `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",` ${r} `),o=o.replace("{{start}}",` ${n} `),o=o.replace("{{return}}",` ${a} `),o}function rr(s,t){let e=s;for(const i in t){const r=t[i];r.join(` `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${r.join(` `)} //----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Mt=Object.create(null),Cs=new Map;let Eh=0;function Bh({template:s,bits:t}){const e=Bn(s,t);if(Mt[e])return Mt[e];const{vertex:i,fragment:r}=Fh(s,t);return Mt[e]=In(i,r,t),Mt[e]}function Ih({template:s,bits:t}){const e=Bn(s,t);return Mt[e]||(Mt[e]=In(s.vertex,s.fragment,t)),Mt[e]}function Fh(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=sr(e,s.vertex,!0);r=kh(e,r);const n=sr(i,s.fragment,!0);return{vertex:r,fragment:n}}function Bn(s,t){return t.map(e=>(Cs.has(e)||Cs.set(e,Eh++),Cs.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function In(s,t,e){const i=tr(s),r=tr(t);return e.forEach(n=>{Ji(n.vertex,i,n.name),Ji(n.fragment,r,n.name)}),{vertex:rr(s,i),fragment:rr(t,r)}}const Rh=` @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}} }; `,Lh=` @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; }; `,Gh=` 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}} } `,Wh=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,Oh={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},Dh={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function Uh({bits:s,name:t}){const e=Bh({template:{fragment:Lh,vertex:Rh},bits:[Oh,...s]});return ts.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function zh({bits:s,name:t}){return new on({name:t,...Ih({template:{vertex:Gh,fragment:Wh},bits:[Dh,...s]})})}const Hh={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Nh={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Ts={};function Vh(s){const t=[];if(s===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 i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` `)}function $h(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @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; ${Vh(s)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${$h(s)} `}}),Ts[s]}const Ms={};function Yh(s){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; } `}},Kh={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; } `}},nr={};function Zh(s){let t=nr[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const il=new D;class Gn{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,i=this.renderable;return i?sl(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||il}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 Se={extension:{type:P.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const b=s;e=b.x,i=b.y,a=o=b.radius,r=n=0}else if(s.type==="ellipse"){const b=s;e=b.x,i=b.y,a=b.halfWidth,o=b.halfHeight,r=n=0}else{const b=s,S=b.width/2,I=b.height/2;e=b.x+S,i=b.y+I,a=o=Math.max(0,Math.min(b.radius,Math.min(S,I))),r=S-a,n=I-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,m=n,g=e+p,x=e-p,y=i+m;if(t[l++]=g,t[l++]=y,t[--u]=y,t[--u]=x,n){const b=i-m;t[d++]=x,t[d++]=b,t[--f]=b,t[--f]=g}for(let b=1;b0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},rl={...Se,extension:{...Se.extension,name:"ellipse"}},nl={...Se,extension:{...Se.extension,name:"roundedRectangle"}},al=1e-4,or=1e-4;function ol(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];iu&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),m=Math.sqrt(h*h+c*c),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/g;if(d+=x,o){a.push(s,t),a.push(e,i);for(let y=1,_=d;y=0&&(l.join==="round"?y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+4:y+=2,g.push(v-N*R,A-q*R),g.push(v+N*E,A+q*E));continue}const wi=(-F+M)*(-B+A)-(-F+v)*(-B+k),vi=(-N+Y)*(-q+A)-(-N+v)*(-q+wt),Ee=(Tt*vi-ae*wi)/ke,Be=(oe*wi-ne*vi)/ke,ns=(Ee-v)*(Ee-v)+(Be-A)*(Be-A),Et=v+(Ee-v)*E,Bt=A+(Be-A)*E,It=v-(Ee-v)*R,Ft=A-(Be-A)*R,ca=Math.min(Tt*Tt+ne*ne,ae*ae+oe*oe),Ai=he?E:R,ua=ca+Ai*Ai*S;ns<=ua?l.join==="bevel"||ns/S>I?(he?(g.push(Et,Bt),g.push(v+F*R,A+B*R),g.push(Et,Bt),g.push(v+N*R,A+q*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),g.push(v-N*E,A-q*E),g.push(It,Ft)),y+=2):l.join==="round"?he?(g.push(Et,Bt),g.push(v+F*R,A+B*R),y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+q*R,g,!0)+4,g.push(Et,Bt),g.push(v+N*R,A+q*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+4,g.push(v-N*E,A-q*E),g.push(It,Ft)):(g.push(Et,Bt),g.push(It,Ft)):(g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),l.join==="round"?he?y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+q*R,g,!0)+2:y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+2:l.join==="miter"&&ns/S<=I&&(he?(g.push(It,Ft),g.push(It,Ft)):(g.push(Et,Bt),g.push(Et,Bt)),y+=2),g.push(v-N*E,A-q*E),g.push(v+N*R,A+q*R),y+=2)}M=s[(x-2)*2],k=s[(x-2)*2+1],v=s[(x-1)*2],A=s[(x-1)*2+1],F=-(k-A),B=M-v,ft=Math.sqrt(F*F+B*B),F/=ft,B/=ft,F*=b,B*=b,g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),p||(l.cap==="round"?y+=Rt(v-F*(E-R)*.5,A-B*(E-R)*.5,v-F*E,A-B*E,v+F*R,A+B*R,g,!1)+2:l.cap==="square"&&(y+=hr(v,A,F,B,E,R,!1,g)));const la=or*or;for(let z=_;z=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},dl={extension:{type:P.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},rs={};nt.handleByMap(P.ShapeBuilder,rs);nt.add(ul,cl,dl,Se,rl,nl);const fl=new U;function pl(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r{const f=h.length,p=a.length/2,m=[],g=rs[l.type];if(g.build(l,m),u&&Ln(m,u),i){const b=l.closePath??!0;hl(m,t,!1,b,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const b=[],S=m.slice();ml(e.shapePath).forEach(M=>{b.push(S.length/2),S.push(...M)}),Wn(S,b,a,2,p,h,f)}else g.triangulate(m,a,2,p,h,f);const x=o.length/2,y=t.texture;if(y!==G.WHITE){const b=t.matrix;b&&(u&&b.append(u.clone().invert()),tl(a,2,p,o,x,2,a.length/2-p,b))}else el(o,x,2,a.length/2-p);const _=At.get(Gn);_.indexOffset=f,_.indexSize=h.length-f,_.attributeOffset=p,_.attributeSize=a.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=y,_.geometryData=n,r.push(_)})}function ml(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i{At.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};ui.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};ui.defaultOptions={bezierSmoothness:.5};let On=ui;const _l=8,He=11920929e-14,bl=1;function Dn(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??On.defaultOptions.bezierSmoothness));let d=(bl-u)/1;return d*=d,wl(t,e,i,r,n,a,o,h,s,d),s}function wl(s,t,e,i,r,n,a,o,h,c){Zs(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function Zs(s,t,e,i,r,n,a,o,h,c,l){if(l>_l)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,m=(r+a)/2,g=(n+o)/2,x=(u+f)/2,y=(d+p)/2,_=(f+m)/2,b=(p+g)/2,S=(x+_)/2,I=(y+b)/2;if(l>0){let M=a-s,k=o-t;const v=Math.abs((e-a)*k-(i-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(v>He&&A>He){if((v+A)*(v+A)<=c*(M*M+k*k)){h.push(S,I);return}}else if(v>He){if(v*v<=c*(M*M+k*k)){h.push(S,I);return}}else if(A>He){if(A*A<=c*(M*M+k*k)){h.push(S,I);return}}else if(M=S-(s+a)/2,k=I-(t+o)/2,M*M+k*k<=c){h.push(S,I);return}}Zs(s,t,u,d,x,y,S,I,h,c,l+1),Zs(S,I,_,b,m,g,a,o,h,c,l+1)}const vl=8,Al=11920929e-14,Sl=1;function Cl(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??On.defaultOptions.bezierSmoothness));let l=(Sl-c)/1;return l*=l,Tl(t,e,i,r,n,a,s,l),s}function Tl(s,t,e,i,r,n,a,o){Qs(a,s,t,e,i,r,n,o,0),a.push(r,n)}function Qs(s,t,e,i,r,n,a,o,h){if(h>vl)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let m=n-t,g=a-e;const x=Math.abs((i-n)*g-(r-a)*m);if(x>Al){if(x*x<=o*(m*m+g*g)){s.push(f,p);return}}else if(m=f-(t+n)/2,g=p-(e+a)/2,m*m+g*g<=o){s.push(f,p);return}Qs(s,t,e,c,l,f,p,o,h+1),Qs(s,f,p,u,d,n,a,o,h+1)}function Un(s,t,e,i,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;uu*h)}const _e=Math.PI*2,Ps={centerX:0,centerY:0,ang1:0,ang2:0},ks=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function Pl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const cr=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},kl=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(l,2),g=Math.pow(u,2);let x=f*p-f*g-p*m;x<0&&(x=0),x/=f*g+p*m,x=Math.sqrt(x)*(a===o?-1:1);const y=x*r/n*u,_=x*-n/r*l,b=c*y-h*_+(s+e)/2,S=h*y+c*_+(t+i)/2,I=(l-y)/r,M=(u-_)/n,k=(-l-y)/r,v=(-u-_)/n,A=cr(1,0,I,M);let Y=cr(I,M,k,v);o===0&&Y>0&&(Y-=_e),o===1&&Y<0&&(Y+=_e),d.centerX=b,d.centerY=S,d.ang1=A,d.ang2=Y};function El(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*_e/360),u=Math.cos(o*_e/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),kl(t,e,i,r,n,a,h,c,l,u,d,f,Ps);let{ang1:m,ang2:g}=Ps;const{centerX:x,centerY:y}=Ps;let _=Math.abs(g)/(_e/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);g/=b;let S=s[s.length-2],I=s[s.length-1];const M={x:0,y:0};for(let k=0;k{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a0&&(f=-1,p=!0);const m=d/2;let g,x=Math.abs(Math.cos(m)*h/Math.sin(m));x>Math.min(l.len/2,u.len/2)?(x=Math.min(l.len/2,u.len/2),g=Math.abs(x*Math.sin(m)/Math.cos(m))):g=h;const y=o.x+u.nx*x+-u.ny*g*f,_=o.y+u.ny*x+u.nx*g*f,b=Math.atan2(l.ny,l.nx)+Math.PI/2*f,S=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(y+Math.cos(b)*g,_+Math.sin(b)*g),s.arc(y,_,g,b,S,p),n=o}}function Il(s,t,e,i){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new li(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new ci(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new ye,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new ye,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eparseInt(k,10)),t.context.poly(y,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":_=s.getAttribute("points"),y=_.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(y,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=Dt({...this._originalFill},ct.defaultFillStyle)})),this._fill=Dt(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ct.defaultStrokeStyle,...t},()=>{this._stroke=Ke({...this._originalStroke},ct.defaultStrokeStyle)})),this._stroke=Ke(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=zl(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=$t.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new $t({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 i,r,n,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,r,n)=>(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Q.isColorLike(t)||t instanceof Ae||t instanceof is)}};fi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};fi.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 mt=fi;function Vl(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=mt.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){W(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Q.isColorLike(e))i.color=e;else if(e instanceof Ae||e instanceof is)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){W(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=mt.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new Ae(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>Q.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);i.addColorStop(o,n)}),s.fill={fill:i}}}class $l{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=j.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Ti(t),e=Ti(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const xr=new $l,Xl=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Js(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Xl.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Es={willReadFrequently:!0},xt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}:${e.styleKey}`;if(T._measurementCache[n])return T._measurementCache[n];const a=Js(e),o=T.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=T.__context;h.font=a;const l=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let _=0;_0&&(r?n-=e:n+=(T.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",Es);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=T._collapseSpaces(l),d=T._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,m=T._tokenize(t);for(let g=0;gp)if(a!==""&&(o+=T._addLine(a),a="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let b=0;b<_.length;b++){let S=_[b],I=S,M=1;for(;_[b+M];){const v=_[b+M];if(!T.canBreakChars(I,v,x,b,e.breakWords))S+=v;else break;I=v,M++}b+=M-1;const k=T._getFromCache(S,c,h,r);k+n>p&&(o+=T._addLine(a),f=!1,a="",n=0),a+=S,n+=k}}else{a.length>0&&(o+=T._addLine(a),a="",n=0);const _=g===m.length-1;o+=T._addLine(x,!_),f=!1,a="",n=0}else y+n>p&&(f=!1,o+=T._addLine(a),a="",n=0),(a.length>0||!T.isBreakingSpace(x)||f)&&(a+=x,n+=y)}return o+=T._addLine(a,!1),o}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();xt.experimentalLetterSpacing=!1;xt._fonts={};xt._newlines=[10,13];xt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];xt._measurementCache={};let ti=xt;function yr(s,t){if(s.texture===G.WHITE&&!s.fill)return Q.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof is){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(D.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof Ae){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,Q.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(D.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return J("FillStyle not recognised",s),"red"}function Nn(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e!this._currentChars.includes(x)).filter((x,y,_)=>_.indexOf(x)===y);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let x=0;xthis._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const v=this._nextPage();r=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,c=0}const k=b/l-(((m=o.dropShadow)==null?void 0:m.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},p){this._drawGlyph(n,_,h+u,c+u,l,o);const v=a.width*l,A=a.height*l,Y=new U(h/v*a.width,c/A*a.height,I/v*a.width,M/A*a.height);this.chars[y].texture=new G({source:a,frame:Y}),h+=Math.ceil(I)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r{const m=n.width;for(let g=0;g{let p=n.chars.length-1;if(i){let m=n.chars[p];for(;m===" ";)n.width-=e.chars[m].xAdvance,m=n.chars[--p]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(n),r.height+=e.lineHeight},u=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let p=0;pf?(l(),c(h),g||n.charPositions.push(0)):(h.start=n.width,c(h),g||n.charPositions.push(0)),m==="\r"||m===` `)n.width!==0&&l();else if(!g){const S=x.xAdvance+(x.kerning[a]||0)+d;n.width+=S,n.spaceWidth=S,n.spacesIndex.push(n.charPositions.length),n.chars.push(m)}}else{const b=x.kerning[a]||0,S=x.xAdvance+b+d;h.positions[h.index++]=h.width+b,h.chars.push(m),h.width+=S}a=m}return l(),t.align==="center"?jl(r):t.align==="right"?ql(r):t.align==="justify"&&Kl(r),r}function jl(s){for(let t=0;t50&&J("BitmapText",`You have dynamically created ${Ne} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Ne--,$.remove(i)}),$.set(i,o)}const n=$.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,i=!0){const r=this.getFont(t,e);return Yl([...t],e,r,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var c,l,u,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},W(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof mt?r:new mt(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new _r({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Nn(e.chars);return o.ensureCharacters(h.join("")),$.set(`${i}-bitmap`,o),o.once("destroy",()=>$.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=$.get(e);i&&($.remove(e),i.destroy())}}const br=new Zl;class Xn extends An{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new U(a.x+o.x,a.y+o.y,a.width,a.height),l=new G({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?wr.test(j.get().parseXML(s)):!1},parse(s){return wr.parse(j.get().parseXML(s))}},Ql=[".xml",".fnt"],Jl={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof Xn,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},tc={extension:{type:P.LoadParser,priority:kt.Normal},name:"loadBitmapFont",test(s){return Ql.includes(lt.extname(s).toLowerCase())},async testParse(s){return Bs.test(s)||vr.test(s)},async parse(s,t,e){const i=Bs.test(s)?Bs.parse(s):vr.parse(s),{src:r}=t,{pages:n}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;uh[u.src]);return new Xn({data:i,textures:c},r)},async load(s,t){return await(await j.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class ec{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;iArray.isArray(s)&&s.every(t=>t instanceof G),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function Yn(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const ic={extension:{type:P.DetectionParser,priority:1},test:async()=>Yn("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Ar=["png","jpg","jpeg"],rc={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Ar],remove:async s=>s.filter(t=>!Ar.includes(t))},nc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function pi(s){return nc?!1:document.createElement("video").canPlayType(s)!==""}const ac={extension:{type:P.DetectionParser,priority:0},test:async()=>pi("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},oc={extension:{type:P.DetectionParser,priority:0},test:async()=>pi("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},hc={extension:{type:P.DetectionParser,priority:0},test:async()=>pi("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},lc={extension:{type:P.DetectionParser,priority:0},test:async()=>Yn("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class cc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||J(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=lt.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}. ${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=lt.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&J(`[Assets] loadParser name conflict "${e.name}"`):J("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function se(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function ie(s,t){const e=s.split("?")[0],i=lt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const uc=".json",dc="application/json",fc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadJson",test(s){return se(s,dc)||ie(s,uc)},async load(s){return await(await j.get().fetch(s)).json()}},pc=".txt",gc="text/plain",mc={name:"loadTxt",extension:{type:P.LoadParser,priority:kt.Low,name:"loadTxt"},test(s){return se(s,gc)||ie(s,pc)},async load(s){return await(await j.get().fetch(s)).text()}},xc=["normal","bold","100","200","300","400","500","600","700","800","900"],yc=[".ttf",".otf",".woff",".woff2"],_c=["font/ttf","font/otf","font/woff","font/woff2"],bc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function wc(s){const t=lt.extname(s),r=lt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(bc)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const vc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Ac(s){return vc.test(s)?s:encodeURI(s)}const Sc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadWebFont",test(s){return se(s,_c)||ie(s,yc)},async load(s,t){var i,r,n;const e=j.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??wc(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>xc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l{$.remove(t.family),j.get().getFontFaceSet().delete(t)})}};function gi(s,t=1){var i;const e=(i=ee.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function mi(s,t,e){s.label=e,s._sourceOrigin=e;const i=new G({source:s,label:e}),r=()=>{delete t.promiseCache[e],$.has(e)&&$.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(J("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(J("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const Cc=".svg",Tc="image/svg+xml",Mc={extension:{type:P.LoadParser,priority:kt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return se(s,Tc)||ie(s,Cc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?kc(s):Pc(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Pc(s,t,e,i){var g,x,y;const n=await(await j.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||gi(s),u=((x=t.data)==null?void 0:x.width)??o.width,d=((y=t.data)==null?void 0:y.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,m=new te({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return mi(m,e,s)}async function kc(s){const e=await(await j.get().fetch(s)).text(),i=new ct;return i.svg(e),i}const Ec=`(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 Yt=null,ei=class{constructor(){Yt||(Yt=URL.createObjectURL(new Blob([Ec],{type:"application/javascript"}))),this.worker=new Worker(Yt)}};ei.revokeObjectURL=function(){Yt&&(URL.revokeObjectURL(Yt),Yt=null)};const Bc=`(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 jt=null;class jn{constructor(){jt||(jt=URL.createObjectURL(new Blob([Bc],{type:"application/javascript"}))),this.worker=new Worker(jt)}}jn.revokeObjectURL=function(){jt&&(URL.revokeObjectURL(jt),jt=null)};let Sr=0,Is;class Ic{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 ei;e.addEventListener("message",i=>{e.terminate(),ei.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Is===void 0&&(Is=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 i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Sr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Sr++,id:i})}}const Cr=new Ic,Fc=[".jpeg",".jpg",".png",".webp",".avif"],Rc=["image/jpeg","image/png","image/webp","image/avif"];async function Lc(s,t){var r;const e=await j.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const qn={name:"loadTextures",extension:{type:P.LoadParser,priority:kt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return se(s,Rc)||ie(s,Fc)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Cr.isImageBitmapSupported()?i=await Cr.loadImageBitmap(s,t):i=await Lc(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new te({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||gi(s),...t.data});return mi(r,e,s)},unload(s){s.destroy(!0)}},Kn=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Gc=Kn.map(s=>`video/${s.substring(1)}`);function Wc(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Dc(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function Oc(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function Dc(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Uc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(s){const t=se(s,Gc),e=ie(s,Kn);return t||e},async load(s,t,e){var h,c;const i={...Ve.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||gi(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await Qr(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),Wc(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=Ve.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new Ve({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await Oc(r),l(mi(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},Zn={extension:{type:P.ResolveParser,name:"resolveTexture"},test:qn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ee.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},zc={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ee.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:Zn.parse};class Hc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ee,this.loader=new cc,this.cache=$,this._backgroundLoader=new ec(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){J("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=qe(t),r=gt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return $.get(t);const e={};for(let i=0;i{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),$.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=gt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=gt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{$.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const K=new Hc;nt.handleByList(P.LoadParser,K.loader.parsers).handleByList(P.ResolveParser,K.resolver.parsers).handleByList(P.CacheParser,K.cache.parsers).handleByList(P.DetectionParser,K.detections);nt.add(sc,rc,ic,lc,ac,oc,hc,fc,mc,Sc,Mc,qn,Uc,tc,Jl,Zn,zc);const Tr={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};nt.handle(P.Asset,s=>{const t=s.ref;Object.entries(Tr).filter(([e])=>!!t[e]).forEach(([e,i])=>nt.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Tr).filter(e=>!!t[e]).forEach(e=>nt.remove(t[e]))});class Qt extends Qe{constructor(t){t instanceof ct&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}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 Qt(this._context.clone()):(this._ownedContext=null,new Qt(this._context))}lineStyle(t,e,i){W(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){W(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){W(O,"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!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return W(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return W(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return W(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return W(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return W(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return W(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Qn=class Jn extends En{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(W(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Jn.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Pt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),h=new Pt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),c=new Pt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:Z.INDEX|Z.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Qn.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Nc=Qn;class Vc extends Qe{constructor(t,e){const{text:i,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new ot({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._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 $c(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(W(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class Ce extends Vc{constructor(...t){const e=$c(t,"Text");super(e,mt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=ti.measureText(this._text,this._style),{width:r,height:n}=i;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const ta=class ea extends Nc{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(W(O,"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={...ea.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;const e=this.verticesX*this.verticesY,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;ue?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};sa.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Vt=sa;const ra=class na extends Qe{constructor(t){var u,d,f,p;t instanceof G&&(t={texture:t});const{width:e,height:i,leftWidth:r,rightWidth:n,topHeight:a,bottomHeight:o,texture:h,roundPixels:c,...l}=t;super({label:"NineSliceSprite",...l}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=r??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.left)??Vt.defaultOptions.leftWidth,this._topHeight=a??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.top)??Vt.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??Vt.defaultOptions.rightWidth,this._bottomHeight=o??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.bottom)??Vt.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??Vt.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??Vt.defaultOptions.height,this.allowChildren=!1,this.texture=h??na.defaultOptions.texture,this.roundPixels=c??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=G.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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};ra.defaultOptions={texture:G.EMPTY};let Me=ra;nt.add(ma,xa);class C{}w(C,"app"),w(C,"GameMaster"),w(C,"WindowHeight"),w(C,"WindowWidth"),w(C,"AspectRatio",16/9),w(C,"Grid"),w(C,"WaveManager"),w(C,"TowerManager"),w(C,"GameScene");class Yc{constructor(){w(this,"currentScene");w(this,"gameScene");w(this,"GameObjects",[]);C.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),C.app.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),C.app.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.GameObjects.forEach(e=>{e.destroy()}),this.currentScene=t,this.currentScene.init()}}const L=class L{static async LoadAssets(){console.log("Loading Texture Assets");const t=new Ce({text:"Loading textures. This might take a while.",style:new mt({fill:3355443,fontSize:50})});t.x=C.app.canvas.width/2,t.y=C.app.canvas.height/2,t.anchor.set(.5,.5),C.app.stage.addChild(t),L.Button01Texture=await K.load({src:"/assets/gui/button_01.png"}),L.Button02Texture=await K.load({src:"/assets/gui/button_02.png"}),L.Frame01Texture=await K.load({src:"/assets/gui/frame_01.png"}),L.Frame02Texture=await K.load({src:"/assets/gui/frame_02.png"}),L.FrameBackground=await K.load({src:"/assets/gui/background_01.png"}),L.FrameTowerTab=await K.load({src:"/assets/gui/background_02.png"}),L.VioletBackground=await K.load({src:"/assets/gui/frame_violet.png"}),L.RedBackground=await K.load({src:"/assets/gui/frame_red.png"}),L.GreenBackground=await K.load({src:"/assets/gui/frame_green.png"}),L.HealthTexture=await K.load({src:"/assets/gui/heart.png"}),L.GoldTexture=await K.load({src:"/assets/gui/money.png"}),L.BasicCreepTexture=await K.load({src:"/assets/creeps/basic.jpg"}),L.BasicTowerTexture=await K.load({src:"/assets/towers/basic_tower.png"}),L.BasicProjectileTexture=await K.load({src:"/assets/projectiles/basic_tower.png"}),await this.LoadMissions(),await this.LoadTowers(),await this.LoadCreepStats(),t.destroy()}static async LoadCreepStats(){const e=await(await fetch("/assets/CreepStats.json")).json();this.CreepStats=e}static async LoadMissions(){L.Missions=[await this.LoadMission("/assets/missions/mission_01.json")]}static async LoadTowers(){const e=await(await fetch("/assets/Towers.json")).json();L.Towers=e,e.forEach(async i=>{let r=this.TowerSprites.length-1;r==-1&&(r=0),this.TowerSprites[r]=await K.load({src:`/assets/towers/${i.sprite}.png`})})}static async LoadMission(t){const i=await(await fetch(t)).json();return await this.LoadBackground(i.mapImage.url),i}static async LoadBackground(t){let e=this.MissionBackgrounds.length-1;e==-1&&(e=0),this.MissionBackgrounds[e]=await K.load({src:t})}};w(L,"BasicCreepTexture"),w(L,"BasicTowerTexture"),w(L,"BasicProjectileTexture"),w(L,"Frame01Texture"),w(L,"Frame02Texture"),w(L,"FrameBackground"),w(L,"FrameTowerTab"),w(L,"VioletBackground"),w(L,"RedBackground"),w(L,"GreenBackground"),w(L,"Button01Texture"),w(L,"Button02Texture"),w(L,"HealthTexture"),w(L,"GoldTexture"),w(L,"MissionBackgrounds",[]),w(L,"TowerSprites",[]),w(L,"Missions"),w(L,"Towers"),w(L,"CreepStats"),w(L,"DebuggingEnabled",!1);let H=L;class Pe{constructor(t){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"_events",new at);w(this,"enabled",!0);C.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onclick=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}}var Te=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(Te||{});class Ze extends Pe{constructor(e,i,r,n=!0){super(!0);w(this,"caption");w(this,"bounds");w(this,"buttonTexture");w(this,"buttonSprite");w(this,"buttonText");r==0&&(this.buttonTexture=H.Button01Texture),r==1&&(this.buttonTexture=H.Button02Texture),this.caption=i,this.enabled=n,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new Me({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 Ce({text:this.caption,style:new mt({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}}class re{constructor(){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"bb",new U);w(this,"_events",new at)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}}var Jt=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(Jt||{});class jc extends re{constructor(e,i,r){super();w(this,"id");w(this,"creepType");w(this,"sprite");w(this,"path");w(this,"stats");w(this,"pathIndex",0);w(this,"speed");w(this,"health");w(this,"maxHealth");w(this,"escaped",!1);w(this,"died",!1);w(this,"x");w(this,"y");w(this,"dead",!1);this.creepType=e,this.stats=structuredClone(H.CreepStats[this.creepType]),this.sprite=new dt({texture:H.BasicCreepTexture}),this.id=r,this.container.x=-70,this.container.y=-50,this.sprite.width=64,this.sprite.height=64,this.speed=this.stats.speed,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=i,this.x=i[0][1]*64+32,this.y=i[0][0]*64+32,C.GameScene.events.on("takenDamage",(n,a)=>{n==this.id&&(this.health-=a)}),C.Grid.container.addChild(this.container),this.container.addChild(this.sprite)}update(e){if(this.dead)return;if(this.health<=0){C.GameScene.events.emit("died",this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit("escaped",this),this.escaped=!0;return}const i=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*64+32,a=r[0]*64+32,o=r[1]-i[1],h=r[0]-i[0];let c=this.speed*e*o,l=this.speed*e*h,u=!1;c>0&&this.x+c>n&&(c=n-this.x,u=!0),c<0&&this.x+c0&&this.y+l>a&&(l=a-this.y,u=!0),l<0&&this.y+l(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Ut||{});class qc extends re{constructor(e,i,r,n){super();w(this,"type");w(this,"row");w(this,"column");w(this,"isPath",!1);w(this,"g");w(this,"clickDetector");if(this.type=e,this.row=i,this.column=r,this.isPath=n,this.bb.x=this.column*64,this.bb.y=this.row*64,this.bb.width=64,this.bb.height=64,C.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new Qt({zIndex:99,interactive:!0}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.clickDetector.onclick=o=>{C.Grid._gridCellClicked(i,r)},!H.DebuggingEnabled)return;const a=new Ce({text:`${this.row}|${this.column}`,style:new mt({fill:16777215,dropShadow:!0,fontSize:16})});this.container.addChild(a),a.anchor.set(.5,.5),a.x=this.bb.width/2,a.y=this.bb.height/2,n&&(a.text+="p")}gDraw(){switch(this.g=new Qt({zIndex:5}),this.g.rect(0,0,this.bb.width,this.bb.height),this.type){case Ut.Restricted:this.g.fill({color:2236962,alpha:.5});break;case Ut.Path:this.g.fill({color:2236962,alpha:.5});break;case Ut.Buildable:this.g.stroke({color:65280,alpha:.9});break}this.container.addChild(this.g)}gClear(){this.g!=null&&(this.container.removeChild(this.g),this.g.destroy())}update(){}}class Kc extends re{constructor(e,i){super();w(this,"gameMap");w(this,"cells",[]);w(this,"creeps",[]);w(this,"gridShown",!1);this.gameMap=e,C.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=64*30,this.bb.height=64*17,C.app.stage.addChild(this.container);let r=new dt(H.MissionBackgrounds[i]);r.x=0,r.y=0,r.width=this.bb.width,r.height=this.bb.height,this.container.addChild(r);for(let n=0;nl.some(u=>u[0]===a&&u[1]===n));h&&(o=Ut.Path);let c=new qc(o,a,n,h);this.cells.push(c)}}toggleGrid(){this.cells.forEach(e=>{this.gridShown?e.gClear():e.gDraw()}),this.gridShown=!this.gridShown}addCreep(e){console.log("ADD CREEP"),this.creeps.push(e),e.events.on(Jt.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(Jt.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(r=>r.row==e&&r.column==i)[0]}_gridCellClicked(e,i){this.onGridCellClicked(e,i)}onGridCellClicked(e,i){}}var aa=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s))(aa||{});class Zc{constructor(t,e){w(this,"creeps",[]);w(this,"rounds");w(this,"paths");w(this,"ticks",0);w(this,"started",!1);w(this,"finished",!1);w(this,"events",new at);w(this,"internalCreepId",0);C.WaveManager=this,this.rounds=t,this.paths=e}start(t){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1;let e=0;this.rounds[t].waves.forEach(i=>{e+=i.firstCreepSpawnTick,i.creeps.forEach(r=>{const n=new jc(r,this.paths[0],this.internalCreepId);this.internalCreepId++;const a={creep:n,tickToSpawnAt:e,spawned:!1};console.log("CREAWTASEDASD"),e+=i.spawnIntervalTicks,this.creeps.push(a)})}),console.log(this.creeps)}end(){this.started=!1}update(t){this.started!=!1&&(this.ticks+=t,this.creeps.forEach(e=>{!e.spawned&&e.tickToSpawnAt<=this.ticks?(e.spawned=!0,this.events.emit("creepSpawned",e.creep),console.log("Wave manager creep spawned, ",e,this.ticks),!this.finished&&this.creeps.every(i=>i.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit("finished"))):e.spawned&&e.creep.update(t)}))}}var oa=(s=>(s.BasicTowerBehaviour="BasicTowerBehaviour",s))(oa||{});class Qc{constructor(){w(this,"isPlacingTower",!1);w(this,"canPlaceTowers",!0);w(this,"selectedTower",null);w(this,"towers",[]);C.TowerManager=this}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(C.Grid.toggleGrid(),this.isPlacingTower?this.selectedTower=null:H.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e)}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)throw console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let i=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(i=r)}),i}PlaceTower(t,e,i,r,n){let a=0;H.Towers.forEach((h,c)=>{h.sprite==t.sprite&&(a=c)});const o=H.TowerSprites[a];if(!C.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return console.warn("Does not have enough gold.");if(!this.GetTowerByRowAndCol(e,i)&&C.Grid.getCellByRowAndCol(e,i).type!=Ut.Path&&C.Grid.getCellByRowAndCol(e,i).type!=Ut.Restricted){C.GameScene.MissionStats.spendGold(t.stats.cost);let h=new su(e,i,o,t,r);this.towers.push(h),this.ToggleChoosingTowerLocation("RESET"),console.log("SHOULDVE PLACED TOWER"),console.log(this.selectedTower),this.selectedTower=null,C.GameScene.events.emit(xi.TowerPlacedEvent,t.name)}else console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}function Jc(s,t,e,i){const r=e-s,n=i-t;return Math.atan2(n,r)}class tu extends re{constructor(e,i,r,n,a){super();w(this,"deleteMe",!1);w(this,"sprite");w(this,"x");w(this,"y");w(this,"angle");w(this,"speed");w(this,"damage");w(this,"timeToLive",1);console.log("I SHOOTTED!"),this.x=e,this.y=i,this.damage=a,this.sprite=new dt({texture:r,scale:.5,rotation:n}),this.sprite.anchor.set(.5),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),C.app.stage.addChild(this.container),this.angle=n,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.timeToLive<=0)return this.destroy();C.Grid.creeps.forEach(i=>{if(!(this.timeToLive<=0)&&i.container&&this.checkCollision(i)){this.timeToLive--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){console.log("COLLIDED WITH"+e),C.GameScene.events.emit(Jt.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let i=this.copyContainerToBB(),r=e.copyContainerToBB();return i.getBounds().intersects(r.getBounds())}}function eu(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}var xi=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s))(xi||{});class su extends re{constructor(e,i,r,n,a){super();w(this,"row");w(this,"column");w(this,"projectiles",[]);w(this,"behaviour");w(this,"definition");w(this,"sprite");w(this,"ticksUntilNextShot");w(this,"graphics",new Qt);this.row=e,this.column=i,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0;let o=C.Grid.getCellByRowAndCol(e,i);this.sprite=new dt({texture:r,height:64,width:64,zIndex:10}),this.container.addChild(this.sprite),o.container.addChild(this.container),o.clickDetector.onmouseenter=h=>{this.graphics.circle(this.column*64+32,this.row*64+32,this.definition.stats.range*64),this.graphics.fill({color:16711680,alpha:.5})},o.clickDetector.onmouseleave=h=>{this.graphics.clear()},C.app.stage.addChild(this.graphics)}GetCreepsInRange(){return C.Grid.creeps.filter(i=>{const r=i.x,n=i.y,a=this.column*64+32,o=this.row*64+32,h=this.definition.stats.range*64;return eu(a,o,r,n){i.deleteMe?(this.projectiles.splice(this.projectiles.indexOf(i),1),i=null):i.update(e)}),this.behaviour==oa.BasicTowerBehaviour){this.ticksUntilNextShot>0&&this.ticksUntilNextShot--;let i=this.GetCreepsInRange();if(i.length>0){let r=i[0];this.ticksUntilNextShot==0&&(this.ticksUntilNextShot=this.definition.stats.cooldown,this.Shoot(r))}}}}class Mr extends Pe{constructor(e,i,r,n,a,o,h){if(e>3||i>2||e<0||i<0)throw"Index/row out of bounds for TowerButton.";super(!0);w(this,"frameSprite");w(this,"background");w(this,"towerName");this.towerName=h,this.container.x=e*r+5,this.container.y=i*n+5,this.background=new dt({texture:o}),this.background.width=r,this.background.height=n,this.container.addChild(this.background),this.frameSprite=new Me({texture:H.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),C.GameScene.events.on(xi.TowerPlacedEvent,c=>{this.frameSprite.tint=16777215}),this.container.onmouseenter=c=>{},this.container.onmouseleave=c=>{}}onClick(e){this.frameSprite.tint==65280?this.frameSprite.tint=16777215:this.frameSprite.tint=65280,C.TowerManager.ToggleChoosingTowerLocation(this.towerName)}}class iu extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"towerTabSprite");w(this,"towerList",[]);this.bounds=e,H.Towers.forEach(i=>{let r={name:i.name,description:i.description,cost:i.stats.cost};this.towerList.push(r)}),this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Me({texture:H.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),new Mr(0,0,70,70,this.container,H.RedBackground,"Basic Tower"),new Mr(0,1,70,70,this.container,H.GreenBackground,"Basic Tower")}}class ru extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"gemTabSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Me({texture:H.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)}}class nu extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"sidebarSprite");w(this,"towerTab");w(this,"gemTab");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Me({texture:H.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 i=new U(60,20,this.bounds.width-65,150);this.towerTab=new iu(i),this.container.addChild(this.towerTab.container);const r=new U(60,180,this.bounds.width-65,this.bounds.height-280);this.gemTab=new ru(r),this.container.addChild(this.gemTab.container)}}class yi{constructor(){w(this,"gui",[]);w(this,"_events",new at)}destroy(){this.gui.forEach(t=>{t.destroy()})}GetGuiObject(t){return this.gui.find(e=>e==t)}GetGuiObjectByName(t){return this.gui.filter(e=>e.name==t)}get events(){return this._events}init(){}}class au extends re{constructor(e,i){super();w(this,"hp",100);w(this,"gold",0);w(this,"goldText");w(this,"healthText");this.hp=e,this.gold=i,this.container.x=0,this.container.y=20,C.app.stage.addChild(this.container),this.healthText=new Ce({text:`${this.hp}`,style:new mt({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new Ce({text:`${this.gold}`,style:new mt({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new dt(H.HealthTexture),n=new dt(H.GoldTexture);this.healthText.x=200,this.healthText.y=-15,r.x=160,r.width=36,r.height=32,r.y=-10,this.goldText.x=200,this.goldText.y=20,n.x=150,n.width=56,n.height=56,n.y=15,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(r),this.container.addChild(n)}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}update(){}}class ha extends yi{constructor(e){super();w(this,"mission");w(this,"missionIndex");w(this,"MissionStats");w(this,"roundMode");w(this,"ticker");w(this,"changeRoundButton");w(this,"sidebar");w(this,"currentRound",0);C.GameScene=this,H.Missions.forEach((i,r)=>{i.name==e&&(this.mission=i,this.missionIndex=r)})}init(){this.ticker=new pe,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.ticker.add(()=>this.update(this.ticker.elapsedMS)),this.ticker.start();const e=new U(64*30-360,0,360,C.app.canvas.height),i=new U(50,C.app.canvas.height-100,310,100);new Kc(this.mission.gameMap,this.missionIndex),new Qc,new Zc(this.mission.rounds,this.mission.gameMap.paths),C.Grid.onGridCellClicked=(r,n)=>{C.TowerManager.isPlacingTower&&C.TowerManager.PlayerClickOnGrid(r,n)},C.WaveManager.events.on(aa.CreepSpawned,r=>{C.Grid.addCreep(r),r.events.on(Jt.Escaped,()=>{this.onCreepEscaped(r)})}),this.events.on(Jt.Died,(r,n)=>{this.MissionStats.earnGold(r)}),this.sidebar=new nu(e),this.changeRoundButton=new Ze(i,"Start",Te.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),this.changeRoundButton.onClick=()=>{console.log("clicked"),this.changeRoundButton.setEnabled(!1),this.changeRoundButton.setCaption("[X]"),this.setRoundMode(1)},this.MissionStats=new au(100,200)}update(e){C.WaveManager.update(e),C.Grid.update(e),C.TowerManager.update(e)}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?C.WaveManager.start(this.currentRound):C.WaveManager.end()}onTowerPlaced(){}}class ou extends yi{init(){H.Missions.forEach((t,e)=>{const i=new Ze(new U(C.app.canvas.width/2-150,C.app.canvas.height/5+e*80,300,60),t.name,Te.Button01);i.onClick=r=>{C.GameMaster.changeScene(new ha(t.name))}})}}class hu extends yi{init(){const t={caption:"New Game",rect:new U(C.WindowWidth/2-150,C.WindowHeight/2-80,300,60),texture:Te.Button01},e={caption:"Settings",rect:new U(C.WindowWidth/2-300/2,C.WindowHeight/2+20,300,60),texture:Te.Button01},i=new Ze(t.rect,t.caption,t.texture,!0);i.onClick=r=>{C.GameMaster.changeScene(new ou)},new Ze(e.rect,e.caption,e.texture,!0)}}(async()=>{const s=new vn;C.app=s,await s.init({width:1920,height:1080,resolution:window.devicePixelRatio||1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(s.canvas);function t(){const i=window.innerWidth,r=window.innerHeight;C.WindowHeight=r,C.WindowWidth=i;const n=i/s.screen.width,a=r/s.screen.height,o=Math.min(n,a),h=Math.round(s.screen.width*o),c=Math.round(s.screen.height*o),l=(i-h)/2,u=(r-c)/2;s.canvas.style.width=`${h}px`,s.canvas.style.height=`${c}px`,s.canvas.style.marginLeft=`${l}px`,s.canvas.style.marginTop=`${u}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}window.addEventListener("resize",t),t(),await H.LoadAssets(),new Yc,globalThis.Globals=C,C.GameMaster.changeScene(new hu),new URLSearchParams(location.href).entries().next().value[1]=="game"&&C.GameMaster.changeScene(new ha("Mission 1"))})();export{W as $,yn as A,Z as B,rt as C,j as D,P as E,Or as F,ts as G,bt as H,Oi as I,dt as J,So as K,Fo as L,D as M,tt as N,U as O,it as P,Zo as Q,Hs as R,xh as S,Ct as T,Os as U,Ui as V,so as W,gs as X,Q as Y,Ur as Z,_n as _,G as a,O as a0,sh as a1,En as a2,zh as a3,Nh as a4,jh as a5,Kh as a6,Zh as a7,Kt as a8,mt as a9,zl as aa,ti as ab,Gn as ac,Ki as ad,Vt as ae,Nc as af,br as ag,Yl as ah,Qt as ai,$ as aj,Ea as ak,Js as al,yr as am,On as an,pe as b,at as c,Pt as d,nt as e,qi as f,ph as g,$e as h,ni as i,gn as j,Kr as k,un as l,xr as m,Ti as n,Uh as o,Hh as p,Xh as q,Ha as r,Cn as s,qh as t,ai as u,on as v,J as w,ka as x,Jh as y,At as z};