const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["games/sunshoes/assets/browserAll-1STCoqOQ.js","games/sunshoes/assets/webworkerAll-3Ebn88U3.js","games/sunshoes/assets/Filter-BiIvpnZm.js","games/sunshoes/assets/WebGPURenderer-Ddwua8JA.js","games/sunshoes/assets/BufferResource-BZpoqTVb.js","games/sunshoes/assets/RenderTargetSystem-Cp6tD-lP.js","games/sunshoes/assets/WebGLRenderer-CdpFaPwH.js","games/sunshoes/assets/CanvasRenderer-Yf_04ykh.js"])))=>i.map(i=>d[i]); var ra=Object.defineProperty;var na=(s,t,e)=>t in s?ra(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var G=(s,t,e)=>na(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 o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).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 oa="modulepreload",aa=function(s){return"/"+s},ji={},pe=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){let o=function(l){return Promise.all(l.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),h=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=o(e.map(l=>{if(l=aa(l),l in ji)return;ji[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const f=document.createElement("link");if(f.rel=c?"stylesheet":oa,c||(f.as="script"),f.crossOrigin="",f.href=l,h&&f.setAttribute("nonce",h),document.head.appendChild(f),c)return new Promise((d,p)=>{f.addEventListener("load",d),f.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return t().catch(n)})};var I=(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.TextureUploaderWebGL="texture-uploader-webgl",s.TextureUploaderWebGPU="texture-uploader-webgpu",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(I||{});const ni=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},Je=(s,t)=>ni(s).priority??t,K={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(ni).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(ni).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,r=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var o;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]&&((o=n[s])==null||o.forEach(a=>t(a)),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,o)=>Je(o.value,e)-Je(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)=>Je(n,e)-Je(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}},ha={extension:{type:I.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await pe(()=>import("./browserAll-1STCoqOQ.js"),__vite__mapDeps([0,1,2]))}},la={extension:{type:I.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await pe(()=>import("./webworkerAll-3Ebn88U3.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=${this._x} y=${this._y} 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 ca(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ls={exports:{}},Yi;function ua(){return Yi||(Yi=1,(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,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new r(c,u||h,f),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],d]:h._events[p].push(d):(h._events[p]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var f=0,d=u.length,p=new Array(d);fqt[s],uY:s=>Kt[s],vX:s=>Qt[s],vY:s=>Zt[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>oi[s][t],sub:(s,t)=>oi[s][O.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?O.S:O.N:Math.abs(t)*2<=Math.abs(s)?s>0?O.E:O.W:t>0?s>0?O.SE:O.SW:s>0?O.NE:O.NW,matrixAppendRotationInv:(s,t,e=0,i=0,r=0,n=0)=>{const o=mn[O.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,u=e-Math.min(0,a*r,l*n,a*r+l*n),f=i-Math.min(0,h*r,c*n,h*r+c*n),d=s.a,p=s.b,g=s.c,m=s.d;s.a=a*d+h*g,s.b=a*p+h*m,s.c=l*d+c*g,s.d=l*p+c*m,s.tx=u*d+f*g+s.tx,s.ty=u*p+f*m+s.ty},transformRectCoords:(s,t,e,i)=>{const{x:r,y:n,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===O.E?(i.set(r+h,n+l,o,a),i):e===O.S?i.set(c-n-a+h,r+l,a,o):e===O.W?i.set(c-r-o+h,u-n-a+l,o,a):e===O.N?i.set(n+h,u-r-o+l,a,o):i.set(r+h,n+l,o,a)}},es=[new lt,new lt,new lt,new lt];class tt{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 tt(0,0,0,0)}clone(){return new tt(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=u&&t<=f&&e>=d&&e<=p&&!(t>g&&t_&&et.right?t.right:this.right)<=k)return!1;const S=this.yt.bottom?t.bottom:this.bottom)>S}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=es[0].set(t.left,t.top),h=es[1].set(t.left,t.bottom),l=es[2].set(t.right,t.top),c=es[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const f=u*(h.y-a.y),d=u*(a.x-h.x),p=f*i+d*n,g=f*r+d*n,m=f*i+d*o,_=f*r+d*o;if(Math.max(p,g,m,_)<=f*a.x+d*a.y||Math.min(p,g,m,_)>=f*c.x+d*c.y)return!1;const y=u*(a.y-l.y),x=u*(l.x-a.x),w=y*i+x*n,v=y*r+x*n,b=y*i+x*o,A=y*r+x*o;return!(Math.max(w,v,b,A)<=y*a.x+x*a.y||Math.min(w,v,b,A)>=y*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),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}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,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 tt),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,r=t.x+t.width,n=t.y+t.height;return e>=this.x&&e=this.y&&i=this.x&&r=this.y&&n{if(ue.quiet||Xi.has(t))return;let i=new Error().stack;const r=`${t} Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!ue.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(` `).splice(e).join(` `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),Xi.add(t)});Object.defineProperties(X,{quiet:{get:()=>ue.quiet,set:s=>{ue.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>ue.noColor,set:s=>{ue.noColor=s},enumerable:!0,configurable:!1}});const gn=()=>{};function _e(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 qi(s){return!(s&s-1)&&!!s}function _n(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Ki=Object.create(null);function ba(s){const t=Ki[s];return t===void 0&&(Ki[s]=J("resource")),t}const yn=class xn extends ft{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...xn.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){X(_t,"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._sharedResourceId=null,this.emit("change",this)}_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=ba(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};yn.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ye=yn;const bn=class wn extends ft{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=J("textureSource"),this._resourceType="textureSource",this._resourceId=J("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.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...wn.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.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new ye(_n(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())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}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.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=J("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}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=J("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=qi(this.pixelWidth)&&qi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};bn.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let St=bn;class Ri extends St{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}}Ri.extension=I.TextureSource;const Qi=new W;class wa{constructor(t,e){this.mapCoord=new W,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),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 tt);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=Zi,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 o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty;let f=this.minX,d=this.minY,p=this.maxX,g=this.maxY,m=o*t+h*e+c,_=a*t+l*e+u;mp&&(p=m),_>g&&(g=_),m=o*i+h*e+c,_=a*i+l*e+u,mp&&(p=m),_>g&&(g=_),m=o*t+h*r+c,_=a*t+l*r+u,mp&&(p=m),_>g&&(g=_),m=o*i+h*r+c,_=a*i+l*r+u,mp&&(p=m),_>g&&(g=_),this.minX=f,this.minY=d,this.maxX=p,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*e+h*n+c,d=a*e+l*n+u,this.minX=fthis.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*r+h*n+c,d=a*r+l*n+u,this.minX=fthis.maxX?f:this.maxX,this.maxY=d>this.maxY?d: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 vt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,c=r.b,u=r.c,f=r.d,d=r.tx,p=r.ty;for(let g=e;ga?y:a,h=x>h?x:h}this.minX=n,this.minY=o,this.maxX=a,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}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var va={grad:.9,turn:360,rad:360/(2*Math.PI)},Et=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},rt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},bt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},An=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Ji=function(s){return{r:bt(s.r,0,255),g:bt(s.g,0,255),b:bt(s.b,0,255),a:bt(s.a)}},Gs=function(s){return{r:rt(s.r),g:rt(s.g),b:rt(s.b),a:rt(s.a,3)}},Aa=/^#([0-9a-f]{3,8})$/i,ss=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Sn=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Cn=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),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},tr=function(s){return{h:An(s.h),s:bt(s.s,0,100),l:bt(s.l,0,100),a:bt(s.a)}},er=function(s){return{h:rt(s.h),s:rt(s.s),l:rt(s.l),a:rt(s.a,3)}},sr=function(s){return Cn((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},Ge=function(s){return{h:(t=Sn(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},Sa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ca=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ta=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ai={string:[[function(s){var t=Aa.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?rt(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?rt(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Ta.exec(s)||Pa.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Ji({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=Sa.exec(s)||Ca.exec(s);if(!t)return null;var e,i,r=tr({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(va[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return sr(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 Et(t)&&Et(e)&&Et(i)?Ji({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(!Et(t)||!Et(e)||!Et(i))return null;var o=tr({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return sr(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!Et(t)||!Et(e)||!Et(i))return null;var o=(function(a){return{h:An(a.h),s:bt(a.s,0,100),v:bt(a.v,0,100),a:bt(a.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Cn(o)},"hsv"]]},ir=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=Gs(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?ss(rt(255*n)):"","#"+ss(e)+ss(i)+ss(r)+o;var t,e,i,r,n,o},s.prototype.toRgb=function(){return Gs(this.rgba)},s.prototype.toRgbString=function(){return t=Gs(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 er(Ge(this.rgba))},s.prototype.toHslString=function(){return t=er(Ge(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=Sn(this.rgba),{h:rt(t.h),s:rt(t.s),v:rt(t.v),a:rt(t.a,3)};var t},s.prototype.invert=function(){return Pt({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),Pt(Ds(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Pt(Ds(this.rgba,-t))},s.prototype.grayscale=function(){return Pt(Ds(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Pt(rr(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Pt(rr(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"?Pt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):rt(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=Ge(this.rgba);return typeof t=="number"?Pt({h:t,s:e.s,l:e.l,a:e.a}):rt(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Pt(t).toHex()},s})(),Pt=function(s){return s instanceof hi?s:new hi(s)},nr=[],ka=function(s){s.forEach(function(t){nr.indexOf(t)<0&&(t(hi,ai),nr.push(t))})};function Ea(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(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,f="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var p in e){var g=(a=c,h=n[p],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));gn===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}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]=Be._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._value=null,this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&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 a=Be.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Pt(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.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 Be||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}};xe.shared=new xe;xe._temp=new xe;xe.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let q=xe;const Ia={cullArea:null,cullable:!1,cullableChildren:!0};let Ws=0;const or=500;function Y(...s){Ws!==or&&(Ws++,Ws===or?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const Qe={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)},release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}};class Ra{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,this._count++),(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(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t{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}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const At=new La;Qe.register(At);const Ba={get isCachedAsTexture(){var s;return!!((s=this.renderGroup)!=null&&s.isCachedAsTexture)},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){var s;(s=this.renderGroup)==null||s.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){X("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function Fa(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 h=this.children[a];h&&(r.push(h),h.parent=null)}Fa(this.children,s,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(r);for(let a=0;a0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||X(_t,"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}`);const i=s.parent===this;if(s.parent){const n=s.parent.children.indexOf(s);if(i){if(n===t)return s;s.parent.children.splice(n,1)}else s.removeFromParent()}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const r=this.renderGroup||this.parentRenderGroup;return r&&r.addChild(s),this.sortableChildren&&(this.sortDirty=!0),i||(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},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s)}},Da={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e))},collectRenderablesSimple(s,t,e){const i=this.children,r=i.length;for(let n=0;n=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,s)}}};class ar{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;ee.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),li.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=li.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new ar);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 ar),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Ua={label:null,get name(){return X(_t,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){X(_t,"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>16&255,i=s>>8&255,r=s&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=r*a/255|0;return(h<<16)+(l<<8)+c}const hr=16777215;function lr(s,t){return s===hr?t:t===hr?s:Mn(s,t)}function fs(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const Na={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(s=new W,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Li(this,ut.get().identity());return s.appendFrom(this.localTransform,e),ut.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?fs(this.renderGroup.worldColor):this.parentRenderGroup?fs(lr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=lr(t,e.localColor),e=e.parent;return fs(t)}};function kn(s,t,e){return t.clear(),e||(e=W.IDENTITY),En(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function En(s,t,e,i,r){var h,l;let n;if(r)n=ut.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const c=s.localTransform;n=ut.get(),n.appendFrom(c,e)}const o=t,a=!!s.effects.length;if(a&&(t=Lt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));const c=s.children;for(let u=0;u-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(t){for(let e=0;ethis.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){X("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),K.mixin(Ut,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||X(_t,"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.parentRenderLayer&&e.parentRenderLayer.detach(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(Za,this),this.groupTransform=W.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),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 W),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*pa}set angle(t){this.rotation=t*ma}get pivot(){return this._pivot===is&&(this._pivot=new ot(this,0,0)),this._pivot}set pivot(t){this._pivot===is&&(this._pivot=new ot(this,0,0),this._origin!==rs&&Y("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Us&&(this._skew=new ot(this,0,0)),this._skew}set skew(t){this._skew===Us&&(this._skew=new ot(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===zs&&(this._scale=new ot(this,1,1)),this._scale}set scale(t){this._scale===zs&&(this._scale=new ot(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===rs&&(this._origin=new ot(this,0,0)),this._origin}set origin(t){this._origin===rs&&(this._origin=new ot(this,0,0),this._pivot!==is&&Y("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.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:this.scale.x,typeof t.scaleY=="number"?t.scaleY: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.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.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._origin,o=this._position,a=i._x,h=i._y,l=r._x,c=r._y,u=-n._x,f=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+f*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+f*e.d)-f}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=cr,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|=cr,this._onUpdate())}get tint(){return fs(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=th,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|=Hs,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}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|=Hs,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|=Hs,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;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&e)for(let n=0;n=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:r}=e;r.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=r[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l{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),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof U?new yt(t):new yt(U.from(t,e))}set texture(t){t||(t=U.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 visualBounds(){return vn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return X("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:r,height:n}=e.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*n,i.maxY=i.minY+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._visualBounds=null,this._bounds=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 eh=new vt;function Bn(s,t,e){const i=eh;s.measurable=!0,Tn(s,e,i),t.addBoundsMask(i),s.measurable=!1}function Fn(s,t,e){const i=Lt.get();s.measurable=!0;const r=ut.get().identity(),n=Gn(s,e,r);kn(s,i,n),s.measurable=!1,t.addBoundsMask(i),ut.return(r),Lt.return(i)}function Gn(s,t,e){return s?(s!==t&&(Gn(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(Y("Mask bounds, renderable is not inside the root container"),e)}class Dn{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof yt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||Bn(this.mask,t,e)}addLocalBounds(t,e){Fn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof yt}}Dn.extension=I.MaskEffect;class On{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"}}On.extension=I.MaskEffect;class Wn{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!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){Bn(this.mask,t,e)}addLocalBounds(t,e){Fn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Ut}}Wn.extension=I.MaskEffect;const sh={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,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 ur=sh;const z={get(){return ur},set(s){ur=s}};class Un extends St{constructor(t){t.resource||(t.resource=z.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,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(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"))}}Un.extension=I.TextureSource;class be extends St{constructor(t){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}}be.extension=I.TextureSource;var ze=(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))(ze||{});class Ns{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 zn=class gt{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 Ns(null,null,1/0),this.deltaMS=1/gt.targetFPMS,this.elapsedMS=1/gt.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=ze.NORMAL){return this._addListener(new Ns(t,e,i))}addOnce(t,e,i=ze.NORMAL){return this._addListener(new Ns(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(nthis.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t{var o;const t=z.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(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),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Vs}const Ps=class Nn extends St{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Nn.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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=dt.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.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Hn(),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._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),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.isValid&&(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("loadedmetadata",this._onLoadedMetadata),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&&(dt.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||(dt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(dt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ps.extension=I.TextureSource;Ps.defaultOptions={...St.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ps.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let De=Ps;const Tt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class ih{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||Y(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Tt(t);let r;for(let h=0;h{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&Y("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){Y(`[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 nt=new ih,ci=[];K.handleByList(I.TextureSource,ci);function Vn(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r{nt.has(i)&&nt.remove(i)}),t||nt.set(i,n),n}function nh(s,t=!1){return typeof s=="string"?nt.get(s):s instanceof St?new U({source:s}):rh(s,t)}U.from=nh;St.from=Vn;K.add(Dn,On,Wn,De,be,Un,Ri);var Gt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Gt||{});function Ct(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Ce(s){return s.split("?")[0].split("#")[0]}function oh(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ah(s,t,e){return s.replace(new RegExp(oh(t),"g"),e)}function hh(s,t){let e="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a2){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=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const at={toPosix(s){return ah(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){Ct(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(Ct(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Ce(this.toPosix(t??z.get().getBaseUrl())),r=Ce(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?at.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(Ct(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=hh(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Ct(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(Ct(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),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=!1;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){Ct(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){Ct(s),t&&Ct(t),s=Ce(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 o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a: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){Ct(s),s=Ce(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?t===-1?t=o: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){Ct(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Ce(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,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function $n(s,t,e,i,r){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");r.push(o)}),$n(s,r,0,e,i)}else i.push(s);return i}const gs=s=>!Array.isArray(s);class ve{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 Tt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&Y("[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,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&Y(`[Resolver] already has key: ${n} overwriting`)},Tt(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=Tt(o).map(g=>typeof g=="string"?lh(g):Array.isArray(g)?g:[g]),f=this.getAlias(n);Array.isArray(f)?f.forEach(i):i(f);const d=[],p=g=>{const m=this._parsers.find(_=>_.test(g));return{src:g,...m==null?void 0:m.parse(g)}};u.forEach(g=>{g.forEach(m=>{let _={};if(typeof m!="object"?_=p(m):(a=m.data??a,h=m.format??h,(m.loadParser||m.parser)&&(l=m.loadParser??l,c=m.parser??c),_={...p(m.src),...m}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this._buildResolvedAsset(_,{aliases:f,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),d.push(_)})}),f.forEach(g=>{this._assetMap[g]=d})})}resolveBundle(t){const e=gs(t);t=Tt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}i[r]=a}}),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=gs(t);t=Tt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),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,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=at.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.parser=o??t.parser,t.format=a??t.format??ch(t.src),h!==void 0&&(t.progressSize=h),t}}ve.RETINA_PREFIX=/@([0-9\.]+)x/;function ch(s){return s.split(".").pop().split("?").shift().split("#").shift()}const ui=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},jn=class Fe{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof St&&(i={texture:t,data:e});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof U?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.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<=Fe.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const r=e?1/0:Fe.BATCH_SIZE;for(;i-t{this._batchIndex*Fe.BATCH_SIZE{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=at.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=Yn([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const dh={extension:I.Asset,cache:{test:s=>s instanceof dr,getCacheableAssets:(s,t)=>Yn(s,t,!1)},resolver:{extension:{type:I.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&uh.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ve.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:I.LoadParser,priority:Gt.Normal,name:"spritesheetLoader"},async testParse(s,t){return at.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,f;const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=at.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof U)h=i;else{const d=ui(a+(r??s.meta.image),t.src);h=(await e.load([{src:d,data:n}]))[d]}const l=new dr({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(c)){const d=[];for(const g of c){if(typeof g!="string")continue;let m=a+g;(f=t.data)!=null&&f.ignoreMultiPack||(m=ui(m,t.src),d.push(e.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(g=>{g.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==g))})}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};K.add(dh);const $s=Object.create(null),fr=Object.create(null);function Bi(s,t){let e=fr[s];return e===void 0&&($s[t]===void 0&&($s[t]=1),fr[s]=e=$s[t]++),e}let ne;function Xn(){return(!ne||ne!=null&&ne.isContextLost())&&(ne=z.get().createCanvas().getContext("webgl",{})),ne}let ns;function fh(){if(!ns){ns="mediump";const s=Xn();s&&s.getShaderPrecisionFormat&&(ns=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return ns}function ph(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 mh(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 gh(s,t){return t?`#version 300 es ${s}`:s}const _h={},yh={};function xh(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?_h:yh;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} ${s}`}function bh(s,t){return t?s.replace("#version 300 es",""):s}const js={stripVersion:bh,ensurePrecision:mh,addProgramDefines:ph,setProgramName:xh,insertVersion:gh},Te=Object.create(null),qn=class di{constructor(t){t={...di.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:fh()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(js).forEach(o=>{const a=i[o];r=js[o](r,a,!0),n=js[o](n,a,!1)}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Bi(`${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,Te[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Te[e]||(Te[e]=new di(t),Te[e]._cacheKey=e),Te[e]}};qn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Kn=qn;const pr={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 wh(s){return pr[s]??pr.float32}const vh={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},mr=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function gr(s,t){let e;for(;(e=mr.exec(s))!==null;){const i=vh[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:i,stride:wh(i).stride,offset:0,instance:!1,start:0}}mr.lastIndex=0}function Ah(s){return s.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Sh({source:s,entryPoint:t}){const e={},i=Ah(s),r=i.indexOf(`fn ${t}(`);if(r===-1)return e;const n=i.indexOf("->",r);if(n===-1)return e;const o=i.substring(r,n);if(gr(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=i.match(l);c&&gr(c[1],e)}}return e}function Ys(s){var u,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(u=s.match(t))==null?void 0:u.map(d=>({group:parseInt(d.match(e)[1],10),binding:parseInt(d.match(i)[1],10),name:d.match(r)[2],isUniform:d.match(r)[1]==="",type:d.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=s.match(o))==null?void 0:f.map(d=>{const p=d.match(h)[1],g=d.match(a).reduce((m,_)=>{const[y,x]=_.split(":");return m[y.trim()]=x.trim(),m},{});return g?{name:p,members:g}:null}).filter(({name:d})=>l.some(p=>p.type===d||p.type.includes(`<${d}>`))))??[];return{groups:l,structs:c}}var Jt=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Jt||{});function Ch({groups:s}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:r,groups:n}}const Pe=Object.create(null);class Ms{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=Ys(e.source);this.structsAndGroups=l}else{const l=Ys(i.source),c=Ys(e.source);this.structsAndGroups=Ph(l,c)}this.layout=r??Th(this.structsAndGroups),this.gpuLayout=n??Ch(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.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=Bi(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Sh(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Pe[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Pe[e]||(Pe[e]=new Ms(t),Pe[e]._cacheKey=e),Pe[e]}}const Qn=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],Mh=Qn.reduce((s,t)=>(s[t]=!0,s),{});function kh(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 Zn=class Jn{constructor(t,e){this._touched=0,this.uid=J("uniform"),this._resourceType="uniformGroup",this._resourceId=J("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Jn.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,!Mh[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Qn.join(", ")}`)}n.value??(n.value=kh(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Bi(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Zn.defaultOptions={ubo:!1,isStatic:!1};let to=Zn;class ps{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&&((r=i==null?void 0:i.off)==null||r.call(i,"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,e){const i=this.resources;for(const r in i)i[r]._gcLastUsed=t,i[r]._touched=e}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r==null?void 0:r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var fi=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.CANVAS=4]="CANVAS",s[s.BOTH=3]="BOTH",s))(fi||{});class Fi extends ft{constructor(t){super(),this.uid=J("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=fi.WEBGPU),i&&(o|=fi.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in n)h[c]||(r[99]||(r[99]=new ps,this._ownedBindGroups.push(r[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let f=n[c];!f.source&&!f._resourceType&&(f=new to(f));const d=h[u];d&&(r[d.group]||(r[d.group]=new ps,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(f,d.binding))}}this.groups=r,this._uniformBindMap=a,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 ps,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(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,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,o;return e&&(n=Ms.from(e)),i&&(o=Kn.from(i)),new Fi({gpuProgram:n,glProgram:o,...r})}}const pi=[];K.handleByNamedList(I.Environment,pi);async function Eh(s){if(!s)for(let t=0;t80*e){a=s[0],h=s[1];let c=a,u=h;for(let f=e;fc&&(c=d),p>u&&(u=p)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return gi(n,o,a,h,l),o}function eo(s,t,e,i,r){let n=null;if(r===qh(s,t,e,i)>0)for(let o=t;o=t;o-=i)n=br(o/i|0,s[o],s[o+1],n);return n&&Ne(n,n.next)&&($e(n),n=n.next),n}function ie(s,t=s){const e=t===s;let i=s,r;do r=!1,i!==i.next&&(He.size===0||!He.has(i))&&(Ne(i,i.next)||st(i.prev,i,i.next)===0)?((e||i===t)&&(t=i.prev),mi=!0,$e(i),i=i.prev,r=!0):(e||i!==t)&&(i=i.next,r=!e);while(r||i!==t);return t}function gi(s,t,e,i,r){r&&Nh(s,e,i,r);let n=s,o=!1;for(;s.prev!==s.next;){const a=s.prev,h=s.next;if(st(a,s,h)<0&&(r?Lh(s,e,i,r):Rh(s))){t.push(a.i,s.i,h.i),$e(s),s=h,n=h;continue}if(s=h,s===n){if(mi=!1,s=ie(s),mi){n=s;continue}if(!o){s=Bh(s,t),n=s,o=!0;continue}Fh(s,t,e,i,r);break}}}function Rh(s){const t=s.prev,e=s,i=s.next,r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(r,n,o),u=Math.min(a,h,l),f=Math.max(r,n,o),d=Math.max(a,h,l);let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=u&&p.y<=d&&!(r===p.x&&a===p.y)&&ys(r,a,n,h,o,l,p.x,p.y)&&st(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Lh(s,t,e,i){const r=s.prev,n=s,o=s.next,a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,f=o.y,d=Math.min(a,h,l),p=Math.min(c,u,f),g=Math.max(a,h,l),m=Math.max(c,u,f),_=bi(d,p,t,e,i),y=bi(g,m,t,e,i);let x=s.prevZ;for(;x&&x.z>=_;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==o&&!(a===x.x&&c===x.y)&&ys(a,c,h,u,l,f,x.x,x.y)&&st(x.prev,x,x.next)>=0)return!1;x=x.prevZ}let w=s.nextZ;for(;w&&w.z<=y;){if(w.x>=d&&w.x<=g&&w.y>=p&&w.y<=m&&w!==o&&!(a===w.x&&c===w.y)&&ys(a,c,h,u,l,f,w.x,w.y)&&st(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Bh(s,t){let e=s,i=!1;do{const r=e.prev,n=e.next.next;ro(r,e,e.next,n,!1)&&Ve(r,n)&&Ve(n,r)&&(t.push(r.i,e.i,n.i),$e(e),$e(e.next),e=s=n,i=!0),e=e.next}while(e!==s);return i?ie(e):e}function Fh(s,t,e,i,r){let n=s;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&jh(n,o)){let a=no(n,o);n=ie(n,n.next),a=ie(a,a.next),gi(n,t,e,i,r),gi(a,t,e,i,r);return}o=o.next}n=n.next}while(n!==s)}let _i=!1;function Gh(s,t,e,i){const r=[];for(let n=0,o=t.length;no&&(o=e.x),e.ya&&(a=e.y),c.xo&&(o=c.x),c.ya&&(a=c.y),e=c}while(++hZ[e+2]&&(Z[e+2]=t.x),t.y>Z[e+3]&&(Z[e+3]=t.y)}function yr(s){let t=xi[s];for(;t.prev.next!==t;)t=t.next;return xi[s]=t,t}function xr(s){let t=yi[s];for(;t.prev.next!==t;)t=t.next;return yi[s]=t,t}function zh(s,t){let e=t;const i=s.x,r=s.y;let n=-1/0,o;if(Ne(s,e))return e;for(let f=0,d=0;f<_s;f++,d+=4){if(rZ[d+3]||Z[d]>i||Z[d+2]<=n)continue;const p=yr(f);e=xr(f);do{if(e.prev.next===e){if(Ne(s,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const g=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(g<=i&&g>n&&(n=g,o=e.xi||Z[d+3]c)continue;const p=yr(f);e=xr(f);do{if(e.prev.next===e&&i>=e.x&&e.x>=a&&i!==e.x&&ys(ri)&&(go.x||e.x===o.x&&Hh(o,e)))&&(o=e,u=g)}e=e.next}while(e!==p)}return o}function Hh(s,t){return st(s.prev,s,t.prev)<0&&st(t.next,s,s.next)<0}const xt=[];let ke=[],jt=new Uint32Array(0),Ee=new Uint32Array(0);const Ie=new Uint32Array(256);function Nh(s,t,e,i){let r=s,n=0;do r.z=bi(r.x,r.y,t,e,i),xt[n++]=r,r=r.next;while(r!==s);Vh(n);let o=null;for(let a=0;a=0&&xt[r].z>i;)xt[r+1]=xt[r],r--;xt[r+1]=e}return}jt.length>>n&255]++;let o=0;for(let a=0;a<256;a++){const h=Ie[a];Ie[a]=o,o+=h}for(let a=0;a>>n&255]++;i[l]=t[a],r[l]=h}}function bi(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 $h(s){let t=s,e=s;do(t.x=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function jh(s,t){const e=Ne(s,t)&&st(s.prev,s,s.next)>0&&st(t.prev,t,t.next)>0;return s.next.i!==t.i&&(e||Ve(s,t)&&Ve(t,s)&&(st(s.prev,s,t.prev)!==0||st(s,t.prev,t)!==0))&&!Yh(s,t)&&(e||Xh(s,t))}function st(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Ne(s,t){return s.x===t.x&&s.y===t.y}function ro(s,t,e,i,r=!0){const n=st(s,t,e),o=st(s,t,i),a=st(e,i,s),h=st(e,i,t);return(n>0&&o<0||n<0&&o>0)&&(a>0&&h<0||a<0&&h>0)?!0:r?!!(n===0&&as(s,e,t)||o===0&&as(s,i,t)||a===0&&as(e,s,i)||h===0&&as(e,t,i)):!1}function as(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 Yh(s,t){const e=Math.min(s.x,t.x),i=Math.max(s.x,t.x),r=Math.min(s.y,t.y),n=Math.max(s.y,t.y);let o=s;do{const a=o.next;if(o.x>i&&a.x>i||o.xn&&a.y>n||o.y=0&&st(s,s.prev,t)>=0:st(s,t,s.prev)<0||st(s,s.next,t)<0}function Xh(s,t){let e=s,i=!1;const r=(s.x+t.x)/2,n=(s.y+t.y)/2;do{const o=e.next;e.y>n!=o.y>n&&r<(o.x-e.x)*(n-e.y)/(o.y-e.y)+e.x&&(i=!i),e=o}while(e!==s);return i}function no(s,t){const e=wi(s.i,s.x,s.y),i=wi(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 br(s,t,e,i){const r=wi(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 $e(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),_i&&Uh(s.prev,s.next)}function wi(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function qh(s,t,e,i){let r=0;for(let n=t,o=e-i;n(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))(oo||{});class Qh{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,o,a,h){const{name:l,items:c}=this;for(let u=0,f=c.length;u{this.runners[e]=new Qh(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,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Qe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ih())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};ao.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let lo=ao,hs;function Jh(s){return hs!==void 0||(hs=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??lo.defaultOptions.failIfMajorPerformanceCaveat};try{if(!z.get().getWebGLRenderingContext())return!1;let r=z.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const o=r.getExtension("WEBGL_lose_context");o&&o.loseContext()}return r=null,n}catch{return!1}})()),hs}let ls;async function tl(s={}){return ls!==void 0||(ls=await(async()=>{const t=z.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),ls}const wr=["webgl","webgpu","canvas"];async function el(s){let t=[];s.preference?Array.isArray(s.preference)?t=s.preference.slice():(t.push(s.preference),wr.forEach(n=>{n!==s.preference&&t.push(n)})):t=wr.slice();let e,i={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-Ddwua8JA.js");return{WebGPURenderer:h}},__vite__mapDeps([3,4,2,5]));e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&Jh(s.failIfMajorPerformanceCaveat??lo.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await pe(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-CdpFaPwH.js");return{WebGLRenderer:h}},__vite__mapDeps([6,4,2,5]));e=a,i={...s,...s.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await pe(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-Yf_04ykh.js");return{CanvasRenderer:h}},__vite__mapDeps([7,5,2]));e=a,i={...s,...s.canvasOptions};break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const co="8.19.0";class uo{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,co)}static destroy(){}}uo.extension=I.Application;class sl{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,co)}destroy(){this._renderer=null}}sl.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"initHook",priority:-10};class fo{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}fo.extension=I.Application;class po{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,ze.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?dt.shared:new dt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}po.extension=I.Application;K.add(fo);K.add(po);const mo=class vi{constructor(...t){this.stage=new Ut,t[0]!==void 0&&X(_t,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new Ut),this.renderer=await el(t),vi._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return X(_t,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const i=vi._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}};mo._plugins=[];let go=mo;K.handleByList(I.Application,go._plugins);K.add(uo);const Xs={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const f=t[u].match(/^[a-z]+/gm)[0],d=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const g in d){const m=d[g].split("="),_=m[0],y=m[1].replace(/"/gm,""),x=parseFloat(y),w=isNaN(x)?y:x;p[_]=w}e[f].push(p)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let u=0;u)/)?vr.test(z.get().parseXML(s)):!1},parse(s){return vr.parse(z.get().parseXML(s))}},il=[".xml",".fnt"],rl={extension:{type:I.CacheParser,name:"cacheBitmapFont"},test:s=>!!(s!=null&&s.pages)&&!!(s!=null&&s.chars)&&typeof(s==null?void 0:s.fontFamily)=="string"&&s.fontFamily!=="",getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},nl={extension:{type:I.LoadParser,priority:Gt.Normal},name:"loadBitmapFont",id:"bitmap-font",test(s){return il.includes(at.extname(s).toLowerCase())},async testParse(s){return Xs.test(s)||Ar.test(s)},async parse(s,t,e){const i=Xs.test(s)?Xs.parse(s):Ar.parse(s),{src:r}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let f=0;fimport("./BitmapFont-CoN36Cy_.js"),[])]),c=o.map(f=>h[f.src]);return new l({data:i,textures:c},r)},async load(s,t){return await(await z.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 ol{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 U),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function _o(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 hl={extension:{type:I.DetectionParser,priority:1},test:async()=>_o("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Sr=["png","jpg","jpeg"],ll={extension:{type:I.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Sr],remove:async s=>s.filter(t=>!Sr.includes(t))},cl="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ks(s){return cl?!1:document.createElement("video").canPlayType(s)!==""}const ul={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},dl={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},fl={extension:{type:I.DetectionParser,priority:0},test:async()=>ks("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},pl={extension:{type:I.DetectionParser,priority:0},test:async()=>_o("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")},yo=class ms{constructor(){this.loadOptions={...ms.defaultOptions},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 o,a;let r=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&Y(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||Y(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h({alias:[g],src:g,data:{}})),d=f.reduce((g,m)=>g+(m.progressSize||1),0),p=f.map(async g=>{const m=at.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(m,g,{onProgress:r,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=g.progressSize||1,r&&r(l/d))});return await Promise.all(p),u?c[f[0].src]:c}async unload(t){const i=Tt(t,r=>({alias:[r],src:r})).map(async r=>{var a,h;const n=at.toAbsolute(r.src),o=this.promiseCache[n];if(o){const l=await o.promise;delete this.promiseCache[n],await((h=(a=o.parser)==null?void 0:a.unload)==null?void 0:h.call(a,l,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?Y("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&Y(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,r){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=u=>new Promise(f=>setTimeout(f,u));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),r[e.src]=await this.promiseCache[t].promise;return}catch(u){delete this.promiseCache[t],delete r[e.src],n++;const f=a!=="retry"||n>h;if(a==="retry"&&!f){o&&o(u,e),await c(l);continue}if(a==="skip"){o&&o(u,e);return}o&&o(u,e);const d=new Error(`[Loader.load] Failed to load ${t}. ${u}`);throw u instanceof Error&&u.stack&&(d.stack=u.stack),d}}};yo.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let ml=yo;function Ae(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 Se(s,t){const e=s.split("?")[0],i=at.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const gl=".json",_l="application/json",yl={extension:{type:I.LoadParser,priority:Gt.Low},name:"loadJson",id:"json",test(s){return Ae(s,_l)||Se(s,gl)},async load(s){return await(await z.get().fetch(s)).json()}},xl=".txt",bl="text/plain",wl={name:"loadTxt",id:"text",extension:{type:I.LoadParser,priority:Gt.Low,name:"loadTxt"},test(s){return Ae(s,bl)||Se(s,xl)},async load(s){return await(await z.get().fetch(s)).text()}},vl=["normal","bold","100","200","300","400","500","600","700","800","900"],Al=[".ttf",".otf",".woff",".woff2"],Sl=["font/ttf","font/otf","font/woff","font/woff2"],Cl=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Tl(s){const t=at.extname(s),r=at.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=r.length>0;for(const a of r)if(!a.match(Cl)){n=!1;break}let o=r.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Pl=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Ml(s){return Pl.test(s)?s:encodeURI(s)}const kl={extension:{type:I.LoadParser,priority:Gt.Low},name:"loadWebFont",id:"web-font",test(s){return Ae(s,Sl)||Se(s,Al)},async load(s,t){var i,r,n;const e=z.get().getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??Tl(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(c=>vl.includes(c)))??["normal"],l=t.data??{};for(let c=0;cn.faces.some(o=>t.indexOf(o)!==-1));r.faces=r.faces.filter(n=>t.indexOf(n)===-1),r.faces.length===0&&(i.entries=i.entries.filter(n=>n!==r)),t.forEach(n=>{z.get().getFontFaceSet().delete(n)}),i.entries.length===0&&nt.remove(`${e}-and-url`)}},qs={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},El=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Il=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function Rl(s){const t=[];return s.replace(El,(e,i,r)=>{let n=i.toLowerCase(),o=i;const a=Ll(r);for(n==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===qs[n])return t.push([o,...a]),"";if(a.length0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:Y(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r))}return t}class Gi{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Gi(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,r=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-r)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new tt),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 Di{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 Di(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,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-r),h=i-a,l=n-h,c=o-h,u=n+a,f=o+a,d=t-this.x,p=e-this.y,g=d*d/(l*l)+p*p/(c*c),m=d*d/(u*u)+p*p/(f*f);return g>1&&m<=1}getBounds(t){return t||(t=new tt),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 Fl(s,t,e,i,r,n){const o=s-e,a=t-i,h=r-e,l=n-i,c=o*h+a*l,u=h*h+l*l;let f=-1;u!==0&&(f=c/u);let d,p;f<0?(d=e,p=i):f>1?(d=r,p=n):(d=e+f*h,p=i+f*l);const g=s-d,m=t-p;return g*g+m*m}let Gl,Dl;class Oe{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!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}strokeContains(t,e,i,r=.5){const n=i*i,o=n*(1-r),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;cr?l:r,n=co?c:o}return t.x=i,t.width=r-i,t.y=n,t.height=o-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 X("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return X("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const cs=(s,t,e,i,r,n,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=r-n&&l<=r+o};class Oi{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 tt),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Oi(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 o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return!0}return!1}strokeContains(t,e,i,r=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-r),u=i-c,f=n+l,d=o+l,p=a-l*2,g=h-l*2,m=n+a,_=o+h;return(t>=n-c&&t<=n+u||t>=m-u&&t<=m+c)&&e>=d&&e<=d+g||(e>=o-c&&e<=o+u||e>=_-u&&e<=_+c)&&t>=f&&t<=f+p?!0:tm-l&&em-l&&e>_-l&&cs(t,e,m-l,_-l,l,u,c)||t_-l&&cs(t,e,f,_-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const xo={};function Ol(s,t,e){let i=2166136261;for(let r=0;r>>=0;return xo[i]||Wl(s,t,i,e)}function Wl(s,t,e,i){const r={};let n=0;for(let a=0;a(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(zl||{});function Pr(s,t){return t.alphaMode==="no-premultiply-alpha"&&Ul[s]||s}const Hl=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Nl(s){let t="";for(let e=0;e0&&(t+=` else `),e{if(We.length>0)for(const s of We)s&&s.destroy();We.length=0,xs=0}});function Mr(){return xs>0?We[--xs]:new Yl}function kr(s){s.elements=null,We[xs++]=s}let Re=0;const bo=class wo{constructor(t){this.uid=J("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...wo.defaultOptions,...t},t.maxTextures||(X("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=$l());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new Cr(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 h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,f=this._batchIndexStart,d="startBatch",p=[];const g=this.maxTextures;for(let m=this.elementStart;m=g||v)&&(this._finishBatch(i,f,u-f,r,o,a,t,d,p),d="renderBatch",f=u,o=w,a=_.topology,i=Mr(),r=i.textures,r.clear(),p=[],++Re),_._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,_._batch=i,p.push(_),u+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,h,l,_._attributeStart,_._textureId),this.packQuadIndex(c,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,h,l,_._attributeStart,_._textureId),this.packIndex(_,c,_._indexStart,_._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,f,u-f,r,o,a,t,d,p),f=u,++Re),this.elementStart=this.elementSize,this._batchIndexStart=f,this._batchIndexSize=u}_finishBatch(t,e,i,r,n,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=r,t.blendMode=n,t.topology=o,t.start=e,t.size=i,t.elements=l,++Re,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Cr(e);Tr(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))(pt||{});class je extends ft{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=J("buffer"),this._resourceType="buffer",this._resourceId=J("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,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 a=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&pt.STATIC)}set static(t){t?this.descriptor.usage|=pt.STATIC:this.descriptor.usage&=~pt.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,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLengtha&&(a=d),p>h&&(h=p),di.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Zl=new Float32Array(1),Jl=new Uint32Array(1);class tc extends Ql{constructor(){const e=new je({data:Zl,label:"attribute-batch-buffer",usage:pt.VERTEX|pt.COPY_DST,shrinkToFit:!1}),i=new je({data:Jl,label:"index-batch-buffer",usage:pt.INDEX|pt.COPY_DST,shrinkToFit:!1}),r=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:20}},indexBuffer:i})}}function Er(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else Y(`${i} placement hook does not exist in shader`)}}const ec=/\{\{(.*?)\}\}/g;function Ir(s){var i;const t={};return(((i=s.match(ec))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function Rr(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Lr(s,t,e=!1){const i=[];Rr(t,i),s.forEach(a=>{a.header&&Rr(a.header,i)});const r=i;e&&r.sort();const n=r.map((a,h)=>` @location(${h}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function Br(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function sc(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function ic(s){const t=/@.*?\s+/g;return s.replace(t,"")}function rc(s,t){const e=[];Br(t,e),s.forEach(h=>{h.header&&Br(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 ${ic(h)};`).join(` `),o=`return VSOutput( ${e.sort().map(h=>` ${sc(h)}`).join(`, `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${r} `),a=a.replace("{{start}}",` ${n} `),a=a.replace("{{return}}",` ${o} `),a}function Fr(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 Wt=Object.create(null),Ks=new Map;let nc=0;function oc({template:s,bits:t}){const e=Ao(s,t);if(Wt[e])return Wt[e];const{vertex:i,fragment:r}=hc(s,t);return Wt[e]=So(i,r,t),Wt[e]}function ac({template:s,bits:t}){const e=Ao(s,t);return Wt[e]||(Wt[e]=So(s.vertex,s.fragment,t)),Wt[e]}function hc(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let r=Lr(e,s.vertex,!0);r=rc(e,r);const n=Lr(i,s.fragment,!0);return{vertex:r,fragment:n}}function Ao(s,t){return t.map(e=>(Ks.has(e)||Ks.set(e,nc++),Ks.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function So(s,t,e){const i=Ir(s),r=Ir(t);return e.forEach(n=>{Er(n.vertex,i,n.name),Er(n.fragment,r,n.name)}),{vertex:Fr(s,i),fragment:Fr(t,r)}}const lc=` @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}} }; `,cc=` @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; }; `,uc=` 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}} } `,dc=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,fc={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},pc={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function mc({bits:s,name:t}){const e=oc({template:{fragment:cc,vertex:lc},bits:[fc,...s]});return Ms.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function gc({bits:s,name:t}){return new Kn({name:t,...ac({template:{vertex:uc,fragment:dc},bits:[pc,...s]})})}const _c={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},yc={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Qs={};function xc(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 bc(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; ${xc(s)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${bc(s)} `}}),Qs[s]}const Zs={};function vc(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; } `}},Cc={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; } `}},Gr={};function Tc(s){let t=Gr[s];if(t)return t;const e=new Int32Array(s);for(let i=0;ie&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Mc(s,t,e,i,r,n,o,a=null){let h=0;e*=t,r*=n;const l=a.a,c=a.b,u=a.c,f=a.d,d=a.tx,p=a.ty;for(;h>16|t&65280|(t&255)<<16,i=this.renderable;return i?Mn(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)||Ec}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,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Ye={extension:{type:I.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,o,a;if(s.type==="circle"){const w=s;if(o=a=w.radius,o<=0)return!1;e=w.x,i=w.y,r=n=0}else if(s.type==="ellipse"){const w=s;if(o=w.halfWidth,a=w.halfHeight,o<=0||a<=0)return!1;e=w.x,i=w.y,r=n=0}else{const w=s,v=w.width/2,b=w.height/2;e=w.x+v,i=w.y+b,o=a=Math.max(0,Math.min(w.radius,Math.min(v,b))),r=v-o,n=b-a}if(r<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return!1;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,!0;let c=0,u=h*4+(r?2:0)+2,f=u,d=l,p=r+o,g=n,m=e+p,_=e-p,y=i+g;if(t[c++]=m,t[c++]=y,t[--u]=y,t[--u]=_,n){const w=i-g;t[f++]=_,t[f++]=w,t[--d]=w,t[--d]=m}for(let w=1;w0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1}},Ic={...Ye,extension:{...Ye.extension,name:"ellipse"}},Rc={...Ye,extension:{...Ye.extension,name:"roundedRectangle"}},Eo=1e-4,Or=1e-4;function Lc(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 f=c;const d=u-c,p=Math.abs(d),g=Math.sqrt(h*h+l*l),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=d/m;if(f+=_,a){o.push(s,t),o.push(e,i);for(let y=1,x=f;y=0&&(a.join==="round"?g+=Yt(b,A,b-S*C,A-T*C,b-M*C,A-R*C,d,!1)+4:g+=2,d.push(b-M*E,A-R*E),d.push(b+M*C,A+R*C));continue}const kt=(-S+w)*(-T+A)-(-S+b)*(-T+v),zt=(-M+k)*(-R+A)-(-M+b)*(-R+P),re=(H*zt-D*kt)/mt,Ze=(et*kt-V*zt)/mt,Rs=(re-b)*(re-b)+(Ze-A)*(Ze-A),Ht=b+(re-b)*C,Nt=A+(Ze-A)*C,Vt=b-(re-b)*E,$t=A-(Ze-A)*E,sa=Math.min(H*H+V*V,D*D+et*et),$i=it?C:E,ia=sa+$i*$i*y;Rs<=ia?a.join==="bevel"||Rs/y>x?(it?(d.push(Ht,Nt),d.push(b+S*E,A+T*E),d.push(Ht,Nt),d.push(b+M*E,A+R*E)):(d.push(b-S*C,A-T*C),d.push(Vt,$t),d.push(b-M*C,A-R*C),d.push(Vt,$t)),g+=2):a.join==="round"?it?(d.push(Ht,Nt),d.push(b+S*E,A+T*E),g+=Yt(b,A,b+S*E,A+T*E,b+M*E,A+R*E,d,!0)+4,d.push(Ht,Nt),d.push(b+M*E,A+R*E)):(d.push(b-S*C,A-T*C),d.push(Vt,$t),g+=Yt(b,A,b-S*C,A-T*C,b-M*C,A-R*C,d,!1)+4,d.push(b-M*C,A-R*C),d.push(Vt,$t)):(d.push(Ht,Nt),d.push(Vt,$t)):(d.push(b-S*C,A-T*C),d.push(b+S*E,A+T*E),a.join==="round"?it?g+=Yt(b,A,b+S*E,A+T*E,b+M*E,A+R*E,d,!0)+2:g+=Yt(b,A,b-S*C,A-T*C,b-M*C,A-R*C,d,!1)+2:a.join==="miter"&&Rs/y<=x&&(it?(d.push(Vt,$t),d.push(Vt,$t)):(d.push(Ht,Nt),d.push(Ht,Nt)),g+=2),d.push(b-M*C,A-R*C),d.push(b+M*E,A+R*E),g+=2)}w=s[(p-2)*2],v=s[(p-2)*2+1],b=s[(p-1)*2],A=s[(p-1)*2+1],S=-(v-A),T=w-b,B=Math.sqrt(S*S+T*T),S/=B,T/=B,S*=_,T*=_,d.push(b-S*C,A-T*C),d.push(b+S*E,A+T*E),u||(a.cap==="round"?g+=Yt(b-S*(C-E)*.5,A-T*(C-E)*.5,b-S*C,A-T*C,b+S*E,A+T*E,d,!1)+2:a.cap==="square"&&(g+=Wr(b,A,S,T,C,E,!1,d)));const N=Or*Or;for(let L=m;L0&&o>0?(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+o,t[6]=i,t[7]=r+o,!0):!1},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[6],t[i+o+1]=s[7],o+=e,t[i+o]=s[4],t[i+o+1]=s[5],o+=e;const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},Wc={extension:{type:I.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,!0},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[4],t[i+o+1]=s[5];const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},Ur=[{offset:0,color:"white"},{offset:1,color:"black"}],Wi=class Ai{constructor(...t){this.uid=J("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Uc(t);e={...e.type==="radial"?Ai.defaultRadialOptions:Ai.defaultLinearOptions,..._n(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:q.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:r}=this.end,n=i-t,o=r-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=t;t=i,i=m,n*=-1}if(o<0){const m=e;e=r,r=m,o*=-1}}const h=this.colorStops.length?this.colorStops:Ur,l=this._textureSize,{canvas:c,context:u}=Hr(l,1),f=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);zr(f,h),u.fillStyle=f,u.fillRect(0,0,l,1),this.texture=new U({source:new be({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),g=new W;g.scale(d/l,1),g.rotate(p),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Ur,e=this._textureSize,{canvas:i,context:r}=Hr(e,e),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,f=h-c,d=e/(c*2),p=(n-u)*d,g=(o-f)*d,m=r.createRadialGradient(p,g,l*d,(a-u)*d,(h-f)*d,c*d);zr(m,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,e,e),r.fillStyle=m,r.translate(p,g),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-p,-g),r.fillRect(0,0,e,e),this.texture=new U({source:new be({resource:i,addressMode:this._wrapMode})});const _=new W;this.textureSpace==="local"?_.scale(2*c,2*c):_.scale(1/d,1/d),_.translate(u,f),this.transform=_}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Wi.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Wi.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ft=Wi;function zr(s,t){for(let e=0;e{const u=[],f=Es[h.type];if(!f.build(h,u))return;const d=a.length,p=n.length/2;let g="triangle-list";if(l&&Mo(u,l),e){const x=h.closePath??!0,w=t;w.pixelLine?(Fc(u,x,n,a),g="line-list"):Bc(u,w,!1,x,n,a)}else if(c){const x=[],w=u.slice();Xc(c).forEach(b=>{x.push(w.length/2),w.push(...b)}),Io(w,x,n,2,p,a,d)}else f.triangulate(u,n,2,p,a,d);const m=o.length/2,_=t.texture;if(_!==U.WHITE){const x=Nc($c,t,h,l);Mc(n,2,p,o,m,2,n.length/2-p,x)}else kc(o,m,2,n.length/2-p);const y=At.get(ko);y.indexOffset=d,y.indexSize=a.length-d,y.attributeOffset=p,y.attributeSize=n.length/2-p,y.baseColor=t.color,y.alpha=t.alpha,y.texture=_,y.geometryData=r,y.topology=g,i.push(y)})}function Xc(s){const t=[];for(let e=0;e{At.return(t)}),this.graphicsData&&At.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Kc{constructor(){this.instructions=new Rn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Pc({maxTextures:e}),this.instructions.reset()}get geometry(){return X(xa,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Ui=class Si{constructor(t){this._renderer=t,this._managedContexts=new Po({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Si.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Si.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),jc(t,i);const r=t.batchMode;t.customShader||r==="no-batch"?i.isBatchable=!1:r==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=At.get(Kc,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:r,geometryData:n}=i;i.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let u=0;uQc)return;const u=(s+e)/2,f=(t+i)/2,d=(e+r)/2,p=(i+n)/2,g=(r+o)/2,m=(n+a)/2,_=(u+d)/2,y=(f+p)/2,x=(d+g)/2,w=(p+m)/2,v=(_+x)/2,b=(y+w)/2;if(c>0){let A=o-s,k=a-t;const P=Math.abs((e-o)*k-(i-a)*A),S=Math.abs((r-o)*k-(n-a)*A);if(P>us&&S>us){if((P+S)*(P+S)<=l*(A*A+k*k)){h.push(v,b);return}}else if(P>us){if(P*P<=l*(A*A+k*k)){h.push(v,b);return}}else if(S>us){if(S*S<=l*(A*A+k*k)){h.push(v,b);return}}else if(A=v-(s+o)/2,k=b-(t+a)/2,A*A+k*k<=l){h.push(v,b);return}}Ci(s,t,u,f,_,y,v,b,h,l,c+1),Ci(v,b,x,w,g,m,o,a,h,l,c+1)}const tu=8,eu=11920929e-14,su=1;function iu(s,t,e,i,r,n,o,a){const l=Math.min(.99,Math.max(0,a??Ro.defaultOptions.bezierSmoothness));let c=(su-l)/1;return c*=c,ru(t,e,i,r,n,o,s,c),s}function ru(s,t,e,i,r,n,o,a){Ti(o,s,t,e,i,r,n,a,0),o.push(r,n)}function Ti(s,t,e,i,r,n,o,a,h){if(h>tu)return;const l=(t+i)/2,c=(e+r)/2,u=(i+n)/2,f=(r+o)/2,d=(l+u)/2,p=(c+f)/2;let g=n-t,m=o-e;const _=Math.abs((i-n)*m-(r-o)*g);if(_>eu){if(_*_<=a*(g*g+m*m)){s.push(d,p);return}}else if(g=d-(t+n)/2,m=p-(e+o)/2,g*g+m*m<=a){s.push(d,p);return}Ti(s,t,e,l,c,d,p,a,h+1),Ti(s,d,p,u,f,n,o,a,h+1)}function Bo(s,t,e,i,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=r;l*=o?-1:1;for(let u=0;uu*h)}const Ue=Math.PI*2,Js={centerX:0,centerY:0,ang1:0,ang2:0},ti=({x:s,y:t},e,i,r,n,o,a,h)=>{s*=e,t*=i;const l=r*s-n*t,c=n*s+r*t;return h.x=l+o,h.y=c+a,h};function ou(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),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Vr=(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)},au=(s,t,e,i,r,n,o,a,h,l,c,u,f)=>{const d=Math.pow(r,2),p=Math.pow(n,2),g=Math.pow(c,2),m=Math.pow(u,2);let _=d*p-d*m-p*g;_<0&&(_=0),_/=d*m+p*g,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/n*u,x=_*-n/r*c,w=l*y-h*x+(s+e)/2,v=h*y+l*x+(t+i)/2,b=(c-y)/r,A=(u-x)/n,k=(-c-y)/r,P=(-u-x)/n,S=Vr(1,0,b,A);let T=Vr(b,A,k,P);a===0&&T>0&&(T-=Ue),a===1&&T<0&&(T+=Ue),f.centerX=w,f.centerY=v,f.ang1=S,f.ang2=T};function hu(s,t,e,i,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*Ue/360),u=Math.cos(a*Ue/360),f=u*(t-i)/2+c*(e-r)/2,d=-c*(t-i)/2+u*(e-r)/2;if(f===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);const p=Math.pow(f,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);p>1&&(n*=Math.sqrt(p),o*=Math.sqrt(p)),au(t,e,i,r,n,o,h,l,c,u,f,d,Js);let{ang1:g,ang2:m}=Js;const{centerX:_,centerY:y}=Js;let x=Math.abs(m)/(Ue/4);Math.abs(1-x)<1e-7&&(x=1);const w=Math.max(Math.ceil(x),1);m/=w;let v=s[s.length-2],b=s[s.length-1];const A={x:0,y:0};for(let k=0;k{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,f=l/c;return{len:c,nx:u,ny:f}},r=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let n=t[t.length-1];for(let o=0;o0&&(d=-1,p=!0);const g=f/2;let m,_=Math.abs(Math.cos(g)*h/Math.sin(g));_>Math.min(c.len/2,u.len/2)?(_=Math.min(c.len/2,u.len/2),m=Math.abs(_*Math.sin(g)/Math.cos(g))):m=h;const y=a.x+u.nx*_+-u.ny*m*d,x=a.y+u.ny*_+u.nx*m*d,w=Math.atan2(c.ny,c.nx)+Math.PI/2*d,v=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(y+Math.cos(w)*m,x+Math.sin(w)*m),s.arc(y,x,m,w,v,p),n=a}}function cu(s,t,e,i){const r=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a1){let n=null;for(let o=r;o=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,r,n){return this.drawShape(new Di(t,e,i,r),n),this}roundRect(t,e,i,r,n,o){return this.drawShape(new Oi(t,e,i,r,n),o),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 Oe,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 Oe,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,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+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;ea.area).sort((a,h)=>h-a),[e,i]=t,r=t[t.length-1],n=e/i,o=i/r;return!(n>3&&o<2)}function _u(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function yu(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],r=[];for(let c=0;c1;if(T&&M){const B=S.map(C=>({path:C,area:yu(C)}));if(B.sort((C,E)=>E.area-C.area),S.length>3||!gu(B))for(let C=0;CparseInt(P,10)),t.context.poly(x,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":w=s.getAttribute("points"),x=w.match(/-?\d+/g).map(P=>parseInt(P,10)),t.context.poly(x,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Y(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let P=0;P1&&(S=1);const T=Math.sqrt((1-S)*.5);if(T<1e-6)continue;const M=Math.min(1/T,t);M>e&&(e=M)}}return e}const Pu=new lt,tn=new W,zi=class Mt extends ft{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=J("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Bt,this._transform=new W,this._fillStyle={...Mt.defaultFillStyle},this._strokeStyle={...Mt.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new vt,this._boundsDirty=!0}clone(){const t=new Mt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=se(t,Mt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=bs(t,Mt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=se(t,Mt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=se(t,Mt.defaultStrokeStyle),this}texture(t,e,i,r,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?q.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Bt,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&(r==null?void 0:r.action)==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(X(_t,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=se(t,Mt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=bs(t,Mt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,r,n,o),this}arcTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}arcToSvg(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,o),this}roundPoly(t,e,i,r,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,o),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,o),this}star(t,e,i,r,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,r,n,o,this._transform.clone()),this}svg(t){return this._tick++,xu(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,o){return t instanceof W?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,o),this)}transform(t,e,i,r,n,o){return t instanceof W?(this._transform.append(t),this):(tn.set(t,e,i,r,n,o),this._transform.append(tn),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e{delete t.promiseCache[e],nt.has(e)&&nt.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(Y("[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||(Y("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const Mu=".svg",ku="image/svg+xml",Eu={extension:{type:I.LoadParser,priority:Gt.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return Ae(s,ku)||Se(s,Mu)},async load(s,t,e){var i;return((i=t.data)==null?void 0:i.parseAsGraphicsContext)??this.config.parseAsGraphicsContext?Ru(s):Iu(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Iu(s,t,e,i){var m,_,y;const r=await z.get().fetch(s),n=z.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,n.crossOrigin=i,await n.decode();const o=((m=t.data)==null?void 0:m.width)??n.width,a=((_=t.data)==null?void 0:_.height)??n.height,h=((y=t.data)==null?void 0:y.resolution)||Hi(s),l=Math.ceil(o*h),c=Math.ceil(a*h),u=z.get().createCanvas(l,c),f=u.getContext("2d");f.imageSmoothingEnabled=!0,f.imageSmoothingQuality="high",f.drawImage(n,0,0,o*h,a*h);const{parseAsGraphicsContext:d,...p}=t.data??{},g=new be({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:h,...p});return Ni(g,e,s)}async function Ru(s){const e=await(await z.get().fetch(s)).text(),i=new te;return i.svg(e),i}const Lu=`(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 me=null,Pi=class{constructor(){me||(me=URL.createObjectURL(new Blob([Lu],{type:"application/javascript"}))),this.worker=new Worker(me)}};Pi.revokeObjectURL=function(){me&&(URL.revokeObjectURL(me),me=null)};const Bu=`(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 ge=null;class Do{constructor(){ge||(ge=URL.createObjectURL(new Blob([Bu],{type:"application/javascript"}))),this.worker=new Worker(ge)}}Do.revokeObjectURL=function(){ge&&(URL.revokeObjectURL(ge),ge=null)};let en=0,ei;class Fu{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 Pi;e.addEventListener("message",i=>{e.terminate(),Pi.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(){ei===void 0&&(ei=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){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}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[en]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:en++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const sn=new Fu,Gu=[".jpeg",".jpg",".png",".webp",".avif"],Du=["image/jpeg","image/png","image/webp","image/avif"];async function Ou(s,t){var r;const e=await z.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 Oo={name:"loadTextures",id:"texture",extension:{type:I.LoadParser,priority:Gt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ae(s,Du)||Se(s,Gu)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await sn.isImageBitmapSupported()?i=await sn.loadImageBitmap(s,t):i=await Ou(s,t):i=await new Promise((o,a)=>{i=z.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const r=new be({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||Hi(s),...t.data});return Ni(r,e,s)},unload(s){s.destroy(!0)}},Wu=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let si,ii;function Uu(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Hu(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function zu(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(o){n(),e(o)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function Hu(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":""}function Nu(){const s=[],t=[];for(const e of Wu){const i=De.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;ks(i)&&(s.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:s,validVideoMime:t}}const Vu={name:"loadVideo",id:"video",extension:{type:I.LoadParser,name:"loadVideo"},test(s){if(!si||!ii){const{validVideoExtensions:i,validVideoMime:r}=Nu();si=i,ii=r}const t=Ae(s,ii),e=Se(s,si);return t||e},async load(s,t,e){var h,l;const i={...De.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Hi(s),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Hn(),...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(c=>{const u=n[c];u!==void 0&&r.setAttribute(c,u)}),i.muted===!0&&(r.muted=!0),Uu(r,s,i.crossorigin);const o=document.createElement("source");let a;if(i.mime)a=i.mime;else if(s.startsWith("data:"))a=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const c=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();a=De.MIME_TYPES[c]||`video/${c}`}return o.src=s,a&&(o.type=a),new Promise((c,u)=>{i.preload&&!i.autoPlay&&r.load(),r.addEventListener("canplay",f),r.addEventListener("error",d),o.addEventListener("error",d),r.appendChild(o);async function f(){const g=new De({...i,resource:r});p(),t.data.preload&&await zu(r),c(Ni(g,e,s))}function d(g){p(),u(g)}function p(){r.removeEventListener("canplay",f),r.removeEventListener("error",d),o.removeEventListener("error",d)}})},unload(s){s.destroy(!0)}},Wo={extension:{type:I.ResolveParser,name:"resolveTexture"},test:Oo.test,parse:s=>{var t;return{resolution:parseFloat(((t=ve.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},$u={extension:{type:I.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ve.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:Wo.parse};class ju{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ve,this.loader=new ml,this.cache=nt,this._backgroundLoader=new ol(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){Y("[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 a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=gs(t),r=Tt(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return i?o[r[0]]:o}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={},o=Object.keys(r);let a=0;const h=[],l=()=>{e==null||e(h.reduce((u,f)=>u+f,0)/a)},c=o.map((u,f)=>{const d=r[u],p=Object.values(d),m=[...new Set(p.flat())].reduce((_,y)=>_+(y.progressSize||1),0);return h.push(0),a+=m,this._mapLoadToResolve(d,_=>{h[f]=_*m,l()}).then(_=>{n[u]=_})});return await Promise.all(c),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 nt.get(t);const e={};for(let i=0;i{const a=r[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a}),nt.set(h,a)}),n}async unload(t){this._initialized||await this.init();const e=Tt(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=Tt(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=>{nt.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 de=new ju;K.handleByList(I.LoadParser,de.loader.parsers).handleByList(I.ResolveParser,de.resolver.parsers).handleByList(I.CacheParser,de.cache.parsers).handleByList(I.DetectionParser,de.detections);K.add(al,ll,hl,pl,ul,dl,fl,yl,wl,kl,Eu,Oo,Vu,nl,rl,Wo,$u);const rn={loader:I.LoadParser,resolver:I.ResolveParser,cache:I.CacheParser,detection:I.DetectionParser};K.handle(I.Asset,s=>{const t=s.ref;Object.entries(rn).filter(([e])=>!!t[e]).forEach(([e,i])=>K.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(rn).filter(e=>!!t[e]).forEach(e=>K.remove(t[e]))});let he;function nn(s){const t=z.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=s,e.fillRect(0,0,6,1),t}function Yu(){if(he!==void 0)return he;try{const s=nn("#ff00ff"),t=nn("#ffff00"),i=z.get().createCanvas(6,1).getContext("2d");i.globalCompositeOperation="multiply",i.drawImage(s,0,0),i.drawImage(t,2,0);const r=i.getImageData(2,0,1,1);if(!r)he=!1;else{const n=r.data;he=n[0]===255&&n[1]===0&&n[2]===0}}catch{he=!1}return he}const $={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Yu(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const t=s.source,e=t==null?void 0:t.resource;if(!e)return null;const i=t.alphaMode==="premultiplied-alpha",r=t.resourceWidth??t.pixelWidth,n=t.resourceHeight??t.pixelHeight,o=r!==t.pixelWidth||n!==t.pixelHeight;if(i){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;const a=$._unpremultipliedCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas}if(e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof ArrayBuffer){const a=$._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=z.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d"),c=l.createImageData(t.pixelWidth,t.pixelHeight),u=c.data,f=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(t.format==="bgra8unorm")for(let d=0;d0){const d=255/f;c[u]=Math.min(255,c[u]*d+.5),c[u+1]=Math.min(255,c[u+1]*d+.5),c[u+2]=Math.min(255,c[u+2]*d+.5)}}return h.putImageData(l,0,0),$._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){const a=$._canvasSourceCache.get(t);if((a==null?void 0:a.resourceId)===t._resourceId)return a.canvas;const h=z.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d");return h.width=t.pixelWidth,h.height=t.pixelHeight,l.drawImage(e,0,0),$._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}return e},getTintedCanvas:(s,t)=>{const e=s.texture,i=q.shared.setValue(t).toHex(),r=e.tintCache||(e.tintCache={}),n=r[i],o=e.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:z.get().createCanvas();return $.tintMethod(e,t,a),a.tintId=o,r[i]=a,r[i]},getTintedPattern:(s,t)=>{const e=q.shared.setValue(t).toHex(),i=s.patternCache||(s.patternCache={}),r=s.source._resourceId;let n=i[e];return(n==null?void 0:n.tintId)===r||($.canvas||($.canvas=z.get().createCanvas()),$.tintMethod(s,t,$.canvas),n=$.canvas.getContext("2d").createPattern($.canvas,"repeat"),n.tintId=r,i[e]=n),n},applyPatternTransform:(s,t,e=!0)=>{if(!t)return;const i=s;if(!i.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const n=new r([t.a,t.b,t.c,t.d,t.tx,t.ty]);i.setTransform(e?n.inverse():n)},tintWithMultiply:(s,t,e)=>{const i=e.getContext("2d"),r=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=O.isVertical(o),h=a?r.height:r.width,l=a?r.width:r.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.fillStyle=q.shared.setValue(t).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="multiply";const c=$.getCanvasSource(s);if(!c){i.restore();return}o&&$._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.globalCompositeOperation="destination-atop",i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.restore()},tintWithOverlay:(s,t,e)=>{const i=e.getContext("2d"),r=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=O.isVertical(o),h=a?r.height:r.width,l=a?r.width:r.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy",i.fillStyle=q.shared.setValue(t).toHex(),i.fillRect(0,0,h,l),i.globalCompositeOperation="destination-atop";const c=$.getCanvasSource(s);if(!c){i.restore();return}o&&$._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.restore()},tintWithPerPixel:(s,t,e)=>{const i=e.getContext("2d"),r=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=O.isVertical(o),h=a?r.height:r.width,l=a?r.width:r.height;e.width=Math.ceil(h),e.height=Math.ceil(l),i.save(),i.globalCompositeOperation="copy";const c=$.getCanvasSource(s);if(!c){i.restore();return}o&&$._applyInverseRotation(i,o,r.width,r.height),i.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.restore();const u=t>>16&255,f=t>>8&255,d=t&255,p=i.getImageData(0,0,h,l),g=p.data;for(let m=0;m{const r=O.inv(t),n=O.uX(r),o=O.uY(r),a=O.vX(r),h=O.vY(r),l=-Math.min(0,n*e,a*i,n*e+a*i),c=-Math.min(0,o*e,h*i,o*e+h*i);s.transform(n,o,a,h,l,c)}};$.tintMethod=$.canUseMultiply?$.tintWithMultiply:$.tintWithPerPixel;class Xu{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=z.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=_e(t),e=_e(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);t.context.resetTransform(),t.context.clearRect(0,0,i,r),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Mi=new Xu;Qe.register(Mi);const qu=new vt;function Ku(s,t,e,i,r=!1){const n=qu;n.minX=0,n.minY=0,n.maxX=s.width/i|0,n.maxY=s.height/i|0;const o=Ts.getOptimalTexture(n.width,n.height,i,!1,r);return o.source.uploadMethodId="image",o.source.resource=s,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/i,o.frame.height=e/i,o.source.emit("update",o.source),o.updateUvs(),o}class ws extends yt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{animationSpeed:i=1,autoPlay:r=!1,autoUpdate:n=!0,loop:o=!0,onComplete:a=null,onFrameChange:h=null,onLoop:l=null,textures:c,updateAnchor:u=!1,...f}=e,[d]=c;super({...f,texture:d instanceof U?d:d.texture}),this._textures=null,this._durations=null,this._autoUpdate=n,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=o,this.updateAnchor=u,this.onComplete=a,this.onFrameChange=h,this.onLoop=l,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,r&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(dt.shared.add(this.update,this,ze.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,r=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):r!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramer)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(r=>{this.texture!==r&&r.destroy(i)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;ithis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(dt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(dt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Qu extends Ln{constructor(t,e){const{text:i,resolution:r,style:n,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new ot({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),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 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)}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(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}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}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Zu(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(X(_t,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}let Xt=null,Rt=null;function Ju(s,t){Xt||(Xt=z.get().createCanvas(256,128),Rt=Xt.getContext("2d",{willReadFrequently:!0}),Rt.globalCompositeOperation="copy",Rt.globalAlpha=1),(Xt.width * @license BSD-3-Clause * @version 11.4.7 */class ed{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let i=0;i0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let r=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(t,e,i=!1,r=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i0}function zo(s){return s.includes("<")}function id(s,t){return s.clone().assign(t)}function rd(s,t){const e=[],i=t.tagStyles;if(!Uo(t)||!zo(s))return e.push({text:s,style:t}),e;const r=[t],n=[];let o="",a=0;for(;a",a);if(l===-1){o+=h,a++;continue}const c=s.indexOf("<",a+1);if(c!==-1&&c0&&n[n.length-1]===f){o.length>0&&(e.push({text:o,style:r[r.length-1]}),o=""),r.pop(),n.pop(),a=l+1;continue}else{o+=s.slice(a,l+1),a=l+1;continue}}else{const f=u.trim();if(i[f]){o.length>0&&(e.push({text:o,style:r[r.length-1]}),o="");const d=r[r.length-1],p=id(d,i[f]);r.push(p),n.push(f),a=l+1;continue}else{o+=s.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&e.push({text:o,style:r[r.length-1]}),e}const nd=[10,13],od=new Set(nd),ad=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],hd=new Set(ad),ld=[9,32],cd=new Set(ld),ud=[45,8208,8211,8212,173],dd=new Set(ud),fd=/(\r\n|\r|\n)/,pd=/(?:\r\n|\r|\n)/;function vs(s){return typeof s!="string"?!1:od.has(s.charCodeAt(0))}function wt(s,t){return typeof s!="string"?!1:hd.has(s.charCodeAt(0))}function Yd(s){return typeof s!="string"?!1:cd.has(s.charCodeAt(0))}function md(s){return typeof s!="string"?!1:dd.has(s.charCodeAt(0))}function Ho(s){return s==="normal"||s==="pre-line"}function No(s){return s==="normal"}function It(s){if(typeof s!="string")return"";let t=s.length-1;for(;t>=0&&wt(s[t]);)t--;return t0&&(t.push(e.join("")),e.length=0),r==="\r"&&n===` `?(t.push(`\r `),i++):t.push(r);continue}e.push(r),md(r)&&n&&!wt(n)&&!vs(n)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function $o(s,t,e,i){const r=e(s),n=[];for(let o=0;o0&&f.push({text:L,style:C.style})}}(f.length>0||u.length===0)&&u.push(f);const d=e?yd(u,t,i,n,a,h):u,p=[],g=[],m=[],_=[],y=[];let x=0;const w=t._fontString,v=o(w);v.fontSize===0&&(v.fontSize=t.fontSize,v.ascent=t.fontSize);let b="",A=!!t.dropShadow,k=((B=t._stroke)==null?void 0:B.width)||0;for(const C of d){let E=0,N=v.ascent,L=v.descent,H="";for(const D of C){const et=D.style._fontString,ct=o(et);et!==b&&(i.font=et,b=et);const mt=r(D.text,D.style.letterSpacing,i);E+=mt,N=Math.max(N,ct.ascent),L=Math.max(L,ct.descent),H+=D.text;const it=((ht=D.style._stroke)==null?void 0:ht.width)||0;it>k&&(k=it),!A&&D.style.dropShadow&&(A=!0)}C.length===0&&(N=v.ascent,L=v.descent),p.push(E),g.push(N),m.push(L),y.push(H);const V=t.lineHeight||N+L;_.push(V+t.leading),x=Math.max(x,E)}const P=k,S=x+P+(t.dropShadow?t.dropShadow.distance:0);let T=0;for(let C=0;C<_.length;C++)T+=_[C];T=Math.max(T,_[0]+P);const M=T+(t.dropShadow?t.dropShadow.distance:0),R=t.lineHeight||v.fontSize;return{width:S,height:M,lines:y,lineWidths:p,lineHeight:R+t.leading,maxLineWidth:x,fontProperties:v,runsByLine:d,lineAscents:g,lineDescents:m,lineHeights:_,hasDropShadow:A}}function yd(s,t,e,i,r,n){var m;const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=Ho(a),u=h+o,f={};let d="";const p=(_,y)=>{const x=`${_}|${y.styleKey}`;let w=f[x];if(w===void 0){const v=y._fontString;v!==d&&(e.font=v,d=v),w=i(_,y.letterSpacing,e)+y.letterSpacing,f[x]=w}return w},g=[];for(const _ of s){const y=xd(_),x=g.length,w=M=>{let R=0,B=M;do{const{token:ht,style:C}=y[B];R+=p(ht,C),B++}while(B{const R=[];let B=M;do R.push({token:y[B].token,style:y[B].style}),B++;while(B{P&&P.text.length>0&&b.push(P),P=null},T=()=>{if(S(),b.length>0){const M=b[b.length-1];M.text=It(M.text),M.text.length===0&&b.pop()}g.push(b),b=[],A=0,k=!1};for(let M=0;Mu&&E)if(A>0&&T(),l){const L=v(M);for(let H=0;Hu&&T(),!P||P.style!==D?(S(),P={text:ct,style:D}):P.text+=ct,A+=mt}}M+=L.length-1}else{const L=v(M);S(),g.push(L.map(H=>({text:H.token,style:H.style}))),k=!1,M+=L.length-1}else if(N+A>u&&E){if(wt(R)){k=!1;continue}T(),P={text:R,style:B},A=C}else if(ht&&!l)!P||P.style!==B?(S(),P={text:R,style:B}):P.text+=R,A+=C;else{const L=wt(R);if(A===0&&L&&!k)continue;!P||P.style!==B?(S(),P={text:R,style:B}):P.text+=R,A+=C}}if(S(),b.length>0){const M=b[b.length-1];M.text=It(M.text),M.text.length===0&&b.pop()}(b.length>0||g.length===x)&&g.push(b)}return g}function xd(s){const t=[];let e=!1;for(const i of s){const r=Vo(i.text);let n=!0;for(const o of r){const a=wt(o)||vs(o),h=n&&e&&!a;t.push({token:o,style:i.style,continuesFromPrevious:h}),e=!a,n=!1}}return t}const bd={willReadFrequently:!0};function hn(s,t,e,i,r){let n=e[s];return typeof n!="number"&&(n=r(s,t,i)+t,e[s]=n),n}function wd(s,t,e,i,r,n,o){const a=e.getContext("2d",bd);a.font=t._fontString;let h=0,l="";const c=[],u=Object.create(null),{letterSpacing:f,whiteSpace:d}=t,p=Ho(d),g=No(d);let m=!p;const _=t.wordWrapWidth+f,y=Vo(s);for(let w=0;w_)if(l!==""&&(c.push(It(l)),l="",h=0),r(v,t.breakWords)){const A=$o(v,t.breakWords,o,n);for(const k of A){const P=hn(k,f,u,a,i);P+h>_&&(c.push(It(l)),m=!1,l="",h=0),l+=k,h+=P}}else l.length>0&&(c.push(It(l)),l="",h=0),c.push(It(v)),m=!1,l="",h=0;else b+h>_&&(m=!1,c.push(It(l)),l="",h=0),(l.length>0||!wt(v)||m)&&(l+=v,h+=b)}const x=It(l);return x.length>0&&c.push(x),c.join(` `)}const ln={willReadFrequently:!0},Dt=class F{static get experimentalLetterSpacingSupported(){let t=F._experimentalLetterSpacingSupported;if(t===void 0){const e=z.get().getCanvasRenderingContext2D().prototype;t=F._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,o,a,h,l,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=F._canvas,r=e.wordWrap){var w;const n=`${t}-${e.styleKey}-wordWrap-${r}`;if(F._measurementCache.has(n))return F._measurementCache.get(n);if(Uo(e)&&zo(t)){const v=_d(t,e,r,F._context,F._measureText,F._measureTextAdvance,F.measureFont,F.canBreakChars,F.wordWrapSplit),b=new F(t,e,v.width,v.height,v.lines,v.lineWidths,v.lineHeight,v.maxLineWidth,v.fontProperties,{runsByLine:v.runsByLine,lineAscents:v.lineAscents,lineDescents:v.lineDescents,lineHeights:v.lineHeights,hasDropShadow:v.hasDropShadow});return F._measurementCache.set(n,b),b}const a=e._fontString,h=F.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=F._context;l.font=a;const u=(r?F._wordWrap(t,e,i):t).split(pd),f=new Array(u.length);let d=0;for(let v=0;v0&&(l+=o),Math.max(r,l)}static _measureTextAdvance(t,e,i){return F._measureTextCore(t,e,i).metricWidth}static _measureTextCore(t,e,i){let r=!1;F.experimentalLetterSpacingSupported&&(F.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width,a=0;return o>0&&(r?a=-e:a=(F.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(t,e,i=F._canvas){return wd(t,e,i,F._measureTextAdvance,F.canBreakWords,F.canBreakChars,F.wordWrapSplit)}static isBreakingSpace(t,e){return wt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return F.graphemeSegmenter(t)}static measureFont(t){if(F._fonts[t])return F._fonts[t];const e=F._context;e.font=t;const i=e.measureText(F.METRICS_STRING+F.BASELINE_SYMBOL),r=i.actualBoundingBoxAscent??0,n=i.actualBoundingBoxDescent??0,o={ascent:r,descent:n,fontSize:r+n};return F._fonts[t]=o,o}static clearMetrics(t=""){t?delete F._fonts[t]:F._fonts={}}static get _canvas(){if(!F.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",ln);if(i!=null&&i.measureText)return F.__canvas=e,e;t=z.get().createCanvas()}catch{t=z.get().createCanvas()}t.width=t.height=10,F.__canvas=t}return F.__canvas}static get _context(){return F.__context||(F.__context=F._canvas.getContext("2d",ln)),F.__context}};Dt.METRICS_STRING="|ÉqÅ";Dt.BASELINE_SYMBOL="M";Dt.BASELINE_MULTIPLIER=1.4;Dt.HEIGHT_MULTIPLIER=2;Dt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let r=0;for(const n of e)i[r++]=n.segment;return i}}return s=>[...s]})();Dt.experimentalLetterSpacing=!1;Dt._fonts={};Dt._measurementCache=sd(1e3);let Ot=Dt;const vd=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ki(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)&&!vd.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const cn=1e5;function ds(s,t,e,i=0,r=0,n=0){if(s.texture===U.WHITE&&!s.fill)return q.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Is){const o=s.fill,a=t.createPattern(o.texture.source.resource,"repeat");return $.applyPatternTransform(a,o.transform,!1),a}else if(s.fill instanceof Ft){const o=s.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+i,c=e.height+i);let u,f=!1;if(a){const{start:d,end:p}=o;u=t.createLinearGradient(d.x*l+r,d.y*c+n,p.x*l+r,p.y*c+n),f=Math.abs(p.x-d.x){let _=g+m.offset*d;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*cn)/cn,q.shared.setValue(m.color).toHex())})}}else o.colorStops.forEach(d=>{u.addColorStop(d.offset,q.shared.setValue(d.color).toHex())});return u}}else{const o=t.createPattern(s.texture.source.resource,"repeat"),a=s.matrix.copyTo(W.shared);return a.scale(s.texture.source.pixelWidth,s.texture.source.pixelHeight),o.setTransform(a),o}return Y("FillStyle not recognised",s),"red"}const un=new tt;function le(s){let t=0;for(let e=0;e0){this._renderTaggedTextToCanvas(n,t,e,i,r);return}const{canvas:o,context:a}=r,h=ki(t),l=n.lines,c=n.lineHeight,u=n.lineWidths,f=n.maxLineWidth,d=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(i,i),a.textBaseline=t.textBaseline,(v=t._stroke)!=null&&v.width){const k=t._stroke;a.lineWidth=k.width,a.miterLimit=k.miterLimit,a.lineJoin=k.join,a.lineCap=k.cap}a.font=h;let g,m;const _=t.dropShadow?2:1,x=(((b=t._stroke)==null?void 0:b.width)??0)/2;let w=(c-d.fontSize)/2;c-d.fontSize<0&&(w=0);for(let k=0;k<_;++k){const P=t.dropShadow&&k===0,S=P?Math.ceil(Math.max(1,p)+e*2):0,T=S*i;if(P)this._setupDropShadow(a,t,i,T);else{const M=t._gradientBounds,R=t._gradientOffset;if(M){const B={width:M.width,height:M.height,lineHeight:M.height,lines:n.lines};this._setFillAndStrokeStyles(a,t,B,e,x,(R==null?void 0:R.x)??0,(R==null?void 0:R.y)??0)}else R?this._setFillAndStrokeStyles(a,t,n,e,x,R.x,R.y):this._setFillAndStrokeStyles(a,t,n,e,x);a.shadowColor="rgba(0,0,0,0)"}for(let M=0;M0&&(R=(f-u[M])/B)}(A=t._stroke)!=null&&A.width&&this._drawLetterSpacing(l[M],t,r,g+e,m+e-S,!0,R),t._fill!==void 0&&this._drawLetterSpacing(l[M],t,r,g+e,m+e-S,!1,R)}}}_renderTaggedTextToCanvas(t,e,i,r,n){var x,w,v;const{canvas:o,context:a}=n,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:u,lineHeights:f,hasDropShadow:d}=t,p=o.height;a.resetTransform(),a.scale(r,r),a.textBaseline=e.textBaseline;const g=d?2:1;let m=((x=e._stroke)==null?void 0:x.width)??0;for(const b of h)for(const A of b){const k=((w=A.style._stroke)==null?void 0:w.width)??0;k>m&&(m=k)}const _=m/2,y=[];for(let b=0;b0&&(N=(c-R)/V)}const L=S+B;let H=E+i;for(let V=0;V{this._fill=se({...this._originalFill},te.defaultFillStyle)})),this._fill=se(t===0?"black":t,te.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...te.defaultStrokeStyle,...t},()=>{this._stroke=bs({...this._originalStroke},te.defaultStrokeStyle)})),this._stroke=bs(t,te.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=ee.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=ki(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,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?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new ee(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(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 Ft||t instanceof Is)}};Vi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Vi.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 As=Vi;function Sd(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=As.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){X(_t,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(q.isColorLike(e))i.color=e;else if(e instanceof Ft||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)){if(X(_t,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&Y("The number of fill colors must match the number of fill gradient stops.");const e=new Ft({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),r=t.fill.map(n=>q.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,r[o])}),s.fill={fill:e}}}function Cd(s,t){const{texture:e,bounds:i}=s,r=t._style._getFinalPadding();vn(i,t._anchor,e);const n=t._anchor._x*r*2,o=t._anchor._y*r*2;i.minX-=r-n,i.minY-=r-o,i.maxX-=r-n,i.maxY-=r-o}class Td{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class Pd extends Td{}class jo{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Po({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const r=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==r)&&this._updateGpuText(t),t._didTextUpdate=!1,Cd(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Pd;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}jo.extension={type:[I.WebGLPipes,I.WebGPUPipes,I.CanvasPipes],name:"text"};class Yo{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,r){typeof t=="string"&&(X("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof As||(t.style=new As(t.style)),t.textureStyle instanceof ye||(t.textureStyle=new ye(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:h}=t,l=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=fe.getCanvasAndContext({text:n,style:o,resolution:l}),f=Ku(u.canvas,c.width,c.height,l,h);if(a&&(f.source.style=a),o.trim&&(c.pad(o.padding),f.frame.copyFrom(c),f.frame.scale(1/l),f.updateUvs()),o.filters){const d=this._applyFilters(f,o.filters);return this.returnTexture(f),fe.returnCanvasAndContext(u),d}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||fe.returnCanvasAndContext(u),f}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&(i!=null&&i.getContext)){const r=i.getContext("2d");r&&fe.returnCanvasAndContext({canvas:i,context:r})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ts.returnTexture(t,!0)}renderTextToCanvas(){X("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,r=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),r}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class Xo extends Yo{constructor(t){super(t,!0)}}Xo.extension={type:[I.CanvasSystem],name:"canvasText"};class qo extends Yo{constructor(t){super(t,!1)}}qo.extension={type:[I.WebGLSystem,I.WebGPUSystem],name:"canvasText"};K.add(Xo);K.add(qo);K.add(jo);class Md extends Qu{constructor(...t){const e=Zu(t,"Text");super(e,As),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof ye?e.textureStyle:new ye(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??St.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,r=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=fe.getCanvasAndContext({text:this.text,style:this._style,resolution:1});fe.returnCanvasAndContext(o),i=n.width,r=n.height}else{const n=Ot.measureText(this._text,this._style);i=n.width,r=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*r,t.maxY=t.minY+r}}K.add(ha,la);let Ko;function kd(s){return Ko=s,s}function Xe(){return Ko}class Ei{static setParamValue(t,e){if(t.setValueAtTime){const i=Xe().context;t.setValueAtTime(e,i.audioContext.currentTime)}else t.value=e;return e}}class Ed extends ft{constructor(){super(...arguments),this.speed=1,this.muted=!1,this.volume=1,this.paused=!1}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}}let Id=0;const Ii=class extends ft{constructor(s){super(),this.id=Id++,this.init(s)}set(s,t){if(this[s]===void 0)throw new Error(`Property with name ${s} does not exist.`);switch(s){case"speed":this.speed=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}get progress(){const{currentTime:s}=this._source;return s/this._duration}get paused(){return this._paused}set paused(s){this._paused=s,this.refreshPaused()}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(s){this._playing=!1,this._duration=s.source.duration;const t=this._source=s.source.cloneNode(!1);t.src=s.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),s.context.on("refresh",this.refresh,this),s.context.on("refreshPaused",this.refreshPaused,this),this._media=s}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._internalStop(),this._source&&this.emit("stop")}get speed(){return this._speed}set speed(s){this._speed=s,this.refresh()}get volume(){return this._volume}set volume(s){this._volume=s,this.refresh()}get loop(){return this._loop}set loop(s){this._loop=s,this.refresh()}get muted(){return this._muted}set muted(s){this._muted=s,this.refresh()}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(s){console.warn("HTML Audio does not support filters")}refresh(){const s=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;const e=s.volume*(s.muted?0:1),i=t.volume*(t.muted?0:1),r=this._volume*(this._muted?0:1);this._source.volume=r*e*i,this._source.playbackRate=this._speed*s.speed*t.speed}refreshPaused(){const s=this._media.context,t=this._media.parent,e=this._paused||t.paused||s.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e))}play(s){const{start:t,end:e,speed:i,loop:r,volume:n,muted:o}=s;e&&console.assert(e>t,"End time is before start time"),this._speed=i,this._volume=n,this._loop=!!r,this._muted=o,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-Ii.PADDING),this._end=Math.min(this._end+Ii.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),dt.shared.add(this._onUpdate,this))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete()}_onComplete(){dt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){dt.shared.remove(this._onUpdate,this),this.removeAllListeners();const s=this._source;s&&(s.onended=null,s.onplay=null,s.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=!1,this._end=null,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null)}toString(){return`[HTMLAudioInstance id=${this.id}]`}};let Qo=Ii;Qo.PADDING=.1;class Rd extends ft{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url)}create(){return new Qo(this)}get isPlayable(){return!!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters")}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null)}get source(){return this._source}load(t){const e=this._source,i=this.parent;if(e.readyState===4){i.isLoaded=!0;const h=i.autoPlayStart();t&&setTimeout(()=>{t(null,i,h)},0);return}if(!i.url){t(new Error("sound.url or sound.source must be set"));return}e.src=i.url;const r=()=>{a(),i.isLoaded=!0;const h=i.autoPlayStart();t&&t(null,i,h)},n=()=>{a(),t&&t(new Error("Sound loading has been aborted"))},o=()=>{a();const h=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(h)):console.error(h)},a=()=>{e.removeEventListener("canplaythrough",r),e.removeEventListener("load",r),e.removeEventListener("abort",n),e.removeEventListener("error",o)};e.addEventListener("canplaythrough",r,!1),e.addEventListener("load",r,!1),e.addEventListener("abort",n,!1),e.addEventListener("error",o,!1),e.load()}}class Ld{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time")}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null}}const Ss=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],Bd=["audio/mpeg","audio/ogg"],Cs={};function Fd(s){const t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"'},e=document.createElement("audio"),i={},r=/^no$/;Ss.forEach(n=>{const o=e.canPlayType(`audio/${n}`).replace(r,""),a=t[n]?e.canPlayType(t[n]).replace(r,""):"";i[n]=!!o||!!a}),Object.assign(Cs,i)}Fd();let Gd=0;class Dd extends ft{constructor(t){super(),this.id=Gd++,this._media=null,this._paused=!1,this._muted=!1,this._elapsed=0,this.init(t)}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"speed":this.speed=e;break;case"volume":this.volume=e;break;case"muted":this.muted=e;break;case"loop":this.loop=e;break;case"paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"))}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh()}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh()}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh()}get filters(){return this._filters}set filters(t){var e;this._filters&&((e=this._filters)==null||e.filter(i=>i).forEach(i=>i.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t!=null&&t.length?t.slice(0):null,this.refresh()}refresh(){if(!this._source)return;const t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;const i=t.volume*(t.muted?0:1),r=e.volume*(e.muted?0:1),n=this._volume*(this._muted?0:1);Ei.setParamValue(this._gain.gain,n*r*i),Ei.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters()}applyFilters(){var t;if((t=this._filters)!=null&&t.length){this._source.disconnect();let e=this._source;this._filters.forEach(i=>{e.connect(i.destination),e=i}),e.connect(this._gain)}}refreshPaused(){const t=this._media.context,e=this._media.parent,i=this._paused||e.paused||t.paused;i!==this._pausedReal&&(this._pausedReal=i,i?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",i))}play(t){const{start:e,end:i,speed:r,loop:n,volume:o,muted:a,filters:h}=t;i&&console.assert(i>e,"End time is before start time"),this._paused=!1;const{source:l,gain:c}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=c,this._speed=r,this._volume=o,this._loop=!!n,this._muted=a,this._filters=h,this.refresh();const u=this._source.buffer.duration;this._duration=u,this._end=i,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=i,this._source.loopStart=e,this._source.start(0,e)):i?this._source.start(0,e,i-e):this._source.start(0,e),this.emit("start"),this._update(!0),this.enableTicker(!0)}enableTicker(t){dt.shared.remove(this._updateListener,this),t&&dt.shared.add(this._updateListener,this)}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused()}destroy(){var t;this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),(t=this._filters)==null||t.forEach(e=>e.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}toString(){return`[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update()}_update(t=!1){if(this._source){const e=this._now(),i=e-this._lastUpdate;if(i>0||t){const r=this._source.playbackRate.value;this._elapsed+=i*r,this._lastUpdate=e;const n=this._duration;let o;if(this._source.loopStart){const a=this._source.loopEnd-this._source.loopStart;o=(this._source.loopStart+this._elapsed%a)/n}else o=this._elapsed%n/n;this._progress=o,this.emit("progress",this._progress,n)}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this)}_internalStop(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null}}_onComplete(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)}}class Zo{constructor(t,e){this._output=e,this._input=t}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect()}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(i=>{e===null?this._input.connect(i.destination):e.connect(i.destination),e=i}),e.connect(this._output)}}destroy(){this.filters=null,this._input=null,this._output=null}}const Jo=class extends Zo{constructor(s){const t=s.audioContext,e=t.createBufferSource(),i=t.createGain(),r=t.createAnalyser();e.connect(r),r.connect(i),i.connect(s.destination),super(r,i),this.context=s,this.bufferSource=e,this.gain=i,this.analyser=r}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(Jo.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null}cloneBufferSource(){const s=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=s.buffer,Ei.setParamValue(t.playbackRate,s.playbackRate.value),t.loop=s.loop;const e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}};let ta=Jo;ta.BUFFER_SIZE=0;class Od{init(t){this.parent=t,this._nodes=new ta(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null,this.source=null}create(){return new Dd(this)}get context(){return this.parent.context}get isPlayable(){return!!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set")}async _loadUrl(t){const e=this.parent.url,i=await z.get().fetch(e);this._decode(await i.arrayBuffer(),t)}_decode(t,e){const i=(r,n)=>{if(r)e&&e(r);else{this.parent.isLoaded=!0,this.buffer=n;const o=this.parent.autoPlayStart();e&&e(null,this.parent,o)}};t instanceof AudioBuffer?i(null,t):this.parent.context.decode(t,i)}}const ce=class{static from(s){let t={};typeof s=="string"?t.url=s:s instanceof ArrayBuffer||s instanceof AudioBuffer||s instanceof HTMLAudioElement?t.source=s:Array.isArray(s)?t.url=s:t=s,t={autoPlay:!1,singleInstance:!1,url:null,source:null,preload:!1,volume:1,speed:1,complete:null,loaded:null,loop:!1,...t},Object.freeze(t);const e=Xe().useLegacy?new Rd:new Od;return new ce(e,t)}constructor(s,t){this.media=s,this.options=t,this._instances=[],this._sprites={},this.media.init(this);const e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=!1,this._preloadQueue=null,this.isPlaying=!1,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded)}preferUrl(s){const[t]=s.map(e=>({url:e,ext:at.extname(e).slice(1)})).filter(({ext:e})=>Cs[e]).sort((e,i)=>Ss.indexOf(e.ext)-Ss.indexOf(i.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return Xe().context}pause(){return this.isPlaying=!1,this.paused=!0,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=!1,this}get paused(){return this._paused}set paused(s){this._paused=s,this.refreshPaused()}get speed(){return this._speed}set speed(s){this._speed=s,this.refresh()}get filters(){return this.media.filters}set filters(s){this.media.filters=s}addSprites(s,t){if(typeof s=="object"){const i={};for(const r in s)i[r]=this.addSprites(r,s[r]);return i}console.assert(!this._sprites[s],`Alias ${s} is already taken`);const e=new Ld(this,t);return this._sprites[s]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null}removeSprites(s){if(s){const t=this._sprites[s];t!==void 0&&(t.destroy(),delete this._sprites[s])}else for(const t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=!1,this._autoPlayOptions=null,this;this.isPlaying=!1;for(let s=this._instances.length-1;s>=0;s--)this._instances[s].stop();return this}play(s,t){let e;if(typeof s=="string"?e={sprite:s,loop:this.loop,complete:t}:typeof s=="function"?(e={},e.complete=s):e=s,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:!1,loop:!1,...e||{}},e.sprite){const r=e.sprite;console.assert(!!this._sprites[r],`Alias ${r} is not available`);const n=this._sprites[r];e.start=n.start+(e.start||0),e.end=n.end,e.speed=n.speed||1,e.loop=n.loop||e.loop,delete e.sprite}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(r=>{this._preloadQueue.push(()=>{r(this.play(e))})}):(this._preloadQueue=[],this.autoPlay=!0,this._autoPlayOptions=e,new Promise((r,n)=>{this._preload((o,a,h)=>{this._preloadQueue.forEach(l=>l()),this._preloadQueue=null,o?n(o):(e.loaded&&e.loaded(o,a,h),r(h))})}));(this.singleInstance||e.singleInstance)&&this._removeInstances();const i=this._createInstance();return this._instances.push(i),this.isPlaying=!0,i.once("end",()=>{e.complete&&e.complete(this),this._onComplete(i)}),i.once("stop",()=>{this._onComplete(i)}),i.play(e),i}refresh(){const s=this._instances.length;for(let t=0;t=0;s--)this._poolInstance(this._instances[s]);this._instances.length=0}_onComplete(s){if(this._instances){const t=this._instances.indexOf(s);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0}this._poolInstance(s)}_createInstance(){if(ce._pool.length>0){const s=ce._pool.pop();return s.init(this.media),s}return this.media.create()}_poolInstance(s){s.destroy(),ce._pool.indexOf(s)<0&&ce._pool.push(s)}};let qe=ce;qe._pool=[];class Ke extends Zo{constructor(){const t=window,e=new Ke.AudioContext,i=e.createDynamicsCompressor(),r=e.createAnalyser();r.connect(i),i.connect(e.destination),super(r,i),this.autoPause=!0,this._ctx=e,this._offlineCtx=new Ke.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=i,this.analyser=r,this.events=new ft,this.volume=1,this.speed=1,this.muted=!1,this.paused=!1,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur)}onFocus(){if(!this.autoPause)return;const t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))}playEmptySound(){const t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}static get AudioContext(){const t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){const t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();const t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t}get paused(){return this._paused}refresh(){this.events.emit("refresh")}refreshPaused(){this.events.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){const i=n=>{e(new Error((n==null?void 0:n.message)||"Unable to decode file"))},r=this._offlineCtx.decodeAudioData(t,n=>{e(null,n)},i);r&&r.catch(i)}}class Wd{constructor(){this.init()}init(){return this.supported&&(this._webAudioContext=new Ke),this._htmlAudioContext=new Ed,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t)}get supported(){return Ke.AudioContext!==null}add(t,e){if(typeof t=="object"){const n={};for(const o in t){const a=this._getOptions(t[o],e);n[o]=this.add(o,a)}return n}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof qe)return this._sounds[t]=e,e;const i=this._getOptions(e),r=qe.from(i);return this._sounds[t]=r,r}_getOptions(t,e){let i;return typeof t=="string"?i={url:t}:Array.isArray(t)?i={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?i={source:t}:i=t,i={...i,...e||{}},i}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext}get disableAutoPause(){return!this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t}remove(t){return this.exists(t,!0),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh()}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh()}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=!0,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=!1,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=!0,this._context.refresh(),this}unmuteAll(){return this._context.muted=!1,this._context.refresh(),this}removeAll(){for(const t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(const t in this._sounds)this._sounds[t].stop();return this}exists(t,e=!1){const i=!!this._sounds[t];return e&&console.assert(i,`No sound matching alias '${t}'.`),i}isPlaying(){for(const t in this._sounds)if(this._sounds[t].isPlaying)return!0;return!1}find(t){return this.exists(t,!0),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){const i=this.find(t);return e!==void 0&&(i.volume=e),i.volume}speed(t,e){const i=this.find(t);return e!==void 0&&(i.speed=e),i.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}}const dn=s=>{var i;const t=s.src;let e=(i=s==null?void 0:s.alias)==null?void 0:i[0];return(!e||s.src===e)&&(e=at.basename(t,at.extname(t))),e},Ud={extension:I.Asset,detection:{test:async()=>!0,add:async s=>[...s,...Ss.filter(t=>Cs[t])],remove:async s=>s.filter(t=>s.includes(t))},loader:{name:"sound",extension:{type:[I.LoadParser],priority:Gt.High},test(s){const t=at.extname(s).slice(1);return!!Cs[t]||Bd.some(e=>s.startsWith(`data:${e}`))},async load(s,t){const e=await new Promise((i,r)=>qe.from({...t.data,url:s,preload:!0,loaded(n,o){var a,h;n?r(n):i(o),(h=(a=t.data)==null?void 0:a.loaded)==null||h.call(a,n,o)}}));return Xe().add(dn(t),e),e},async unload(s,t){Xe().remove(dn(t))}}};K.add(Ud);const j=kd(new Wd);class fn{constructor(t,e){G(this,"font");G(this,"difficulty");G(this,"game");G(this,"currentPlayerLives");G(this,"updatePlayerLives",!0);G(this,"updateEnemyLives",!0);G(this,"playerLives");G(this,"enemyLives");G(this,"outcome",null);this.font="",this.difficulty=t,this.game=e,this.currentPlayerLives=3,this.playerLives=[],this.enemyLives=[]}render(){this.updatePlayerLives&&(this.drawLives(this.game.playerLives),this.updatePlayerLives=!1,this.drawEnemyLives())}drawLives(t){let e=0;for(;e!r.destroyed);this.playerLives.forEach(r=>{e.length==1&&(r.rotation==0?r.rotation=.5*1*t.deltaTime:r.rotation>0?r.rotation=.5*-1*t.deltaTime:r.rotation<0&&(r.rotation=.5*1*t.deltaTime))});const i=this.enemyLives.filter(r=>r.destroyed).length;this.enemyLives.forEach(r=>{i===2&&!r.destroyed&&r.label==="enemyLife1"&&(r.y==10||r.y>10?r.y=r.y-2*t.deltaTime:r.y<10&&(r.y=r.y+2*t.deltaTime))})}}renderOutcome(t,e,i){if(!this.game.app.stage.getChildByLabel("outcome")){const r=new Md({text:t,style:{fill:"#ffffff",fontSize:36,fontFamily:"silkscreen"},anchor:.5});return r.x=e,r.y=i,r.label="outcome",this.game.app.stage.addChild(r),r}}update(t){this.shakeLives(t)}}class we{constructor(t,e,i,r,n){G(this,"type");G(this,"texture");G(this,"sound");G(this,"speed");G(this,"yDirection");G(this,"behavior");G(this,"sprite");G(this,"entity");G(this,"stats");G(this,"game");G(this,"scattered",!1);G(this,"scatterSpeed",.25);this.stats=this.getStats(e),this.game=t.game,this.entity=t,this.type=e,this.texture=this.stats.texture,this.behavior=this.stats.behavior,this.speed=this.stats.speed,this.sound=this.stats.sound,this.yDirection=i,this.sprite=this.spawn(r,n),this.scatterSpeed=.25}spawn(t,e){const i=yt.from(this.texture);return i.x=t,i.y=e,i.anchor.set(.5),i.scale.set(.075),this.game.app.stage.addChild(i),j.play(this.sound,{volume:.45}),i}update(t){if(this.sprite.destroyed){this.entity.bullets=this.entity.bullets.filter(i=>!i.sprite.destroyed);return}const e=this.sprite.getBounds();if(e.y<-(this.sprite.height+5)||e.y>this.game.app.screen.height+this.sprite.height)this.sprite.destroy(),this.entity.bullets=this.entity.bullets.filter(i=>!i.sprite.destroyed);else{switch(this.type){case 1:this.entity.constructor.name=="Enemy"&&(console.log(this.entity.constructor.name),this.sprite.tint="#ff1362");break;case 2:this.sprite.width+=.2*t.deltaTime,this.sprite.height+=.2*t.deltaTime;break;case 3:this.sprite.y>this.game.app.screen.height/2-20&&!this.scattered&&this.sprite.label!=="left"&&this.sprite.label!=="right"&&this.scatter(this),this.sprite.rotation+=.5*t.deltaTime;break}this.sprite.y+=this.stats.speed*this.yDirection*.2*t.deltaTime,this.sprite.label=="left"?this.sprite.x-=this.scatterSpeed*t.deltaTime:this.sprite.label=="right"&&(this.sprite.x+=this.scatterSpeed*t.deltaTime)}}scatter(t){let e=t.sprite.x-t.sprite.width/2;const i=t.sprite.y,r=new we(t.entity,t.type,t.yDirection,e,i);r.sprite.label="left",r.sprite.alpha=.5,this.entity.bullets.push(r),e=t.sprite.x+t.sprite.width/2;const n=new we(t.entity,t.type,t.yDirection,e,i);n.sprite.label="right",n.sprite.alpha=.5,t.scattered=!0,this.entity.bullets.push(n)}getStats(t){return{1:{texture:"bullet1",behavior:"normal",speed:9,sound:"enemyShoot1"},2:{texture:"bullet2",behavior:"grow",speed:6,sound:"shoot1"},3:{texture:"bullet3",behavior:"scatter",speed:10-.75,sound:"enemyShoot"}}[t]}}class ea{constructor(t,e,i){G(this,"health");G(this,"texture");G(this,"fireRate");G(this,"bulletType");G(this,"sprite");G(this,"game");G(this,"shootCooldown",250);G(this,"shootOnCooldown",!1);G(this,"bullets",[]);this.health=e,this.texture="",this.fireRate=0,this.bulletType=t,this.sprite=yt.from(""),this.game=i}takeDamage(){this.health--,this.health<=0?(this.destroy(),this.game.removeLife(this)):j.play("hit")}collided(t){if(this.sprite.destroyed||t.destroyed)return!1;const e=this.sprite.getBounds(),i=t.getBounds();return e.xi.x&&e.yi.y}shoot(){if(!this.sprite)return;const t=this.sprite.x,e=this.sprite.y;new we(this,this.bulletType,1,t,e)}update(t){this.bullets.forEach(e=>{e.update(t)})}destroy(){const t=de.cache.get("explosion").animations,e=new ws(t.explosion),i=this.sprite.getBounds();e.animationSpeed=.16,e.loop=!1,e.position.set(i.x,i.y),e.play(),j.play("explosion2"),this.game.app.stage.addChild(e),this.sprite.destroy(),setTimeout(()=>{e.destroy()},500)}}class ri extends ea{constructor(t,e){super(1,t,e),this.texture="player"}spawn(){const t=yt.from(this.texture);return t.anchor.set(.5),t.scale.set(.05),t.position.set(this.game.app.screen.width/2,this.game.app.screen.height-t.height),t.label="player",this.game.app.stage.addChild(t),this.sprite=t,this.game.app.stage.on("pointermove",this.move.bind(this)),t}shoot(){if(!this.sprite||this.shootOnCooldown)return;const t=this.sprite.x,e=this.sprite.y,i=new we(this,this.bulletType,-1,t,e);this.sprite&&this.bullets.push(i),this.cooldown()}cooldown(){this.shootOnCooldown=!0,setTimeout(()=>{this.shootOnCooldown=!1},this.shootCooldown)}move(t){if(!this.sprite.destroyed){const e=this.sprite.width/2,i=this.sprite.height/2,r=t.global;r.x<=this.game.app.screen.width-e&&r.x>=e&&(this.sprite.x=r.x),r.y<=this.game.app.screen.height-i&&r.y>=i&&(this.sprite.y=r.y)}}takeDamage(){if(this.health--,this.game.playerDamageTaken++,this.game.removeLife(this),this.health<=0){this.game.music.stop(),this.destroy();const t=Math.floor(Math.random()*2)+1;setTimeout(()=>{j.play(`player_death_${t}`,{complete:()=>{this.game.end(!1)}})},400)}else j.play(`player_hit_0${this.game.playerDamageTaken}`)}update(t){super.update(t),this.game.enemies.forEach(e=>{e.bullets.forEach(i=>{this.collided(i.sprite)&&(i.sprite.destroy(),this.takeDamage())})})}}class pn extends ea{constructor(e,i){super(e,0,i);G(this,"direction",1);G(this,"stats");this.stats=this.getStats(e),this.health=this.stats.health,this.texture=this.stats.texture,this.fireRate=this.stats.fireRate,this.sprite=this.spawn(),this.shootCooldown=this.stats.fireRate}spawn(){const e=yt.from(this.texture);return e.anchor=.5,e.scale.set(.075),e.x=Math.floor(Math.random()*this.game.app.stage.width),e.y=-e.height,e.rotation=Math.PI,this.game.app.stage.addChild(e),e}update(e){this.sprite.destroyed?this.sprite.destroyed&&this.bullets.length===0&&(this.game.enemies=[]):(this.move(),this.shoot()),this.bullets.forEach(i=>{i.update(e)}),this.game.player.bullets.forEach(i=>{this.collided(i.sprite)&&(i.sprite.destroy(),this.takeDamage())})}shoot(){if(!this.sprite||this.shootOnCooldown||this.game.player.sprite.destroyed)return;const e=this.sprite.x,i=this.sprite.y,r=new we(this,this.bulletType,1,e,i);this.sprite&&this.bullets.push(r),this.cooldown()}move(){if(this.sprite.y<25)this.sprite.y+=1;else{const e=this.direction;let i=e;Math.floor(Math.random()*500)===1?i=-i:(this.sprite.x>=this.game.app.screen.width-this.sprite.width/2&&e==1||this.sprite.x>=this.game.app.screen.width&&e==-1?i=-1:(this.sprite.x<=this.game.app.screen.width&&e==1||this.sprite.x<=15&&e==-1)&&(i=1),this.sprite.x+=i),this.direction=i}}cooldown(){this.shootOnCooldown=!0,setTimeout(()=>{this.shootOnCooldown=!1},this.shootCooldown)}getStats(e){return{1:{texture:"enemy1",health:1,fireRate:750},2:{texture:"enemy2",health:4,fireRate:800},3:{texture:"enemy3",health:6,fireRate:750}}[e]}}const zd=240,Hd=160;class Nd{constructor(){G(this,"app");G(this,"ready",!1);G(this,"width",zd);G(this,"height",Hd);G(this,"difficulty",0);G(this,"playerLives",3);G(this,"playerKills",0);G(this,"playerDamageTaken",0);G(this,"music");G(this,"player");G(this,"ui");G(this,"state","loading");G(this,"enemies",[]);G(this,"framesRendered");this.app=new go,this.music=qe.from({url:"assets/sounds/bgm.wav",preload:!0,loop:!0,volume:.25}),this.ui=new fn(this.difficulty,this),this.framesRendered=0,this.player=new ri(3,this)}listen(){window.addEventListener("message",t=>{switch(t.data.op){case"start":t.data.difficulty!==void 0&&t.data.difficulty!==null&&(this.difficulty=t.data.difficulty),this.restart(),window.parent.postMessage({op:"started",verb:"shoot!"});break;default:console.log(`shoot! - received unknown event: ${t}`);break}}),this.ready=!0,this.music.play(),window.parent.postMessage({op:"ready"})}async preload(){const t=[{alias:"background",src:"/games/sunshoes/assets/sprites/bg.png"},{alias:"player",src:"/games/sunshoes/assets/sprites/player.png"},{alias:"bullet1",src:"/games/sunshoes/assets/sprites/bullet1.png"},{alias:"bullet2",src:"/games/sunshoes/assets/sprites/bullet2.png"},{alias:"bullet3",src:"/games/sunshoes/assets/sprites/bullet3.png"},{alias:"enemy1",src:"/games/sunshoes/assets/sprites/enemy1.png"},{alias:"enemy2",src:"/games/sunshoes/assets/sprites/enemy2.png"},{alias:"enemy3",src:"/games/sunshoes/assets/sprites/enemy3.png"},{alias:"life",src:"/games/sunshoes/assets/sprites/mrgreen.png"},{alias:"wave",src:"/games/sunshoes/assets/sprites/mrred.png"},{alias:"explosion",src:"/games/sunshoes/assets/animations/explosion.json"},{alias:"silkscreen",src:"/games/sunshoes/assets/ui/silkscreen_regular.ttf",data:{family:"silkscreen"}},{alias:"bungeespice",src:"/games/sunshoes/assets/ui/bungeespice.ttf",data:{family:"bungeespice"}}];j.add("bgm","/games/sunshoes/assets/sounds/bgm.wav"),j.add("shoot","/games/sunshoes/assets/sounds/shoot.wav"),j.add("shoot1","/games/sunshoes/assets/sounds/shoot1.wav"),j.add("enemyShoot","/games/sunshoes/assets/sounds/enemyShoot.wav"),j.add("enemyShoot1","/games/sunshoes/assets/sounds/enemyShoot1.wav"),j.add("hit","/games/sunshoes/assets/sounds/hit.wav"),j.add("success","/games/sunshoes/assets/sounds/success.wav"),j.add("failure","/games/sunshoes/assets/sounds/failure.wav"),j.add("explosion2","/games/sunshoes/assets/sounds/explosion2.wav"),j.add("player_hit_01","/games/sunshoes/assets/sounds/pain_jack_01.wav"),j.add("player_hit_02","/games/sunshoes/assets/sounds/pain_jack_02.wav"),j.add("player_hit_03","/games/sunshoes/assets/sounds/pain_jack_03.wav"),j.add("player_death_1","/games/sunshoes/assets/sounds/death_jack_01.wav"),j.add("player_death_2","/games/sunshoes/assets/sounds/death_jack_02.wav"),j.disableAutoPause=!0,await de.load(t)}setup(){(this.player.sprite.texture==null||this.player.sprite.texture.label==="EMPTY")&&(this.player=new ri(this.playerLives,this),this.player.spawn()),this.drawUI(),this.app.stage.onclick=()=>{this.player.sprite.destroyed||this.player.shoot()}}async initialize(){await this.app.init({width:this.width,height:this.height,background:"#1e1e1f"}),document.getElementById("container").appendChild(this.app.canvas);const t=yt.from("background");this.app.stage.addChild(t),this.app.stage.interactive=!0,this.app.renderer.events.cursorStyles.default="none",this.setup(),this.state="playing"}drawUI(){this.ui.outcome!==null&&this.ui.outcome!==void 0&&this.ui.outcome.destroy(),this.ui.render()}removeLife(t){t instanceof ri?this.ui.removeLife():t instanceof pn&&(this.ui.removeEnemyLife(),this.playerKills++)}update(t){if(this.framesRendered+=1,this.ui.update(t),this.player.update(t),this.enemies.length>0)this.enemies.forEach(e=>{e.update(t)});else if(this.playerKills<3){const e=new pn(this.playerKills+1,this);this.enemies.push(e)}this.playerKills===3&&this.state!=="ended"?this.end(!0):this.playerDamageTaken===this.playerLives&&this.state}end(t){this.ready=!1;const e=this.width/2,i=this.height/2,r=t?"YOU WIN!":"YOU LOSE!",n=t?"success":"failure";!j.find(n).isPlaying&&this.state!=="ended"&&(this.ui.outcome=this.ui.renderOutcome(r,e,i),this.app.stage.onclick=null,j.stopAll(),this.music.stop(),this.state="ended",setTimeout(()=>{j.play(n,{volume:.25,complete:()=>{for(;this.playerKills>0;)this.ui.removeEnemyLife(),this.playerKills--;for(;this.playerLives>0;)this.ui.removeLife(),this.playerLives--;this.app.stop(),window.parent.postMessage({op:"done",win:t})}})},500))}restart(){for(this.music.stop(),j.stopAll(),this.state="loading",this.player.bullets.forEach(t=>{t.sprite.destroyed||t.sprite.destroy()}),this.enemies.forEach(t=>{t.sprite.destroyed||t.sprite.destroy()}),this.enemies=[],this.teardown();this.playerKills>0;)this.ui.removeEnemyLife(),this.playerKills--;for(;this.playerLives>0;)this.ui.removeLife(),this.playerLives--;this.playerLives=3,this.playerKills=0,this.playerDamageTaken=0,this.app.stage.removeChild(this.player.sprite),this.player.sprite.destroy(),this.ui=new fn(this.difficulty,this),this.ui.updatePlayerLives=!0,this.setup(),this.listen(),this.app.start()}teardown(){var e,i;this.ui.outcome&&(this.app.stage.removeChild(this.ui.outcome),(e=this.ui.outcome)==null||e.destroy(),(i=this.app.stage.getChildByLabel("outcome"))==null||i.destroy());const t=this.app.stage.getChildByLabel("outcome");t!==null&&t.destroy()}triggerRestart(t=10){window.postMessage({op:"start",difficulty:t})}}(async()=>{const s=new Nd;await s.preload(),await s.initialize(),s.listen();const t=s.app;window.restart=()=>{s.restart()},window.triggerRestart=()=>{s.triggerRestart()},t.ticker.add(e=>{s.update(e)})})();export{fi as $,At as A,je as B,Ot as C,ko as D,ft as E,K as F,Ms as G,Ro as H,be as I,te as J,$ as K,fs as L,Mn as M,W as N,Es as O,Bc as P,Yu as Q,tt as R,Fi as S,U as T,Nc as U,Ln as V,Ft as W,Is as X,Un as Y,z as Z,lo as _,Kn as a,dt as a0,ze as a1,lt as a2,Fa as a3,Ut as a4,Ol as a5,Tr as a6,ps as a7,Bi as a8,oo as a9,gc as aA,yc as aB,Cc as aC,Ac as aD,Tc as aE,Ku as aF,St as aa,to as ab,mc as ac,_c as ad,Sc as ae,wc as af,wa as ag,Pc as ah,Tn as ai,vt as aj,Ts as ak,ar as al,yt as am,Td as an,Za as ao,lr as ap,Hs as aq,cr as ar,th as as,kn as at,co as au,Qe as av,sl as aw,Qh as ax,Ql as ay,Vl as az,ye as b,Mi as c,X as d,q as e,ki as f,ds as g,As as h,Ho as i,No as j,wt as k,Yd as l,md as m,sd as n,nt as o,O as p,wh as q,zl as r,pt as s,J as t,Ih as u,_t as v,Y as w,Po as x,Rn as y,I as z};