o?h:o}return t.x=s,t.width=i-s,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}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Bi=(r,t,e,s,i,n,o)=>{const a=r-e,l=t-s,u=Math.sqrt(a*a+l*l);return u>=i-n&&u<=i+o};class Bo{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t||(t=new it),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Bo(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.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s,i=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,h=s*(1-i),c=s-h,d=n+u,p=o+u,f=a-u*2,m=l-u*2,g=n+a,_=o+l;return(t>=n-h&&t<=n+c||t>=g-c&&t<=g+h)&&e>=p&&e<=p+m||(e>=o-h&&e<=o+c||e>=_-c&&e<=_+h)&&t>=d&&t<=d+f?!0:tg-u&&eg-u&&e>_-u&&Bi(t,e,g-u,_-u,u,c,h)||t_-u&&Bi(t,e,d,_-u,u,c,h)}}class Wc{constructor(t=0,e=0,s=0,i=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=s,this.y2=i,this.x3=n,this.y3=o}contains(t,e){const s=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),i=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(s<0!=i<0&&s!==0&&i!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==s+i<=0}strokeContains(t,e,s,i=.5){const n=s/2,o=n*n,{x:a,x2:l,x3:u,y:h,y2:c,y3:d}=this;return Ss(t,e,a,h,l,c)<=o||Ss(t,e,l,c,u,d)<=o||Ss(t,e,u,d,a,h)<=o}clone(){return new Wc(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new it);const e=Math.min(this.x,this.x2,this.x3),s=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=i,t.width=s-e,t.height=n-i,t}}const rf=new D;function Sa(r,t){var e;t.clear();const s=t.matrix;for(let i=0;i!l.enabled)){e.skip=!0;return}const i=[],n=1;for(const l of s){if(!l.enabled)continue;if(!wa(l)){this._warnUnsupportedFilter(l);continue}const u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&i.push(u)}if(i.length===0&&n===1){e.skip=!0;return}e.cssFilterString=i.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),o.clip()}else e.useClip=!1;n!==1&&(this._alphaMultiplier*=n),e.cssFilterString&&(o.filter=a!=="none"?`${a} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const s=this.renderer.canvasContext.activeContext;t.useClip?s.restore():s.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){var s,i;if(!(e!=null&&e.length)||e.every(v=>!v.enabled))return t;const n=[],o=1;for(const v of e){if(!v.enabled)continue;if(!wa(v)){this._warnUnsupportedFilter(v);continue}const b=v.getCanvasFilterString();if(b===null){this._warnUnsupportedFilter(v);continue}b&&n.push(b)}if(n.length===0&&o===1)return t;const a=Z.getCanvasSource(t);if(!a)return t;const l=t.frame,u=(i=(s=t.source._resolution)!=null?s:t.source.resolution)!=null?i:1,h=l.width,c=l.height,d=se.getOptimalCanvasAndContext(h,c,u),{canvas:p,context:f}=d;f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,p.width,p.height),n.length&&(f.filter=n.join(" ")),o!==1&&(f.globalAlpha=o);const m=l.x*u,g=l.y*u,_=h*u,x=c*u;return f.drawImage(a,m,g,_,x,0,0,_,x),f.filter="none",f.globalAlpha=1,Di(p,h,c,u)}_calculateFilterArea(t,e){if(t.renderables?Sa(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const s=t.container.renderGroup||t.container.parentRenderGroup,i=s==null?void 0:s.cacheToLocalTransform;i&&e.applyMatrix(i)}}_warnUnsupportedFilter(t){var e;const s=((e=t==null?void 0:t.constructor)==null?void 0:e.name)||"Filter";this._warnedFilterTypes.has(s)||(this._warnedFilterTypes.add(s),console.warn(`CanvasRenderer: filter "${s}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new $w),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Ea.extension={type:[T.CanvasSystem],name:"filter"};class Aa{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Aa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};const Pa=Object.create(null),sf=Object.create(null);function ur(r,t){let e=sf[r];return e===void 0&&(Pa[t]===void 0&&(Pa[t]=1),sf[r]=e=Pa[t]++),e}let ws;function Ca(){return(!ws||ws!=null&&ws.isContextLost())&&(ws=X.get().createCanvas().getContext("webgl",{})),ws}let $i;function nf(){if(!$i){$i="mediump";const r=Ca();r&&r.getShaderPrecisionFormat&&($i=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return $i}function of(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${r}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${r}
`}function af(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float;
${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function lf(r,t){return t?`#version 300 es
${r}`:r}const Uw={},kw={};function uf(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Uw:kw;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
${r}`}function hf(r,t){return t?r.replace("#version 300 es",""):r}var Lw=Object.defineProperty,cf=Object.getOwnPropertySymbols,Nw=Object.prototype.hasOwnProperty,jw=Object.prototype.propertyIsEnumerable,df=(r,t,e)=>t in r?Lw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pf=(r,t)=>{for(var e in t||(t={}))Nw.call(t,e)&&df(r,e,t[e]);if(cf)for(var e of cf(t))jw.call(t,e)&&df(r,e,t[e]);return r};const Ra={stripVersion:hf,ensurePrecision:af,addProgramDefines:of,setProgramName:uf,insertVersion:lf},Es=Object.create(null),ff=class $c{constructor(t){t=pf(pf({},$c.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:nf()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(Ra).forEach(o=>{const a=s[o];i=Ra[o](i,a,!0),n=Ra[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=ur(`${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,Es[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Es[e]||(Es[e]=new $c(t),Es[e]._cacheKey=e),Es[e]}};ff.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Yt=ff;const mf={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 Be(r){var t;return(t=mf[r])!=null?t:mf.float32}const Xw={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"},gf=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function _f(r,t){var e;let s;for(;(s=gf.exec(r))!==null;){const i=(e=Xw[s[3]])!=null?e:"float32";t[s[2]]={location:parseInt(s[1],10),format:i,stride:Be(i).stride,offset:0,instance:!1,start:0}}gf.lastIndex=0}function Hw(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function xf({source:r,entryPoint:t}){const e={},s=Hw(r),i=s.indexOf(`fn ${t}(`);if(i===-1)return e;const n=s.indexOf("->",i);if(n===-1)return e;const o=s.substring(i,n);if(_f(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const l=a[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),h=s.match(u);h&&_f(h[1],e)}}return e}function Ui(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*([\w<>]+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>{var m;const g=f.match(a),_=(m=g==null?void 0:g[1])!=null?m:"";let x;return _===""?x="uniform":_.startsWith("{const m=f.match(c)[1],g=f.match(h).reduce((_,x)=>{const[v,b]=x.split(":");return _[v.trim()]=b.trim(),_},{});return g?{name:m,members:g}:null}).filter(({name:f})=>d.some(m=>m.type===f||m.type.includes(`<${f}>`))))!=null?s:[];return{groups:d,structs:p}}var At=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(At||{});function vf({groups:r}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const As=Object.create(null);class zt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=i,this.vertex=n,i.source===n.source){const u=Ui(i.source);this.structsAndGroups=u}else{const u=Ui(n.source),h=Ui(i.source);this.structsAndGroups=yf(u,h)}this.layout=o!=null?o:bf(this.structsAndGroups),this.gpuLayout=a!=null?a:vf(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((s=this.layout[1])==null?void 0:s.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ur(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=xf(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,As[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return As[e]||(As[e]=new zt(t),As[e]._cacheKey=e),As[e]}}class Ee{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}}get _key(){if(this._dirty){this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]?this.resources[s]._resourceId:-1;this._keyValue=t.join("|")}return this._keyValue}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=n.off)==null||s.call(n,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e){const i=e[s];i&&(i._gcLastUsed=t)}}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i==null?void 0:i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}}}var Mt=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Mt||{}),zw=Object.defineProperty,Tf=Object.getOwnPropertySymbols,Ww=Object.prototype.hasOwnProperty,Vw=Object.prototype.propertyIsEnumerable,Sf=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yw=(r,t)=>{for(var e in t||(t={}))Ww.call(t,e)&&Sf(r,e,t[e]);if(Tf)for(var e of Tf(t))Vw.call(t,e)&&Sf(r,e,t[e]);return r};class as{constructor(t){this.data=Yw({},t);const e=Object.keys(t).sort().map(s=>`${s}:${t[s]}`).join("|");this.id=ur(e,"shader-overrides")}static from(t){return t instanceof as?t:new as(t)}}const Ma=["f32","i32","u32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4","vec2","vec3","vec4"],wf=Ma.reduce((r,t)=>(r[t]=!0,r),{});function Ef(r,t){switch(r){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}var Kw=Object.defineProperty,Af=Object.getOwnPropertySymbols,qw=Object.prototype.hasOwnProperty,Zw=Object.prototype.propertyIsEnumerable,Pf=(r,t,e)=>t in r?Kw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cf=(r,t)=>{for(var e in t||(t={}))qw.call(t,e)&&Pf(r,e,t[e]);if(Af)for(var e of Af(t))Zw.call(t,e)&&Pf(r,e,t[e]);return r};const Rf=class sS extends It{constructor(t,e){var s,i;super(),this.uid=ut("uniform"),this._resourceType="uniformGroup",this._resourceId=ut("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e=Cf(Cf({},sS.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(s=a.size)!=null?s:1,!wf[a.type]){const l=a.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,h]=l;throw new Error(`Uniform type ${a.type} is not supported. Use type: '${u}', size: ${h} instead.`)}throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${Ma.join(", ")}`)}(i=a.value)!=null||(a.value=Ef(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ur(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(t){var e;this._buffer!==t&&((e=this._buffer)==null||e.off("change",this.onBufferChange,this),this._buffer=t,t==null||t.on("change",this.onBufferChange,this))}get _gcLastUsed(){var t,e;return(e=(t=this._buffer)==null?void 0:t._gcLastUsed)!=null?e:-1}set _gcLastUsed(t){this._buffer&&(this._buffer._gcLastUsed=t)}onBufferChange(){this._resourceId=ut("resource"),this.emit("change",this)}update(){this._dirtyId++}};Rf.defaultOptions={ubo:!1,isStatic:!1};let wt=Rf;var Qw=Object.defineProperty,ki=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Of=Object.prototype.propertyIsEnumerable,Gf=(r,t,e)=>t in r?Qw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jw=(r,t)=>{for(var e in t||(t={}))Mf.call(t,e)&&Gf(r,e,t[e]);if(ki)for(var e of ki(t))Of.call(t,e)&&Gf(r,e,t[e]);return r},tE=(r,t)=>{var e={};for(var s in r)Mf.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ki)for(var s of ki(r))t.indexOf(s)<0&&Of.call(r,s)&&(e[s]=r[s]);return e};class ne extends It{constructor(t){super(),this.uid=ut("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a,overrides:l}=t;this._overrides=l?as.from(l):null,this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=Mt.WEBGPU),s&&(o|=Mt.WEBGL)),this.compatibleRenderers=o;const u={};if(a)for(const h in a)for(const c in a[h]){const d=a[h][c];u[d]={group:h,binding:c,name:d}}if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(e&&i&&!a){const h=e.structsAndGroups.groups;a={},h.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c})}else if(n){i={},a||(a={}),e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c});let h=0;for(const c in n)u[c]||(i[99]||(i[99]=new Ee,this._ownedBindGroups.push(i[99])),u[c]={group:99,binding:h,name:c},a[99]=a[99]||{},a[99][h]=c,h++);for(const c in n){const d=c;let p=n[c];!p.source&&!p._resourceType&&(p=new wt(p));const f=u[d];f&&(i[f.group]||(i[f.group]=new Ee,this._ownedBindGroups.push(i[f.group])),i[f.group].setResource(p,f.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,u)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Ee,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null)}static from(t){const e=t,{gpu:s,gl:i}=e,n=tE(e,["gpu","gl"]);let o,a;return s&&(o=zt.from(s)),i&&(a=Yt.from(i)),new ne(Jw({gpuProgram:o,glProgram:a},n))}}const eE={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Oa={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:Ga,OFFSET:Ia,CULLING:Fa,DEPTH_TEST:Ba,WINDING:Da,DEPTH_MASK:$a}=Oa,Ua=class iS{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<t in r?rE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ka=(r,t)=>{for(var e in t||(t={}))If.call(t,e)&&Bf(r,e,t[e]);if(Li)for(var e of Li(t))Ff.call(t,e)&&Bf(r,e,t[e]);return r},sE=(r,t)=>{var e={};for(var s in r)If.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Li)for(var s of Li(r))t.indexOf(s)<0&&Ff.call(r,s)&&(e[s]=r[s]);return e};const Df=class Uc extends ne{constructor(t){t=ka(ka({},Uc.defaultOptions),t),super(t),this.enabled=!0,this._state=Kt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,s,i){t.applyFilter(this,e,s,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:s,gl:i}=e,n=sE(e,["gpu","gl"]);let o,a;return s&&(o=zt.from(s)),i&&(a=Yt.from(i)),new Uc(ka({gpuProgram:o,glProgram:a},n))}};Df.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ae=Df;var Ps=`in vec2 aPosition;
out vec2 vTextureCoord;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
}
`,$f=`in vec2 vTextureCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
finalColor = texture(uTexture, vTextureCoord);
}
`,La=`struct GlobalFilterUniforms {
uInputSize: vec4,
uInputPixel: vec4,
uInputClamp: vec4,
uOutputFrame: vec4,
uGlobalFrame: vec4,
uOutputTexture: vec4,
};
@group(0) @binding(0) var gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d;
@group(0) @binding(2) var uSampler: sampler;
struct VSOutput {
@builtin(position) position: vec4,
@location(0) uv: vec2
};
fn filterVertexPosition(aPosition: vec2) -> vec4
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord(aPosition: vec2) -> vec2
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition: vec2,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2,
) -> @location(0) vec4 {
return textureSample(uTexture, uSampler, uv);
}
`;class Uf extends Ae{constructor(){const t=zt.from({vertex:{source:La,entryPoint:"mainVertex"},fragment:{source:La,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Yt.from({vertex:Ps,fragment:$f,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var st=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(st||{});class qt extends It{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ut("buffer"),this._resourceType="buffer",this._resourceId=ut("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s!=null||(s=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?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&st.STATIC)}set static(t){t?this.descriptor.usage|=st.STATIC:this.descriptor.usage&=~st.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLengtha&&(a=p),f>l&&(l=f),p"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Ee({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,s=t.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=t.container,i.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(s.every(p=>!p.enabled)){i.skip=!0;return}const l=i.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(i,e.renderTarget.rootViewPort,a,o,1),i.skip)return;const u=this._getPreviousFilterData(),h=this._findFilterResolution(o);let c=0,d=0;u&&(c=u.bounds.minX,d=u.bounds.minY),this._calculateGlobalFrame(i,c,d,h,n.width,n.height),this._setupFilterTextures(i,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=e;const i=t.source,n=i.resolution,o=i.antialias;if(e.every(h=>!h.enabled))return s.skip=!0,t;const a=s.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(s,a.rectangle,o,n,0),s.skip)return t;const l=n;this._calculateGlobalFrame(s,0,0,l,i.width,i.height),s.outputRenderSurface=ft.getOptimalTexture({width:a.width,height:a.height,resolution:s.resolution,antialias:s.antialias}),s.backTexture=B.EMPTY,s.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);const u=s.outputRenderSurface;return u.source.alphaMode="premultiplied-alpha",u}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&ft.returnTexture(e.backTexture),ft.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const i=t.colorTexture.source._resolution,n=ft.getOptimalTexture({width:e.width,height:e.height,resolution:i});let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*i),a=Math.floor(a*i);const l=Math.ceil(e.width*i),u=Math.ceil(e.height*i);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:u},{x:0,y:0}),n}applyFilter(t,e,s,i){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface===s,l=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let h=0,c=0;if(a){const p=this._findPreviousFilterOffset();h=p.x,c=p.y}this._updateFilterUniforms(e,s,o,h,c,u,a,i);const d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,n)}calculateSpriteMatrix(t,e){const s=this._activeFilterData,i=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(D.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/e.texture.orig.width,1/e.texture.orig.height),i.translate(e.anchor.x,e.anchor.y),i}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new Uf),this._passthroughFilter}_setupBindGroupsAndRender(t,e,s){if(s.renderPipes.uniformBatch){const i=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,s.encoder.draw({geometry:nE,shader:t,state:t._state,topology:"triangle-list"}),s.type===Mt.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,i){if(t.backTexture=B.EMPTY,t.inputTexture=ft.getOptimalTexture({width:e.width,height:e.height,resolution:t.resolution,antialias:t.antialias}),t.blendRequired){s.renderTarget.finishRenderPass();const n=s.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,i==null?void 0:i.bounds)}s.renderTarget.bind({target:t.inputTexture,clear:!0}),s.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,s,i,n,o){const a=t.globalFrame;a.x=e*i,a.y=s*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(t,e,s,i,n,o,a,l){const u=this._filterGlobalUniforms.uniforms,h=u.uOutputFrame,c=u.uInputSize,d=u.uInputPixel,p=u.uInputClamp,f=u.uGlobalFrame,m=u.uOutputTexture;a?(h[0]=s.bounds.minX-i,h[1]=s.bounds.minY-n):(h[0]=0,h[1]=0),h[2]=t.frame.width,h[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],p[0]=.5*d[2],p[1]=.5*d[3],p[2]=t.frame.width*c[2]-.5*d[2],p[3]=t.frame.height*c[3]-.5*d[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;f[0]=i*o,f[1]=n*o,f[2]=g.source.width*o,f[3]=g.source.height*o,e instanceof B&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind({target:e,clear:!!l}),e instanceof B?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=_.width,m[1]=_.height),m[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,s=this._filterStackIndex;for(;s>0;){s--;const i=this._filterStack[s];if(!i.skip){t=i.bounds.minX,e=i.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Sa(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){const s=t.inputTexture,i=t.bounds,n=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)n[o].apply(this,s,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=ft.getOptimalTexture({width:i.width,height:i.height,resolution:l.source._resolution});let h=u;for(let c=o;c0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new oE),this._filterStackIndex++,t}}ja.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"},L.add(ja,Ea),L.add(Aa);var aE={__proto__:null};const Xa=[];L.handleByNamedList(T.Environment,Xa);async function Ha(r){if(!r)for(let t=0;t80*e){a=r[0],l=r[1];let h=a,c=l;for(let d=e;dh&&(h=p),f>c&&(c=f)}u=Math.max(h-a,c-l),u=u!==0?32767/u:0}return Rs(n,o,e,a,l,u,0),o}function Nf(r,t,e,s,i){let n;if(i===Ya(r,t,e,s)>0)for(let o=t;o=t;o-=s)n=zf(o/s|0,r[o],r[o+1],n);return n&&Or(n,n.next)&&(Gs(n),n=n.next),n}function cr(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(Or(e,e.next)||xt(e.prev,e,e.next)===0)){if(Gs(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Rs(r,t,e,s,i,n,o){if(!r)return;!o&&n&&xE(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?hE(r,s,i,n):uE(r)){t.push(l.i,r.i,u.i),Gs(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=cE(cr(r),t),Rs(r,t,e,s,i,n,2)):o===2&&dE(r,t,e,s,i,n):Rs(cr(r),t,e,s,i,n,1);break}}}function uE(r){const t=r.prev,e=r,s=r.next;if(xt(t,e,s)>=0)return!1;const i=t.x,n=e.x,o=s.x,a=t.y,l=e.y,u=s.y,h=Math.min(i,n,o),c=Math.min(a,l,u),d=Math.max(i,n,o),p=Math.max(a,l,u);let f=s.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&Ms(i,a,n,l,o,u,f.x,f.y)&&xt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function hE(r,t,e,s){const i=r.prev,n=r,o=r.next;if(xt(i,n,o)>=0)return!1;const a=i.x,l=n.x,u=o.x,h=i.y,c=n.y,d=o.y,p=Math.min(a,l,u),f=Math.min(h,c,d),m=Math.max(a,l,u),g=Math.max(h,c,d),_=Wa(p,f,t,e,s),x=Wa(m,g,t,e,s);let v=r.prevZ,b=r.nextZ;for(;v&&v.z>=_&&b&&b.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==i&&v!==o&&Ms(a,h,l,c,u,d,v.x,v.y)&&xt(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==o&&Ms(a,h,l,c,u,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==i&&v!==o&&Ms(a,h,l,c,u,d,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==i&&b!==o&&Ms(a,h,l,c,u,d,b.x,b.y)&&xt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function cE(r,t){let e=r;do{const s=e.prev,i=e.next.next;!Or(s,i)&&Xf(s,e,e.next,i)&&Os(s,i)&&Os(i,s)&&(t.push(s.i,e.i,i.i),Gs(e),Gs(e.next),e=r=i),e=e.next}while(e!==r);return cr(e)}function dE(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&yE(o,a)){let l=Hf(o,a);o=cr(o,o.next),l=cr(l,l.next),Rs(o,t,e,s,i,n,0),Rs(l,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function pE(r,t,e,s){const i=[];for(let n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){const c=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=s&&c>n&&(n=c,o=e.x=e.x&&e.x>=l&&s!==e.x&&jf(io.x||e.x===o.x&&_E(o,e)))&&(o=e,h=c)}e=e.next}while(e!==a);return o}function _E(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function xE(r,t,e,s){let i=r;do i.z===0&&(i.z=Wa(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,vE(i)}function vE(r){let t,e=1;do{let s=r,i;r=null;let n=null;for(t=0;s;){t++;let o=s,a=0;for(let u=0;u0||l>0&&o;)a!==0&&(l===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,e*=2}while(t>1);return r}function Wa(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function bE(r){let t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function Ms(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&jf(r,t,e,s,i,n,o,a)}function yE(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!TE(r,t)&&(Os(r,t)&&Os(t,r)&&SE(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Or(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Or(r,t){return r.x===t.x&&r.y===t.y}function Xf(r,t,e,s){const i=ji(xt(r,t,e)),n=ji(xt(r,t,s)),o=ji(xt(e,s,r)),a=ji(xt(e,s,t));return!!(i!==n&&o!==a||i===0&&Ni(r,e,t)||n===0&&Ni(r,s,t)||o===0&&Ni(e,r,s)||a===0&&Ni(e,t,s))}function Ni(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ji(r){return r>0?1:r<0?-1:0}function TE(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Xf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Os(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function SE(r,t){let e=r,s=!1;const i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function Hf(r,t){const e=Va(r.i,r.x,r.y),s=Va(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function zf(r,t,e,s){const i=Va(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Gs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Va(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qB(r,t,e,s){const i=t&&t.length,n=i?t[0]*e:r.length;let o=Math.abs(Ya(r,0,n,e));if(i)for(let l=0,u=t.length;l(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Pt||{});class Ka{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,l){const{name:u,items:h}=this;for(let c=0,d=h.length;ct in r?wE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xi=(r,t)=>{for(var e in t||(t={}))EE.call(t,e)&&Yf(r,e,t[e]);if(Vf)for(var e of Vf(t))AE.call(t,e)&&Yf(r,e,t[e]);return r};const PE=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Kf=class nS extends It{constructor(t){var e;super(),this.tick=0,this.uid=ut("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const s=[...PE,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Ha(e),!e&&this.config.loaders&&await Promise.all(this.config.loaders.map(s=>s.value.load())),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash){const i=this._systemsHash[s].constructor.defaultOptions;t=Xi(Xi({},i),t)}t=Xi(Xi({},nS.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[e]=new Ka(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(t,e){const s=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{const n=i.value,o=i.name,a=s[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)&&tr.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(!za())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()}};Kf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Gr=Kf,qa;function Is(r){return qa!==void 0||(qa=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Gr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!X.get().getWebGLRenderingContext())return!1;let s=X.get().createCanvas().getContext("webgl",e);const i=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,i}catch(s){return!1}})()),qa}let Za;async function Fs(r={}){return Za!==void 0||(Za=await(async()=>{const t=X.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Za}var CE=Object.defineProperty,qf=Object.getOwnPropertySymbols,RE=Object.prototype.hasOwnProperty,ME=Object.prototype.propertyIsEnumerable,Zf=(r,t,e)=>t in r?CE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ir=(r,t)=>{for(var e in t||(t={}))RE.call(t,e)&&Zf(r,e,t[e]);if(qf)for(var e of qf(t))ME.call(t,e)&&Zf(r,e,t[e]);return r};const Qf=["webgl","webgpu","canvas"];async function Jf(r){var t;let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Qf.forEach(o=>{o!==r.preference&&e.push(o)})):e=Qf.slice();let s,i={};for(let o=0;o{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,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),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}}tl.extension=T.Application;class el{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,Te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Rt.shared:new Rt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}el.extension=T.Application,L.add(tl),L.add(el);var GE=Object.defineProperty,tm=Object.getOwnPropertySymbols,IE=Object.prototype.hasOwnProperty,FE=Object.prototype.propertyIsEnumerable,em=(r,t,e)=>t in r?GE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BE=(r,t)=>{for(var e in t||(t={}))IE.call(t,e)&&em(r,e,t[e]);if(tm)for(var e of tm(t))FE.call(t,e)&&em(r,e,t[e]);return r};const rm=class kc{constructor(...t){this.stage=new dt}async init(t){t=BE({},t),this.stage||(this.stage=new dt),this.renderer=await Jf(t),kc._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return 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 s=kc._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};rm._plugins=[];let sm=rm;L.handleByList(T.Application,sm._plugins),L.add(Qa);const Hi={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,s;const i=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const f in i){const m=i[f].match(/^[a-z]+/gm)[0],g=i[f].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),_={};for(const x in g){const v=g[x].split("="),b=v[0],S=v[1].replace(/"/gm,""),y=parseFloat(S),w=isNaN(y)?S:y;_[b]=w}n[m].push(_)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=n.info,[l]=n.common,[u]=(t=n.distanceField)!=null?t:[];u&&(o.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const h=n.page;for(let f=0;f)/)?rl.test(X.get().parseXML(r)):!1},parse(r){return rl.parse(X.get().parseXML(r))}},DE=[".xml",".fnt"],im={extension:{type:T.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},nm={extension:{type:T.LoadParser,priority:ee.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return DE.includes(Vt.extname(r).toLowerCase())},async testParse(r){return Hi.test(r)||sl.test(r)},async parse(r,t,e){const s=Hi.test(r)?Hi.parse(r):sl.parse(r),{src:i}=t,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;cl[c.src]);return new u({data:s,textures:h},i)},async load(r,t){return await(await X.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),r.destroy()}};class om{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(r)&&r.every(t=>t instanceof B),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function il(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const lm={extension:{type:T.DetectionParser,priority:1},test:async()=>il("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},um=["png","jpg","jpeg"],hm={extension:{type:T.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...um],remove:async r=>r.filter(t=>!um.includes(t))},$E="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ds(r){return $E?!1:document.createElement("video").canPlayType(r)!==""}const cm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},dm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},pm={extension:{type:T.DetectionParser,priority:0},test:async()=>Ds("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},fm={extension:{type:T.DetectionParser,priority:0},test:async()=>il("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var UE=Object.defineProperty,kE=Object.defineProperties,LE=Object.getOwnPropertyDescriptors,mm=Object.getOwnPropertySymbols,NE=Object.prototype.hasOwnProperty,jE=Object.prototype.propertyIsEnumerable,gm=(r,t,e)=>t in r?UE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fr=(r,t)=>{for(var e in t||(t={}))NE.call(t,e)&&gm(r,e,t[e]);if(mm)for(var e of mm(t))jE.call(t,e)&&gm(r,e,t[e]);return r},XE=(r,t)=>kE(r,LE(t));const _m=class Po{constructor(){this.loadOptions=Fr({},Po.defaultOptions),this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var i,n;let o=null,a=null;if((e.parser||e.loadParser)&&(a=this._parserHash[e.parser||e.loadParser]),!a){for(let l=0;l({alias:[m],src:m,data:{}})),p=d.reduce((m,g)=>m+(g.progressSize||1),0),f=d.map(async m=>{const g=Vt.toAbsolute(m.src);h[m.src]||(await this._loadAssetWithRetry(g,m,{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l},h),u+=m.progressSize||1,i&&i(u/p))});return await Promise.all(f),c?h[d[0].src]:h}async unload(t){const e=ue(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=Vt.toAbsolute(s.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],await((n=(i=a.parser)==null?void 0:i.unload)==null?void 0:n.call(i,l,s,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id||t[e.name]||t[e.id],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,s,i){let n=0;const{onError:o,strategy:a,retryCount:l,retryDelay:u}=s,h=c=>new Promise(d=>setTimeout(d,c));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),i[e.src]=await this.promiseCache[t].promise;return}catch(c){delete this.promiseCache[t],delete i[e.src],n++;const d=a!=="retry"||n>l;if(a==="retry"&&!d){o&&o(c,e),await h(u);continue}if(a==="skip"){o&&o(c,e);return}o&&o(c,e);const p=new Error(`[Loader.load] Failed to load ${t}.
${c}`);throw c instanceof Error&&c.stack&&(p.stack=c.stack),p}}};_m.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let xm=_m;function dr(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function he(r,t){const e=r.split("?")[0],s=Vt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const HE=".json",zE="application/json",vm={extension:{type:T.LoadParser,priority:ee.Low},name:"loadJson",id:"json",test(r){return dr(r,zE)||he(r,HE)},async load(r){return await(await X.get().fetch(r)).json()}},WE=".txt",VE="text/plain",bm={name:"loadTxt",id:"text",extension:{type:T.LoadParser,priority:ee.Low,name:"loadTxt"},test(r){return dr(r,VE)||he(r,WE)},async load(r){return await(await X.get().fetch(r)).text()}};var YE=Object.defineProperty,KE=Object.defineProperties,qE=Object.getOwnPropertyDescriptors,ym=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,Tm=(r,t,e)=>t in r?YE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JE=(r,t)=>{for(var e in t||(t={}))ZE.call(t,e)&&Tm(r,e,t[e]);if(ym)for(var e of ym(t))QE.call(t,e)&&Tm(r,e,t[e]);return r},tA=(r,t)=>KE(r,qE(t));const eA=["normal","bold","100","200","300","400","500","600","700","800","900"],rA=[".ttf",".otf",".woff",".woff2"],sA=["font/ttf","font/otf","font/woff","font/woff2"],iA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Sm(r){const t=Vt.extname(r),e=Vt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(iA)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const nA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function oA(r){return nA.test(r)?r:encodeURI(r)}const wm={extension:{type:T.LoadParser,priority:ee.Low},name:"loadWebFont",id:"web-font",test(r){return dr(r,sA)||he(r,rA)},async load(r,t){var e,s,i,n,o,a;const l=X.get().getFontFaceSet();if(l){const u=[],h=(s=(e=t.data)==null?void 0:e.family)!=null?s:Sm(r),c=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>eA.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;pn.faces.some(o=>t.indexOf(o)!==-1));i.faces=i.faces.filter(n=>t.indexOf(n)===-1),i.faces.length===0&&(s.entries=s.entries.filter(n=>n!==i)),t.forEach(n=>{X.get().getFontFaceSet().delete(n)}),s.entries.length===0&&rt.remove(`${e}-and-url`)}},nl={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},aA=/([astvzqmhlc])([^astvzqmhlc]*)/gi,lA=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function uA(r){const t=[];return r.replace(aA,(e,s,i)=>{let n=s.toLowerCase(),o=s;const a=hA(i);for(n==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===nl[n])return t.push([o,...a]),"";if(a.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}u!=="Z"&&u!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}const Am={};function zi(r,t,e){let s=2166136261;for(let i=0;i>>=0;return Am[s]||cA(r,t,s,e)}function cA(r,t,e,s){const i={};let n=0;for(let a=0;a{if(Br.quiet||Pm.has(t))return;let s=new Error().stack;const i=`${t}
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!Br.noColor;typeof s=="undefined"?console.warn("PixiJS Deprecation Warning: ",i):(s=s.split(`
`).splice(e).join(`
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(s))),Pm.add(t)});Object.defineProperties($s,{quiet:{get:()=>Br.quiet,set:r=>{Br.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Br.noColor,set:r=>{Br.noColor=r},enumerable:!0,configurable:!1}});function Wi(r,t,e,s){if(e!=null||(e=0),s!=null||(s=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const i=s/8;new Float64Array(t,0,i).set(new Float64Array(r,e,i))}else if(!(e&3)&&!(s&3)){const i=s/4;new Float32Array(t,0,i).set(new Float32Array(r,e,i))}else new Uint8Array(t).set(new Uint8Array(r,e,s))}const Cm={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var bt=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(bt||{});function Dr(r,t){return t.alphaMode==="no-premultiply-alpha"&&Cm[r]||r}const fA=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function mA(r){let t="";for(let e=0;e0&&(t+=`
else `),et in r?gA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Im=(r,t)=>{for(var e in t||(t={}))_A.call(t,e)&&Gm(r,e,t[e]);if(Om)for(var e of Om(t))xA.call(t,e)&&Gm(r,e,t[e]);return r};class Fm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Mm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Us=[];let Vi=0;tr.register({clear:()=>{if(Us.length>0)for(const r of Us)r&&r.destroy();Us.length=0,Vi=0}});function Bm(){return Vi>0?Us[--Vi]:new Fm}function Dm(r){r.elements=null,Us[Vi++]=r}let ks=0;const $m=class oS{constructor(t){this.uid=ut("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=Im(Im({},oS.defaultOptions),t),t.maxTextures||($s("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Rm());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new pr(s*4),this.indexBuffer=new Uint16Array(i),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 l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,p="startBatch",f=[];const m=this.maxTextures;for(let g=this.elementStart;g=m||b)&&(this._finishBatch(s,d,c-d,i,o,a,t,p,f),p="renderBatch",d=c,o=v,a=_.topology,s=Bm(),i=s.textures,i.clear(),f=[],++ks),_._textureId=x._textureBindLocation=i.count,i.ids[x.uid]=i.count,i.textures[i.count++]=x,_._batch=s,f.push(_),c+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,l,u,_._attributeStart,_._textureId),this.packQuadIndex(h,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,l,u,_._attributeStart,_._textureId),this.packIndex(_,h,_._indexStart,_._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,d,c-d,i,o,a,t,p,f),d=c,++ks),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,i,n,o,a,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=s,t.elements=u,++ks,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new pr(e);Wi(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;ni.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function Lm(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function hl(r,t,e=!1){const s=[];Lm(t,s),r.forEach(a=>{a.header&&Lm(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,l)=>` @location(${l}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}function Nm(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function TA(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function SA(r){const t=/@.*?\s+/g;return r.replace(t,"")}function jm(r,t){const e=[];Nm(t,e),r.forEach(l=>{l.header&&Nm(l.header,e)});let s=0;const i=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${s++}) ${l}`).join(`,
`),n=e.sort().map(l=>` var ${SA(l)};`).join(`
`),o=`return VSOutput(
${e.sort().map(l=>` ${TA(l)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${i}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function cl(r,t){let e=r;for(const s in t){const i=t[s];i.join(`
`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
${i.join(`
`)}
//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const fr=Object.create(null),dl=new Map;let wA=0;function Xm({template:r,bits:t}){const e=zm(r,t);if(fr[e])return fr[e];const{vertex:s,fragment:i}=EA(r,t);return fr[e]=Wm(s,i,t),fr[e]}function Hm({template:r,bits:t}){const e=zm(r,t);return fr[e]||(fr[e]=Wm(r.vertex,r.fragment,t)),fr[e]}function EA(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=hl(e,r.vertex,!0);i=jm(e,i);const n=hl(s,r.fragment,!0);return{vertex:i,fragment:n}}function zm(r,t){return t.map(e=>(dl.has(e)||dl.set(e,wA++),dl.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function Wm(r,t,e){const s=ul(r),i=ul(t);return e.forEach(n=>{ll(n.vertex,s,n.name),ll(n.fragment,i,n.name)}),{vertex:cl(r,s),fragment:cl(t,i)}}const Vm=`
@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}}
};
`,Ym=`
@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;
};
`,Km=`
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}}
}
`,qm=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,Zm={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3,
uWorldTransformMatrix:mat3x3,
uWorldColorAlpha: vec4,
uResolution: vec2,
}
@group(0) @binding(0) var globalUniforms : GlobalUniforms;
`}},AA={name:"global-uniforms-ubo-bit",vertex:{header:`
uniform globalUniforms {
mat3 uProjectionMatrix;
mat3 uWorldTransformMatrix;
vec4 uWorldColorAlpha;
vec2 uResolution;
};
`}},Qm={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};var PA=Object.defineProperty,Jm=Object.getOwnPropertySymbols,CA=Object.prototype.hasOwnProperty,RA=Object.prototype.propertyIsEnumerable,tg=(r,t,e)=>t in r?PA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MA=(r,t)=>{for(var e in t||(t={}))CA.call(t,e)&&tg(r,e,t[e]);if(Jm)for(var e of Jm(t))RA.call(t,e)&&tg(r,e,t[e]);return r};function Ur({bits:r,name:t}){const e=Xm({template:{fragment:Ym,vertex:Vm},bits:[Zm,...r]});return zt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function kr({bits:r,name:t}){return new Yt(MA({name:t},Hm({template:{vertex:Km,fragment:qm},bits:[Qm,...r]})))}const Yi={name:"color-bit",vertex:{header:`
@in aColor: vec4;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},Ki={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},pl={};function OA(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
`)}function GA(r){const t=[];if(r===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;
${OA(r)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${GA(r)}
`}}),pl[r]}const fl={};function IA(r){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;
}
`}},Nr={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;
}
`}},eg={};function Qi(r){let t=eg[r];if(t)return t;const e=new Int32Array(r);for(let s=0;se&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function gl(r,t,e,s,i,n,o,a=null){let l=0;e*=t,i*=n;const u=a.a,h=a.b,c=a.c,d=a.d,p=a.tx,f=a.ty;for(;l>16|t&65280|(t&255)<<16,s=this.renderable;return s?be(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||FA}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}}var BA=Object.defineProperty,DA=Object.defineProperties,$A=Object.getOwnPropertyDescriptors,sg=Object.getOwnPropertySymbols,UA=Object.prototype.hasOwnProperty,kA=Object.prototype.propertyIsEnumerable,ig=(r,t,e)=>t in r?BA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rn=(r,t)=>{for(var e in t||(t={}))UA.call(t,e)&&ig(r,e,t[e]);if(sg)for(var e of sg(t))kA.call(t,e)&&ig(r,e,t[e]);return r},sn=(r,t)=>DA(r,$A(t));const jr={extension:{type:T.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const b=r;if(o=a=b.radius,o<=0)return!1;e=b.x,s=b.y,i=n=0}else if(r.type==="ellipse"){const b=r;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,s=b.y,i=n=0}else{const b=r,S=b.width/2,y=b.height/2;e=b.x+S,s=b.y+y,o=a=Math.max(0,Math.min(b.radius,Math.min(S,y))),i=S-o,n=y-a}if(i<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(i?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,!0;let h=0,c=l*4+(i?2:0)+2,d=c,p=u,f=i+o,m=n,g=e+f,_=e-f,x=s+m;if(t[h++]=g,t[h++]=x,t[--c]=x,t[--c]=_,n){const b=s-m;t[d++]=_,t[d++]=b,t[--p]=b,t[--p]=g}for(let b=1;b0&&(i[n++]=l,i[n++]=u,i[n++]=l-1),l++;i[n++]=u+1,i[n++]=u,i[n++]=l-1}},ng=sn(rn({},jr),{extension:sn(rn({},jr.extension),{name:"ellipse"})}),og=sn(rn({},jr),{extension:sn(rn({},jr.extension),{name:"roundedRectangle"})}),xl=1e-4,vl=1e-4;function ag(r,t,e,s,i,n,o,a){const l=r-e*i,u=t-s*i,h=r+e*n,c=t+s*n;let d,p;o?(d=s,p=-e):(d=-s,p=e);const f=l+d,m=u+p,g=h+d,_=c+p;return a.push(f,m),a.push(g,_),2}function mr(r,t,e,s,i,n,o,a){const l=e-r,u=s-t;let h=Math.atan2(l,u),c=Math.atan2(i-r,n-t);a&&hc&&(c+=Math.PI*2);let d=h;const p=c-h,f=Math.abs(p),m=Math.sqrt(l*l+u*u),g=(15*f*Math.sqrt(m)/Math.PI>>0)+1,_=p/g;if(d+=_,a){o.push(r,t),o.push(e,s);for(let x=1,v=d;x=0&&(a.join==="round"?m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+4:m+=2,p.push(y-O*I,w-F*I),p.push(y+O*M,w+F*M));continue}const mt=(-P+b)*(-C+w)-(-P+y)*(-C+S),J=(-O+E)*(-F+w)-(-O+y)*(-F+A),ot=(Q*J-N*mt)/z,nt=(k*mt-K*J)/z,ht=(ot-y)*(ot-y)+(nt-w)*(nt-w),Tt=y+(ot-y)*M,Et=w+(nt-w)*M,_t=y-(ot-y)*I,q=w-(nt-w)*I,Wt=Math.min(Q*Q+K*K,N*N+k*k),Gt=et?M:I,Me=Wt+Gt*Gt*x;ht<=Me?a.join==="bevel"||ht/x>v?(et?(p.push(Tt,Et),p.push(y+P*I,w+C*I),p.push(Tt,Et),p.push(y+O*I,w+F*I)):(p.push(y-P*M,w-C*M),p.push(_t,q),p.push(y-O*M,w-F*M),p.push(_t,q)),m+=2):a.join==="round"?et?(p.push(Tt,Et),p.push(y+P*I,w+C*I),m+=mr(y,w,y+P*I,w+C*I,y+O*I,w+F*I,p,!0)+4,p.push(Tt,Et),p.push(y+O*I,w+F*I)):(p.push(y-P*M,w-C*M),p.push(_t,q),m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+4,p.push(y-O*M,w-F*M),p.push(_t,q)):(p.push(Tt,Et),p.push(_t,q)):(p.push(y-P*M,w-C*M),p.push(y+P*I,w+C*I),a.join==="round"?et?m+=mr(y,w,y+P*I,w+C*I,y+O*I,w+F*I,p,!0)+2:m+=mr(y,w,y-P*M,w-C*M,y-O*M,w-F*M,p,!1)+2:a.join==="miter"&&ht/x<=v&&(et?(p.push(_t,q),p.push(_t,q)):(p.push(Tt,Et),p.push(Tt,Et)),m+=2),p.push(y-O*M,w-F*M),p.push(y+O*I,w+F*I),m+=2)}b=r[(f-2)*2],S=r[(f-2)*2+1],y=r[(f-1)*2],w=r[(f-1)*2+1],P=-(S-w),C=b-y,R=Math.sqrt(P*P+C*C),P/=R,C/=R,P*=_,C*=_,p.push(y-P*M,w-C*M),p.push(y+P*I,w+C*I),c||(a.cap==="round"?m+=mr(y-P*(M-I)*.5,w-C*(M-I)*.5,y-P*M,w-C*M,y+P*I,w+C*I,p,!1)+2:a.cap==="square"&&(m+=ag(y,w,P,C,M,I,!1,p)));const U=vl*vl;for(let j=g;j0&&o>0?(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o,!0):!1},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},cg={extension:{type:T.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}};var NA=Object.defineProperty,dg=Object.getOwnPropertySymbols,jA=Object.prototype.hasOwnProperty,XA=Object.prototype.propertyIsEnumerable,pg=(r,t,e)=>t in r?NA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fg=(r,t)=>{for(var e in t||(t={}))jA.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))XA.call(t,e)&&pg(r,e,t[e]);return r};const mg=[{offset:0,color:"white"},{offset:1,color:"black"}],yl=class Lc{constructor(...t){this.uid=ut("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let s=HA(t);const i=s.type==="radial"?Lc.defaultRadialOptions:Lc.defaultLinearOptions;s=fg(fg({},i),ce(s)),this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,s.type==="radial"?(this.center=s.center,this.outerCenter=(e=s.outerCenter)!=null?e:this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:tt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:i}=this.end,n=s-t,o=i-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=t;t=s,s=g,n*=-1}if(o<0){const g=e;e=i,i=g,o*=-1}}const l=this.colorStops.length?this.colorStops:mg,u=this._textureSize,{canvas:h,context:c}=_g(u,1),d=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);gg(d,l),c.fillStyle=d,c.fillRect(0,0,u,1),this.texture=new B({source:new je({resource:h,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),m=new D;m.scale(p/u,1),m.rotate(f),m.translate(t,e),this.textureSpace==="local"&&m.scale(u,u),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:mg,e=this._textureSize,{canvas:s,context:i}=_g(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,h=this.outerRadius,c=a-h,d=l-h,p=e/(h*2),f=(n-c)*p,m=(o-d)*p,g=i.createRadialGradient(f,m,u*p,(a-c)*p,(l-d)*p,h*p);gg(g,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=g,i.translate(f,m),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-f,-m),i.fillRect(0,0,e,e),this.texture=new B({source:new je({resource:s,addressMode:this._wrapMode})});const _=new D;this.textureSpace==="local"?_.scale(2*h,2*h):_.scale(1/p,1/p),_.translate(c,d),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}`}};yl.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},yl.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 Lt=yl;function gg(r,t){for(let e=0;e{var c;const d=[],p=Xe[l.type];if(!p.build(l,d))return;const f=a.length,m=n.length/2;let g="triangle-list";if(u&&tn(d,u),e){const b=(c=l.closePath)!=null?c:!0,S=t;S.pixelLine?(lg(d,b,n,a),g="line-list"):nn(d,S,!1,b,n,a)}else if(h){const b=[],S=d.slice();ZA(h).forEach(y=>{b.push(S.length/2),S.push(...y)}),bl(S,b,n,2,m,a,f)}else p.triangulate(d,n,2,m,a,f);const _=o.length/2,x=t.texture;if(x!==B.WHITE){const b=Tl(KA,t,l,u);gl(n,2,m,o,_,2,n.length/2-m,b)}else _l(o,_,2,n.length/2-m);const v=St.get(en);v.indexOffset=f,v.indexSize=a.length-f,v.attributeOffset=m,v.attributeSize=n.length/2-m,v.baseColor=t.color,v.alpha=t.alpha,v.texture=x,v.geometryData=i,v.topology=g,s.push(v)})}function ZA(r){const t=[];for(let e=0;e{St.return(t)}),this.graphicsData&&St.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 yg{constructor(){this.instructions=new yi}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Ji({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Sl=class Nc{constructor(t){this._renderer=t,this._managedContexts=new kt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Nc.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Nc.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&s.reset(),xg(t,s);const i=t.batchMode;t.customShader||i==="no-batch"?s.isBatchable=!1:i==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=St.get(yg,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:i,geometryData:n}=s;s.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let c=0;cQA)return;const c=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,m=(s+n)/2,g=(i+o)/2,_=(n+a)/2,x=(d+f)/2,v=(p+m)/2,b=(f+g)/2,S=(m+_)/2,y=(x+b)/2,w=(v+S)/2;if(h>0){let E=o-r,A=a-t;const P=Math.abs((e-o)*A-(s-a)*E),C=Math.abs((i-o)*A-(n-a)*E);let O,F;if(P>an&&C>an){if((P+C)*(P+C)<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),F>=c&&(F=2*c-F),O+Fgr){l.push(e,s);return}if(F>gr){l.push(i,n);return}}}}else if(P>an){if(P*P<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),Ogr){l.push(e,s);return}}}else if(C>an){if(C*C<=u*(E*E+A*A)){if(Xr=c&&(O=2*c-O),Ogr){l.push(i,n);return}}}else if(E=y-(r+o)/2,A=w-(t+a)/2,E*E+A*A<=u){l.push(y,w);return}}Al(r,t,d,p,x,v,y,w,l,u,h+1),Al(y,w,b,S,g,_,o,a,l,u,h+1)}const eP=8,rP=11920929e-14,sP=1,iP=.01,Tg=0;function Sg(r,t,e,s,i,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:on.defaultOptions.bezierSmoothness));let u=(sP-l)/1;return u*=u,nP(t,e,s,i,n,o,r,u),r}function nP(r,t,e,s,i,n,o,a){Pl(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Pl(r,t,e,s,i,n,o,a,l){if(l>eP)return;const u=Math.PI,h=(t+s)/2,c=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(h+d)/2,m=(c+p)/2;let g=n-t,_=o-e;const x=Math.abs((s-n)*_-(i-o)*g);if(x>rP){if(x*x<=a*(g*g+_*_)){if(Tg=u&&(v=2*u-v),vn||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,h=i;u*=o?-1:1;for(let c=0;ch*a)}const Ns=Math.PI*2,Rl={centerX:0,centerY:0,ang1:0,ang2:0},Ml=({x:r,y:t},e,s,i,n,o,a,l)=>{r*=e,t*=s;const u=i*r-n*t,h=n*r+i*t;return l.x=u+o,l.y=h+a,l};function oP(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Eg=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},aP=(r,t,e,s,i,n,o,a,l,u,h,c,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),m=Math.pow(h,2),g=Math.pow(c,2);let _=p*f-p*g-f*m;_<0&&(_=0),_/=p*g+f*m,_=Math.sqrt(_)*(o===a?-1:1);const x=_*i/n*c,v=_*-n/i*h,b=u*x-l*v+(r+e)/2,S=l*x+u*v+(t+s)/2,y=(h-x)/i,w=(c-v)/n,E=(-h-x)/i,A=(-c-v)/n,P=Eg(1,0,y,w);let C=Eg(y,w,E,A);a===0&&C>0&&(C-=Ns),a===1&&C<0&&(C+=Ns),d.centerX=b,d.centerY=S,d.ang1=P,d.ang2=C};function Ag(r,t,e,s,i,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const h=Math.sin(a*Ns/360),c=Math.cos(a*Ns/360),d=c*(t-s)/2+h*(e-i)/2,p=-h*(t-s)/2+c*(e-i)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),aP(t,e,s,i,n,o,l,u,h,c,d,p,Rl);let{ang1:m,ang2:g}=Rl;const{centerX:_,centerY:x}=Rl;let v=Math.abs(g)/(Ns/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);g/=b;let S=r[r.length-2],y=r[r.length-1];const w={x:0,y:0};for(let E=0;E{const u=l.x-a.x,h=l.y-a.y,c=Math.sqrt(u*u+h*h),d=u/c,p=h/c;return{len:c,nx:d,ny:p}},n=(a,l)=>{a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let o=t[t.length-1];for(let a=0;a0&&(f=-1,m=!0);const g=p/2;let _,x=Math.abs(Math.cos(g)*u/Math.sin(g));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),_=Math.abs(x*Math.sin(g)/Math.cos(g))):_=u;const v=l.x+d.nx*x+-d.ny*_*f,b=l.y+d.ny*x+d.nx*_*f,S=Math.atan2(c.ny,c.nx)+Math.PI/2*f,y=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(v+Math.cos(S)*_,b+Math.sin(S)*_),r.arc(v,b,_,S,y,m),o=l}}function Cg(r,t,e,s){var i;const n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,h)=>({x:l.x+(u.x-l.x)*h,y:l.y+(u.y-l.y)*h}),a=t.length;for(let l=0;l1){let n=null;for(let o=i;o=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,o)}ellipse(t,e,s,i,n){return this.drawShape(new Fo(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new Bo(t,e,s,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new os,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new os,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}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,l)=>l-a),[e,s]=t,i=t[t.length-1],n=e/s,o=s/i;return!(n>3&&o<2)}function cP(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function Dg(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function $g(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],i=[];for(let u=0;ut in r?dP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ln=(r,t)=>{for(var e in t||(t={}))pP.call(t,e)&&kg(r,e,t[e]);if(Ug)for(var e of Ug(t))fP.call(t,e)&&kg(r,e,t[e]);return r};function Lg(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new ge};Og(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=Fl(r,e);for(let o=0;o1;if(C&&O){const F=P.map(R=>({path:R,area:$g(R)}));if(F.sort((R,G)=>G.area-R.area),P.length>3||!Bg(F))for(let R=0;RparseInt(A,10)),t.context.poly(v,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(A=>parseInt(A,10)),t.context.poly(v,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Bt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let A=0;At in r?gP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fe=(r,t)=>{for(var e in t||(t={}))Xg.call(t,e)&&zg(r,e,t[e]);if(un)for(var e of un(t))Hg.call(t,e)&&zg(r,e,t[e]);return r},_P=(r,t)=>{var e={};for(var s in r)Xg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&un)for(var s of un(r))t.indexOf(s)<0&&Hg.call(r,s)&&(e[s]=r[s]);return e};function xP(r){return tt.isColorLike(r)}function Wg(r){return r instanceof zr}function Vg(r){return r instanceof Lt}function vP(r){return r instanceof B}function bP(r,t,e){const s=tt.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=B.WHITE,fe(fe({},e),r)}function yP(r,t,e){return r.texture=t,fe(fe({},e),r)}function Yg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,fe(fe({},e),r)}function Kg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,fe(fe({},e),r)}function TP(r,t){const e=fe(fe({},t),r),s=tt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function He(r,t){if(r==null)return null;const e={},s=r;return xP(r)?bP(e,r,t):vP(r)?yP(e,r,t):Wg(r)?Yg(e,r,t):Vg(r)?Kg(e,r,t):s.fill&&Wg(s.fill)?Yg(s,s.fill,t):s.fill&&Vg(s.fill)?Kg(s,s.fill,t):TP(s,t)}function js(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=_P(e,["width","alignment","miterLimit","cap","join","pixelLine"]),h=He(r,u);return h?fe({width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l},h):null}function qg(r,t){let e=1;const s=r.shapePath.shapePrimitives;for(let i=0;i1&&(E=1);const A=Math.sqrt((1-E)*.5);if(A<1e-6)continue;const P=Math.min(1/A,t);P>e&&(e=P)}}return e}var SP=Object.defineProperty,Zg=Object.getOwnPropertySymbols,wP=Object.prototype.hasOwnProperty,EP=Object.prototype.propertyIsEnumerable,Qg=(r,t,e)=>t in r?SP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wr=(r,t)=>{for(var e in t||(t={}))wP.call(t,e)&&Qg(r,e,t[e]);if(Zg)for(var e of Zg(t))EP.call(t,e)&&Qg(r,e,t[e]);return r};const AP=new lt,Jg=new D,Dl=class Re extends It{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ut("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ge,this._transform=new D,this._fillStyle=Wr({},Re.defaultFillStyle),this._strokeStyle=Wr({},Re.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Ct,this._boundsDirty=!0}clone(){const t=new Re;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Wr({},this._fillStyle),t._strokeStyle=Wr({},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=He(t,Re.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=js(t,Re.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=He(t,Re.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=He(t,Re.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?tt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ge,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=He(t,Re.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),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 s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=js(t,Re.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],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,i,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,s,i,n,o),this}arcTo(t,e,s,i,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*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,s,i,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*s+l.c*i+l.tx,l.b*s+l.d*i+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,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*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,Lg(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:Wr({},this._fillStyle),strokeStyle:Wr({},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,s,i,n,o){return t instanceof D?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof D?(this._transform.append(t),this):(Jg.set(t,e,s,i,n,o),this._transform.append(Jg),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],rt.has(e)&&rt.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var PP=Object.defineProperty,hn=Object.getOwnPropertySymbols,t_=Object.prototype.hasOwnProperty,e_=Object.prototype.propertyIsEnumerable,r_=(r,t,e)=>t in r?PP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CP=(r,t)=>{for(var e in t||(t={}))t_.call(t,e)&&r_(r,e,t[e]);if(hn)for(var e of hn(t))e_.call(t,e)&&r_(r,e,t[e]);return r},RP=(r,t)=>{var e={};for(var s in r)t_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&hn)for(var s of hn(r))t.indexOf(s)<0&&e_.call(r,s)&&(e[s]=r[s]);return e};const MP=".svg",OP="image/svg+xml",s_={extension:{type:T.LoadParser,priority:ee.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return dr(r,OP)||he(r,MP)},async load(r,t,e){var s,i;return((i=(s=t.data)==null?void 0:s.parseAsGraphicsContext)!=null?i:this.config.parseAsGraphicsContext)?IP(r):GP(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function GP(r,t,e,s){var i,n,o,a,l,u;const h=await X.get().fetch(r),c=X.get().createImage();c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await h.text())}`,c.crossOrigin=s,await c.decode();const d=(n=(i=t.data)==null?void 0:i.width)!=null?n:c.width,p=(a=(o=t.data)==null?void 0:o.height)!=null?a:c.height,f=((l=t.data)==null?void 0:l.resolution)||ze(r),m=Math.ceil(d*f),g=Math.ceil(p*f),_=X.get().createCanvas(m,g),x=_.getContext("2d");x.imageSmoothingEnabled=!0,x.imageSmoothingQuality="high",x.drawImage(c,0,0,d*f,p*f);const v=(u=t.data)!=null?u:{},{parseAsGraphicsContext:b}=v,S=RP(v,["parseAsGraphicsContext"]),y=new je(CP({resource:_,alphaMode:"premultiply-alpha-on-upload",resolution:f},S));return We(y,e,r)}async function IP(r){const t=await(await X.get().fetch(r)).text(),e=new Nt;return e.svg(t),e}const FP=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})();
`;let Vr=null,$l=class{constructor(){Vr||(Vr=URL.createObjectURL(new Blob([FP],{type:"application/javascript"}))),this.worker=new Worker(Vr)}};$l.revokeObjectURL=function(){Vr&&(URL.revokeObjectURL(Vr),Vr=null)};const BP='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let Yr=null,i_=class{constructor(){Yr||(Yr=URL.createObjectURL(new Blob([BP],{type:"application/javascript"}))),this.worker=new Worker(Yr)}};i_.revokeObjectURL=function(){Yr&&(URL.revokeObjectURL(Yr),Yr=null)};let n_=0,Ul,DP=class{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 $l;e.addEventListener("message",s=>{e.terminate(),$l.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ul===void 0&&(Ul=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 s=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[n_]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:n_++,id:s})}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 kl=new DP;var $P=Object.defineProperty,o_=Object.getOwnPropertySymbols,UP=Object.prototype.hasOwnProperty,kP=Object.prototype.propertyIsEnumerable,a_=(r,t,e)=>t in r?$P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LP=(r,t)=>{for(var e in t||(t={}))UP.call(t,e)&&a_(r,e,t[e]);if(o_)for(var e of o_(t))kP.call(t,e)&&a_(r,e,t[e]);return r};const NP=[".jpeg",".jpg",".png",".webp",".avif"],jP=["image/jpeg","image/png","image/webp","image/avif"];async function l_(r,t){var e;const s=await X.get().fetch(r);if(!s.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${s.status} ${s.statusText}`);const i=await s.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Ll={name:"loadTextures",id:"texture",extension:{type:T.LoadParser,priority:ee.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return dr(r,jP)||he(r,NP)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await kl.isImageBitmapSupported()?i=await kl.loadImageBitmap(r,t):i=await l_(r,t):i=await new Promise((o,a)=>{i=X.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const n=new je(LP({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)},t.data));return We(n,e,r)},unload(r){r.destroy(!0)}};var XP=Object.defineProperty,HP=Object.defineProperties,zP=Object.getOwnPropertyDescriptors,u_=Object.getOwnPropertySymbols,WP=Object.prototype.hasOwnProperty,VP=Object.prototype.propertyIsEnumerable,h_=(r,t,e)=>t in r?XP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nl=(r,t)=>{for(var e in t||(t={}))WP.call(t,e)&&h_(r,e,t[e]);if(u_)for(var e of u_(t))VP.call(t,e)&&h_(r,e,t[e]);return r},c_=(r,t)=>HP(r,zP(t));const YP=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let jl,Xl;function d_(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=f_(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function p_(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",s),r.addEventListener("error",i),r.load();function s(){n(),t()}function i(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",s),r.removeEventListener("error",i)}})}function f_(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function KP(){const r=[],t=[];for(const e of YP){const s=Rr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ds(s)&&(r.push(e),t.includes(s)||t.push(s))}return{validVideoExtensions:r,validVideoMime:t}}const m_={name:"loadVideo",id:"video",extension:{type:T.LoadParser,name:"loadVideo"},test(r){if(!jl||!Xl){const{validVideoExtensions:s,validVideoMime:i}=KP();jl=s,Xl=i}const t=dr(r,Xl),e=he(r,jl);return t||e},async load(r,t,e){var s,i;const n=Nl(c_(Nl({},Rr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await ga()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(h=>{const c=a[h];c!==void 0&&o.setAttribute(h,c)}),n.muted===!0&&(o.muted=!0),d_(o,r,n.crossorigin);const l=document.createElement("source");let u;if(n.mime)u=n.mime;else if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const h=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=Rr.MIME_TYPES[h]||`video/${h}`}return l.src=r,u&&(l.type=u),new Promise((h,c)=>{n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",d),o.addEventListener("error",p),l.addEventListener("error",p),o.appendChild(l);async function d(){const m=new Rr(c_(Nl({},n),{resource:o}));f(),t.data.preload&&await p_(o),h(We(m,e,r))}function p(m){f(),c(m)}function f(){o.removeEventListener("canplay",d),o.removeEventListener("error",p),l.removeEventListener("error",p)}})},unload(r){r.destroy(!0)}},Hl={extension:{type:T.ResolveParser,name:"resolveTexture"},test:Ll.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=Ne.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},g_={extension:{type:T.ResolveParser,priority:-2,name:"resolveJson"},test:r=>Ne.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Hl.parse};var qP=Object.defineProperty,__=Object.getOwnPropertySymbols,ZP=Object.prototype.hasOwnProperty,QP=Object.prototype.propertyIsEnumerable,x_=(r,t,e)=>t in r?qP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v_=(r,t)=>{for(var e in t||(t={}))ZP.call(t,e)&&x_(r,e,t[e]);if(__)for(var e of __(t))QP.call(t,e)&&x_(r,e,t[e]);return r};class b_{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ne,this.loader=new xm,this.cache=rt,this._backgroundLoader=new om(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,i;if(this._initialized)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 l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const n=(s=(e=t.texturePreference)==null?void 0:e.resolution)!=null?s:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(i=t.texturePreference)==null?void 0:i.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=v_(v_({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=Ts(t),i=ue(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(u=>!this.resolver.hasKey(u))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(i),o=await this._mapLoadToResolve(n,e);return s?o[i[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const i=this.resolver.resolveBundle(t),n={},o=Object.keys(i);let a=0;const l=[],u=()=>{e==null||e(l.reduce((c,d)=>c+d,0)/a)},h=o.map((c,d)=>{const p=i[c],f=Object.values(p),m=[...new Set(f.flat())].reduce((g,_)=>g+(_.progressSize||1),0);return l.push(0),a+=m,this._mapLoadToResolve(p,g=>{l[d]=g*m,u()}).then(g=>{n[c]=g})});return await Promise.all(h),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return rt.get(t);const e={};for(let s=0;s{const a=i[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),rt.set(l,a)}),n}async unload(t){this._initialized||await this.init();const e=ue(t).map(i=>typeof i!="string"?i.src:i),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=ue(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(i=>this._unloadFromResolved(e[i]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{rt.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,i)=>e.indexOf(s)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Xs=new b_;L.handleByList(T.LoadParser,Xs.loader.parsers).handleByList(T.ResolveParser,Xs.resolver.parsers).handleByList(T.CacheParser,Xs.cache.parsers).handleByList(T.DetectionParser,Xs.detections),L.add(am,hm,lm,fm,cm,dm,pm,vm,bm,wm,s_,Ll,m_,nm,im,Hl,g_);const y_={loader:T.LoadParser,resolver:T.ResolveParser,cache:T.CacheParser,detection:T.DetectionParser};L.handle(T.Asset,r=>{const t=r.ref;Object.entries(y_).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return L.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(y_).filter(e=>!!t[e]).forEach(e=>L.remove(t[e]))});const JP={extension:{type:T.DetectionParser,priority:3},test:async()=>!!(await Fs()||Is()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var tC=Object.defineProperty,eC=Object.defineProperties,rC=Object.getOwnPropertyDescriptors,T_=Object.getOwnPropertySymbols,sC=Object.prototype.hasOwnProperty,iC=Object.prototype.propertyIsEnumerable,S_=(r,t,e)=>t in r?tC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nC=(r,t)=>{for(var e in t||(t={}))sC.call(t,e)&&S_(r,e,t[e]);if(T_)for(var e of T_(t))iC.call(t,e)&&S_(r,e,t[e]);return r},oC=(r,t)=>eC(r,rC(t));class Hs extends ct{constructor(t){super(oC(nC({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let cn;function zl(){if(cn)return cn;const r=X.get().createCanvas(1,1).getContext("webgl");return r?(cn=[...r.getExtension("EXT_texture_compression_bptc")?["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc")?["bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc_srgb")?["bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"]:[],...r.getExtension("EXT_texture_compression_rgtc")?["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"]:[],...r.getExtension("WEBGL_compressed_texture_etc")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","eac-r11unorm","eac-rg11unorm"]:[],...r.getExtension("WEBGL_compressed_texture_astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],cn):[]}let dn;async function Wl(){if(dn)return dn;const r=await X.get().getNavigator().gpu.requestAdapter();return dn=[...r.features.has("texture-compression-bc")?["bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.features.has("texture-compression-etc2")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"]:[],...r.features.has("texture-compression-astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],dn}let Vl;async function Yl(){return Vl!==void 0||(Vl=await(async()=>{const r=await Fs(),t=Is();if(r&&t){const e=await Wl(),s=zl();return e.filter(i=>s.includes(i))}else{if(r)return await Wl();if(t)return zl()}return[]})()),Vl}const w_=["r8unorm","r8snorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb9e5ufloat","rgb10a2unorm","rg11b10ufloat","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];let pn;async function zs(){if(pn!==void 0)return pn;const r=await Yl();return pn=[...w_,...r],pn}const aC='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=(async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)})})();\n';let Kr=null,E_=class{constructor(){Kr||(Kr=URL.createObjectURL(new Blob([aC],{type:"application/javascript"}))),this.worker=new Worker(Kr)}};E_.revokeObjectURL=function(){Kr&&(URL.revokeObjectURL(Kr),Kr=null)};const fn={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function lC(r){Object.assign(fn,r)}let Ws;const A_={};function uC(r){return Ws||(Ws=new E_().worker,Ws.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),A_[s](i)},Ws.postMessage({type:"init",jsUrl:fn.jsUrl,wasmUrl:fn.wasmUrl,supportedTextures:r})),Ws}function P_(r,t){const e=uC(t);return new Promise(s=>{A_[r]=s,e.postMessage({type:"load",url:r})})}var hC=Object.defineProperty,cC=Object.defineProperties,dC=Object.getOwnPropertyDescriptors,C_=Object.getOwnPropertySymbols,pC=Object.prototype.hasOwnProperty,fC=Object.prototype.propertyIsEnumerable,R_=(r,t,e)=>t in r?hC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mC=(r,t)=>{for(var e in t||(t={}))pC.call(t,e)&&R_(r,e,t[e]);if(C_)for(var e of C_(t))fC.call(t,e)&&R_(r,e,t[e]);return r},gC=(r,t)=>cC(r,dC(t));const _C={extension:{type:T.LoadParser,priority:ee.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return he(r,[".basis"])},async load(r,t,e){var s;const i=await zs(),n=await P_(r,i),o=new Hs(gC(mC({},n),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function xC(r,t){const e=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const i=[];for(let n=0;n(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(Kl||{}),ql=(r=>(r[r.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",r[r.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",r[r.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",r))(ql||{});function Dt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Zt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=Dt("UYVY")]="UYVY",r[r.R8G8_B8G8=Dt("RGBG")]="R8G8_B8G8",r[r.YUY2=Dt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Dt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Dt("DXT1")]="DXT1",r[r.DXT2=Dt("DXT2")]="DXT2",r[r.DXT3=Dt("DXT3")]="DXT3",r[r.DXT4=Dt("DXT4")]="DXT4",r[r.DXT5=Dt("DXT5")]="DXT5",r[r.ATI1=Dt("ATI1")]="ATI1",r[r.AT1N=Dt("AT1N")]="AT1N",r[r.ATI2=Dt("ATI2")]="ATI2",r[r.AT2N=Dt("AT2N")]="AT2N",r[r.BC4U=Dt("BC4U")]="BC4U",r[r.BC4S=Dt("BC4S")]="BC4S",r[r.BC5U=Dt("BC5U")]="BC5U",r[r.BC5S=Dt("BC5S")]="BC5S",r[r.DX10=Dt("DX10")]="DX10",r))(Zt||{});const Zl={[Zt.DXT1]:"bc1-rgba-unorm",[Zt.DXT2]:"bc2-rgba-unorm",[Zt.DXT3]:"bc2-rgba-unorm",[Zt.DXT4]:"bc3-rgba-unorm",[Zt.DXT5]:"bc3-rgba-unorm",[Zt.ATI1]:"bc4-r-unorm",[Zt.BC4U]:"bc4-r-unorm",[Zt.BC4S]:"bc4-r-snorm",[Zt.ATI2]:"bc5-rg-unorm",[Zt.BC5U]:"bc5-rg-unorm",[Zt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Qt={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},Y={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:yC,HEADER_DX10_FIELDS:TC,DXGI_FORMAT:Kl,D3D10_RESOURCE_DIMENSION:ql,D3DFMT:Zt},M_={"bc1-rgba-unorm":8,"bc1-rgba-unorm-srgb":8,"bc2-rgba-unorm":16,"bc2-rgba-unorm-srgb":16,"bc3-rgba-unorm":16,"bc3-rgba-unorm-srgb":16,"bc4-r-unorm":8,"bc4-r-snorm":8,"bc5-rg-unorm":16,"bc5-rg-snorm":16,"bc6h-rgb-ufloat":16,"bc6h-rgb-float":16,"bc7-rgba-unorm":16,"bc7-rgba-unorm-srgb":16};function O_(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=wC(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${s} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:i,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const l=SC(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function SC(r,t,e,s,i,n){const o=[],a=M_[r];let l=t,u=e,h=s;for(let c=0;c>1,1),u=Math.max(u>>1,1)}return o}function wC(r){const t=new Uint32Array(r,0,Y.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[Y.HEADER_FIELDS.MAGIC]!==Y.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[Y.HEADER_FIELDS.HEIGHT],s=t[Y.HEADER_FIELDS.WIDTH],i=Math.max(1,t[Y.HEADER_FIELDS.MIPMAP_COUNT]),n=t[Y.HEADER_FIELDS.PF_FLAGS],o=t[Y.HEADER_FIELDS.FOURCC],a=EC(t,n,o,r),l=Y.MAGIC_SIZE+Y.HEADER_SIZE+(o===Y.D3DFMT.DX10?Y.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:s,height:e,dataOffset:l,mipmapCount:i}}function EC(r,t,e,s){if(t&Y.PIXEL_FORMAT_FLAGS.FOURCC){if(e===Y.D3DFMT.DX10){const i=new Uint32Array(s,Y.MAGIC_SIZE+Y.HEADER_SIZE,Y.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(i[Y.HEADER_DX10_FIELDS.MISC_FLAG]===Y.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[Y.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===Y.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=i[Y.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in Qt)return Qt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Zl)return Zl[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&Y.PIXEL_FORMAT_FLAGS.RGB||t&Y.PIXEL_FORMAT_FLAGS.RGBA)return AC(r);throw t&Y.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&Y.PIXEL_FORMAT_FLAGS.LUMINANCE||t&Y.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&Y.PIXEL_FORMAT_FLAGS.ALPHA||t&Y.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function AC(r){const t=r[Y.HEADER_FIELDS.RGB_BITCOUNT],e=r[Y.HEADER_FIELDS.R_BIT_MASK],s=r[Y.HEADER_FIELDS.G_BIT_MASK],i=r[Y.HEADER_FIELDS.B_BIT_MASK],n=r[Y.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&s===65280&&i===16711680&&n===4278190080)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return Qt[Y.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration:
bitCount = ${t}, rBitMask = ${e}, gBitMask = ${s}, aBitMask = ${n}`)}var PC=Object.defineProperty,CC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,G_=Object.getOwnPropertySymbols,MC=Object.prototype.hasOwnProperty,OC=Object.prototype.propertyIsEnumerable,I_=(r,t,e)=>t in r?PC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GC=(r,t)=>{for(var e in t||(t={}))MC.call(t,e)&&I_(r,e,t[e]);if(G_)for(var e of G_(t))OC.call(t,e)&&I_(r,e,t[e]);return r},IC=(r,t)=>CC(r,RC(t));const FC={extension:{type:T.LoadParser,priority:ee.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return he(r,[".dds"])},async load(r,t,e){var s;const i=await zs(),n=await(await fetch(r)).arrayBuffer(),o=O_(n,i),a=new Hs(IC(GC({},o),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var F_=(r=>(r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGBA=6408]="RGBA",r[r.RGBA8UI=36220]="RGBA8UI",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.RGBA8I=36238]="RGBA8I",r[r.RGBA8=32856]="RGBA8",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(F_||{}),BC=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(BC||{}),DC=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(DC||{});const $C={33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},UC=[171,75,84,88,32,49,49,187,13,10,26,10],kC={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},LC=64,NC=67305985,jC={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},XC={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},HC={32819:2,32820:2,33635:2},zC={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},yt={FILE_HEADER_SIZE:LC,FILE_IDENTIFIER:UC,FORMATS_TO_COMPONENTS:XC,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:zC,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:$C,FIELDS:kC,TYPES_TO_BYTES_PER_COMPONENT:jC,TYPES_TO_BYTES_PER_PIXEL:HC,ENDIANNESS:NC};function B_(r,t){const e=new DataView(r);if(!KC(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:s,glType:i,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:h}=YC(e),c=yt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!c)throw new Error(`Unknown texture format ${o}`);if(!t.includes(c))throw new Error(`Unsupported texture format: ${c}, supportedFormats: ${t}`);const d=VC(i,n,o),p=WC(e,i,d,a,l,h,u,s);return{format:c,width:a,height:l,resource:p,alphaMode:"no-premultiply-alpha"}}function WC(r,t,e,s,i,n,o,a){const l=s+3&-4,u=i+3&-4;let h=s*i;t===0&&(h=l*u);let c=h*e,d=s,p=i,f=l,m=u,g=n;const _=new Array(o);for(let x=0;x>1||1,p=p>>1||1,f=d+4-1&-4,m=p+4-1&-4,c=f*m*e}return _}function VC(r,t,e){let s=yt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(yt.TYPES_TO_BYTES_PER_COMPONENT[r]?s=yt.TYPES_TO_BYTES_PER_COMPONENT[r]*yt.FORMATS_TO_COMPONENTS[t]:s=yt.TYPES_TO_BYTES_PER_PIXEL[r]),s===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return s}function YC(r){const t=r.getUint32(yt.FIELDS.ENDIANNESS,!0)===yt.ENDIANNESS,e=r.getUint32(yt.FIELDS.GL_TYPE,t),s=r.getUint32(yt.FIELDS.GL_FORMAT,t),i=r.getUint32(yt.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(yt.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(yt.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(yt.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(yt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(yt.FIELDS.NUMBER_OF_FACES,t),h=r.getUint32(yt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=r.getUint32(yt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:s,glInternalFormat:i,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:h,offset:yt.FILE_HEADER_SIZE+c}}function KC(r){for(let t=0;tt in r?qC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eR=(r,t)=>{for(var e in t||(t={}))JC.call(t,e)&&$_(r,e,t[e]);if(D_)for(var e of D_(t))tR.call(t,e)&&$_(r,e,t[e]);return r},rR=(r,t)=>ZC(r,QC(t));const sR={extension:{type:T.LoadParser,priority:ee.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return he(r,".ktx")},async load(r,t,e){var s;const i=await zs(),n=await(await fetch(r)).arrayBuffer(),o=B_(n,i),a=new Hs(rR(eR({},o),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},iR='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=T(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=(async r=>{var t;const n=r.data;try{const o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}catch(o){self.postMessage({type:"error",err:o,url:n.url})}})})();\n';let qr=null;class U_{constructor(){qr||(qr=URL.createObjectURL(new Blob([iR],{type:"application/javascript"}))),this.worker=new Worker(qr)}}U_.revokeObjectURL=function(){qr&&(URL.revokeObjectURL(qr),qr=null)};const mn={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function nR(r){Object.assign(mn,r)}let Vs;const k_={},L_={};function oR(r){return Vs||(Vs=new U_().worker,Vs.onmessage=t=>{const{err:e,success:s,url:i,textureOptions:n}=t.data;if(e){L_[i](e);return}s||console.warn("Failed to load KTX texture",i),k_[i](n)},Vs.postMessage({type:"init",jsUrl:mn.jsUrl,wasmUrl:mn.wasmUrl,supportedTextures:r})),Vs}function N_(r,t){const e=oR(t);return new Promise((s,i)=>{k_[r]=s,L_[r]=i,e.postMessage({type:"load",url:r})})}var aR=Object.defineProperty,lR=Object.defineProperties,uR=Object.getOwnPropertyDescriptors,j_=Object.getOwnPropertySymbols,hR=Object.prototype.hasOwnProperty,cR=Object.prototype.propertyIsEnumerable,X_=(r,t,e)=>t in r?aR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dR=(r,t)=>{for(var e in t||(t={}))hR.call(t,e)&&X_(r,e,t[e]);if(j_)for(var e of j_(t))cR.call(t,e)&&X_(r,e,t[e]);return r},pR=(r,t)=>lR(r,uR(t));const fR={extension:{type:T.LoadParser,priority:ee.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return he(r,".ktx2")},async load(r,t,e){var s;const i=await zs(),n=await N_(r,i),o=new Hs(pR(dR({},n),{resolution:((s=t.data)==null?void 0:s.resolution)||ze(r)}));return We(o,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ql={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:H_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:H_}};function mR(r){const t=r.format;if(Ql[t]){const e=Ql[t].convertFunction,s=r.resource;for(let i=0;ihe(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let s;const i=r.split(".");if(i.length>2){const n=i[i.length-2];gn.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=Ne.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let _n;const SR={extension:{type:T.DetectionParser,priority:2},test:async()=>!!(await Fs()||Is()),add:async r=>{const t=await Yl();return _n=wR(t),[..._n,...r]},remove:async r=>_n?r.filter(t=>!(t in _n)):r};function wR(r){const t=["basis"],e={};return r.forEach(s=>{const i=s.split("-")[0];i&&!e[i]&&(e[i]=!0,t.push(i))}),t.sort((s,i)=>{const n=gn.indexOf(s),o=gn.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const ER=new Ct,AR=new D,Ys=new it,Jl=class{cull(t,e,s=!0){this._cullRecursive(t,e,s)}_cullRecursive(t,e,s=!0){if(t.cullable&&t.measurable&&t.includeInBuild)if(t.cullArea){Ys.x=e.x,Ys.y=e.y,Ys.width=e.width,Ys.height=e.height;const i=s?t.worldTransform:t.getGlobalTransform(AR,s);t.culled=!Ys.intersects(t.cullArea,i)}else{const i=gs(t,s,ER);t.culled=i.x>=e.x+e.width||i.y>=e.y+e.height||i.x+i.width<=e.x||i.y+i.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let i=0;i{var e;const s=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;V_.shared.cull(this.stage,this.renderer.screen,s),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}Y_.extension={priority:10,type:T.Application,name:"culler"};const PR={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return aE})}};var K_=`
in vec2 vTextureCoord;
in vec4 vColor;
out vec4 finalColor;
uniform float uBlend;
uniform sampler2D uTexture;
uniform sampler2D uBackTexture;
{FUNCTIONS}
void main()
{
vec4 back = texture(uBackTexture, vTextureCoord);
vec4 front = texture(uTexture, vTextureCoord);
float blendedAlpha = front.a + back.a * (1.0 - front.a);
{MAIN}
}
`,q_=`in vec2 aPosition;
out vec2 vTextureCoord;
out vec2 backgroundUv;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
}
`,Z_=`
struct GlobalFilterUniforms {
uInputSize:vec4,
uInputPixel:vec4,
uInputClamp:vec4,
uOutputFrame:vec4,
uGlobalFrame:vec4,
uOutputTexture:vec4,
};
struct BlendUniforms {
uBlend:f32,
};
@group(0) @binding(0) var gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d;
@group(0) @binding(2) var uSampler : sampler;
@group(0) @binding(3) var uBackTexture: texture_2d;
@group(1) @binding(0) var blendUniforms : BlendUniforms;
struct VSOutput {
@builtin(position) position: vec4,
@location(0) uv : vec2
};
fn filterVertexPosition(aPosition:vec2) -> vec4
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord( aPosition:vec2 ) -> vec2
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2 ) -> vec2
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
{FUNCTIONS}
@fragment
fn mainFragment(
@location(0) uv: vec2
) -> @location(0) vec4 {
var back = textureSample(uBackTexture, uSampler, uv);
var front = textureSample(uTexture, uSampler, uv);
var blendedAlpha = front.a + back.a * (1.0 - front.a);
var out = vec4(0.0,0.0,0.0,0.0);
{MAIN}
return out;
}`,CR=Object.defineProperty,Q_=Object.getOwnPropertySymbols,RR=Object.prototype.hasOwnProperty,MR=Object.prototype.propertyIsEnumerable,J_=(r,t,e)=>t in r?CR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tx=(r,t)=>{for(var e in t||(t={}))RR.call(t,e)&&J_(r,e,t[e]);if(Q_)for(var e of Q_(t))MR.call(t,e)&&J_(r,e,t[e]);return r};class OR extends Ae{constructor(t){const e=t.gpu,s=ex(tx({source:Z_},e)),i=zt.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=ex(tx({source:K_},n)),a=Yt.from({vertex:q_,fragment:o}),l=new wt({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:B.EMPTY}})}}function ex(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const GR=`
float getLuminosity(vec3 c) {
return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
}
vec3 setLuminosity(vec3 c, float lum) {
float modLum = lum - getLuminosity(c);
vec3 color = c.rgb + vec3(modLum);
// clip back into legal range
modLum = getLuminosity(color);
vec3 modLumVec = vec3(modLum);
float cMin = min(color.r, min(color.g, color.b));
float cMax = max(color.r, max(color.g, color.b));
if(cMin < 0.0) {
color = mix(modLumVec, color, modLum / (modLum - cMin));
}
if(cMax > 1.0) {
color = mix(modLumVec, color, (1.0 - modLum) / (cMax - modLum));
}
return color;
}
float getSaturation(vec3 c) {
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
vec3 setSaturationMinMidMax(vec3 cSorted, float s) {
vec3 colorSorted = cSorted;
if(colorSorted.z > colorSorted.x) {
colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
colorSorted.z = s;
}
else {
colorSorted.y = 0.0;
colorSorted.z = 0.0;
}
colorSorted.x = 0.0;
return colorSorted;
}
vec3 setSaturation(vec3 c, float s) {
vec3 color = c;
if(color.r <= color.g && color.r <= color.b) {
if(color.g <= color.b) {
color = setSaturationMinMidMax(color.rgb, s).rgb;
}
else {
color = setSaturationMinMidMax(color.rbg, s).rbg;
}
}
else if(color.g <= color.r && color.g <= color.b) {
if(color.r <= color.b) {
color = setSaturationMinMidMax(color.grb, s).grb;
}
else {
color = setSaturationMinMidMax(color.gbr, s).gbr;
}
}
else {
// Using bgr for both fixes part of hue
if(color.r <= color.g) {
color = setSaturationMinMidMax(color.brg, s).brg;
}
else {
color = setSaturationMinMidMax(color.bgr, s).bgr;
}
}
return color;
}
`,IR=`
fn getLuminosity(c: vec3) -> f32
{
return 0.3*c.r + 0.59*c.g + 0.11*c.b;
}
fn setLuminosity(c: vec3, lum: f32) -> vec3
{
var modLum: f32 = lum - getLuminosity(c);
var color: vec3 = c.rgb + modLum;
// clip back into legal range
modLum = getLuminosity(color);
let modLumVec = vec3(modLum);
let cMin: f32 = min(color.r, min(color.g, color.b));
let cMax: f32 = max(color.r, max(color.g, color.b));
if(cMin < 0.0)
{
color = mix(modLumVec, color, modLum / (modLum - cMin));
}
if(cMax > 1.0)
{
color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum));
}
return color;
}
fn getSaturation(c: vec3) -> f32
{
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
fn setSaturationMinMidMax(cSorted: vec3