var BT=Object.defineProperty;var Rc=Object.getOwnPropertySymbols;var FT=Object.prototype.hasOwnProperty,DT=Object.prototype.propertyIsEnumerable;var Mc=(r,t,e)=>t in r?BT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oc=(r,t)=>{for(var e in t||(t={}))FT.call(t,e)&&Mc(r,e,t[e]);if(Rc)for(var e of Rc(t))DT.call(t,e)&&Mc(r,e,t[e]);return r};/*!
 * PixiJS - v8.17.0
 * Compiled Mon, 09 Mar 2026 15:29:45 UTC
 *
 * PixiJS is licensed under the MIT License.
 * http://www.opensource.org/licenses/mit-license
 */var UT=Object.defineProperty,kT=Object.defineProperties,$T=Object.getOwnPropertyDescriptors,Gc=Object.getOwnPropertySymbols,LT=Object.prototype.hasOwnProperty,NT=Object.prototype.propertyIsEnumerable,Ic=(r,t,e)=>t in r?UT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bc=(r,t)=>{for(var e in t||(t={}))LT.call(t,e)&&Ic(r,e,t[e]);if(Gc)for(var e of Gc(t))NT.call(t,e)&&Ic(r,e,t[e]);return r},XT=(r,t)=>kT(r,$T(t)),S=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(S||{});const So=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=XT(Bc({},t),{ref:r})}if(typeof r=="object")r=Bc({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Yr=(r,t)=>{var e;return(e=So(r).priority)!=null?e:t},N={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(So).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(So).forEach(t=>{t.type.forEach(e=>{var s,i;const n=this._addHandlers,o=this._queue;n[e]?(i=n[e])==null||i.call(n,t):(o[e]=o[e]||[],(s=o[e])==null||s.push(t))})}),this},handle(r,t,e){var s;const i=this._addHandlers,n=this._removeHandlers;i[r]=t,n[r]=e;const o=this._queue;return o[r]&&((s=o[r])==null||s.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(i=>i.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((i,n)=>Yr(n.value,e)-Yr(i.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>Yr(n,e)-Yr(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var BI=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Fc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function FI(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function DI(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function UI(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function s(){var i=!1;try{i=this instanceof s}catch(n){}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var Ks={exports:{}},kI=Ks.exports,Dc;function HT(){return Dc||(Dc=1,(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(l,u,h){this.fn=l,this.context=u,this.once=h||!1}function n(l,u,h,c,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var p=new i(h,c||l,d),f=e?e+u:u;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new s:delete l._events[u]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],h,c;if(this._eventsCount===0)return u;for(c in h=this._events)t.call(h,c)&&u.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},a.prototype.listeners=function(u){var h=e?e+u:u,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d<p;d++)f[d]=c[d].fn;return f},a.prototype.listenerCount=function(u){var h=e?e+u:u,c=this._events[h];return c?c.fn?1:c.length:0},a.prototype.emit=function(u,h,c,d,p,f){var m=e?e+u:u;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,x,v;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,c),!0;case 4:return g.fn.call(g.context,h,c,d),!0;case 5:return g.fn.call(g.context,h,c,d,p),!0;case 6:return g.fn.call(g.context,h,c,d,p,f),!0}for(v=1,x=new Array(_-1);v<_;v++)x[v-1]=arguments[v];g.fn.apply(g.context,x)}else{var b=g.length,T;for(v=0;v<b;v++)switch(g[v].once&&this.removeListener(u,g[v].fn,void 0,!0),_){case 1:g[v].fn.call(g[v].context);break;case 2:g[v].fn.call(g[v].context,h);break;case 3:g[v].fn.call(g[v].context,h,c);break;case 4:g[v].fn.call(g[v].context,h,c,d);break;default:if(!x)for(T=1,x=new Array(_-1);T<_;T++)x[T-1]=arguments[T];g[v].fn.apply(g[v].context,x)}}return!0},a.prototype.on=function(u,h,c){return n(this,u,h,c,!1)},a.prototype.once=function(u,h,c){return n(this,u,h,c,!0)},a.prototype.removeListener=function(u,h,c,d){var p=e?e+u:u;if(!this._events[p])return this;if(!h)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===h&&(!d||f.once)&&(!c||f.context===c)&&o(this,p);else{for(var m=0,g=[],_=f.length;m<_;m++)(f[m].fn!==h||d&&!f[m].once||c&&f[m].context!==c)&&g.push(f[m]);g.length?this._events[p]=g.length===1?g[0]:g:o(this,p)}return this},a.prototype.removeAllListeners=function(u){var h;return u?(h=e?e+u:u,this._events[h]&&o(this,h)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Ks)),Ks.exports}var jT=HT(),Dt=Fc(jT),zT={grad:.9,turn:360,rad:360/(2*Math.PI)},Ee=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Mt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},ee=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Uc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},kc=function(r){return{r:ee(r.r,0,255),g:ee(r.g,0,255),b:ee(r.b,0,255),a:ee(r.a)}},wo=function(r){return{r:Mt(r.r),g:Mt(r.g),b:Mt(r.b),a:Mt(r.a,3)}},WT=/^#([0-9a-f]{3,8})$/i,qs=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},$c=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},Lc=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),l=s*(1-(1-t+n)*e),u=n%6;return{r:255*[s,a,o,o,l,s][u],g:255*[l,s,s,a,o,o][u],b:255*[o,o,l,s,s,a][u],a:i}},Nc=function(r){return{h:Uc(r.h),s:ee(r.s,0,100),l:ee(r.l,0,100),a:ee(r.a)}},Xc=function(r){return{h:Mt(r.h),s:Mt(r.s),l:Mt(r.l),a:Mt(r.a,3)}},Hc=function(r){return Lc((e=(t=r).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Kr=function(r){return{h:(t=$c(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},VT=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,YT=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,KT=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qT=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Eo={string:[[function(r){var t=WT.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Mt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Mt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=KT.exec(r)||qT.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:kc({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=VT.exec(r)||YT.exec(r);if(!t)return null;var e,s,i=Nc({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(zT[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Hc(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Ee(t)&&Ee(e)&&Ee(s)?kc({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Ee(t)||!Ee(e)||!Ee(s))return null;var o=Nc({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return Hc(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Ee(t)||!Ee(e)||!Ee(s))return null;var o=(function(a){return{h:Uc(a.h),s:ee(a.s,0,100),v:ee(a.v,0,100),a:ee(a.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return Lc(o)},"hsv"]]},jc=function(r,t){for(var e=0;e<t.length;e++){var s=t[e][0](r);if(s)return[s,t[e][1]]}return[null,void 0]},zc=function(r){return typeof r=="string"?jc(r.trim(),Eo.string):typeof r=="object"&&r!==null?jc(r,Eo.object):[null,void 0]},$I=function(r){return zc(r)[1]},Ao=function(r,t){var e=Kr(r);return{h:e.h,s:ee(e.s+100*t,0,100),l:e.l,a:e.a}},Po=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Wc=function(r,t){var e=Kr(r);return{h:e.h,s:e.s,l:ee(e.l+100*t,0,100),a:e.a}},Zs=(function(){function r(t){this.parsed=zc(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Mt(Po(this.rgba),2)},r.prototype.isDark=function(){return Po(this.rgba)<.5},r.prototype.isLight=function(){return Po(this.rgba)>=.5},r.prototype.toHex=function(){return t=wo(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?qs(Mt(255*n)):"","#"+qs(e)+qs(s)+qs(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return wo(this.rgba)},r.prototype.toRgbString=function(){return t=wo(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return Xc(Kr(this.rgba))},r.prototype.toHslString=function(){return t=Xc(Kr(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=$c(this.rgba),{h:Mt(t.h),s:Mt(t.s),v:Mt(t.v),a:Mt(t.a,3)};var t},r.prototype.invert=function(){return fe({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),fe(Ao(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),fe(Ao(this.rgba,-t))},r.prototype.grayscale=function(){return fe(Ao(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),fe(Wc(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),fe(Wc(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?fe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Mt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Kr(this.rgba);return typeof t=="number"?fe({h:t,s:e.s,l:e.l,a:e.a}):Mt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===fe(t).toHex()},r})(),fe=function(r){return r instanceof Zs?r:new Zs(r)},Vc=[],ZT=function(r){r.forEach(function(t){Vc.indexOf(t)<0&&(t(Zs,Eo),Vc.push(t))})},LI=function(){return new Zs({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function QT(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=s[this.toHex()];if(u)return u;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var m=(a=h,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<c&&(c=m,d=f)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}var JT=Object.defineProperty,Yc=Object.getOwnPropertySymbols,tS=Object.prototype.hasOwnProperty,eS=Object.prototype.propertyIsEnumerable,Kc=(r,t,e)=>t in r?JT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rS=(r,t)=>{for(var e in t||(t={}))tS.call(t,e)&&Kc(r,e,t[e]);if(Yc)for(var e of Yc(t))eS.call(t,e)&&Kc(r,e,t[e]);return r};ZT([QT]);const dr=class js{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof js)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?rS({},t):t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((i,n)=>i===e[n]);if(t!==null&&e!==null){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,i,n]=js._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=js.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=fe(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof js||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};dr.shared=new dr,dr._temp=new dr,dr.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let rt=dr;const qc={cullArea:null,cullable:!1,cullableChildren:!0},Zc=Math.PI*2,Qc=180/Math.PI,Jc=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}static get shared(){return Co.x=0,Co.y=0,Co}}const Co=new lt;class D{constructor(t=1,e=0,s=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,i,n,o){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new lt;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new lt;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(s*o+n*-i),h=t.x,c=t.y;return e.x=o*u*h+-n*u*c+(l*n-a*o)*u,e.y=s*u*c+-i*u*h+(-l*s+a*i)*u,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,i=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,h=e.b,c=e.c,d=e.d;return this.a=s*u+i*c,this.b=s*h+i*d,this.c=n*u+o*c,this.d=n*h+o*d,this.tx=a*u+l*c+e.tx,this.ty=a*h+l*d+e.ty,this}setTransform(t,e,s,i,n,o,a,l,u){return this.a=Math.cos(a+u)*n,this.b=Math.sin(a+u)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,i=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),l=Math.atan2(s,e),u=Math.abs(a+l);return u<1e-5||Math.abs(Zc-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new D;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}static get IDENTITY(){return iS.identity()}static get shared(){return sS.identity()}}const sS=new D,iS=new D;class xt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new xt(t!=null?t:this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}const qr={default:-1};function ct(r="default"){return qr[r]===void 0&&(qr[r]=-1),++qr[r]}function nS(){for(const r in qr)delete qr[r]}const Xe={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class td{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let s;return this._index>0?s=this._pool[--this._index]:(s=new this._classType,this._count++),(e=s.init)==null||e.call(s,t),s}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class ed{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new td(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const Et=new ed;Xe.register(Et);const rd={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function Ro(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i<n;++i)r[i]=r[i+e];r.length=n}const sd={allowChildren:!0,removeChildren(r=0,t){var e;const s=t!=null?t:this.children.length,i=s-r,n=[];if(i>0&&i<=s){for(let a=s-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}Ro(this.children,r,s);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a<n.length;++a){const l=n[a];(e=l.parentRenderLayer)==null||e.detach(l),this.emit("childRemoved",l,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=r.parent===this;if(r.parent){const n=r.parent.children.indexOf(r);if(s){if(n===t)return r;r.parent.children.splice(n,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),s||(this.emit("childAdded",r,this,t),r.emit("added",this)),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},id={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const s=this.children,i=s.length;for(let n=0;n<i;n++)s[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:s}=t;for(let i=0;i<this.effects.length;i++){const n=this.effects[i];s[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let i=this.effects.length-1;i>=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class Zr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class nd{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return Et.get(s.maskClass,t)}return t}returnMaskEffect(t){Et.return(t)}}const Qs=new nd;N.handleByList(S.MaskEffect,Qs._effectClasses);var oS=Object.defineProperty,od=Object.getOwnPropertySymbols,aS=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,ad=(r,t,e)=>t in r?oS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ld=(r,t)=>{for(var e in t||(t={}))aS.call(t,e)&&ad(r,e,t[e]);if(od)for(var e of od(t))lS.call(t,e)&&ad(r,e,t[e]);return r};const ud={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),Qs.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Qs.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=ld(ld({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new Zr);r=r;const s=(r==null?void 0:r.length)>0,i=((t=e.filters)==null?void 0:t.length)>0,n=s!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new Zr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},hd={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const i=e[s];if(i.label===r||r instanceof RegExp&&r.test(i.label))return i}if(t)for(let s=0;s<e.length;s++){const i=e[s].getChildByLabel(r,!0);if(i)return i}return null},getChildrenByLabel(r,t=!1,e=[]){const s=this.children;for(let i=0;i<s.length;i++){const n=s[i];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let i=0;i<s.length;i++)s[i].getChildrenByLabel(r,!0,e);return e}},Js=[new lt,new lt,new lt,new lt];class ut{constructor(t=0,e=0,s=0,i=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(i)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new ut(0,0,0,0)}clone(){return new ut(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,s,i=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,u=s*(1-i),h=s-u,c=a-u,d=a+n+u,p=l-u,f=l+o+u,m=a+h,g=a+n-h,_=l+h,x=l+o-h;return t>=c&&t<=d&&e>=p&&e<=f&&!(t>m&&t<g&&e>_&&e<x)}intersects(t,e){if(!e){const A=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=A)return!1;const R=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>R}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=Js[0].set(t.left,t.top),l=Js[1].set(t.left,t.bottom),u=Js[2].set(t.right,t.top),h=Js[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(h,h),Math.max(a.x,l.x,u.x,h.x)<=s||Math.min(a.x,l.x,u.x,h.x)>=i||Math.max(a.y,l.y,u.y,h.y)<=n||Math.min(a.y,l.y,u.y,h.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*s+p*n,m=d*i+p*n,g=d*s+p*o,_=d*i+p*o;if(Math.max(f,m,g,_)<=d*a.x+p*a.y||Math.min(f,m,g,_)>=d*h.x+p*h.y)return!1;const x=c*(a.y-u.y),v=c*(u.x-a.x),b=x*s+v*n,T=x*i+v*n,y=x*s+v*o,w=x*i+v*o;return!(Math.max(b,T,y,w)<=x*a.x+v*a.y||Math.min(b,T,y,w)>=x*h.x+v*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=i-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new ut),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height&&i>=this.x&&i<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,s,i){return this.x=t,this.y=e,this.width=s,this.height=i,this}}const cd=new D;class Ct{constructor(t=1/0,e=1/0,s=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=cd,this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new ut);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=cd,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,h=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,g=o*t+l*e+h,_=a*t+u*e+c;g<d&&(d=g),_<p&&(p=_),g>f&&(f=g),_>m&&(m=_),g=o*s+l*e+h,_=a*s+u*e+c,g<d&&(d=g),_<p&&(p=_),g>f&&(f=g),_>m&&(m=_),g=o*t+l*i+h,_=a*t+u*i+c,g<d&&(d=g),_<p&&(p=_),g>f&&(f=g),_>m&&(m=_),g=o*s+l*i+h,_=a*s+u*i+c,g<d&&(d=g),_<p&&(p=_),g>f&&(f=g),_>m&&(m=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,i=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:u,tx:h,ty:c}=t;let d=o*e+l*s+h,p=a*e+u*s+c;this.minX=d,this.minY=p,this.maxX=d,this.maxY=p,d=o*i+l*s+h,p=a*i+u*s+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+l*n+h,p=a*e+u*n+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+l*n+h,p=a*i+u*n+c,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,i){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>i&&(this.maxY=i),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Ct(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,i){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const u=i.a,h=i.b,c=i.c,d=i.d,p=i.tx,f=i.ty;for(let m=e;m<s;m+=2){const g=t[m],_=t[m+1],x=u*g+c*_+p,v=h*g+d*_+f;n=x<n?x:n,o=v<o?v:o,a=x>a?x:a,l=v>l?v:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}const It=Et.getPool(D),me=Et.getPool(Ct),uS=new D,dd={getFastGlobalBounds(r,t){t||(t=new Ct),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let s=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=me.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,s,e)}if(i){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,s.applyMatrix(o.worldTransform)),this.effects[a].addBounds(s,!0));n&&s.applyMatrix(o.worldTransform.copyTo(uS).invert()),t.addBounds(s),me.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),me.return(s))}};function Qr(r,t,e){e.clear();let s,i;return r.parent?t?s=r.parent.worldTransform:(i=It.get().identity(),s=ti(r,i)):s=D.IDENTITY,pd(r,e,s,t),i&&It.return(i),e.isValid||e.set(0,0,0,0),e}function pd(r,t,e,s){var i,n;if(!r.visible||!r.measurable)return;let o;s?o=r.worldTransform:(r.updateLocalTransform(),o=It.get(),o.appendFrom(r.localTransform,e));const a=t,l=!!r.effects.length;if(l&&(t=me.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{const u=r.bounds;u&&!u.isEmpty()&&(t.matrix=o,t.addBounds(u));for(let h=0;h<r.children.length;h++)pd(r.children[h],t,o,s)}if(l){for(let u=0;u<r.effects.length;u++)(n=(i=r.effects[u]).addBounds)==null||n.call(i,t);a.addBounds(t,D.IDENTITY),me.return(t)}s||It.return(o)}function ti(r,t){const e=r.parent;return e&&(ti(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Ae(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=s*o/255|0,h=i*a/255|0;return(l<<16)+(u<<8)+h}const fd=16777215;function Jr(r,t){return r===fd?t:t===fd?r:Ae(r,t)}function ge(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const md={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new D,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=ti(this,It.get().identity());return r.appendFrom(this.localTransform,e),It.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?ge(this.renderGroup.worldColor):this.parentRenderGroup?ge(Jr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Jr(t,e.localColor),e=e.parent;return ge(t)}};function ei(r,t,e){return t.clear(),e||(e=D.IDENTITY),gd(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function gd(r,t,e,s,i){var n,o;let a;if(i)a=It.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const h=r.localTransform;a=It.get(),a.appendFrom(h,e)}const l=t,u=!!r.effects.length;if(u&&(t=me.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const h=r.children;for(let c=0;c<h.length;c++)gd(h[c],t,a,s,!1)}if(u){for(let h=0;h<r.effects.length;h++)(o=(n=r.effects[h]).addLocalBounds)==null||o.call(n,t,s);l.addBounds(t,D.IDENTITY),me.return(t)}It.return(a)}function Mo(r,t){const e=r.children;for(let s=0;s<e.length;s++){const i=e[s],n=i.uid,o=(i._didViewChangeTick&65535)<<16|i._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,i.children.length&&Mo(i,t)}return t.didChange}const hS=new D,_d={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Ct});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),Mo(this,r),r.didChange&&ei(this,r.localBounds,hS),r.localBounds},getBounds(r,t){return Qr(this,r,t||new Ct)}},xd={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},vd={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(cS))}};function cS(r,t){return r._zIndex-t._zIndex}const bd={getGlobalPosition(r=new lt,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const s=this.getGlobalTransform(It.get(),e);return t=s.apply(r,t),It.return(s),t},toLocal(r,t,e,s){t&&(r=t.toGlobal(r,e,s));const i=this.getGlobalTransform(It.get(),s);return e=i.applyInverse(r,e),It.return(i),e}};class ri{constructor(){this.uid=ct("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}function He(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Oo(r){return!(r&r-1)&&!!r}function dS(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function oe(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var pS=Object.defineProperty,yd=Object.getOwnPropertySymbols,fS=Object.prototype.hasOwnProperty,mS=Object.prototype.propertyIsEnumerable,Td=(r,t,e)=>t in r?pS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sd=(r,t)=>{for(var e in t||(t={}))fS.call(t,e)&&Td(r,e,t[e]);if(yd)for(var e of yd(t))mS.call(t,e)&&Td(r,e,t[e]);return r};const wd=Object.create(null);function gS(r){const t=wd[r];return t===void 0&&(wd[r]=ct("resource")),t}const Ed=class eT extends Dt{constructor(t={}){var e,s,i,n,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Sd(Sd({},eT.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(i=t.addressModeW)!=null?i:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=gS(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ed.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let qt=Ed;var _S=Object.defineProperty,Ad=Object.getOwnPropertySymbols,xS=Object.prototype.hasOwnProperty,vS=Object.prototype.propertyIsEnumerable,Pd=(r,t,e)=>t in r?_S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cd=(r,t)=>{for(var e in t||(t={}))xS.call(t,e)&&Pd(r,e,t[e]);if(Ad)for(var e of Ad(t))vS.call(t,e)&&Pd(r,e,t[e]);return r};const Rd=class rT extends Dt{constructor(t={}){var e,s,i,n;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ct("textureSource"),this._resourceType="textureSource",this._resourceId=ct("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Cd(Cd({},rT.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=(n=t.viewDimension)!=null?n:t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new qt(oe(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=ct("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(e=(t=this._gpuData[s])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=ct("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Oo(this.pixelWidth)&&Oo(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Rd.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ft=Rd;const je=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ze=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],We=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ve=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Go=[],Md=[],si=Math.sign;function bS(){for(let r=0;r<16;r++){const t=[];Go.push(t);for(let e=0;e<16;e++){const s=si(je[r]*je[e]+We[r]*ze[e]),i=si(ze[r]*je[e]+Ve[r]*ze[e]),n=si(je[r]*We[e]+We[r]*Ve[e]),o=si(ze[r]*We[e]+Ve[r]*Ve[e]);for(let a=0;a<16;a++)if(je[a]===s&&ze[a]===i&&We[a]===n&&Ve[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new D;t.set(je[r],ze[r],We[r],Ve[r],0,0),Md.push(t)}}bS();const j={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>je[r],uY:r=>ze[r],vX:r=>We[r],vY:r=>Ve[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Go[r][t],sub:(r,t)=>Go[r][j.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?j.S:j.N:Math.abs(t)*2<=Math.abs(r)?r>0?j.E:j.W:t>0?r>0?j.SE:j.SW:r>0?j.NE:j.NW,matrixAppendRotationInv:(r,t,e=0,s=0,i=0,n=0)=>{const o=Md[j.inv(t)],a=o.a,l=o.b,u=o.c,h=o.d,c=e-Math.min(0,a*i,u*n,a*i+u*n),d=s-Math.min(0,l*i,h*n,l*i+h*n),p=r.a,f=r.b,m=r.c,g=r.d;r.a=a*p+l*m,r.b=a*f+l*g,r.c=u*p+h*m,r.d=u*f+h*g,r.tx=c*p+d*m+r.tx,r.ty=c*f+d*g+r.ty},transformRectCoords:(r,t,e,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:l,y:u,width:h,height:c}=t;return e===j.E?(s.set(i+l,n+u,o,a),s):e===j.S?s.set(h-n-a+l,i+u,a,o):e===j.W?s.set(h-i-o+l,c-n-a+u,o,a):e===j.N?s.set(n+l,c-i-o+u,a,o):s.set(i+l,n+u,o,a)}},Io=()=>{};var yS=Object.defineProperty,TS=Object.defineProperties,SS=Object.getOwnPropertyDescriptors,Od=Object.getOwnPropertySymbols,wS=Object.prototype.hasOwnProperty,ES=Object.prototype.propertyIsEnumerable,Gd=(r,t,e)=>t in r?yS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,AS=(r,t)=>{for(var e in t||(t={}))wS.call(t,e)&&Gd(r,e,t[e]);if(Od)for(var e of Od(t))ES.call(t,e)&&Gd(r,e,t[e]);return r},PS=(r,t)=>TS(r,SS(t));class ii extends ft{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super(PS(AS({},t),{resource:e,format:s})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ii.extension=S.TextureSource;const Id=new D;class Bo{constructor(t,e){this.mapCoord=new D,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;i<t.length;i+=2){const n=t[i],o=t[i+1];e[i]=n*s.a+o*s.c+s.tx,e[i+1]=n*s.b+o*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,i=t.trim;i&&(Id.set(s.width/i.width,0,0,s.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(Id));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+l)/n.width,o[1]=(t.frame.y+a+l)/n.height,o[2]=(t.frame.x+t.frame.width-a+l)/n.width,o[3]=(t.frame.y+t.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class F extends Dt{constructor({source:t,label:e,frame:s,orig:i,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:u}={}){var h;if(super(),this.uid=ct("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new ut,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(h=t==null?void 0:t.source)!=null?h:new ft,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:d}=this._source;this.frame.width=c,this.frame.height=d}this.orig=i||this.frame,this.trim=n,this.rotate=l!=null?l:0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Bo(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:i}=this._source,n=e.x/s,o=e.y/i,a=e.width/s,l=e.height/i;let u=this.rotate;if(u){const h=a/2,c=l/2,d=n+h,p=o+c;u=j.add(u,j.NW),t.x0=d+h*j.uX(u),t.y0=p+c*j.uY(u),u=j.add(u,2),t.x1=d+h*j.uX(u),t.y1=p+c*j.uY(u),u=j.add(u,2),t.x2=d+h*j.uX(u),t.y2=p+c*j.uY(u),u=j.add(u,2),t.x3=d+h*j.uX(u),t.y3=p+c*j.uY(u)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+l,t.x3=n,t.y3=o+l}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return this._source}}F.EMPTY=new F({label:"EMPTY",source:new ft({label:"EMPTY"})}),F.EMPTY.destroy=Io,F.WHITE=new F({source:new ii({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),F.WHITE.destroy=Io;var CS=Object.defineProperty,RS=Object.defineProperties,MS=Object.getOwnPropertyDescriptors,Bd=Object.getOwnPropertySymbols,OS=Object.prototype.hasOwnProperty,GS=Object.prototype.propertyIsEnumerable,Fd=(r,t,e)=>t in r?CS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IS=(r,t)=>{for(var e in t||(t={}))OS.call(t,e)&&Fd(r,e,t[e]);if(Bd)for(var e of Bd(t))GS.call(t,e)&&Fd(r,e,t[e]);return r},BS=(r,t)=>RS(r,MS(t));let FS=0;class Dd{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new qt(this.textureOptions)}createTexture(t,e,s,i){const n=new ft(BS(IS({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:i}));return new F({source:n,label:`texturePool_${FS++}`})}getOptimalTexture(t,e,s=1,i,n=!1){let o=Math.ceil(t*s-1e-6),a=Math.ceil(e*s-1e-6);o=He(o),a=He(a);const l=i?1:0,u=n?1:0,h=(o<<17)+(a<<2)+(u<<1)+l;this._texturePool[h]||(this._texturePool[h]=[]);let c=this._texturePool[h].pop();return c||(c=this.createTexture(o,a,i,n)),c.source._resolution=s,c.source.width=o/s,c.source.height=a/s,c.source.pixelWidth=o,c.source.pixelHeight=a,c.frame.x=0,c.frame.y=0,c.frame.width=t,c.frame.height=e,c.updateUvs(),this._poolKeyHash[c.uid]=h,c}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let i=0;i<s.length;i++)s[i].destroy(!0)}this._texturePool={}}}const _t=new Dd;Xe.register(_t);class ni{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new D,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new ri,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++){const i=e[s];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(_t.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let i=0;i<s.length;i++)this._getChildren(s[i],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new D),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new D),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new D),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function oi(r,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(r[s]=t[s])}const Fo=new xt(null),Do=new xt(null),Uo=new xt(null,1,1),ko=new xt(null),ts=1,ai=2,pr=4,DS=8;class pt extends Dt{constructor(t={}){var e,s;super(),this.uid=ct("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new D,this.relativeGroupTransform=new D,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new xt(this,0,0),this._scale=Uo,this._pivot=Do,this._origin=ko,this._skew=Fo,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],oi(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(i=>this.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){N.mixin(pt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let i=0;i<t.length;i++)this.addChild(t[i]);return t[0]}const e=t[0],s=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),s&&(s.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,s&&s.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let i=0;i<t.length;i++)this.removeChild(t[i]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=Et.get(ni,this),this.groupTransform=D.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Et.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new D),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Qc}set angle(t){this.rotation=t*Jc}get pivot(){return this._pivot===Do&&(this._pivot=new xt(this,0,0)),this._pivot}set pivot(t){this._pivot===Do&&(this._pivot=new xt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Fo&&(this._skew=new xt(this,0,0)),this._skew}set skew(t){this._skew===Fo&&(this._skew=new xt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Uo&&(this._scale=new xt(this,1,1)),this._scale}set scale(t){this._scale===Uo&&(this._scale=new xt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===ko&&(this._origin=new xt(this,0,0)),this._origin}set origin(t){this._origin===ko&&(this._origin=new xt(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var s;const i=this.getLocalBounds();typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,i=this._pivot,n=this._origin,o=this._position,a=s._x,l=s._y,u=i._x,h=i._y,c=-n._x,d=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*l,e.d=this._sy*l,e.tx=o._x-(u*e.a+h*e.c)+(c*e.a+d*e.c)-c,e.ty=o._y-(u*e.b+h*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=ts,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=rt.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=ts,this._onUpdate())}get tint(){return ge(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ai,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=pr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=pr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=pr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let s;if(this.children.length&&(s=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&s)for(let i=0;i<s.length;++i)s[i].destroy(t);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}}N.mixin(pt,sd,dd,bd,xd,_d,ud,hd,vd,qc,rd,md,id);var _e=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(_e||{});class li{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Ud=class Qt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new li(null,null,1/0),this.deltaMS=1/Qt.targetFPMS,this.elapsedMS=1/Qt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=_e.NORMAL){return this._addListener(new li(t,e,s))}addOnce(t,e,s=_e.NORMAL){return this._addListener(new li(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Qt.targetFPMS;const s=this._head;let i=s.next;for(;i;)i=i.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(Math.max(0,t)/1e3,Qt.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!Qt._shared){const t=Qt._shared=new Qt;t.autoStart=!0,t._protected=!0}return Qt._shared}static get system(){if(!Qt._system){const t=Qt._system=new Qt;t.autoStart=!0,t._protected=!0}return Qt._system}};Ud.targetFPMS=.06;let Rt=Ud;class $o{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),s=this._canvas.width,i=this._canvas.height,n=e.width/s*this._renderer.resolution,o=e.height/i*this._renderer.resolution,a=e.left,l=e.top,u=`translate(${a}px, ${l}px) scale(${n}, ${o})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const s=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/s*this._renderer.resolution,o=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||Rt.shared.add(this.updateTranslation,this,_e.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Rt.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class zr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=zr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,s,i,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var Lo=/iPhone/i,kd=/iPod/i,$d=/iPad/i,Ld=/\biOS-universal(?:.+)Mac\b/i,No=/\bAndroid(?:.+)Mobile\b/i,Nd=/Android/i,fr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ui=/Silk/i,Pe=/Windows Phone/i,Xd=/\bWindows(?:.+)ARM\b/i,Hd=/BlackBerry/i,jd=/BB10/i,zd=/Opera Mini/i,Wd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Vd=/Mobile(?:.+)Firefox\b/i,Yd=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function US(r){return function(t){return t.test(r)}}function Kd(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var i=US(e),n={apple:{phone:i(Lo)&&!i(Pe),ipod:i(kd),tablet:!i(Lo)&&(i($d)||Yd(t))&&!i(Pe),universal:i(Ld),device:(i(Lo)||i(kd)||i($d)||i(Ld)||Yd(t))&&!i(Pe)},amazon:{phone:i(fr),tablet:!i(fr)&&i(ui),device:i(fr)||i(ui)},android:{phone:!i(Pe)&&i(fr)||!i(Pe)&&i(No),tablet:!i(Pe)&&!i(fr)&&!i(No)&&(i(ui)||i(Nd)),device:!i(Pe)&&(i(fr)||i(ui)||i(No)||i(Nd))||i(/\bokhttp\b/i)},windows:{phone:i(Pe),tablet:i(Xd),device:i(Pe)||i(Xd)},other:{blackberry:i(Hd),blackberry10:i(jd),opera:i(zd),firefox:i(Vd),chrome:i(Wd),device:i(Hd)||i(jd)||i(zd)||i(Vd)||i(Wd)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var qd;const kS=(qd=Kd.default)!=null?qd:Kd,Zd=kS(globalThis.navigator);var $S=Object.defineProperty,Qd=Object.getOwnPropertySymbols,LS=Object.prototype.hasOwnProperty,NS=Object.prototype.propertyIsEnumerable,Jd=(r,t,e)=>t in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tp=(r,t)=>{for(var e in t||(t={}))LS.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))NS.call(t,e)&&Jd(r,e,t[e]);return r};const XS=9,ep=100,HS=0,jS=0,rp=2,sp=1,zS=-1e3,WS=-1e3,VS=2,Xo=class sT{constructor(t,e=Zd){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width=`${sp}px`,t.style.height=`${sp}px`,t.style.position="absolute",t.style.top=`${zS}px`,t.style.left=`${WS}px`,t.style.zIndex=VS.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${HS}px`,this._div.style.left=`${jS}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=rp.toString(),this._canvasObserver=new $o({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var t,e;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const s of this._children)(t=s._accessibleDiv)!=null&&t.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1;for(const s in this._pools)this._pools[s].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[s];(e=this._div)!=null&&e.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let s=0;s<e.length;s++)this._updateAccessibleObjects(e[s])}init(t){const e=sT.defaultOptions,s={accessibilityOptions:tp(tp({},e),(t==null?void 0:t.accessibilityOptions)||{})};this.debug=s.accessibilityOptions.debug,this._activateOnTab=s.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=s.accessibilityOptions.deactivateOnMouseMove,s.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const s of this._children)s._renderId===this._renderId&&e.add(this._children.indexOf(s))}for(let s=this._children.length-1;s>=0;s--){const i=this._children[s];e.has(s)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,Ro(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s<this._children.length;s++){const i=this._children[s];if(!i._accessibleActive||!i._accessibleDiv)continue;const n=i._accessibleDiv,o=i.hitArea||i.getBounds().rectangle;if(i.hitArea){const a=i.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let e=this._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=`
                        color: transparent;
                        pointer-events: none;
                        padding: 0;
                        margin: 0;
                        border: 0;
                        outline: 0;
                        background: transparent;
                        box-sizing: border-box;
                        user-select: none;
                        -webkit-user-select: none;
                        -moz-user-select: none;
                        -ms-user-select: none;
                    `,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${ep}px`,e.style.height=`${ep}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=rp.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:s}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new zr(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==XS||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};Xo.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"accessibility"},Xo.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let ip=Xo;const np={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};N.add(ip),N.mixin(pt,np);class Ho{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new $o({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const s=t[e],i=s.element;if(!s.parent||s.globalDisplayStatus<7)i==null||i.remove(),t.splice(e,1),e--;else{this._domElement.contains(i)||(i.style.position="absolute",i.style.pointerEvents="auto",this._domElement.appendChild(i));const n=s.worldTransform,o=s._anchor,a=s.width*o.x,l=s.height*o.y;i.style.transformOrigin=`${a}px ${l}px`,i.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,i.style.opacity=s.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Ho.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"dom"};class xe extends pt{constructor(t){var e;super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Ct(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=(e=t.autoGarbageCollect)!=null?e:!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:i}=t;return s>=e.minX&&s<=e.maxX&&i>=e.minY&&i<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,s){const{renderPipes:i}=e;i.blendMode.pushBlendMode(this,this.groupBlendMode,t);const n=i[this.renderPipeId];n!=null&&n.addRenderable&&n.addRenderable(this,t),this.didViewUpdate=!1;const o=this.children,a=o.length;for(let l=0;l<a;l++)o[l].collectRenderables(t,e,s);i.blendMode.popBlendMode(t)}}var YS=Object.defineProperty,hi=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,lp=(r,t,e)=>t in r?YS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KS=(r,t)=>{for(var e in t||(t={}))op.call(t,e)&&lp(r,e,t[e]);if(hi)for(var e of hi(t))ap.call(t,e)&&lp(r,e,t[e]);return r},qS=(r,t)=>{var e={};for(var s in r)op.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&hi)for(var s of hi(r))t.indexOf(s)<0&&ap.call(r,s)&&(e[s]=r[s]);return e};class ZS extends xe{constructor(t={}){const e=t,{element:s,anchor:i}=e,n=qS(e,["element","anchor"]);super(KS({label:"DOMContainer"},n)),this.renderPipeId="dom",this.batched=!1,this._anchor=new lt(0,0),i&&(this.anchor=i),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:s,offsetHeight:i}=e;t.minX=0,t.maxX=s,t.minY=0,t.maxY=i}destroy(t=!1){var e,s;super.destroy(t),(s=(e=this._element)==null?void 0:e.parentNode)==null||s.removeChild(this._element),this._element=null,this._anchor=null}}N.add(Ho);let QS=class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this._tickerAdded||!this.domElement||(Rt.system.add(this._tickerUpdate,this,_e.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Rt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};const ve=new QS;class es extends zr{constructor(){super(...arguments),this.client=new lt,this.movement=new lt,this.offset=new lt,this.global=new lt,this.screen=new lt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,s){return t.worldTransform.applyInverse(s||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,s,i,n,o,a,l,u,h,c,d,p,f,m){throw new Error("Method not implemented.")}}class re extends es{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ye extends es{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ye.DOM_DELTA_PIXEL=0,Ye.DOM_DELTA_LINE=1,Ye.DOM_DELTA_PAGE=2;const JS=2048,t2=new lt,rs=new lt;class up{constructor(t){this.dispatch=new Dt,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((s,i)=>s.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let s=0,i=e.length;s<i;s++)e[s].fn(t)}hitTest(t,e){ve.pauseUpdate=!0;const s=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",i=this[s](this.rootTarget,this.rootTarget.eventMode,t2.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const s=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,n=s.length-1;i<n;i++)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let i=s.length-2;i>=0;i--)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s<JS&&t!==this.rootTarget&&t.parent;s++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,s,i,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ve.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let c=h.length-1;c>=0;c--){const d=h[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,i,n,o||n(t,s));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,s)&&i(t,s)?u?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ve.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=s;for(let h=l.length-1;h>=0;h--){const c=l[h],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,u,i,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const p=t.isInteractive();return(d.length>0||p)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&i(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,rs),!t.hitArea.contains(rs.x,rs.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s<t.effects.length;s++){const i=t.effects[s];if(i.containsPoint&&!i.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,rs),t.containsPoint(rs)):!1}notifyTarget(t,e){var s,i;if(!t.currentTarget.isInteractive())return;e!=null||(e=t.type);const n=`on${e}`;(i=(s=t.currentTarget)[n])==null||i.call(s,t);const o=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,o),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof re))return;const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const s=this.trackingData(t.pointerId);s.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,s,i;if(!(t instanceof re))return;this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=n.pointerType==="mouse"||n.pointerType==="pen",a=this.trackingData(t.pointerId),l=this.findMountedTarget(a.overTargets);if(((e=a.overTargets)==null?void 0:e.length)>0&&l!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,l);if(this.dispatchEvent(d,"pointerout"),o&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(l)){const p=this.createPointerEvent(t,"pointerleave",l);for(p.eventPhase=p.AT_TARGET;p.target&&!n.composedPath().includes(p.target);)p.currentTarget=p.target,this.notifyTarget(p),o&&this.notifyTarget(p,"mouseleave"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}if(l!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(n,c);this.dispatchEvent(d,"pointerover"),o&&this.dispatchEvent(d,"mouseover");let p=l==null?void 0:l.parent;for(;p&&p!==this.rootTarget.parent&&p!==n.target;)p=p.parent;if(!p||p===this.rootTarget.parent){const f=this.clonePointerEvent(n,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==l&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}const u=[],h=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&u.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.cursor),u.length>0&&this.all(n,u),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof re))return;const s=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;s.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof re))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof re))return;const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=i.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const u=a.button===2;this.dispatchEvent(a,u?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof re))return;const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(s){let n=s;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof Ye))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;s<t.length&&t[s].parent===e;s++)e=t[s];return e}createPointerEvent(t,e,s){var i;const n=this.allocateEvent(re);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=(i=s!=null?s:this.hitTest(n.global.x,n.global.y))!=null?i:this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(Ye);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const s=this.allocateEvent(re);return s.nativeEvent=t.nativeEvent,s.originalEvent=t.originalEvent,this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.target=t.target,s.path=t.composedPath().slice(),s.type=e!=null?e:s.type,s}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof re&&e instanceof re&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof es&&e instanceof es&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const s=t.currentTarget._events[e];if(s)if("fn"in s)s.once&&t.currentTarget.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,t);else for(let i=0,n=s.length;i<n&&!t.propagationImmediatelyStopped;i++)s[i].once&&t.currentTarget.removeListener(e,s[i].fn,void 0,!0),s[i].fn.call(s[i].context,t)}}var e2=Object.defineProperty,hp=Object.getOwnPropertySymbols,r2=Object.prototype.hasOwnProperty,s2=Object.prototype.propertyIsEnumerable,cp=(r,t,e)=>t in r?e2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,i2=(r,t)=>{for(var e in t||(t={}))r2.call(t,e)&&cp(r,e,t[e]);if(hp)for(var e of hp(t))s2.call(t,e)&&cp(r,e,t[e]);return r};const n2=1,o2={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},jo=class hc{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new up(null),ve.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new re(null),this._rootWheelEvent=new Ye(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(i2({},hc.defaultEventFeatures),{set:(e,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[s]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,s;const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,hc._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(s=t.eventFeatures)!=null?s:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){ve.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let s=0,i=e.length;s<i;s++){const n=e[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ve.pointerMoved();const e=this._normalizeToPointerData(t);for(let s=0,i=e.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,i[n]);a.type+=s,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let s=0,i=e.length;s<i;s++){const n=this._bootstrapEvent(this._rootPointerEvent,e[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,ve.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ve.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;ve.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,s){const i=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-i.left)*(this.domElement.width/i.width)*n,t.y=(s-i.top)*(this.domElement.height/i.height)*n}_normalizeToPointerData(t){var e,s,i,n;const o=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let a=0,l=t.changedTouches.length;a<l;a++){const u=t.changedTouches[a];typeof u.button=="undefined"&&(u.button=0),typeof u.buttons=="undefined"&&(u.buttons=1),typeof u.isPrimary=="undefined"&&(u.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof u.width=="undefined"&&(u.width=u.radiusX||1),typeof u.height=="undefined"&&(u.height=u.radiusY||1),typeof u.tiltX=="undefined"&&(u.tiltX=0),typeof u.tiltY=="undefined"&&(u.tiltY=0),typeof u.pointerType=="undefined"&&(u.pointerType="touch"),typeof u.pointerId=="undefined"&&(u.pointerId=u.identifier||0),typeof u.pressure=="undefined"&&(u.pressure=u.force||.5),typeof u.twist=="undefined"&&(u.twist=0),typeof u.tangentialPressure=="undefined"&&(u.tangentialPressure=0),typeof u.layerX=="undefined"&&(u.layerX=u.offsetX=u.clientX),typeof u.layerY=="undefined"&&(u.layerY=u.offsetY=u.clientY),u.isNormalized=!0,u.type=t.type,(e=u.altKey)!=null||(u.altKey=t.altKey),(s=u.ctrlKey)!=null||(u.ctrlKey=t.ctrlKey),(i=u.metaKey)!=null||(u.metaKey=t.metaKey),(n=u.shiftKey)!=null||(u.shiftKey=t.shiftKey),o.push(u)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const a=t;typeof a.isPrimary=="undefined"&&(a.isPrimary=!0),typeof a.width=="undefined"&&(a.width=1),typeof a.height=="undefined"&&(a.height=1),typeof a.tiltX=="undefined"&&(a.tiltX=0),typeof a.tiltY=="undefined"&&(a.tiltY=0),typeof a.pointerType=="undefined"&&(a.pointerType="mouse"),typeof a.pointerId=="undefined"&&(a.pointerId=n2),typeof a.pressure=="undefined"&&(a.pressure=.5),typeof a.twist=="undefined"&&(a.twist=0),typeof a.tangentialPressure=="undefined"&&(a.tangentialPressure=0),a.isNormalized=!0,o.push(a)}else o.push(t);return o}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=o2[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};jo.extension={name:"events",type:[S.WebGLSystem,S.CanvasSystem,S.WebGPUSystem],priority:-1},jo.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let zo=jo;const dp={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){var r;return(r=this._internalEventMode)!=null?r:zo.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=s?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;i&&i.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;r=s?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,i)},dispatchEvent(r){if(!(r instanceof zr))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};N.add(zo),N.mixin(pt,dp);var Zt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Zt||{});const pp={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let fp=pp;const H={get(){return fp},set(r){fp=r}};function ae(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ss(r){return r.split("?")[0].split("#")[0]}function a2(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l2(r,t,e){return r.replace(new RegExp(a2(t),"g"),e)}function u2(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||n===1))if(i!==a-1&&n===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",s=0):(e=e.slice(0,l),s=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Xt={toPosix(r){return l2(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){ae(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(ae(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=ss(this.toPosix(t!=null?t:H.get().getBaseUrl())),i=ss(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?Xt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(ae(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=u2(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return ae(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let s=0;s<r.length;++s){const i=r[s];if(ae(i),i.length>0)if(e===void 0)e=i;else{const n=(t=r[s-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(ae(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){ae(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){ae(r),t&&ae(t),r=ss(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){ae(r),r=ss(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){ae(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=ss(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;const n="";t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let o=-1,a=0,l=-1,u=!0,h=r.length-1,c=0;for(;h>=i;--h){if(e=r.charCodeAt(h),e===47){if(!u){a=h+1;break}continue}l===-1&&(u=!1,l=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&s?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&s?(t.name=r.slice(1,o),t.base=r.slice(1,l)):(t.name=r.slice(a,o),t.base=r.slice(a,l)),t.ext=r.slice(o,l)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},se=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function mp(r,t,e,s,i){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?mp(r.replace(s[e],a),t,e+1,s,i):i.push(r.replace(s[e],a))}}function gp(r){const t=/\{(.*?)\}/g,e=r.match(t),s=[];if(e){const i=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");i.push(o)}),mp(r,i,0,e,s)}else s.push(r);return s}const is=r=>!Array.isArray(r);var h2=Object.defineProperty,c2=Object.defineProperties,d2=Object.getOwnPropertyDescriptors,_p=Object.getOwnPropertySymbols,p2=Object.prototype.hasOwnProperty,f2=Object.prototype.propertyIsEnumerable,xp=(r,t,e)=>t in r?h2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ke=(r,t)=>{for(var e in t||(t={}))p2.call(t,e)&&xp(r,e,t[e]);if(_p)for(var e of _p(t))f2.call(t,e)&&xp(r,e,t[e]);return r},m2=(r,t)=>c2(r,d2(t));class Ge{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,i;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(i=t.extractAssetIdFromBundle)!=null?i:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return se(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Ke({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const u=this._createBundleAssetId(t,a);s.push(u),l=[a,u]}else{const u=a.map(h=>this._createBundleAssetId(t,h));s.push(...u),l=[...a,...u]}this.add(m2(Ke({},n),{alias:l,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;se(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:l,parser:u}=i;const h=se(n).map(f=>typeof f=="string"?gp(f):Array.isArray(f)?f:[f]),c=this.getAlias(i),d=[],p=f=>{const m=this._parsers.find(g=>g.test(f));return Ke({src:f},m==null?void 0:m.parse(f))};h.forEach(f=>{f.forEach(m=>{var g,_,x,v;let b={};if(typeof m!="object"?b=p(m):(o=(g=m.data)!=null?g:o,a=(_=m.format)!=null?_:a,(m.loadParser||m.parser)&&(l=(x=m.loadParser)!=null?x:l,u=(v=m.parser)!=null?v:u),b=Ke(Ke({},p(m.src)),m)),!c)throw new Error(`[Resolver] alias is undefined for this asset: ${b.src}`);b=this._buildResolvedAsset(b,{aliases:c,data:o,format:a,loadParser:l,parser:u,progressSize:i.progressSize}),d.push(b)})}),c.forEach(f=>{this._assetMap[f]=d})})}resolveBundle(t){const e=is(t);t=se(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(i,l)]=u}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=is(t);t=se(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(h=>h[a]?h[a]===l:!1);u.length&&(n=u)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[e],i=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var s,i;const{aliases:n,data:o,loadParser:a,parser:l,format:u,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=n!=null?n:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Ke(Ke({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(i=u!=null?u:t.format)!=null?i:vp(t.src),h!==void 0&&(t.progressSize=h),t}}Ge.RETINA_PREFIX=/@([0-9\.]+)x/;function vp(r){return r.split(".").pop().split("?").shift().split("#").shift()}const ci=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},bp=class zs{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof ft&&(s={texture:t,data:e});const{texture:i,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=i instanceof F?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=zs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let s=t;const i=e?1/0:zs.BATCH_SIZE;for(;s-t<i&&s<this._frameKeys.length;){const n=this._frameKeys[s],o=this._frames[n],a=o.frame;if(a){let l=null,u=null;const h=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,c=new ut(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);o.rotated?l=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new ut(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(u=new ut(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new F({source:this.textureSource,frame:l,orig:c,trim:u,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}s++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const i=t[e][s];this.animations[e].push(this.textures[i])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*zs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*zs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};bp.BATCH_SIZE=1e3;let Wo=bp;const g2=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function yp(r,t,e){const s={};if(r.forEach(i=>{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){const i=Xt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=yp([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Tp={extension:S.Asset,cache:{test:r=>r instanceof Wo,getCacheableAssets:(r,t)=>yp(r,t,!1)},resolver:{extension:{type:S.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&g2.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=Ge.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:Zt.Normal,name:"spritesheetLoader"},async testParse(r,t){return Xt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(s=t==null?void 0:t.data)!=null?s:{};let h=Xt.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let c;if(o instanceof F)c=o;else{const f=ci(h+(a!=null?a:r.meta.image),t.src);c=(await e.load([{src:f,data:l}]))[f]}const d=new Wo({texture:c.source,data:r,cachePrefix:u});await d.parse();const p=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(p)){const f=[];for(const g of p){if(typeof g!="string")continue;let _=h+g;(n=t.data)!=null&&n.ignoreMultiPack||(_=ci(_,t.src),f.push(e.load({src:_,data:{textureOptions:l,ignoreMultiPack:!0}})))}const m=await Promise.all(f);d.linkedSheets=m,m.forEach(g=>{g.linkedSheets=[d].concat(d.linkedSheets.filter(_=>_!==g))})}return d},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};N.add(Tp);function Vo(r,t,e){const{width:s,height:i}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*s,r.maxX=r.minX+o,r.minY=n.y-t._y*i,r.maxY=r.minY+a}else r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}var _2=Object.defineProperty,di=Object.getOwnPropertySymbols,Sp=Object.prototype.hasOwnProperty,wp=Object.prototype.propertyIsEnumerable,Ep=(r,t,e)=>t in r?_2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,x2=(r,t)=>{for(var e in t||(t={}))Sp.call(t,e)&&Ep(r,e,t[e]);if(di)for(var e of di(t))wp.call(t,e)&&Ep(r,e,t[e]);return r},v2=(r,t)=>{var e={};for(var s in r)Sp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&di)for(var s of di(r))t.indexOf(s)<0&&wp.call(r,s)&&(e[s]=r[s]);return e};class pe extends xe{constructor(t=F.EMPTY){t instanceof F&&(t={texture:t});const e=t,{texture:s=F.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,l=v2(e,["texture","anchor","roundPixels","width","height"]);super(x2({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new xt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof F?new pe(t):new pe(F.from(t,e))}set texture(t){t||(t=F.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Vo(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:i,height:n}=e.orig;s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const b2=new Ct;function pi(r,t,e){const s=b2;r.measurable=!0,Qr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function fi(r,t,e){const s=me.get();r.measurable=!0;const i=It.get().identity(),n=Ap(r,e,i);ei(r,s,n),r.measurable=!1,t.addBoundsMask(s),It.return(i),me.return(s)}function Ap(r,t,e){return r&&r!==t&&(Ap(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Yo{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof pe),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||pi(this.mask,t,e)}addLocalBounds(t,e){fi(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof pe}}Yo.extension=S.MaskEffect;class Ko{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Ko.extension=S.MaskEffect;class qo{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){pi(this.mask,t,e)}addLocalBounds(t,e){fi(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof pt}}qo.extension=S.MaskEffect;class le extends ft{constructor(t){t.resource||(t.resource=H.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}le.extension=S.TextureSource;class Ie extends ft{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Ie.extension=S.TextureSource;let Zo;async function Qo(){return Zo!=null||(Zo=(async()=>{var r;const t=H.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Zo}var y2=Object.defineProperty,T2=Object.defineProperties,S2=Object.getOwnPropertyDescriptors,Pp=Object.getOwnPropertySymbols,w2=Object.prototype.hasOwnProperty,E2=Object.prototype.propertyIsEnumerable,Cp=(r,t,e)=>t in r?y2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jo=(r,t)=>{for(var e in t||(t={}))w2.call(t,e)&&Cp(r,e,t[e]);if(Pp)for(var e of Pp(t))E2.call(t,e)&&Cp(r,e,t[e]);return r},A2=(r,t)=>T2(r,S2(t));const mi=class iT extends ft{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=Jo(Jo({},iT.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Rt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Qo(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Rt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Rt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Rt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};mi.extension=S.TextureSource,mi.defaultOptions=A2(Jo({},ft.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),mi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let mr=mi,P2=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const s=se(t);let i;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.test(e)){i=u.getCacheableAssets(s,e);break}}const n=new Map(Object.entries(i||{}));i||s.forEach(l=>{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=i?i[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const st=new P2,ta=[];N.handleByList(S.TextureSource,ta);function C2(r={}){return ea(r)}function ea(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i<ta.length;i++){const n=ta[i];if(n.test(e))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function Rp(r={},t=!1){const e=r&&r.resource,s=e?r.resource:r,i=e?r:{resource:r};if(!t&&st.has(s))return st.get(s);const n=new F({source:ea(i)});return n.on("destroy",()=>{st.has(s)&&st.remove(s)}),t||st.set(s,n),n}function Mp(r,t=!1){return typeof r=="string"?st.get(r):r instanceof ft?new F({source:r}):Rp(r,t)}F.from=Mp,ft.from=ea,N.add(Yo,Ko,qo,mr,Ie,le,ii);class ra{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}}ra.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};const sa=Object.create(null),Op=Object.create(null);function gr(r,t){let e=Op[r];return e===void 0&&(sa[t]===void 0&&(sa[t]=1),Op[r]=e=sa[t]++),e}let ns;function ia(){return(!ns||ns!=null&&ns.isContextLost())&&(ns=H.get().createCanvas().getContext("webgl",{})),ns}let gi;function Gp(){if(!gi){gi="mediump";const r=ia();r&&r.getShaderPrecisionFormat&&(gi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return gi}function Ip(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 Bp(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 Fp(r,t){return t?`#version 300 es
${r}`:r}const R2={},M2={};function Dp(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?R2:M2;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
${r}`}function Up(r,t){return t?r.replace("#version 300 es",""):r}var O2=Object.defineProperty,kp=Object.getOwnPropertySymbols,G2=Object.prototype.hasOwnProperty,I2=Object.prototype.propertyIsEnumerable,$p=(r,t,e)=>t in r?O2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lp=(r,t)=>{for(var e in t||(t={}))G2.call(t,e)&&$p(r,e,t[e]);if(kp)for(var e of kp(t))I2.call(t,e)&&$p(r,e,t[e]);return r};const na={stripVersion:Up,ensurePrecision:Bp,addProgramDefines:Ip,setProgramName:Dp,insertVersion:Fp},os=Object.create(null),Np=class cc{constructor(t){t=Lp(Lp({},cc.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Gp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(na).forEach(o=>{const a=s[o];i=na[o](i,a,!0),n=na[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=gr(`${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,os[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return os[e]||(os[e]=new cc(t),os[e]._cacheKey=e),os[e]}};Np.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Ht=Np;const Xp={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 Ce(r){var t;return(t=Xp[r])!=null?t:Xp.float32}const B2={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},Hp=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function jp(r,t){var e;let s;for(;(s=Hp.exec(r))!==null;){const i=(e=B2[s[3]])!=null?e:"float32";t[s[2]]={location:parseInt(s[1],10),format:i,stride:Ce(i).stride,offset:0,instance:!1,start:0}}Hp.lastIndex=0}function F2(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function zp({source:r,entryPoint:t}){const e={},s=F2(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(jp(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&&jp(h[1],e)}}return e}function _i(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=>({group:parseInt(f.match(n)[1],10),binding:parseInt(f.match(o)[1],10),name:f.match(a)[2],isUniform:f.match(a)[1]==="<uniform>",type:f.match(l)[1]}));if(!d)return{groups:[],structs:[]};const p=(s=(e=r.match(u))==null?void 0:e.map(f=>{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 Be=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Be||{});function Wp({groups:r}){const t=[];for(let e=0;e<r.length;e++){const s=r[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:Be.VERTEX|Be.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Be.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:Be.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):s.type==="texture_2d_array"||s.type.startsWith("texture_2d_array<")?t[s.group].push({binding:s.binding,visibility:Be.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(s.type==="texture_cube"||s.type.startsWith("texture_cube<"))&&t[s.group].push({binding:s.binding,visibility:Be.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function Vp({groups:r}){const t=[];for(let e=0;e<r.length;e++){const s=r[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function Yp(r,t){const e=new Set,s=new Set,i=[...r.structs,...t.structs].filter(o=>e.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 Nt{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=_i(i.source);this.structsAndGroups=u}else{const u=_i(n.source),h=_i(i.source);this.structsAndGroups=Yp(u,h)}this.layout=o!=null?o:Vp(this.structsAndGroups),this.gpuLayout=a!=null?a:Wp(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=gr(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=zp(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 Nt(t),as[e]._cacheKey=e),as[e]}}class be{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++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&((s=n==null?void 0: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,e){const s=this.resources;for(const i in s)s[i]._gcLastUsed=t,s[i]._touched=e}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){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Ot=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(Ot||{});const oa=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Kp=oa.reduce((r,t)=>(r[t]=!0,r),{});function qp(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var D2=Object.defineProperty,Zp=Object.getOwnPropertySymbols,U2=Object.prototype.hasOwnProperty,k2=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?D2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jp=(r,t)=>{for(var e in t||(t={}))U2.call(t,e)&&Qp(r,e,t[e]);if(Zp)for(var e of Zp(t))k2.call(t,e)&&Qp(r,e,t[e]);return r};const tf=class nT{constructor(t,e){this._touched=0,this.uid=ct("uniform"),this._resourceType="uniformGroup",this._resourceId=ct("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=Jp(Jp({},nT.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,!Kp[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: ${oa.join(", ")}`)}(i=a.value)!=null||(a.value=qp(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=gr(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};tf.defaultOptions={ubo:!1,isStatic:!1};let At=tf;var $2=Object.defineProperty,xi=Object.getOwnPropertySymbols,ef=Object.prototype.hasOwnProperty,rf=Object.prototype.propertyIsEnumerable,sf=(r,t,e)=>t in r?$2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L2=(r,t)=>{for(var e in t||(t={}))ef.call(t,e)&&sf(r,e,t[e]);if(xi)for(var e of xi(t))rf.call(t,e)&&sf(r,e,t[e]);return r},N2=(r,t)=>{var e={};for(var s in r)ef.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&xi)for(var s of xi(r))t.indexOf(s)<0&&rf.call(r,s)&&(e[s]=r[s]);return e};class Jt extends Dt{constructor(t){super(),this.uid=ct("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=Ot.WEBGPU),s&&(o|=Ot.WEBGL)),this.compatibleRenderers=o;const l={};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)for(const u in a)for(const h in a[u]){const c=a[u][h];l[c]={group:u,binding:h,name:c}}else if(e&&i&&!a){const u=e.structsAndGroups.groups;a={},u.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h});let u=0;for(const h in n)l[h]||(i[99]||(i[99]=new be,this._ownedBindGroups.push(i[99])),l[h]={group:99,binding:u,name:h},a[99]=a[99]||{},a[99][u]=h,u++);for(const h in n){const c=h;let d=n[h];!d.source&&!d._resourceType&&(d=new At(d));const p=l[c];p&&(i[p.group]||(i[p.group]=new be,this._ownedBindGroups.push(i[p.group])),i[p.group].setResource(d,p.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,l)}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 be,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)}static from(t){const e=t,{gpu:s,gl:i}=e,n=N2(e,["gpu","gl"]);let o,a;return s&&(o=Nt.from(s)),i&&(a=Ht.from(i)),new Jt(L2({gpuProgram:o,glProgram:a},n))}}const X2={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},aa=0,la=1,ua=2,ha=3,ca=4,da=5,pa=class oT{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<aa)}set blend(t){!!(this.data&1<<aa)!==t&&(this.data^=1<<aa)}get offsets(){return!!(this.data&1<<la)}set offsets(t){!!(this.data&1<<la)!==t&&(this.data^=1<<la)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<ua)}set culling(t){!!(this.data&1<<ua)!==t&&(this.data^=1<<ua)}get depthTest(){return!!(this.data&1<<ha)}set depthTest(t){!!(this.data&1<<ha)!==t&&(this.data^=1<<ha)}get depthMask(){return!!(this.data&1<<da)}set depthMask(t){!!(this.data&1<<da)!==t&&(this.data^=1<<da)}get clockwiseFrontFace(){return!!(this.data&1<<ca)}set clockwiseFrontFace(t){!!(this.data&1<<ca)!==t&&(this.data^=1<<ca)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=X2[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new oT;return t.depthTest=!1,t.blend=!0,t}};pa.default2d=pa.for2d();let jt=pa;var H2=Object.defineProperty,vi=Object.getOwnPropertySymbols,nf=Object.prototype.hasOwnProperty,of=Object.prototype.propertyIsEnumerable,af=(r,t,e)=>t in r?H2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fa=(r,t)=>{for(var e in t||(t={}))nf.call(t,e)&&af(r,e,t[e]);if(vi)for(var e of vi(t))of.call(t,e)&&af(r,e,t[e]);return r},j2=(r,t)=>{var e={};for(var s in r)nf.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&vi)for(var s of vi(r))t.indexOf(s)<0&&of.call(r,s)&&(e[s]=r[s]);return e};const lf=class dc extends Jt{constructor(t){t=fa(fa({},dc.defaultOptions),t),super(t),this.enabled=!0,this._state=jt.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=j2(e,["gpu","gl"]);let o,a;return s&&(o=Nt.from(s)),i&&(a=Ht.from(i)),new dc(fa({gpuProgram:o,glProgram:a},n))}};lf.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let ye=lf;var ls=`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();
}
`,uf=`in vec2 vTextureCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
    finalColor = texture(uTexture, vTextureCoord);
}
`,ma=`struct GlobalFilterUniforms {
  uInputSize: vec4<f32>,
  uInputPixel: vec4<f32>,
  uInputClamp: vec4<f32>,
  uOutputFrame: vec4<f32>,
  uGlobalFrame: vec4<f32>,
  uOutputTexture: vec4<f32>,
};

@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler: sampler;

struct VSOutput {
  @builtin(position) position: vec4<f32>,
  @location(0) uv: vec2<f32>
};

fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
{
    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<f32>) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

@vertex
fn mainVertex(
  @location(0) aPosition: vec2<f32>,
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {
    return textureSample(uTexture, uSampler, uv);
}
`;class hf extends ye{constructor(){const t=Nt.from({vertex:{source:ma,entryPoint:"mainVertex"},fragment:{source:ma,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Ht.from({vertex:ls,fragment:uf,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var ot=(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))(ot||{});class zt extends Dt{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=ct("buffer"),this._resourceType="buffer",this._resourceId=ct("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,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&ot.STATIC)}set static(t){t?this.descriptor.usage|=ot.STATIC:this.descriptor.usage&=~ot.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLength<i.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=ct("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t!=null?t:this._updateSize,this._updateID++,this.emit("update",this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function ga(r,t){if(!(r instanceof zt)){let e=t?ot.INDEX:ot.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=ot.INDEX|ot.COPY_DST):(r=new Float32Array(r),e=ot.VERTEX|ot.COPY_DST)),r=new zt({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function cf(r,t,e){const s=r.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const i=s.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const u=i.BYTES_PER_ELEMENT,h=(s.offset||0)/u,c=(s.stride||8)/u;for(let d=h;d<i.length;d+=c){const p=i[d],f=i[d+1];p>a&&(a=p),f>l&&(l=f),p<n&&(n=p),f<o&&(o=f)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=l,e}function z2(r){return(r instanceof zt||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=ga(r.buffer,!1),r}class qe extends Dt{constructor(t={}){var e;super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ct("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Ct,this._boundsDirty=!0;const{attributes:s,indexBuffer:i,topology:n}=t;if(this.buffers=[],this.attributes={},s)for(const o in s)this.addAttribute(o,s[o]);this.instanceCount=(e=t.instanceCount)!=null?e:1,i&&this.addIndex(i),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const s=z2(e);this.buffers.indexOf(s.buffer)===-1&&(this.buffers.push(s.buffer),s.buffer.on("update",this.onBufferUpdate,this),s.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=s}addIndex(t){this.indexBuffer=ga(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,cf(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(s=>s.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}function us(r,t,e,s,i,n){const o=r-e,a=t-s,l=i-e,u=n-s,h=o*l+a*u,c=l*l+u*u;let d=-1;c!==0&&(d=h/c);let p,f;d<0?(p=e,f=s):d>1?(p=i,f=n):(p=e+d*l,f=s+d*u);const m=r-p,g=t-f;return m*m+g*g}function _a(r,t,e,s,i,n,o,a){const l=o-e,u=a-s,h=i-e,c=n-s,d=r-e,p=t-s,f=l*l+u*u,m=l*h+u*c,g=l*d+u*p,_=h*h+c*c,x=h*d+c*p,v=1/(f*_-m*m),b=(_*g-m*x)*v,T=(f*x-m*g)*v;return b>=0&&T>=0&&b+T<1}class ho{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new ho(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s,i=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-i)*s,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(s-l)}getBounds(t){return t||(t=new ut),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class co{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new co(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),l=s-a,u=n-l,h=o-l,c=n+a,d=o+a,p=t-this.x,f=e-this.y,m=p*p/(u*u)+f*f/(h*h),g=p*p/(c*c)+f*f/(d*d);return m>1&&g<=1}getBounds(t){return t||(t=new ut),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}let W2,V2;class Wr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;i<n;i++)s.push(e[i].x,e[i].y);e=s}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,s=e.length;for(let i=0;i<s;i+=2){const n=e[i],o=e[i+1],a=e[(i+2)%s],l=e[(i+3)%s];t+=(a-n)*(l+o)}return t<0}containsPolygon(t){const e=this.getBounds(W2),s=t.getBounds(V2);if(!e.containsRect(s))return!1;const i=t.points;for(let n=0;n<i.length;n+=2){const o=i[n],a=i[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new Wr(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const i=this.points.length/2;for(let n=0,o=i-1;n<i;o=n++){const a=this.points[n*2],l=this.points[n*2+1],u=this.points[o*2],h=this.points[o*2+1];l>e!=h>e&&t<(u-a)*((e-l)/(h-l))+a&&(s=!s)}return s}strokeContains(t,e,s,i=.5){const n=s*s,o=n*(1-i),a=n-o,{points:l}=this,u=l.length-(this.closePath?0:2);for(let h=0;h<u;h+=2){const c=l[h],d=l[h+1],p=l[(h+2)%l.length],f=l[(h+3)%l.length],m=us(t,e,c,d,p,f),g=Math.sign((p-c)*(e-d)-(f-d)*(t-c));if(m<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new ut);const e=this.points;let s=1/0,i=-1/0,n=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){const u=e[a],h=e[a+1];s=u<s?u:s,i=u>i?u:i,n=h<n?h:n,o=h>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 po{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 ut),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new po(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let 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:t<d&&e<p&&bi(t,e,d,p,u,c,h)||t>g-u&&e<p&&bi(t,e,g-u,p,u,c,h)||t>g-u&&e>_-u&&bi(t,e,g-u,_-u,u,c,h)||t<d&&e>_-u&&bi(t,e,d,_-u,u,c,h)}}class bc{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 us(t,e,a,h,l,d)<=o||us(t,e,l,c,u,d)<=o||us(t,e,u,d,a,h)<=o}clone(){return new bc(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 ut);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 df=new D;function xa(r,t){var e;t.clear();const s=t.matrix;for(let i=0;i<r.length;i++){const n=r[i];if(n.globalDisplayStatus<7)continue;const o=(e=n.renderGroup)!=null?e:n.parentRenderGroup;o!=null&&o.isCachedAsTexture?t.matrix=df.copyFrom(o.textureOffsetInverseTransform).append(n.worldTransform):o!=null&&o._parentCacheAsTextureRenderGroup?t.matrix=df.copyFrom(o._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(n.groupTransform):t.matrix=n.worldTransform,t.addBounds(n.bounds)}return t.matrix=s,t}const Y2=new qe({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});let K2=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Ct,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}};class va{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new At({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new be({}),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=_t.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=F.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&&_t.returnTexture(e.backTexture),_t.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const i=t.colorTexture.source._resolution,n=_t.getOptimalTexture(e.width,e.height,i,!1);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 hf),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:Y2,shader:t,state:t._state,topology:"triangle-list"}),s.type===Ot.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,i){if(t.backTexture=F.EMPTY,t.inputTexture=_t.getOptimalTexture(e.width,e.height,t.resolution,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(t.inputTexture,!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 F&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof F?(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?xa(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=_t.getOptimalTexture(i.width,i.height,l.source._resolution,!1);let h=u;for(let c=o;c<a;c++){const d=n[c];if(!d.enabled)continue;d.apply(this,l,h,!0);const p=l;l=h,h=p}n[a].apply(this,l,t.outputRenderSurface,e),_t.returnTexture(u)}}_calculateFilterBounds(t,e,s,i,n){var o,a;const l=this.renderer,u=t.bounds,h=t.filters;let c=1/0,d=0,p=!0,f=!1,m=!1,g=!0,_=-1,x=-1;for(let v=0;v<h.length;v++){const b=h[v];if(b.enabled){if(_===-1&&(_=v),x=v,c=Math.min(c,b.resolution==="inherit"?i:b.resolution),d+=b.padding,b.antialias==="off"?p=!1:b.antialias==="inherit"&&p&&(p=s),b.clipToViewport||(g=!1),!(b.compatibleRenderers&l.type)){m=!1;break}if(b.blendRequired&&!((a=(o=l.backBuffer)==null?void 0:o.useBackBuffer)==null||a)){m=!1;break}m=!0,f||(f=b.blendRequired)}}if(!m){t.skip=!0;return}if(g&&u.fitBounds(0,e.width/i,0,e.height/i),u.scale(c).ceil().scale(1/c).pad((d|0)*n),!u.isPositive){t.skip=!0;return}t.antialias=p,t.resolution=c,t.blendRequired=f,t.firstEnabledIndex=_,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new K2),this._filterStackIndex++,t}}va.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"},N.add(va),N.add(ra);var q2={__proto__:null};const ba=[];N.handleByNamedList(S.Environment,ba);async function ya(r){if(!r)for(let t=0;t<ba.length;t++){const e=ba[t];if(e.value.test()){await e.value.load();return}}}async function Z2(r){return ya(!r)}let hs;function Ta(){if(typeof hs=="boolean")return hs;try{hs=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(r){hs=!1}return hs}function pf(r,t,e=2){const s=t&&t.length,i=s?t[0]*e:r.length;let n=ff(r,0,i,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,u;if(s&&(n=rw(r,t,n,e)),r.length>80*e){a=r[0],l=r[1];let h=a,c=l;for(let d=e;d<i;d+=e){const p=r[d],f=r[d+1];p<a&&(a=p),f<l&&(l=f),p>h&&(h=p),f>c&&(c=f)}u=Math.max(h-a,c-l),u=u!==0?32767/u:0}return cs(n,o,e,a,l,u,0),o}function ff(r,t,e,s,i){let n;if(i===Ea(r,t,e,s)>0)for(let o=t;o<e;o+=s)n=xf(o/s|0,r[o],r[o+1],n);else for(let o=e-s;o>=t;o-=s)n=xf(o/s|0,r[o],r[o+1],n);return n&&_r(n,n.next)&&(fs(n),n=n.next),n}function Ze(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(_r(e,e.next)||vt(e.prev,e,e.next)===0)){if(fs(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function cs(r,t,e,s,i,n,o){if(!r)return;!o&&n&&aw(r,s,i,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?J2(r,s,i,n):Q2(r)){t.push(l.i,r.i,u.i),fs(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=tw(Ze(r),t),cs(r,t,e,s,i,n,2)):o===2&&ew(r,t,e,s,i,n):cs(Ze(r),t,e,s,i,n,1);break}}}function Q2(r){const t=r.prev,e=r,s=r.next;if(vt(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&&ds(i,a,n,l,o,u,f.x,f.y)&&vt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function J2(r,t,e,s){const i=r.prev,n=r,o=r.next;if(vt(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),_=Sa(p,f,t,e,s),x=Sa(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&&ds(a,h,l,c,u,d,v.x,v.y)&&vt(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&&ds(a,h,l,c,u,d,b.x,b.y)&&vt(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&&ds(a,h,l,c,u,d,v.x,v.y)&&vt(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&&ds(a,h,l,c,u,d,b.x,b.y)&&vt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function tw(r,t){let e=r;do{const s=e.prev,i=e.next.next;!_r(s,i)&&gf(s,e,e.next,i)&&ps(s,i)&&ps(i,s)&&(t.push(s.i,e.i,i.i),fs(e),fs(e.next),e=r=i),e=e.next}while(e!==r);return Ze(e)}function ew(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&hw(o,a)){let l=_f(o,a);o=Ze(o,o.next),l=Ze(l,l.next),cs(o,t,e,s,i,n,0),cs(l,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function rw(r,t,e,s){const i=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*s,l=n<o-1?t[n+1]*s:r.length,u=ff(r,a,l,s,!1);u===u.next&&(u.steiner=!0),i.push(uw(u))}i.sort(sw);for(let n=0;n<i.length;n++)e=iw(i[n],e);return e}function sw(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const s=(r.next.y-r.y)/(r.next.x-r.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=s-i}return e}function iw(r,t){const e=nw(r,t);if(!e)return t;const s=_f(e,r);return Ze(s,s.next),Ze(e,e.next)}function nw(r,t){let e=t;const s=r.x,i=r.y;let n=-1/0,o;if(_r(r,e))return e;do{if(_r(r,e.next))return e.next;if(i<=e.y&&i>=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.next.x?e:e.next,c===s))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,u=o.y;let h=1/0;e=o;do{if(s>=e.x&&e.x>=l&&s!==e.x&&mf(i<u?s:n,i,l,u,i<u?n:s,i,e.x,e.y)){const c=Math.abs(i-e.y)/(s-e.x);ps(e,r)&&(c<h||c===h&&(e.x>o.x||e.x===o.x&&ow(o,e)))&&(o=e,h=c)}e=e.next}while(e!==a);return o}function ow(r,t){return vt(r.prev,r,t.prev)<0&&vt(t.next,r,r.next)<0}function aw(r,t,e,s){let i=r;do i.z===0&&(i.z=Sa(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,lw(i)}function lw(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;u<e&&(a++,o=o.nextZ,!!o);u++);let l=e;for(;a>0||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 Sa(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 uw(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function mf(r,t,e,s,i,n,o,a){return(i-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function ds(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&mf(r,t,e,s,i,n,o,a)}function hw(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!cw(r,t)&&(ps(r,t)&&ps(t,r)&&dw(r,t)&&(vt(r.prev,r,t.prev)||vt(r,t.prev,t))||_r(r,t)&&vt(r.prev,r,r.next)>0&&vt(t.prev,t,t.next)>0)}function vt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function _r(r,t){return r.x===t.x&&r.y===t.y}function gf(r,t,e,s){const i=Ti(vt(r,t,e)),n=Ti(vt(r,t,s)),o=Ti(vt(e,s,r)),a=Ti(vt(e,s,t));return!!(i!==n&&o!==a||i===0&&yi(r,e,t)||n===0&&yi(r,s,t)||o===0&&yi(e,r,s)||a===0&&yi(e,t,s))}function yi(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 Ti(r){return r>0?1:r<0?-1:0}function cw(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&&gf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function ps(r,t){return vt(r.prev,r,r.next)<0?vt(r,t,r.next)>=0&&vt(r,r.prev,t)>=0:vt(r,t,r.prev)<0||vt(r,r.next,t)<0}function dw(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 _f(r,t){const e=wa(r.i,r.x,r.y),s=wa(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 xf(r,t,e,s){const i=wa(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 fs(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 wa(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function jI(r,t,e,s){const i=t&&t.length,n=i?t[0]*e:r.length;let o=Math.abs(Ea(r,0,n,e));if(i)for(let l=0,u=t.length;l<u;l++){const h=t[l]*e,c=l<u-1?t[l+1]*e:r.length;o-=Math.abs(Ea(r,h,c,e))}let a=0;for(let l=0;l<s.length;l+=3){const u=s[l]*e,h=s[l+1]*e,c=s[l+2]*e;a+=Math.abs((r[u]-r[c])*(r[h+1]-r[u+1])-(r[u]-r[h])*(r[c+1]-r[u+1]))}return o===0&&a===0?0:Math.abs((a-o)/o)}function Ea(r,t,e,s){let i=0;for(let n=t,o=e-s;n<e;n+=s)i+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return i}function zI(r){const t=[],e=[],s=r[0][0].length;let i=0,n=0;for(const o of r){for(const a of o)for(let l=0;l<s;l++)t.push(a[l]);n&&(i+=n,e.push(i)),n=o.length}return{vertices:t,holes:e,dimensions:s}}const vf=pf.default||pf;var Wt=(r=>(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))(Wt||{});class Aa{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;c<d;c++)h[c][u](t,e,s,i,n,o,a,l);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}var pw=Object.defineProperty,bf=Object.getOwnPropertySymbols,fw=Object.prototype.hasOwnProperty,mw=Object.prototype.propertyIsEnumerable,yf=(r,t,e)=>t in r?pw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Si=(r,t)=>{for(var e in t||(t={}))fw.call(t,e)&&yf(r,e,t[e]);if(bf)for(var e of bf(t))mw.call(t,e)&&yf(r,e,t[e]);return r};const gw=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Tf=class aT extends Dt{constructor(t){var e;super(),this.tick=0,this.uid=ct("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=[...gw,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await ya(e),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=Si(Si({},i),t)}t=Si(Si({},aT.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){var s,i;this.tick++;let n=t;if(n instanceof pt&&(n={container:n},e&&(n.target=e.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,(s=n.clearColor)!=null||(n.clearColor=this.background.colorRgba),(i=n.clear)!=null||(n.clear=this.background.clearBeforeRender)),n.clearColor){const o=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=o?n.clearColor:rt.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.visible&&(n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n))}resize(t,e,s){const i=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==i&&this.runners.resolutionChange.emit(s)}clear(t={}){var e;const s=this;t.target||(t.target=s.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),(e=t.clear)!=null||(t.clear=Wt.ALL);const{clear:i,clearColor:n,target:o,mipLevel:a,layer:l}=t;rt.shared.setValue(n!=null?n:this.background.colorRgba),s.renderTarget.clear(o,i,rt.shared.toArray(),a!=null?a:0,l!=null?l:0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Aa(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)&&Xe.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(!Ta())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()}};Tf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let xr=Tf,Pa;function ms(r){return Pa!==void 0||(Pa=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:xr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!H.get().getWebGLRenderingContext())return!1;let s=H.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}})()),Pa}let Ca;async function gs(r={}){return Ca!==void 0||(Ca=await(async()=>{const t=H.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Ca}var _w=Object.defineProperty,Sf=Object.getOwnPropertySymbols,xw=Object.prototype.hasOwnProperty,vw=Object.prototype.propertyIsEnumerable,wf=(r,t,e)=>t in r?_w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vr=(r,t)=>{for(var e in t||(t={}))xw.call(t,e)&&wf(r,e,t[e]);if(Sf)for(var e of Sf(t))vw.call(t,e)&&wf(r,e,t[e]);return r};const Ef=["webgl","webgpu","canvas"];async function Af(r){var t;let e=[];r.preference?(e.push(r.preference),Ef.forEach(o=>{o!==r.preference&&e.push(o)})):e=Ef.slice();let s,i={};for(let o=0;o<e.length;o++){const a=e[o];if(a==="webgpu"&&await gs()){const{WebGPURenderer:l}=await Promise.resolve().then(function(){return _3});s=l,i=vr(vr({},r),r.webgpu);break}else if(a==="webgl"&&ms((t=r.failIfMajorPerformanceCaveat)!=null?t:xr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Promise.resolve().then(function(){return WO});s=l,i=vr(vr({},r),r.webgl);break}else if(a==="canvas"){const{CanvasRenderer:l}=await Promise.resolve().then(function(){return YM});s=l,i=vr(vr({},r),r.canvasOptions);break}}if(delete i.webgpu,delete i.webgl,delete i.canvasOptions,!s)throw new Error("No available renderer for the current environment");const n=new s;return await n.init(i),n}const bw=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,_s="8.17.0";class Ra{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,_s)}static destroy(){}}Ra.extension=S.Application;class Ma{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,_s)}destroy(){this._renderer=null}}Ma.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"initHook",priority:-10};class Oa{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,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}}Oa.extension=S.Application;class Ga{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,_e.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()}}}Ga.extension=S.Application,N.add(Oa),N.add(Ga);var yw=Object.defineProperty,Pf=Object.getOwnPropertySymbols,Tw=Object.prototype.hasOwnProperty,Sw=Object.prototype.propertyIsEnumerable,Cf=(r,t,e)=>t in r?yw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ww=(r,t)=>{for(var e in t||(t={}))Tw.call(t,e)&&Cf(r,e,t[e]);if(Pf)for(var e of Pf(t))Sw.call(t,e)&&Cf(r,e,t[e]);return r};const Rf=class pc{constructor(...t){this.stage=new pt}async init(t){t=ww({},t),this.stage||(this.stage=new pt),this.renderer=await Af(t),pc._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}destroy(t=!1,e=!1){const s=pc._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}};Rf._plugins=[];let Mf=Rf;N.handleByList(S.Application,Mf._plugins),N.add(Ra);const wi={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],T=v[1].replace(/"/gm,""),y=parseFloat(T),w=isNaN(y)?T: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<h.length;f++)o.pages.push({id:parseInt(h[f].id,10)||0,file:h[f].file});const c={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const d=n.char;for(let f=0;f<d.length;f++){const m=d[f],g=parseInt(m.id,10);let _=(s=(e=m.letter)!=null?e:m.char)!=null?s:String.fromCharCode(g);_==="space"&&(_=" "),c[g]=_,o.chars[_]={id:g,page:parseInt(m.page,10)||0,x:parseInt(m.x,10),y:parseInt(m.y,10),width:parseInt(m.width,10),height:parseInt(m.height,10),xOffset:parseInt(m.xoffset,10),yOffset:parseInt(m.yoffset,10),xAdvance:parseInt(m.xadvance,10),kerning:{}}}const p=n.kerning||[];for(let f=0;f<p.length;f++){const m=parseInt(p[f].first,10),g=parseInt(p[f].second,10),_=parseInt(p[f].amount,10);o.chars[c[g]]&&(o.chars[c[g]].kerning[c[m]]=_)}return o}},Ia={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){var t,e;const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},i=r.getElementsByTagName("info")[0],n=r.getElementsByTagName("common")[0],o=r.getElementsByTagName("distanceField")[0];o&&(s.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=r.getElementsByTagName("page"),l=r.getElementsByTagName("char"),u=r.getElementsByTagName("kerning");s.fontSize=parseInt(i.getAttribute("size"),10),s.fontFamily=i.getAttribute("face"),s.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let c=0;c<a.length;c++)s.pages.push({id:parseInt(a[c].getAttribute("id"),10)||0,file:a[c].getAttribute("file")});const h={};s.baseLineOffset=s.lineHeight-parseInt(n.getAttribute("base"),10);for(let c=0;c<l.length;c++){const d=l[c],p=parseInt(d.getAttribute("id"),10);let f=(e=(t=d.getAttribute("letter"))!=null?t:d.getAttribute("char"))!=null?e:String.fromCharCode(p);f==="space"&&(f=" "),h[p]=f,s.chars[f]={id:p,page:parseInt(d.getAttribute("page"),10)||0,x:parseInt(d.getAttribute("x"),10),y:parseInt(d.getAttribute("y"),10),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10),xOffset:parseInt(d.getAttribute("xoffset"),10),yOffset:parseInt(d.getAttribute("yoffset"),10),xAdvance:parseInt(d.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<u.length;c++){const d=parseInt(u[c].getAttribute("first"),10),p=parseInt(u[c].getAttribute("second"),10),f=parseInt(u[c].getAttribute("amount"),10);s.chars[h[p]]&&(s.chars[h[p]].kerning[h[d]]=f)}return s}},Ba={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Ia.test(H.get().parseXML(r)):!1},parse(r){return Ia.parse(H.get().parseXML(r))}},Ew=[".xml",".fnt"],Of={extension:{type:S.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}},Gf={extension:{type:S.LoadParser,priority:Zt.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return Ew.includes(Xt.extname(r).toLowerCase())},async testParse(r){return wi.test(r)||Ba.test(r)},async parse(r,t,e){const s=wi.test(r)?wi.parse(r):Ba.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;c<n.length;++c){const d=n[c].file;let p=Xt.join(Xt.dirname(i),d);p=ci(p,i),o.push({src:p,data:a})}const[l,{BitmapFont:u}]=await Promise.all([e.load(o),Promise.resolve().then(function(){return JG})]),h=o.map(c=>l[c.src]);return new u({data:s,textures:h},i)},async load(r,t){return await(await H.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 If{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;s<e;s++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Bf={extension:{type:S.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof F),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function Fa(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 Ff={extension:{type:S.DetectionParser,priority:1},test:async()=>Fa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Df=["png","jpg","jpeg"],Uf={extension:{type:S.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Df],remove:async r=>r.filter(t=>!Df.includes(t))},Aw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function xs(r){return Aw?!1:document.createElement("video").canPlayType(r)!==""}const kf={extension:{type:S.DetectionParser,priority:0},test:async()=>xs("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},$f={extension:{type:S.DetectionParser,priority:0},test:async()=>xs("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Lf={extension:{type:S.DetectionParser,priority:0},test:async()=>xs("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Nf={extension:{type:S.DetectionParser,priority:0},test:async()=>Fa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var Pw=Object.defineProperty,Cw=Object.defineProperties,Rw=Object.getOwnPropertyDescriptors,Xf=Object.getOwnPropertySymbols,Mw=Object.prototype.hasOwnProperty,Ow=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?Pw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,br=(r,t)=>{for(var e in t||(t={}))Mw.call(t,e)&&Hf(r,e,t[e]);if(Xf)for(var e of Xf(t))Ow.call(t,e)&&Hf(r,e,t[e]);return r},Gw=(r,t)=>Cw(r,Rw(t));const jf=class io{constructor(){this.loadOptions=br({},io.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<this.parsers.length;l++){const u=this.parsers[l];if(u.load&&(i=u.test)!=null&&i.call(u,t,e,this)){a=u;break}}if(!a)return null}o=await a.load(t,e,this),s.parser=a;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];u.parse&&u.parse&&await((n=u.testParse)==null?void 0:n.call(u,o,e,this))&&(o=await u.parse(o,e,this)||o,s.parser=u)}return o})(),s}async load(t,e){this._parsersValidated||this._validateParsers();const s=typeof e=="function"?Gw(br(br({},io.defaultOptions),this.loadOptions),{onProgress:e}):br(br(br({},io.defaultOptions),this.loadOptions),e||{}),{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l}=s;let u=0;const h={},c=is(t),d=se(t,m=>({alias:[m],src:m,data:{}})),p=d.reduce((m,g)=>m+(g.progressSize||1),0),f=d.map(async m=>{const g=Xt.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=se(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=Xt.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}}};jf.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let zf=jf;function Qe(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 ie(r,t){const e=r.split("?")[0],s=Xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Iw=".json",Bw="application/json",Wf={extension:{type:S.LoadParser,priority:Zt.Low},name:"loadJson",id:"json",test(r){return Qe(r,Bw)||ie(r,Iw)},async load(r){return await(await H.get().fetch(r)).json()}},Fw=".txt",Dw="text/plain",Vf={name:"loadTxt",id:"text",extension:{type:S.LoadParser,priority:Zt.Low,name:"loadTxt"},test(r){return Qe(r,Dw)||ie(r,Fw)},async load(r){return await(await H.get().fetch(r)).text()}};var Uw=Object.defineProperty,kw=Object.defineProperties,$w=Object.getOwnPropertyDescriptors,Yf=Object.getOwnPropertySymbols,Lw=Object.prototype.hasOwnProperty,Nw=Object.prototype.propertyIsEnumerable,Kf=(r,t,e)=>t in r?Uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xw=(r,t)=>{for(var e in t||(t={}))Lw.call(t,e)&&Kf(r,e,t[e]);if(Yf)for(var e of Yf(t))Nw.call(t,e)&&Kf(r,e,t[e]);return r},Hw=(r,t)=>kw(r,$w(t));const jw=["normal","bold","100","200","300","400","500","600","700","800","900"],zw=[".ttf",".otf",".woff",".woff2"],Ww=["font/ttf","font/otf","font/woff","font/woff2"],Vw=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function qf(r){const t=Xt.extname(r),e=Xt.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(Vw)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const Yw=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kw(r){return Yw.test(r)?r:encodeURI(r)}const Zf={extension:{type:S.LoadParser,priority:Zt.Low},name:"loadWebFont",id:"web-font",test(r){return Qe(r,Ww)||ie(r,zw)},async load(r,t){var e,s,i,n,o,a;const l=H.get().getFontFaceSet();if(l){const u=[],h=(s=(e=t.data)==null?void 0:e.family)!=null?s:qf(r),c=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>jw.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;p<c.length;p++){const f=c[p],m=new FontFace(h,`url('${Kw(r)}')`,Hw(Xw({},d),{weight:f}));await m.load(),l.add(m),u.push(m)}return st.has(`${h}-and-url`)?st.get(`${h}-and-url`).entries.push({url:r,faces:u}):st.set(`${h}-and-url`,{entries:[{url:r,faces:u}]}),u.length===1?u[0]:u}return null},unload(r){const t=Array.isArray(r)?r:[r],e=t[0].family,s=st.get(`${e}-and-url`),i=s.entries.find(n=>n.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=>{H.get().getFontFaceSet().delete(n)}),s.entries.length===0&&st.remove(`${e}-and-url`)}};var Da,Qf;function qw(){if(Qf)return Da;Qf=1,Da=e;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(n){var o=[];return n.replace(t,function(a,l,u){var h=l.toLowerCase();for(u=i(u),h=="m"&&u.length>2&&(o.push([l].concat(u.splice(0,2))),h="l",l=l=="m"?"l":"L");;){if(u.length==r[h])return u.unshift(l),o.push(u);if(u.length<r[h])throw new Error("malformed path data");o.push([l].concat(u.splice(0,r[h])))}}),o}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function i(n){var o=n.match(s);return o?o.map(Number):[]}return Da}var Zw=qw(),Qw=Fc(Zw);function Jf(r,t){const e=Qw(r),s=[];let i=null,n=0,o=0;for(let a=0;a<e.length;a++){const l=e[a],u=l[0],h=l;switch(u){case"M":n=h[1],o=h[2],t.moveTo(n,o);break;case"m":n+=h[1],o+=h[2],t.moveTo(n,o);break;case"H":n=h[1],t.lineTo(n,o);break;case"h":n+=h[1],t.lineTo(n,o);break;case"V":o=h[1],t.lineTo(n,o);break;case"v":o+=h[1],t.lineTo(n,o);break;case"L":n=h[1],o=h[2],t.lineTo(n,o);break;case"l":n+=h[1],o+=h[2],t.lineTo(n,o);break;case"C":n=h[5],o=h[6],t.bezierCurveTo(h[1],h[2],h[3],h[4],n,o);break;case"c":t.bezierCurveTo(n+h[1],o+h[2],n+h[3],o+h[4],n+h[5],o+h[6]),n+=h[5],o+=h[6];break;case"S":n=h[3],o=h[4],t.bezierCurveToShort(h[1],h[2],n,o);break;case"s":t.bezierCurveToShort(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"Q":n=h[3],o=h[4],t.quadraticCurveTo(h[1],h[2],n,o);break;case"q":t.quadraticCurveTo(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"T":n=h[1],o=h[2],t.quadraticCurveToShort(n,o);break;case"t":n+=h[1],o+=h[2],t.quadraticCurveToShort(n,o);break;case"A":n=h[6],o=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"a":n+=h[6],o+=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"Z":case"z":t.closePath(),s.length>0&&(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 tm={};function Ei(r,t,e){let s=2166136261;for(let i=0;i<t;i++)s^=r[i].uid,s=Math.imul(s,16777619),s>>>=0;return tm[s]||Jw(r,t,s,e)}function Jw(r,t,e,s){const i={};let n=0;for(let a=0;a<s;a++){const l=a<t?r[a]:F.EMPTY.source;i[n++]=l.source,i[n++]=l.style}const o=new be(i);return tm[e]=o,o}class Je{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const em=new Set,Ua="8.0.0",tE="8.3.4",yr={quiet:!1,noColor:!1},vs=((r,t,e=3)=>{if(yr.quiet||em.has(t))return;let s=new Error().stack;const i=`${t}
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!yr.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))),em.add(t)});Object.defineProperties(vs,{quiet:{get:()=>yr.quiet,set:r=>{yr.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>yr.noColor,set:r=>{yr.noColor=r},enumerable:!0,configurable:!1}});function Ai(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 rm={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Tt=(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))(Tt||{});function Tr(r,t){return t.alphaMode==="no-premultiply-alpha"&&rm[r]||r}const eE=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function rE(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function ka(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=eE.replace(/%forloop%/gi,rE(r));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let Sr=null;function sm(){var r;if(Sr)return Sr;const t=ia();return Sr=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Sr=ka(Sr,t),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),Sr}class im{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}var sE=Object.defineProperty,nm=Object.getOwnPropertySymbols,iE=Object.prototype.hasOwnProperty,nE=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?sE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,am=(r,t)=>{for(var e in t||(t={}))iE.call(t,e)&&om(r,e,t[e]);if(nm)for(var e of nm(t))nE.call(t,e)&&om(r,e,t[e]);return r};class lm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new im,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 bs=[];let Pi=0;Xe.register({clear:()=>{if(bs.length>0)for(const r of bs)r&&r.destroy();bs.length=0,Pi=0}});function um(){return Pi>0?bs[--Pi]:new lm}function hm(r){r.elements=null,bs[Pi++]=r}let ys=0;const cm=class lT{constructor(t){this.uid=ct("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=am(am({},lT.defaultOptions),t),t.maxTextures||(vs("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=sm());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new Je(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;t<this.batchIndex;t++)hm(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=um(),i=s.textures;i.clear();const n=e[this.elementStart];let o=Tr(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.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<this.elementSize;++g){const _=e[g];e[g]=null;const x=_.texture._source,v=Tr(_.blendMode,x),b=o!==v||a!==_.topology;if(x._batchTick===ys&&!b){_._textureId=x._textureBindLocation,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)),_._batch=s,f.push(_);continue}x._batchTick=ys,(i.count>=m||b)&&(this._finishBatch(s,d,c-d,i,o,a,t,p,f),p="renderBatch",d=c,o=v,a=_.topology,s=um(),i=s.textures,i.clear(),f=[],++ys),_._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,++ys),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,++ys,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 Je(e);Ai(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;n<e.length;n++)i[n]=e[n];else Ai(e.buffer,i.buffer);this.indexBuffer=i}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,i){const n=t.indices,o=t.indexSize,a=t.indexOffset,l=t.attributeOffset;for(let u=0;u<o;u++)e[s++]=i+n[u+a]-l}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)hm(this.batches[s]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let s=0;s<this._elements.length;s++)this._elements[s]&&(this._elements[s]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};cm.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let dm=cm;const oE=new Float32Array(1),aE=new Uint32Array(1);class pm extends qe{constructor(){const t=new zt({data:oE,label:"attribute-batch-buffer",usage:ot.VERTEX|ot.COPY_DST,shrinkToFit:!1}),e=new zt({data:aE,label:"index-batch-buffer",usage:ot.INDEX|ot.COPY_DST,shrinkToFit:!1}),s=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:20}},indexBuffer:e})}}function $a(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const lE=/\{\{(.*?)\}\}/g;function La(r){var t,e;const s={};return((e=(t=r.match(lE))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function fm(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Na(r,t,e=!1){const s=[];fm(t,s),r.forEach(a=>{a.header&&fm(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 mm(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function uE(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function hE(r){const t=/@.*?\s+/g;return r.replace(t,"")}function gm(r,t){const e=[];mm(t,e),r.forEach(l=>{l.header&&mm(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 ${hE(l)};`).join(`
`),o=`return VSOutput(
            ${e.sort().map(l=>` ${uE(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 Xa(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 tr=Object.create(null),Ha=new Map;let cE=0;function _m({template:r,bits:t}){const e=vm(r,t);if(tr[e])return tr[e];const{vertex:s,fragment:i}=dE(r,t);return tr[e]=bm(s,i,t),tr[e]}function xm({template:r,bits:t}){const e=vm(r,t);return tr[e]||(tr[e]=bm(r.vertex,r.fragment,t)),tr[e]}function dE(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=Na(e,r.vertex,!0);i=gm(e,i);const n=Na(s,r.fragment,!0);return{vertex:i,fragment:n}}function vm(r,t){return t.map(e=>(Ha.has(e)||Ha.set(e,cE++),Ha.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function bm(r,t,e){const s=La(r),i=La(t);return e.forEach(n=>{$a(n.vertex,s,n.name),$a(n.fragment,i,n.name)}),{vertex:Xa(r,s),fragment:Xa(t,i)}}const ym=`
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            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<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);

        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`,Tm=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;

    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {

        {{start}}

        var outColor:vec4<f32>;

        {{main}}

        var finalColor:vec4<f32> = outColor * vColor;

        {{end}}

        return finalColor;
      };
`,Sm=`
    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}}
    }
`,wm=`

    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {

        {{start}}

        vec4 outColor;

        {{main}}

        finalColor = outColor * vColor;

        {{end}}
    }
`,Em={name:"global-uniforms-bit",vertex:{header:`
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `}},pE={name:"global-uniforms-ubo-bit",vertex:{header:`
          uniform globalUniforms {
            mat3 uProjectionMatrix;
            mat3 uWorldTransformMatrix;
            vec4 uWorldColorAlpha;
            vec2 uResolution;
          };
        `}},Am={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}};var fE=Object.defineProperty,Pm=Object.getOwnPropertySymbols,mE=Object.prototype.hasOwnProperty,gE=Object.prototype.propertyIsEnumerable,Cm=(r,t,e)=>t in r?fE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_E=(r,t)=>{for(var e in t||(t={}))mE.call(t,e)&&Cm(r,e,t[e]);if(Pm)for(var e of Pm(t))gE.call(t,e)&&Cm(r,e,t[e]);return r};function wr({bits:r,name:t}){const e=_m({template:{fragment:Tm,vertex:ym},bits:[Em,...r]});return Nt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Er({bits:r,name:t}){return new Ht(_E({name:t},xm({template:{vertex:Sm,fragment:wm},bits:[Am,...r]})))}const Ci={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},Ri={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}},ja={};function xE(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<r;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
`)}function vE(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<r;e++)e===r-1?t.push("  default:{"):t.push(`  case ${e}:{`),t.push(`      outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push("      break;}");t.push("}")}return t.join(`
`)}function Mi(r){return ja[r]||(ja[r]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;

                ${xE(r)}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);

                ${vE(r)}
            `}}),ja[r]}const za={};function bE(r){const t=[];for(let e=0;e<r;e++)e>0&&t.push("else"),e<r-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(`	outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Oi(r){return za[r]||(za[r]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;

            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;

                uniform sampler2D uTextures[${r}];

            `,main:`

                ${bE(r)}
            `}}),za[r]}const Ar={name:"round-pixels-bit",vertex:{header:`
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},Pr={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;
            }
        `}},Rm={};function Gi(r){let t=Rm[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s<r;s++)e[s]=s;return t=Rm[r]=new At({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}class Wa extends Jt{constructor(t){const e=Er({name:"batch",bits:[Ri,Oi(t),Pr]}),s=wr({name:"batch",bits:[Ci,Mi(t),Ar]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Gi(t)}}),this.maxTextures=t}}let Ts=null;const Mm=class uT extends dm{constructor(t){super(t),this.geometry=new pm,this.name=uT.extension.name,this.vertexSize=6,Ts!=null||(Ts=new Wa(t.maxTextures)),this.shader=Ts}packAttributes(t,e,s,i,n){const o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,u=a.b,h=a.c,c=a.d,d=a.tx,p=a.ty,{positions:f,uvs:m}=t,g=t.color,_=t.attributeOffset,x=_+t.attributeSize;for(let v=_;v<x;v++){const b=v*2,T=f[b],y=f[b+1];e[i++]=l*T+h*y+d,e[i++]=c*y+u*T+p,e[i++]=m[b],e[i++]=m[b+1],s[i++]=g,s[i++]=o}}packQuadAttributes(t,e,s,i,n){const o=t.texture,a=t.transform,l=a.a,u=a.b,h=a.c,c=a.d,d=a.tx,p=a.ty,f=t.bounds,m=f.maxX,g=f.minX,_=f.maxY,x=f.minY,v=o.uvs,b=t.color,T=n<<16|t.roundPixels&65535;e[i+0]=l*g+h*x+d,e[i+1]=c*x+u*g+p,e[i+2]=v.x0,e[i+3]=v.y0,s[i+4]=b,s[i+5]=T,e[i+6]=l*m+h*x+d,e[i+7]=c*x+u*m+p,e[i+8]=v.x1,e[i+9]=v.y1,s[i+10]=b,s[i+11]=T,e[i+12]=l*m+h*_+d,e[i+13]=c*_+u*m+p,e[i+14]=v.x2,e[i+15]=v.y2,s[i+16]=b,s[i+17]=T,e[i+18]=l*g+h*_+d,e[i+19]=c*_+u*g+p,e[i+20]=v.x3,e[i+21]=v.y3,s[i+22]=b,s[i+23]=T}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Ts=new Wa(t),this.shader=Ts)}destroy(){this.shader=null,super.destroy()}};Mm.extension={type:[S.Batcher],name:"default"};let Ii=Mm;class Bt{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:i,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,n!=null?n:0),this._onUnload=i,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){var s;if(!this.items[t.uid])return;const i=t._gpuData[this._renderer.uid];i&&((s=this._onUnload)==null||s.call(this,t,...e),i.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function Va(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<o;){const m=r[e],g=r[e+1];s[i]=u*m+c*g+p,s[i+1]=h*m+d*g+f,i+=n,e+=t,l++}}function Ya(r,t,e,s){let i=0;for(t*=e;i<s;)r[t]=0,r[t+1]=0,t+=e,i++}function Bi(r,t,e,s,i){const n=t.a,o=t.b,a=t.c,l=t.d,u=t.tx,h=t.ty;e||(e=0),s||(s=2),i||(i=r.length/s-e);let c=e*s;for(let d=0;d<i;d++){const p=r[c],f=r[c+1];r[c]=n*p+a*f+u,r[c+1]=o*p+l*f+h,c+=s}}const yE=new D;class Fi{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Ae(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)||yE}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 TE=Object.defineProperty,SE=Object.defineProperties,wE=Object.getOwnPropertyDescriptors,Om=Object.getOwnPropertySymbols,EE=Object.prototype.hasOwnProperty,AE=Object.prototype.propertyIsEnumerable,Gm=(r,t,e)=>t in r?TE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Di=(r,t)=>{for(var e in t||(t={}))EE.call(t,e)&&Gm(r,e,t[e]);if(Om)for(var e of Om(t))AE.call(t,e)&&Gm(r,e,t[e]);return r},Ui=(r,t)=>SE(r,wE(t));const Cr={extension:{type:S.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,T=b.width/2,y=b.height/2;e=b.x+T,s=b.y+y,o=a=Math.max(0,Math.min(b.radius,Math.min(T,y))),i=T-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;b<l;b++){const T=Math.PI/2*(b/l),y=i+Math.cos(T)*o,w=n+Math.sin(T)*a,A=e+y,R=e-y,C=s+w,E=s-w;t[h++]=A,t[h++]=C,t[--c]=C,t[--c]=R,t[d++]=R,t[d++]=E,t[--p]=E,t[--p]=A}f=i,m=n+a,g=e+f,_=e-f,x=s+m;const v=s-m;return t[h++]=g,t[h++]=x,t[--p]=v,t[--p]=g,i&&(t[h++]=_,t[h++]=x,t[--p]=v,t[--p]=_),!0},triangulate(r,t,e,s,i,n){if(r.length===0)return;let o=0,a=0;for(let h=0;h<r.length;h+=2)o+=r[h],a+=r[h+1];o/=r.length/2,a/=r.length/2;let l=s;t[l*e]=o,t[l*e+1]=a;const u=l++;for(let h=0;h<r.length;h+=2)t[l*e]=r[h],t[l*e+1]=r[h+1],h>0&&(i[n++]=l,i[n++]=u,i[n++]=l-1),l++;i[n++]=u+1,i[n++]=u,i[n++]=l-1}},Im=Ui(Di({},Cr),{extension:Ui(Di({},Cr.extension),{name:"ellipse"})}),Bm=Ui(Di({},Cr),{extension:Ui(Di({},Cr.extension),{name:"roundedRectangle"})}),Ka=1e-4,qa=1e-4;function Fm(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];s<t;s+=2){const o=r[s],a=r[s+1];e+=(o-i)*(a+n),i=o,n=a}return e<0?-1:1}function Dm(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 er(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&&h<c?h+=Math.PI*2:!a&&h>c&&(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<g;x++,v+=_)o.push(r,t),o.push(r+Math.sin(v)*m,t+Math.cos(v)*m);o.push(r,t),o.push(i,n)}else{o.push(e,s),o.push(r,t);for(let x=1,v=d;x<g;x++,v+=_)o.push(r+Math.sin(v)*m,t+Math.cos(v)*m),o.push(r,t);o.push(i,n),o.push(r,t)}return g*2}function Za(r,t,e,s,i,n){const o=Ka;if(r.length===0)return;const a=t;let l=a.alignment;if(t.alignment!==.5){let k=Fm(r);e&&(k*=-1),l=(l-.5)*k+.5}const u=new lt(r[0],r[1]),h=new lt(r[r.length-2],r[r.length-1]),c=s,d=Math.abs(u.x-h.x)<o&&Math.abs(u.y-h.y)<o;if(c){r=r.slice(),d&&(r.pop(),r.pop(),h.set(r[r.length-2],r[r.length-1]));const k=(u.x+h.x)*.5,K=(h.y+u.y)*.5;r.unshift(k,K),r.push(k,K)}const p=i,f=r.length/2;let m=r.length;const g=p.length/2,_=a.width/2,x=_*_,v=a.miterLimit*a.miterLimit;let b=r[0],T=r[1],y=r[2],w=r[3],A=0,R=0,C=-(T-w),E=b-y,G=0,I=0,M=Math.sqrt(C*C+E*E);C/=M,E/=M,C*=_,E*=_;const B=l,P=(1-B)*2,O=B*2;c||(a.cap==="round"?m+=er(b-C*(P-O)*.5,T-E*(P-O)*.5,b-C*P,T-E*P,b+C*O,T+E*O,p,!0)+2:a.cap==="square"&&(m+=Dm(b,T,C,E,P,O,!0,p))),p.push(b-C*P,T-E*P),p.push(b+C*O,T+E*O);for(let k=1;k<f-1;++k){b=r[(k-1)*2],T=r[(k-1)*2+1],y=r[k*2],w=r[k*2+1],A=r[(k+1)*2],R=r[(k+1)*2+1],C=-(T-w),E=b-y,M=Math.sqrt(C*C+E*E),C/=M,E/=M,C*=_,E*=_,G=-(w-R),I=y-A,M=Math.sqrt(G*G+I*I),G/=M,I/=M,G*=_,I*=_;const K=y-b,X=T-w,W=y-A,U=R-w,L=K*W+X*U,$=X*W-U*K,Z=$<0;if(Math.abs($)<.001*Math.abs(L)){p.push(y-C*P,w-E*P),p.push(y+C*O,w+E*O),L>=0&&(a.join==="round"?m+=er(y,w,y-C*P,w-E*P,y-G*P,w-I*P,p,!1)+4:m+=2,p.push(y-G*O,w-I*O),p.push(y+G*P,w+I*P));continue}const ht=(-C+b)*(-E+w)-(-C+y)*(-E+T),J=(-G+A)*(-I+w)-(-G+y)*(-I+R),tt=(K*J-W*ht)/$,it=(U*ht-X*J)/$,nt=(tt-y)*(tt-y)+(it-w)*(it-w),et=y+(tt-y)*P,gt=w+(it-w)*P,dt=y-(tt-y)*O,z=w-(it-w)*O,Pt=Math.min(K*K+X*X,W*W+U*U),wt=Z?P:O,te=Pt+wt*wt*x;nt<=te?a.join==="bevel"||nt/x>v?(Z?(p.push(et,gt),p.push(y+C*O,w+E*O),p.push(et,gt),p.push(y+G*O,w+I*O)):(p.push(y-C*P,w-E*P),p.push(dt,z),p.push(y-G*P,w-I*P),p.push(dt,z)),m+=2):a.join==="round"?Z?(p.push(et,gt),p.push(y+C*O,w+E*O),m+=er(y,w,y+C*O,w+E*O,y+G*O,w+I*O,p,!0)+4,p.push(et,gt),p.push(y+G*O,w+I*O)):(p.push(y-C*P,w-E*P),p.push(dt,z),m+=er(y,w,y-C*P,w-E*P,y-G*P,w-I*P,p,!1)+4,p.push(y-G*P,w-I*P),p.push(dt,z)):(p.push(et,gt),p.push(dt,z)):(p.push(y-C*P,w-E*P),p.push(y+C*O,w+E*O),a.join==="round"?Z?m+=er(y,w,y+C*O,w+E*O,y+G*O,w+I*O,p,!0)+2:m+=er(y,w,y-C*P,w-E*P,y-G*P,w-I*P,p,!1)+2:a.join==="miter"&&nt/x<=v&&(Z?(p.push(dt,z),p.push(dt,z)):(p.push(et,gt),p.push(et,gt)),m+=2),p.push(y-G*P,w-I*P),p.push(y+G*O,w+I*O),m+=2)}b=r[(f-2)*2],T=r[(f-2)*2+1],y=r[(f-1)*2],w=r[(f-1)*2+1],C=-(T-w),E=b-y,M=Math.sqrt(C*C+E*E),C/=M,E/=M,C*=_,E*=_,p.push(y-C*P,w-E*P),p.push(y+C*O,w+E*O),c||(a.cap==="round"?m+=er(y-C*(P-O)*.5,w-E*(P-O)*.5,y-C*P,w-E*P,y+C*O,w+E*O,p,!1)+2:a.cap==="square"&&(m+=Dm(y,w,C,E,P,O,!1,p)));const q=qa*qa;for(let k=g;k<m+g-2;++k)b=p[k*2],T=p[k*2+1],y=p[(k+1)*2],w=p[(k+1)*2+1],A=p[(k+2)*2],R=p[(k+2)*2+1],!(Math.abs(b*(w-R)+y*(R-T)+A*(T-w))<q)&&n.push(k,k+1,k+2)}function Um(r,t,e,s){const i=Ka;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],u=t||Math.abs(n-a)<i&&Math.abs(o-l)<i,h=e,c=r.length/2,d=h.length/2;for(let p=0;p<c;p++)h.push(r[p*2]),h.push(r[p*2+1]);for(let p=0;p<c-1;p++)s.push(d+p,d+p+1);u&&s.push(d+c-1,d)}function Qa(r,t,e,s,i,n,o){const a=vf(r,t,2);if(!a)return;for(let u=0;u<a.length;u+=3)n[o++]=a[u]+i,n[o++]=a[u+1]+i,n[o++]=a[u+2]+i;let l=i*s;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=s}const PE=[],km={extension:{type:S.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,s,i,n){Qa(r,PE,t,e,s,i,n)}},$m={extension:{type:S.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,s=e.x,i=e.y,n=e.width,o=e.height;return n>0&&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}},Lm={extension:{type:S.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 CE=Object.defineProperty,Nm=Object.getOwnPropertySymbols,RE=Object.prototype.hasOwnProperty,ME=Object.prototype.propertyIsEnumerable,Xm=(r,t,e)=>t in r?CE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hm=(r,t)=>{for(var e in t||(t={}))RE.call(t,e)&&Xm(r,e,t[e]);if(Nm)for(var e of Nm(t))ME.call(t,e)&&Xm(r,e,t[e]);return r};const jm=[{offset:0,color:"white"},{offset:1,color:"black"}],Ja=class fc{constructor(...t){this.uid=ct("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let s=OE(t);const i=s.type==="radial"?fc.defaultRadialOptions:fc.defaultLinearOptions;s=Hm(Hm({},i),oe(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:rt.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:jm,u=this._textureSize,{canvas:h,context:c}=Wm(u,1),d=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);zm(d,l),c.fillStyle=d,c.fillRect(0,0,u,1),this.texture=new F({source:new Ie({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:jm,e=this._textureSize,{canvas:s,context:i}=Wm(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);zm(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 F({source:new Ie({resource:s,addressMode:this._wrapMode})});const _=new D;_.scale(1/p,1/p),_.translate(c,d),this.textureSpace==="local"&&_.scale(e,e),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}`}};Ja.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Ja.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Ut=Ja;function zm(r,t){for(let e=0;e<t.length;e++){const s=t[e];r.addColorStop(s.offset,s.color)}}function Wm(r,t){const e=H.get().createCanvas(r,t),s=e.getContext("2d");return{canvas:e,context:s}}function OE(r){var t,e;let s=(t=r[0])!=null?t:{};return(typeof s=="number"||r[1])&&(s={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:(e=r[5])!=null?e:Ut.defaultLinearOptions.textureSize}),s}const GE=new D,IE=new ut;function tl(r,t,e,s){const i=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const o=e.getBounds(IE);t.width&&o.pad(t.width);const{x:a,y:l}=o,u=1/o.width,h=1/o.height,c=-a*u,d=-l*h,p=i.a,f=i.b,m=i.c,g=i.d;i.a*=u,i.b*=u,i.c*=h,i.d*=h,i.tx=c*p+d*m+i.tx,i.ty=c*f+d*g+i.ty}else i.translate(t.texture.frame.x,t.texture.frame.y),i.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof Ut)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&i.append(GE.copyFrom(s).invert()),i}const rr={};N.handleByMap(S.ShapeBuilder,rr),N.add($m,km,Lm,Cr,Im,Bm);const BE=new ut,FE=new D;function Vm(r,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i<r.instructions.length;i++){const n=r.instructions[i];if(n.action==="texture")DE(n.data,s,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,u=n.data.hole;o&&u&&Ym(u.shapePath,l,!0,s,e),u&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),Ym(a,l,o,s,e)}}}function DE(r,t,e){const s=[],i=rr.rectangle,n=BE;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!i.build(n,s))return;const{vertices:a,uvs:l,indices:u}=e,h=u.length,c=a.length/2;o&&Bi(s,o),i.triangulate(s,a,2,c,u,h);const d=r.image,p=d.uvs;l.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const f=Et.get(Fi);f.indexOffset=h,f.indexSize=u.length-h,f.attributeOffset=c,f.attributeSize=a.length/2-c,f.baseColor=r.style,f.alpha=r.alpha,f.texture=d,f.geometryData=e,t.push(f)}function Ym(r,t,e,s,i){const{vertices:n,uvs:o,indices:a}=i;r.shapePrimitives.forEach(({shape:l,transform:u,holes:h})=>{var c;const d=[],p=rr[l.type];if(!p.build(l,d))return;const f=a.length,m=n.length/2;let g="triangle-list";if(u&&Bi(d,u),e){const b=(c=l.closePath)!=null?c:!0,T=t;T.pixelLine?(Um(d,b,n,a),g="line-list"):Za(d,T,!1,b,n,a)}else if(h){const b=[],T=d.slice();UE(h).forEach(y=>{b.push(T.length/2),T.push(...y)}),Qa(T,b,n,2,m,a,f)}else p.triangulate(d,n,2,m,a,f);const _=o.length/2,x=t.texture;if(x!==F.WHITE){const b=tl(FE,t,l,u);Va(n,2,m,o,_,2,n.length/2-m,b)}else Ya(o,_,2,n.length/2-m);const v=Et.get(Fi);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 UE(r){const t=[];for(let e=0;e<r.length;e++){const s=r[e].shape,i=[];rr[s.type].build(s,i)&&t.push(i)}return t}class Km{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{Et.return(t)}),this.graphicsData&&Et.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 qm{constructor(){this.instructions=new ri}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Ii({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 el=class mc{constructor(t){this._renderer=t,this._managedContexts=new Bt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;mc.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:mc.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(),Vm(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=Et.get(qm,{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;c<i.length;c++)i[c].applyTransform=!1;const l=e.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let c=0;c<i.length;c++){const d=i[c];l.add(d)}l.finish(e.instructions);const u=l.geometry;u.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),u.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const h=l.batches;for(let c=0;c<h.length;c++){const d=h[c];d.bindGroup=Ei(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Km;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};el.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"graphicsContext"},el.defaultOptions={bezierSmoothness:.5};let ki=el;const kE=8,$i=11920929e-14,$E=1,rl=.01,Rr=0,sr=0;function sl(r,t,e,s,i,n,o,a,l,u){const h=Math.min(.99,Math.max(0,u!=null?u:ki.defaultOptions.bezierSmoothness));let c=($E-h)/1;return c*=c,LE(t,e,s,i,n,o,a,l,r,c),r}function LE(r,t,e,s,i,n,o,a,l,u){il(r,t,e,s,i,n,o,a,l,u,0),l.push(o,a)}function il(r,t,e,s,i,n,o,a,l,u,h){if(h>kE)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,T=(m+_)/2,y=(x+b)/2,w=(v+T)/2;if(h>0){let A=o-r,R=a-t;const C=Math.abs((e-o)*R-(s-a)*A),E=Math.abs((i-o)*R-(n-a)*A);let G,I;if(C>$i&&E>$i){if((C+E)*(C+E)<=u*(A*A+R*R)){if(Rr<rl){l.push(y,w);return}const M=Math.atan2(n-s,i-e);if(G=Math.abs(M-Math.atan2(s-t,e-r)),I=Math.abs(Math.atan2(a-n,o-i)-M),G>=c&&(G=2*c-G),I>=c&&(I=2*c-I),G+I<Rr){l.push(y,w);return}if(sr!==0){if(G>sr){l.push(e,s);return}if(I>sr){l.push(i,n);return}}}}else if(C>$i){if(C*C<=u*(A*A+R*R)){if(Rr<rl){l.push(y,w);return}if(G=Math.abs(Math.atan2(n-s,i-e)-Math.atan2(s-t,e-r)),G>=c&&(G=2*c-G),G<Rr){l.push(e,s),l.push(i,n);return}if(sr!==0&&G>sr){l.push(e,s);return}}}else if(E>$i){if(E*E<=u*(A*A+R*R)){if(Rr<rl){l.push(y,w);return}if(G=Math.abs(Math.atan2(a-n,o-i)-Math.atan2(n-s,i-e)),G>=c&&(G=2*c-G),G<Rr){l.push(e,s),l.push(i,n);return}if(sr!==0&&G>sr){l.push(i,n);return}}}else if(A=y-(r+o)/2,R=w-(t+a)/2,A*A+R*R<=u){l.push(y,w);return}}il(r,t,d,p,x,v,y,w,l,u,h+1),il(y,w,b,T,g,_,o,a,l,u,h+1)}const NE=8,XE=11920929e-14,HE=1,jE=.01,Zm=0;function Qm(r,t,e,s,i,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:ki.defaultOptions.bezierSmoothness));let u=(HE-l)/1;return u*=u,zE(t,e,s,i,n,o,r,u),r}function zE(r,t,e,s,i,n,o,a){nl(o,r,t,e,s,i,n,a,0),o.push(i,n)}function nl(r,t,e,s,i,n,o,a,l){if(l>NE)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>XE){if(x*x<=a*(g*g+_*_)){if(Zm<jE){r.push(f,m);return}let v=Math.abs(Math.atan2(o-i,n-s)-Math.atan2(i-e,s-t));if(v>=u&&(v=2*u-v),v<Zm){r.push(f,m);return}}}else if(g=f-(t+n)/2,_=m-(e+o)/2,g*g+_*_<=a){r.push(f,m);return}nl(r,t,e,h,c,f,m,a,l+1),nl(r,f,m,d,p,n,o,a,l+1)}function ol(r,t,e,s,i,n,o,a){let l=Math.abs(i-n);(!o&&i>n||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;c<a+1;c++){const d=Math.cos(h),p=Math.sin(h),f=t+d*s,m=e+p*s;r.push(f,m),h+=u}}function Jm(r,t,e,s,i,n){const o=r[r.length-2],a=r[r.length-1]-e,l=o-t,u=i-e,h=s-t,c=Math.abs(a*h-l*u);if(c<1e-8||n===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const d=a*a+l*l,p=u*u+h*h,f=a*u+l*h,m=n*Math.sqrt(d)/c,g=n*Math.sqrt(p)/c,_=m*f/d,x=g*f/p,v=m*h+g*l,b=m*u+g*a,T=l*(g+_),y=a*(g+_),w=h*(m+x),A=u*(m+x),R=Math.atan2(y-b,T-v),C=Math.atan2(A-b,w-v);ol(r,v+t,b+e,n,R,C,l*u>h*a)}const Ss=Math.PI*2,al={centerX:0,centerY:0,ang1:0,ang2:0},ll=({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 WE(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 tg=(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)},VE=(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,T=l*x+u*v+(t+s)/2,y=(h-x)/i,w=(c-v)/n,A=(-h-x)/i,R=(-c-v)/n,C=tg(1,0,y,w);let E=tg(y,w,A,R);a===0&&E>0&&(E-=Ss),a===1&&E<0&&(E+=Ss),d.centerX=b,d.centerY=T,d.ang1=C,d.ang2=E};function eg(r,t,e,s,i,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const h=Math.sin(a*Ss/360),c=Math.cos(a*Ss/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)),VE(t,e,s,i,n,o,l,u,h,c,d,p,al);let{ang1:m,ang2:g}=al;const{centerX:_,centerY:x}=al;let v=Math.abs(g)/(Ss/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);g/=b;let T=r[r.length-2],y=r[r.length-1];const w={x:0,y:0};for(let A=0;A<b;A++){const R=WE(m,g),{x:C,y:E}=ll(R[0],n,o,c,h,_,x,w),{x:G,y:I}=ll(R[1],n,o,c,h,_,x,w),{x:M,y:B}=ll(R[2],n,o,c,h,_,x,w);sl(r,T,y,C,E,G,I,M,B),T=M,y=B,m+=g}}function rg(r,t,e){var s;const i=(a,l)=>{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;a<t.length;a++){const l=t[a%t.length],u=(s=l.radius)!=null?s:e;if(u<=0){n(a,l),o=l;continue}const h=t[(a+1)%t.length],c=i(l,o),d=i(l,h);if(c.len<1e-4||d.len<1e-4){n(a,l),o=l;continue}let p=Math.asin(c.nx*d.ny-c.ny*d.nx),f=1,m=!1;c.nx*d.nx-c.ny*-d.ny<0?p<0?p=Math.PI+p:(p=Math.PI-p,f=-1,m=!0):p>0&&(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,T=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(T)*_,b+Math.sin(T)*_),r.arc(v,b,_,T,y,m),o=l}}function sg(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;l<a;l++){const u=t[(l+1)%a],h=(i=u.radius)!=null?i:e;if(h<=0){l===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y);continue}const c=t[l],d=t[(l+2)%a],p=n(c,u);let f;if(p<1e-4)f=u;else{const _=Math.min(p/2,h);f=o(u,c,_/p)}const m=n(d,u);let g;if(m<1e-4)g=u;else{const _=Math.min(m/2,h);g=o(u,d,_/m)}l===0?r.moveTo(f.x,f.y):r.lineTo(f.x,f.y),r.quadraticCurveTo(u.x,u.y,g.x,g.y,s)}}const YE=new ut;class ig{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Ct,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,i=s[s.length-2],n=s[s.length-1];return(i!==t||n!==e)&&s.push(t,e),this}arc(t,e,s,i,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return ol(a,t,e,s,i,n,o),this}arcTo(t,e,s,i,n){this._ensurePoly();const o=this._currentPoly.points;return Jm(o,t,e,s,i,n),this}arcToSvg(t,e,s,i,n,o,a){const l=this._currentPoly.points;return eg(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,s,i,n),this}bezierCurveTo(t,e,s,i,n,o,a){this._ensurePoly();const l=this._currentPoly;return sl(this._currentPoly.points,l.lastX,l.lastY,t,e,s,i,n,o,a),this}quadraticCurveTo(t,e,s,i,n){this._ensurePoly();const o=this._currentPoly;return Qm(this._currentPoly.points,o.lastX,o.lastY,t,e,s,i,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const s=this.shapePrimitives,i=s.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&s.length-i>1){let n=null;for(let o=i;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const l=a.shape,u=n==null?void 0:n.shape;u&&u.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,i,n){return this.drawShape(new ut(t,e,s,i),n),this}circle(t,e,s,i){return this.drawShape(new ho(t,e,s),i),this}poly(t,e,s){const i=new Wr(t);return i.closePath=e,this.drawShape(i,s),this}regularPoly(t,e,s,i,n=0,o){i=Math.max(i|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/i,u=[];for(let h=0;h<i;h++){const c=a-h*l;u.push(t+s*Math.cos(c),e+s*Math.sin(c))}return this.poly(u,!0,o),this}roundPoly(t,e,s,i,n,o=0,a){if(i=Math.max(i|0,3),n<=0)return this.regularPoly(t,e,s,i,o);const l=s*Math.sin(Math.PI/i)-.001;n=Math.min(n,l);const u=-1*Math.PI/2+o,h=Math.PI*2/i,c=(i-2)*Math.PI/i/2;for(let d=0;d<i;d++){const p=d*h+u,f=t+s*Math.cos(p),m=e+s*Math.sin(p),g=p+Math.PI+c,_=p-Math.PI-c,x=f+n*Math.cos(g),v=m+n*Math.sin(g),b=f+n*Math.cos(_),T=m+n*Math.sin(_);d===0?this.moveTo(x,v):this.lineTo(x,v),this.quadraticCurveTo(f,m,b,T,a)}return this.closePath()}roundShape(t,e,s=!1,i){return t.length<3?this:(s?sg(this,t,e,i):rg(this,t,e),this.closePath())}filletRect(t,e,s,i,n){if(n===0)return this.rect(t,e,s,i);const o=Math.min(s,i)/2,a=Math.min(o,Math.max(-o,n)),l=t+s,u=e+i,h=a<0?-a:0,c=Math.abs(a);return this.moveTo(t,e+c).arcTo(t+h,e+h,t+c,e,c).lineTo(l-c,e).arcTo(l-h,e+h,l,e+c,c).lineTo(l,u-c).arcTo(l-h,u-h,t+s-c,u,c).lineTo(t+c,u).arcTo(t+h,u-h,t,u-c,c).closePath()}chamferRect(t,e,s,i,n,o){if(n<=0)return this.rect(t,e,s,i);const a=Math.min(n,Math.min(s,i)/2),l=t+s,u=e+i,h=[t+a,e,l-a,e,l,e+a,l,u-a,l-a,u,t+a,u,t,u-a,t,e+a];for(let c=h.length-1;c>=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 co(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new po(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 Wr,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 Wr,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;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const i=e[s],n=i.shape.getBounds(YE);i.transform?t.addRect(n,i.transform):t.addRect(n)}return t}}class de{constructor(t,e=!1){this.instructions=[],this.uid=ct("graphicsPath"),this._dirty=!0;var s;this.checkForHoles=e,typeof t=="string"?Jf(t,this):this.instructions=(s=t==null?void 0:t.slice())!=null?s:[]}get shapePath(){return this._shapePath||(this._shapePath=new ig(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,i,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(lt.shared);let l=0,u=0;if(!o||o.action!=="bezierCurveTo")l=a.x,u=a.y;else{l=o.data[2],u=o.data[3];const h=a.x,c=a.y;l=h+(h-l),u=c+(c-u)}return this.instructions.push({action:"bezierCurveTo",data:[l,u,t,e,s,i,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const i=this.instructions[this.instructions.length-1],n=this.getLastPoint(lt.shared);let o=0,a=0;if(!i||i.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=i.data[0],a=i.data[1];const l=n.x,u=n.y;o=l+(l-o),a=u+(u-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,s]}),this._dirty=!0,this}rect(t,e,s,i,n){return this.instructions.push({action:"rect",data:[t,e,s,i,n]}),this._dirty=!0,this}circle(t,e,s,i){return this.instructions.push({action:"circle",data:[t,e,s,i]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,i,n,o,a){n||(n=i/2);const l=-1*Math.PI/2+o,u=s*2,h=Math.PI*2/u,c=[];for(let d=0;d<u;d++){const p=d%2?n:i,f=d*h+l;c.push(t+p*Math.cos(f),e+p*Math.sin(f))}return this.poly(c,!0,a),this}clone(t=!1){const e=new de;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const i=this.instructions[s];e.instructions.push({action:i.action,data:i.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,i=t.c,n=t.d,o=t.tx,a=t.ty;let l=0,u=0,h=0,c=0,d=0,p=0,f=0,m=0;for(let g=0;g<this.instructions.length;g++){const _=this.instructions[g],x=_.data;switch(_.action){case"moveTo":case"lineTo":l=x[0],u=x[1],x[0]=e*l+i*u+o,x[1]=s*l+n*u+a;break;case"bezierCurveTo":h=x[0],c=x[1],d=x[2],p=x[3],l=x[4],u=x[5],x[0]=e*h+i*c+o,x[1]=s*h+n*c+a,x[2]=e*d+i*p+o,x[3]=s*d+n*p+a,x[4]=e*l+i*u+o,x[5]=s*l+n*u+a;break;case"quadraticCurveTo":h=x[0],c=x[1],l=x[2],u=x[3],x[0]=e*h+i*c+o,x[1]=s*h+n*c+a,x[2]=e*l+i*u+o,x[3]=s*l+n*u+a;break;case"arcToSvg":l=x[5],u=x[6],f=x[0],m=x[1],x[0]=e*f+i*m,x[1]=s*f+n*m,x[5]=e*l+i*u+o,x[6]=s*l+n*u+a;break;case"circle":x[4]=ws(x[3],t);break;case"rect":x[4]=ws(x[4],t);break;case"ellipse":x[8]=ws(x[8],t);break;case"roundRect":x[5]=ws(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=ws(x[2],t);break;default:break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function ws(r,t){return r?r.prepend(t):t.clone()}let ul=0;const ng=500;function ne(...r){ul!==ng&&(ul++,ul===ng?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function bt(r,t,e){const s=r.getAttribute(t);return s?Number(s):e}function og(r,t){const e=r.querySelectorAll("defs");for(let s=0;s<e.length;s++){const i=e[s];for(let n=0;n<i.children.length;n++){const o=i.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=KE(o);break;case"radialgradient":t.defs[o.id]=qE(o);break;default:break}}}}function KE(r){const t=bt(r,"x1",0),e=bt(r,"y1",0),s=bt(r,"x2",1),i=bt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Ut(t,e,s,i,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const l=r.children[a],u=bt(l,"offset",0),h=rt.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(u,h)}return o}function qE(r){return new Ut(0,0,1,0)}function hl(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const cl={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function dl(r,t){const e=r.getAttribute("style"),s={},i={},n={strokeStyle:s,fillStyle:i,useFill:!1,useStroke:!1};for(const o in cl){const a=r.getAttribute(o);a&&ag(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[u,h]=l.split(":");cl[u]&&ag(t,n,u,h.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function ag(r,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const i=hl(s);t.strokeStyle.fill=r.defs[i]}else t.strokeStyle.color=rt.shared.setValue(s).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const i=hl(s);t.fillStyle.fill=r.defs[i]}else t.fillStyle.color=rt.shared.setValue(s).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(s);break;case"stroke-opacity":t.strokeStyle.alpha=Number(s);break;case"opacity":t.fillStyle.alpha=Number(s),t.strokeStyle.alpha=Number(s);break}}function lg(r){if(r.length<=2)return!0;const t=r.map(a=>a.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 ZE(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 ug(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function hg(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;u<e.length;u+=2)u+1<e.length&&(s.push(e[u]),i.push(e[u+1]));if(s.length===0||i.length===0)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...i),l=Math.max(...i);return(o-n)*(l-a)}function pl(r,t){const e=new de(r,!1);for(const s of e.instructions)t.instructions.push(s)}var QE=Object.defineProperty,cg=Object.getOwnPropertySymbols,JE=Object.prototype.hasOwnProperty,tA=Object.prototype.propertyIsEnumerable,dg=(r,t,e)=>t in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Li=(r,t)=>{for(var e in t||(t={}))JE.call(t,e)&&dg(r,e,t[e]);if(cg)for(var e of cg(t))tA.call(t,e)&&dg(r,e,t[e]);return r};function pg(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 de};og(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=dl(r,e);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&fg(a,e,i,n)}return t}function fg(r,t,e,s){const i=r.children,{fillStyle:n,strokeStyle:o}=dl(r,t);n&&e?e=Li(Li({},e),n):n&&(e=n),o&&s?s=Li(Li({},s),o):o&&(s=o);const a=!e&&!s;a&&(e={color:0});let l,u,h,c,d,p,f,m,g,_,x,v,b,T,y,w,A;switch(r.nodeName.toLowerCase()){case"path":{T=r.getAttribute("d");const R=r.getAttribute("fill-rule"),C=ug(T),E=R==="evenodd",G=C.length>1;if(E&&G){const I=C.map(M=>({path:M,area:hg(M)}));if(I.sort((M,B)=>B.area-M.area),C.length>3||!lg(I))for(let M=0;M<I.length;M++){const B=I[M],P=M===0;t.context.beginPath();const O=new de(void 0,!0);pl(B.path,O),t.context.path(O),P?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let M=0;M<I.length;M++){const B=I[M],P=M%2===1;t.context.beginPath();const O=new de(void 0,!0);pl(B.path,O),t.context.path(O),P?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const I=R?R==="evenodd":!0;y=new de(T,I),t.context.path(y),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":f=bt(r,"cx",0),m=bt(r,"cy",0),g=bt(r,"r",0),t.context.ellipse(f,m,g,g),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":l=bt(r,"x",0),u=bt(r,"y",0),w=bt(r,"width",0),A=bt(r,"height",0),_=bt(r,"rx",0),x=bt(r,"ry",0),_||x?t.context.roundRect(l,u,w,A,_||x):t.context.rect(l,u,w,A),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":f=bt(r,"cx",0),m=bt(r,"cy",0),_=bt(r,"rx",0),x=bt(r,"ry",0),t.context.beginPath(),t.context.ellipse(f,m,_,x),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":h=bt(r,"x1",0),c=bt(r,"y1",0),d=bt(r,"x2",0),p=bt(r,"y2",0),t.context.beginPath(),t.context.moveTo(h,c),t.context.lineTo(d,p),s&&t.context.stroke(s);break;case"polygon":b=r.getAttribute("points"),v=b.match(/-?\d+/g).map(R=>parseInt(R,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(R=>parseInt(R,10)),t.context.poly(v,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{ne(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let R=0;R<i.length;R++)fg(i[R],t,e,s)}const mg={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Mr{constructor(t,e){this.uid=ct("fillPattern"),this._tick=0,this.transform=new D,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=mg[e].addressModeU,t.source.style.addressModeV=mg[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var eA=Object.defineProperty,Ni=Object.getOwnPropertySymbols,gg=Object.prototype.hasOwnProperty,_g=Object.prototype.propertyIsEnumerable,xg=(r,t,e)=>t in r?eA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ue=(r,t)=>{for(var e in t||(t={}))gg.call(t,e)&&xg(r,e,t[e]);if(Ni)for(var e of Ni(t))_g.call(t,e)&&xg(r,e,t[e]);return r},rA=(r,t)=>{var e={};for(var s in r)gg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ni)for(var s of Ni(r))t.indexOf(s)<0&&_g.call(r,s)&&(e[s]=r[s]);return e};function sA(r){return rt.isColorLike(r)}function vg(r){return r instanceof Mr}function bg(r){return r instanceof Ut}function iA(r){return r instanceof F}function nA(r,t,e){const s=rt.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=F.WHITE,ue(ue({},e),r)}function oA(r,t,e){return r.texture=t,ue(ue({},e),r)}function yg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,ue(ue({},e),r)}function Tg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,ue(ue({},e),r)}function aA(r,t){const e=ue(ue({},t),r),s=rt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function Fe(r,t){if(r==null)return null;const e={},s=r;return sA(r)?nA(e,r,t):iA(r)?oA(e,r,t):vg(r)?yg(e,r,t):bg(r)?Tg(e,r,t):s.fill&&vg(s.fill)?yg(s,s.fill,t):s.fill&&bg(s.fill)?Tg(s,s.fill,t):aA(s,t)}function Es(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=rA(e,["width","alignment","miterLimit","cap","join","pixelLine"]),h=Fe(r,u);return h?ue({width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:l},h):null}function Sg(r,t){let e=1;const s=r.shapePath.shapePrimitives;for(let i=0;i<s.length;i++){const n=s[i].shape;if(n.type!=="polygon")continue;const o=n.points,a=o.length;if(a<6)continue;const l=n.closePath;for(let u=0;u<a;u+=2){if(!l&&(u===0||u===a-2))continue;const h=(u-2+a)%a,c=(u+2)%a,d=o[h],p=o[h+1],f=o[u],m=o[u+1],g=o[c],_=o[c+1],x=d-f,v=p-m,b=g-f,T=_-m,y=x*x+v*v,w=b*b+T*T;if(y<1e-12||w<1e-12)continue;let A=(x*b+v*T)/Math.sqrt(y*w);A<-1?A=-1:A>1&&(A=1);const R=Math.sqrt((1-A)*.5);if(R<1e-6)continue;const C=Math.min(1/R,t);C>e&&(e=C)}}return e}var lA=Object.defineProperty,wg=Object.getOwnPropertySymbols,uA=Object.prototype.hasOwnProperty,hA=Object.prototype.propertyIsEnumerable,Eg=(r,t,e)=>t in r?lA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Or=(r,t)=>{for(var e in t||(t={}))uA.call(t,e)&&Eg(r,e,t[e]);if(wg)for(var e of wg(t))hA.call(t,e)&&Eg(r,e,t[e]);return r};const cA=new lt,Ag=new D,fl=class we extends Dt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ct("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new de,this._transform=new D,this._fillStyle=Or({},we.defaultFillStyle),this._strokeStyle=Or({},we.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Ct,this._boundsDirty=!0}clone(){const t=new we;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Or({},this._fillStyle),t._strokeStyle=Or({},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=Fe(t,we.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Es(t,we.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Fe(t,we.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Fe(t,we.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?rt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new de,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=Fe(t,we.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=Es(t,we.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++,pg(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:Or({},this._fillStyle),strokeStyle:Or({},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):(Ag.set(t,e,s,i,n,o),this._transform.append(Ag),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<this.instructions.length;e++){const s=this.instructions[e],i=s.action;if(i==="fill"){const n=s.data;t.addBounds(n.path.bounds)}else if(i==="texture"){const n=s.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(i==="stroke"){const n=s.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=Sg(n.path,n.style.miterLimit));const l=n.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const s=this.instructions;let i=!1;for(let n=0;n<s.length;n++){const o=s[n],a=o.data,l=a.path;if(!o.action||!l)continue;const u=a.style,h=l.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){const d=h[c].shape;if(!u||!d)continue;const p=h[c].transform,f=p?p.applyInverse(t,cA):t;if(o.action==="fill")i=d.contains(f.x,f.y);else{const g=u;i=d.strokeContains(f.x,f.y,g.width,g.alignment)}const m=a.hole;if(m){const g=(e=m.shapePath)==null?void 0:e.shapePrimitives;if(g)for(let _=0;_<g.length;_++)g[_].shape.contains(f.x,f.y)&&(i=!1)}if(i)return!0}}return i}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(!this.destroyed){if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}}};fl.defaultFillStyle={color:16777215,alpha:1,texture:F.WHITE,matrix:null,fill:null,textureSpace:"local"},fl.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:F.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let kt=fl;function Xi(r,t=1){var e;const s=(e=Ge.RETINA_PREFIX)==null?void 0:e.exec(r);return s?parseFloat(s[1]):t}function De(r,t,e){r.label=e,r._sourceOrigin=e;const s=new F({source:r,label:e}),i=()=>{delete t.promiseCache[e],st.has(e)&&st.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var dA=Object.defineProperty,Hi=Object.getOwnPropertySymbols,Pg=Object.prototype.hasOwnProperty,Cg=Object.prototype.propertyIsEnumerable,Rg=(r,t,e)=>t in r?dA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pA=(r,t)=>{for(var e in t||(t={}))Pg.call(t,e)&&Rg(r,e,t[e]);if(Hi)for(var e of Hi(t))Cg.call(t,e)&&Rg(r,e,t[e]);return r},fA=(r,t)=>{var e={};for(var s in r)Pg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Hi)for(var s of Hi(r))t.indexOf(s)<0&&Cg.call(r,s)&&(e[s]=r[s]);return e};const mA=".svg",gA="image/svg+xml",Mg={extension:{type:S.LoadParser,priority:Zt.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Qe(r,gA)||ie(r,mA)},async load(r,t,e){var s,i;return((i=(s=t.data)==null?void 0:s.parseAsGraphicsContext)!=null?i:this.config.parseAsGraphicsContext)?xA(r):_A(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function _A(r,t,e,s){var i,n,o,a,l,u;const h=await H.get().fetch(r),c=H.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)||Xi(r),m=Math.ceil(d*f),g=Math.ceil(p*f),_=H.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,T=fA(v,["parseAsGraphicsContext"]),y=new Ie(pA({resource:_,alphaMode:"premultiply-alpha-on-upload",resolution:f},T));return De(y,e,r)}async function xA(r){const t=await(await H.get().fetch(r)).text(),e=new kt;return e.svg(t),e}const vA=`(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 Gr=null,ml=class{constructor(){Gr||(Gr=URL.createObjectURL(new Blob([vA],{type:"application/javascript"}))),this.worker=new Worker(Gr)}};ml.revokeObjectURL=function(){Gr&&(URL.revokeObjectURL(Gr),Gr=null)};const bA='(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 Ir=null,Og=class{constructor(){Ir||(Ir=URL.createObjectURL(new Blob([bA],{type:"application/javascript"}))),this.worker=new Worker(Ir)}};Og.revokeObjectURL=function(){Ir&&(URL.revokeObjectURL(Ir),Ir=null)};let Gg=0,gl,yA=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 ml;e.addEventListener("message",s=>{e.terminate(),ml.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(){gl===void 0&&(gl=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<gl&&(this._createdWorkers++,t=new Og().worker,t.addEventListener("message",e=>{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[Gg]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Gg++,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 _l=new yA;var TA=Object.defineProperty,Ig=Object.getOwnPropertySymbols,SA=Object.prototype.hasOwnProperty,wA=Object.prototype.propertyIsEnumerable,Bg=(r,t,e)=>t in r?TA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,EA=(r,t)=>{for(var e in t||(t={}))SA.call(t,e)&&Bg(r,e,t[e]);if(Ig)for(var e of Ig(t))wA.call(t,e)&&Bg(r,e,t[e]);return r};const AA=[".jpeg",".jpg",".png",".webp",".avif"],PA=["image/jpeg","image/png","image/webp","image/avif"];async function Fg(r,t){var e;const s=await H.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 xl={name:"loadTextures",id:"texture",extension:{type:S.LoadParser,priority:Zt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Qe(r,PA)||ie(r,AA)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await _l.isImageBitmapSupported()?i=await _l.loadImageBitmap(r,t):i=await Fg(r,t):i=await new Promise((o,a)=>{i=H.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const n=new Ie(EA({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||Xi(r)},t.data));return De(n,e,r)},unload(r){r.destroy(!0)}};var CA=Object.defineProperty,RA=Object.defineProperties,MA=Object.getOwnPropertyDescriptors,Dg=Object.getOwnPropertySymbols,OA=Object.prototype.hasOwnProperty,GA=Object.prototype.propertyIsEnumerable,Ug=(r,t,e)=>t in r?CA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vl=(r,t)=>{for(var e in t||(t={}))OA.call(t,e)&&Ug(r,e,t[e]);if(Dg)for(var e of Dg(t))GA.call(t,e)&&Ug(r,e,t[e]);return r},kg=(r,t)=>RA(r,MA(t));const IA=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let bl,yl;function $g(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Ng(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Lg(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 Ng(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 BA(){const r=[],t=[];for(const e of IA){const s=mr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;xs(s)&&(r.push(e),t.includes(s)||t.push(s))}return{validVideoExtensions:r,validVideoMime:t}}const Xg={name:"loadVideo",id:"video",extension:{type:S.LoadParser,name:"loadVideo"},test(r){if(!bl||!yl){const{validVideoExtensions:s,validVideoMime:i}=BA();bl=s,yl=i}const t=Qe(r,yl),e=ie(r,bl);return t||e},async load(r,t,e){var s,i;const n=vl(kg(vl({},mr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||Xi(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await Qo()}),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),$g(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=mr.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 mr(kg(vl({},n),{resource:o}));f(),t.data.preload&&await Lg(o),h(De(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)}},Tl={extension:{type:S.ResolveParser,name:"resolveTexture"},test:xl.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=Ge.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Hg={extension:{type:S.ResolveParser,priority:-2,name:"resolveJson"},test:r=>Ge.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Tl.parse};var FA=Object.defineProperty,jg=Object.getOwnPropertySymbols,DA=Object.prototype.hasOwnProperty,UA=Object.prototype.propertyIsEnumerable,zg=(r,t,e)=>t in r?FA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wg=(r,t)=>{for(var e in t||(t={}))DA.call(t,e)&&zg(r,e,t[e]);if(jg)for(var e of jg(t))UA.call(t,e)&&zg(r,e,t[e]);return r};class Vg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ge,this.loader=new zf,this.cache=st,this._backgroundLoader=new If(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=Wg(Wg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=is(t),i=se(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 st.get(t);const e={};for(let s=0;s<t.length;s++)e[s]=st.get(t[s]);return e}async _mapLoadToResolve(t,e){const s=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const i=await this.loader.load(s,e);this._backgroundLoader.active=!0;const n={};return s.forEach(o=>{const a=i[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),st.set(l,a)}),n}async unload(t){this._initialized||await this.init();const e=se(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=se(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=>{st.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 As=new Vg;N.handleByList(S.LoadParser,As.loader.parsers).handleByList(S.ResolveParser,As.resolver.parsers).handleByList(S.CacheParser,As.cache.parsers).handleByList(S.DetectionParser,As.detections),N.add(Bf,Uf,Ff,Nf,kf,$f,Lf,Wf,Vf,Zf,Mg,xl,Xg,Gf,Of,Tl,Hg);const Yg={loader:S.LoadParser,resolver:S.ResolveParser,cache:S.CacheParser,detection:S.DetectionParser};N.handle(S.Asset,r=>{const t=r.ref;Object.entries(Yg).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return N.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(Yg).filter(e=>!!t[e]).forEach(e=>N.remove(t[e]))});const kA={extension:{type:S.DetectionParser,priority:3},test:async()=>!!(await gs()||ms()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var $A=Object.defineProperty,LA=Object.defineProperties,NA=Object.getOwnPropertyDescriptors,Kg=Object.getOwnPropertySymbols,XA=Object.prototype.hasOwnProperty,HA=Object.prototype.propertyIsEnumerable,qg=(r,t,e)=>t in r?$A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jA=(r,t)=>{for(var e in t||(t={}))XA.call(t,e)&&qg(r,e,t[e]);if(Kg)for(var e of Kg(t))HA.call(t,e)&&qg(r,e,t[e]);return r},zA=(r,t)=>LA(r,NA(t));class Ps extends ft{constructor(t){super(zA(jA({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let ji;function Sl(){if(ji)return ji;const r=H.get().createCanvas(1,1).getContext("webgl");return r?(ji=[...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"]:[]],ji):[]}let zi;async function wl(){if(zi)return zi;const r=await H.get().getNavigator().gpu.requestAdapter();return zi=[...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"]:[]],zi}let El;async function Al(){return El!==void 0||(El=await(async()=>{const r=await gs(),t=ms();if(r&&t){const e=await wl(),s=Sl();return e.filter(i=>s.includes(i))}else{if(r)return await wl();if(t)return Sl()}return[]})()),El}const Zg=["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 Wi;async function Cs(){if(Wi!==void 0)return Wi;const r=await Al();return Wi=[...Zg,...r],Wi}const WA='(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<s;++e)for(let o=0;o<t;++o){const B=r.getImageTranscodedSizeInBytes(o,e,a),f=new Uint8Array(B);if(!r.transcodeImage(f,o,e,a,1,0))throw new Error("transcodeImage failed");m.push(f)}return m}const w={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function d(r){const a=w[r];if(a)return a;throw new Error(`Unsupported transcoderFormat: ${r}`)}const n={jsUrl:"basis/basis_transcoder.js",wasmUrl:"basis/basis_transcoder.wasm"};let u,i,c;async function l(){if(!c){const r=new URL(n.jsUrl,location.origin).href,a=new URL(n.wasmUrl,location.origin).href;importScripts(r),c=new Promise(t=>{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 Br=null,Qg=class{constructor(){Br||(Br=URL.createObjectURL(new Blob([WA],{type:"application/javascript"}))),this.worker=new Worker(Br)}};Qg.revokeObjectURL=function(){Br&&(URL.revokeObjectURL(Br),Br=null)};const Vi={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 VA(r){Object.assign(Vi,r)}let Rs;const Jg={};function YA(r){return Rs||(Rs=new Qg().worker,Rs.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),Jg[s](i)},Rs.postMessage({type:"init",jsUrl:Vi.jsUrl,wasmUrl:Vi.wasmUrl,supportedTextures:r})),Rs}function t_(r,t){const e=YA(t);return new Promise(s=>{Jg[r]=s,e.postMessage({type:"load",url:r})})}const KA={extension:{type:S.LoadParser,priority:Zt.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return ie(r,[".basis"])},async load(r,t,e){const s=await Cs(),i=await t_(r,s),n=new Ps(i);return De(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function qA(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<s;++n)for(let o=0;o<e;++o){const a=r.getImageTranscodedSizeInBytes(o,n,t),l=new Uint8Array(a);if(!r.transcodeImage(l,o,n,t,1,0))throw new Error("transcodeImage failed");i.push(l)}return i}const ZA={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function QA(r){const t=ZA[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const JA={MAGIC:0,SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19,PF_FLAGS:20,FOURCC:21,RGB_BITCOUNT:22,R_BIT_MASK:23,G_BIT_MASK:24,B_BIT_MASK:25,A_BIT_MASK:26},tP={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Pl=(r=>(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))(Pl||{}),Cl=(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))(Cl||{});function Gt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Vt=(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=Gt("UYVY")]="UYVY",r[r.R8G8_B8G8=Gt("RGBG")]="R8G8_B8G8",r[r.YUY2=Gt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Gt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Gt("DXT1")]="DXT1",r[r.DXT2=Gt("DXT2")]="DXT2",r[r.DXT3=Gt("DXT3")]="DXT3",r[r.DXT4=Gt("DXT4")]="DXT4",r[r.DXT5=Gt("DXT5")]="DXT5",r[r.ATI1=Gt("ATI1")]="ATI1",r[r.AT1N=Gt("AT1N")]="AT1N",r[r.ATI2=Gt("ATI2")]="ATI2",r[r.AT2N=Gt("AT2N")]="AT2N",r[r.BC4U=Gt("BC4U")]="BC4U",r[r.BC4S=Gt("BC4S")]="BC4S",r[r.BC5U=Gt("BC5U")]="BC5U",r[r.BC5S=Gt("BC5S")]="BC5S",r[r.DX10=Gt("DX10")]="DX10",r))(Vt||{});const Rl={[Vt.DXT1]:"bc1-rgba-unorm",[Vt.DXT2]:"bc2-rgba-unorm",[Vt.DXT3]:"bc2-rgba-unorm",[Vt.DXT4]:"bc3-rgba-unorm",[Vt.DXT5]:"bc3-rgba-unorm",[Vt.ATI1]:"bc4-r-unorm",[Vt.BC4U]:"bc4-r-unorm",[Vt.BC4S]:"bc4-r-snorm",[Vt.ATI2]:"bc5-rg-unorm",[Vt.BC5U]:"bc5-rg-unorm",[Vt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Yt={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:JA,HEADER_DX10_FIELDS:tP,DXGI_FORMAT:Pl,D3D10_RESOURCE_DIMENSION:Cl,D3DFMT:Vt},e_={"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 r_(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=rP(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=eP(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function eP(r,t,e,s,i,n){const o=[],a=e_[r];let l=t,u=e,h=s;for(let c=0;c<i;++c){const d=Math.ceil(Math.max(4,l)/4)*4,p=Math.ceil(Math.max(4,u)/4)*4,f=a?d/4*p/4*a:l*u*4,m=new Uint8Array(n,h,f);o.push(m),h+=f,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return o}function rP(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=sP(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 sP(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 Yt)return Yt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Rl)return Rl[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 iP(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 iP(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 Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return Yt[Y.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return Yt[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}`)}const nP={extension:{type:S.LoadParser,priority:Zt.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return ie(r,[".dds"])},async load(r,t,e){const s=await Cs(),i=await(await fetch(r)).arrayBuffer(),n=r_(i,s),o=new Ps(n);return De(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var s_=(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))(s_||{}),oP=(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))(oP||{}),aP=(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))(aP||{});const lP={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"},uP=[171,75,84,88,32,49,49,187,13,10,26,10],hP={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},cP=64,dP=67305985,pP={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},fP={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},mP={32819:2,32820:2,33635:2},gP={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},St={FILE_HEADER_SIZE:cP,FILE_IDENTIFIER:uP,FORMATS_TO_COMPONENTS:fP,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:gP,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:lP,FIELDS:hP,TYPES_TO_BYTES_PER_COMPONENT:pP,TYPES_TO_BYTES_PER_PIXEL:mP,ENDIANNESS:dP};function i_(r,t){const e=new DataView(r);if(!bP(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}=vP(e),c=St.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=xP(i,n,o),p=_P(e,i,d,a,l,h,u,s);return{format:c,width:a,height:l,resource:p,alphaMode:"no-premultiply-alpha"}}function _P(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<o;x++){const v=r.getUint32(g,a);let b=g+4;_[x]=new Uint8Array(r.buffer,b,c),b+=c,g+=v+4,g=g%4!==0?g+4-g%4:g,d=d>>1||1,p=p>>1||1,f=d+4-1&-4,m=p+4-1&-4,c=f*m*e}return _}function xP(r,t,e){let s=St.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(St.TYPES_TO_BYTES_PER_COMPONENT[r]?s=St.TYPES_TO_BYTES_PER_COMPONENT[r]*St.FORMATS_TO_COMPONENTS[t]:s=St.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 vP(r){const t=r.getUint32(St.FIELDS.ENDIANNESS,!0)===St.ENDIANNESS,e=r.getUint32(St.FIELDS.GL_TYPE,t),s=r.getUint32(St.FIELDS.GL_FORMAT,t),i=r.getUint32(St.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(St.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(St.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(St.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(St.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(St.FIELDS.NUMBER_OF_FACES,t),h=r.getUint32(St.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=r.getUint32(St.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:St.FILE_HEADER_SIZE+c}}function bP(r){for(let t=0;t<St.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==St.FILE_IDENTIFIER[t])return!1;return!0}const yP={extension:{type:S.LoadParser,priority:Zt.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return ie(r,".ktx")},async load(r,t,e){const s=await Cs(),i=await(await fetch(r)).arrayBuffer(),n=i_(i,s),o=new Ps(n);return De(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},TP='(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<o.length;e++)o[e]=n(o[e]);r.format=s[t].convertedFormat}}function i(r){const t=r.byteLength/3,n=new Uint32Array(t);for(let o=0;o<t;++o)n[o]=r[o*3]+(r[o*3+1]<<8)+(r[o*3+2]<<16)+4278190080;return new Uint8Array(n.buffer)}function d(r){const t=[];for(let n=0;n<r.numLevels;n++){const o=r.getImageData(n,0,0),e=new Uint8Array(o.byteLength);e.set(o),t.push(e)}return t}const w={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function p(r){const t=w[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const h={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function F(r){const t=h[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function U(r){return r.classId===2?F(r.vkFormat):p(r.glInternalformat)}const y={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function T(r){const t=y[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const a={jsUrl:"",wasmUrl:""};let l,u,c;async function g(){if(!c){const r=new URL(a.jsUrl,location.origin).href,t=new URL(a.wasmUrl,location.origin).href;importScripts(r),c=new Promise(n=>{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 Fr=null;class n_{constructor(){Fr||(Fr=URL.createObjectURL(new Blob([TP],{type:"application/javascript"}))),this.worker=new Worker(Fr)}}n_.revokeObjectURL=function(){Fr&&(URL.revokeObjectURL(Fr),Fr=null)};const Yi={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 SP(r){Object.assign(Yi,r)}let Ms;const o_={},a_={};function wP(r){return Ms||(Ms=new n_().worker,Ms.onmessage=t=>{const{err:e,success:s,url:i,textureOptions:n}=t.data;if(e){a_[i](e);return}s||console.warn("Failed to load KTX texture",i),o_[i](n)},Ms.postMessage({type:"init",jsUrl:Yi.jsUrl,wasmUrl:Yi.wasmUrl,supportedTextures:r})),Ms}function l_(r,t){const e=wP(t);return new Promise((s,i)=>{o_[r]=s,a_[r]=i,e.postMessage({type:"load",url:r})})}const EP={extension:{type:S.LoadParser,priority:Zt.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return ie(r,".ktx2")},async load(r,t,e){const s=await Cs(),i=await l_(r,s),n=new Ps(i);return De(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ml={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:u_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:u_}};function AP(r){const t=r.format;if(Ml[t]){const e=Ml[t].convertFunction,s=r.resource;for(let i=0;i<s.length;i++)s[i]=e(s[i]);r.format=Ml[t].convertedFormat}}function u_(r){const t=r.byteLength/3,e=new Uint32Array(t);for(let s=0;s<t;++s)e[s]=r[s*3]+(r[s*3+1]<<8)+(r[s*3+2]<<16)+4278190080;return new Uint8Array(e.buffer)}function PP(r){const t=[];for(let e=0;e<r.numLevels;e++){const s=r.getImageData(e,0,0),i=new Uint8Array(s.byteLength);i.set(s),t.push(i)}return t}const CP={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function h_(r){const t=CP[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const RP={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function c_(r){const t=RP[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function MP(r){return r.classId===2?c_(r.vkFormat):h_(r.glInternalformat)}const OP={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function GP(r){const t=OP[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const Ki=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],IP={extension:S.ResolveParser,test:r=>ie(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];Ki.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=Ge.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let qi;const BP={extension:{type:S.DetectionParser,priority:2},test:async()=>!!(await gs()||ms()),add:async r=>{const t=await Al();return qi=FP(t),[...qi,...r]},remove:async r=>qi?r.filter(t=>!(t in qi)):r};function FP(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=Ki.indexOf(s),o=Ki.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const DP=new Ct,UP=new D,Os=new ut,Ol=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){Os.x=e.x,Os.y=e.y,Os.width=e.width,Os.height=e.height;const i=s?t.worldTransform:t.getGlobalTransform(UP,s);t.culled=!Os.intersects(t.cullArea,i)}else{const i=Qr(t,s,DP);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<t.children.length;i++)this._cullRecursive(t.children[i],e,s)}};Ol.shared=new Ol;let d_=Ol;class p_{static init(t){this._renderRef=this.render.bind(this),this.render=()=>{var e;const s=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;d_.shared.cull(this.stage,this.renderer.screen,s),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}p_.extension={priority:10,type:S.Application,name:"culler"};const kP={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return q2})}};var f_=`
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}
}
`,m_=`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();
}
`,g_=`
struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct BlendUniforms {
  uBlend:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(0) @binding(3) var uBackTexture: texture_2d<f32>;

@group(1) @binding(0) var<uniform> blendUniforms : BlendUniforms;


struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}

{FUNCTIONS}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>
) -> @location(0) vec4<f32> {


   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<f32>(0.0,0.0,0.0,0.0);

   {MAIN}

   return out;
}`,$P=Object.defineProperty,__=Object.getOwnPropertySymbols,LP=Object.prototype.hasOwnProperty,NP=Object.prototype.propertyIsEnumerable,x_=(r,t,e)=>t in r?$P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v_=(r,t)=>{for(var e in t||(t={}))LP.call(t,e)&&x_(r,e,t[e]);if(__)for(var e of __(t))NP.call(t,e)&&x_(r,e,t[e]);return r};class XP extends ye{constructor(t){const e=t.gpu,s=b_(v_({source:g_},e)),i=Nt.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=b_(v_({source:f_},n)),a=Ht.from({vertex:m_,fragment:o}),l=new At({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:F.EMPTY}})}}function b_(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const HP=`
	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;
	}
    `,jP=`
	fn getLuminosity(c: vec3<f32>) -> f32
	{
		return 0.3*c.r + 0.59*c.g + 0.11*c.b;
	}

	fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32>
	{
		var modLum: f32 = lum - getLuminosity(c);
		var color: vec3<f32> = c.rgb + modLum;

		// clip back into legal range
		modLum = getLuminosity(color);
		let modLumVec = vec3<f32>(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>) -> f32
	{
		return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
	}

	fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32>
	{
		var 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;
			colorSorted.z = 0;
		}

		colorSorted.x = 0;

		return colorSorted;
	}

	fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32>
	{
		var color = c;

		if (color.r <= color.g && color.r <= color.b)
		{
			if (color.g <= color.b)
			{
				color = vec3<f32>(setSaturationMinMidMax(color.rgb, s)).rgb;
			}
			else
			{
				color = vec3<f32>(setSaturationMinMidMax(color.rbg, s)).rbg;
			}
		}
		else if (color.g <= color.r && color.g <= color.b)
		{
			if (color.r <= color.b)
			{
				color = vec3<f32>(setSaturationMinMidMax(color.grb, s)).grb;
			}
			else
			{
				color = vec3<f32>(setSaturationMinMidMax(color.gbr, s)).gbr;
			}
		}
		else
		{
			// Using bgr for both fixes part of hue
			if (color.r <= color.g)
			{
				color = vec3<f32>(setSaturationMinMidMax(color.brg, s)).brg;
			}
			else
			{
				color  = vec3<f32>(setSaturationMinMidMax(color.bgr, s)).bgr;
			}
		}

		return color;
	}
	`;var y_=`
in vec2 vTextureCoord;

out vec4 finalColor;

uniform float uAlpha;
uniform sampler2D uTexture;

void main()
{
    finalColor =  texture(uTexture, vTextureCoord) * uAlpha;
}
`,Gl=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct AlphaUniforms {
  uAlpha:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> alphaUniforms : AlphaUniforms;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
 
    var sample = textureSample(uTexture, uSampler, uv);
    
    return sample * alphaUniforms.uAlpha;
}`,zP=Object.defineProperty,WP=Object.defineProperties,VP=Object.getOwnPropertyDescriptors,Zi=Object.getOwnPropertySymbols,T_=Object.prototype.hasOwnProperty,S_=Object.prototype.propertyIsEnumerable,w_=(r,t,e)=>t in r?zP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Il=(r,t)=>{for(var e in t||(t={}))T_.call(t,e)&&w_(r,e,t[e]);if(Zi)for(var e of Zi(t))S_.call(t,e)&&w_(r,e,t[e]);return r},YP=(r,t)=>WP(r,VP(t)),KP=(r,t)=>{var e={};for(var s in r)T_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Zi)for(var s of Zi(r))t.indexOf(s)<0&&S_.call(r,s)&&(e[s]=r[s]);return e};const E_=class hT extends ye{constructor(t){t=Il(Il({},hT.defaultOptions),t);const e=Nt.from({vertex:{source:Gl,entryPoint:"mainVertex"},fragment:{source:Gl,entryPoint:"mainFragment"}}),s=Ht.from({vertex:ls,fragment:y_,name:"alpha-filter"}),i=t,{alpha:n}=i,o=KP(i,["alpha"]),a=new At({uAlpha:{value:n,type:"f32"}});super(YP(Il({},o),{gpuProgram:e,glProgram:s,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};E_.defaultOptions={alpha:1};let qP=E_;const Bl={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},ZP=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{","    %blur%","}"].join(`
`);function A_(r){const t=Bl[r],e=t.length;let s="";const i="finalColor = ",n="    + ",o="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let a=0;a<r;a++){const l=a===0?i:n,u=a<e?a:r-a-1,h=o.replace("%index%",a.toString()).replace("%value%",t[u].toString());s+=`${l}${h}
`}return ZP.replace("%blur%",`${s};`).replace("%size%",r.toString())}const QP=`
    in vec2 aPosition;

    uniform float uStrength;

    out vec2 vBlurTexCoords[%size%];

    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();

        float pixelStrength = uInputSize.%dimension% * uStrength;

        vec2 textureCoord = filterTextureCoord();
        %blur%
    }`;function P_(r,t){const e=Math.ceil(r/2);let s=QP,i="",n;t?n="vBlurTexCoords[%index%] =  textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] =  textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),i+=a,i+=`
`}return s=s.replace("%blur%",i),s=s.replace("%size%",r.toString()),s=s.replace("%dimension%",t?"z":"w"),s}function C_(r,t){const e=P_(t,r),s=A_(t);return Ht.from({vertex:e,fragment:s,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var R_=`

struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct BlurUniforms {
  uStrength:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;


struct VSOutput {
    @builtin(position) position: vec4<f32>,
    %blur-struct%
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}


@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>,
) -> VSOutput {

  let filteredCord = filterTextureCoord(aPosition);

  let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;

  return VSOutput(
   filterVertexPosition(aPosition),
    %blur-vertex-out%
  );
}

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  %blur-fragment-in%
) -> @location(0) vec4<f32> {

    var   finalColor = vec4(0.0);

    %blur-sampling%

    return finalColor;
}
`;function M_(r,t){const e=Bl[t],s=e.length,i=[],n=[],o=[];for(let c=0;c<t;c++){i[c]=`@location(${c}) offset${c}: vec2<f32>,`,r?n[c]=`filteredCord + vec2(${c-s+1} * pixelStrength, 0.0),`:n[c]=`filteredCord + vec2(0.0, ${c-s+1} * pixelStrength),`;const d=c<s?c:t-c-1,p=e[d].toString();o[c]=`finalColor += textureSample(uTexture, uSampler, offset${c}) * ${p};`}const a=i.join(`
`),l=n.join(`
`),u=o.join(`
`),h=R_.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return Nt.from({vertex:{source:h,entryPoint:"mainVertex"},fragment:{source:h,entryPoint:"mainFragment"}})}var JP=Object.defineProperty,O_=Object.getOwnPropertySymbols,tC=Object.prototype.hasOwnProperty,eC=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?JP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fl=(r,t)=>{for(var e in t||(t={}))tC.call(t,e)&&G_(r,e,t[e]);if(O_)for(var e of O_(t))eC.call(t,e)&&G_(r,e,t[e]);return r};const I_=class cT extends ye{constructor(t){var e;t=Fl(Fl({},cT.defaultOptions),t);const s=C_(t.horizontal,t.kernelSize),i=M_(t.horizontal,t.kernelSize);super(Fl({glProgram:s,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this.legacy=(e=t.legacy)!=null?e:!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,s,i){this.legacy?this._applyLegacy(t,e,s,i):this._applyOptimized(t,e,s,i)}_applyLegacy(t,e,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,i);else{const n=_t.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer.type===Ot.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,o,a,u===0?!0:l);const h=a;a=o,o=h}this._state.blend=!0,t.applyFilter(this,o,s,i),_t.returnTexture(n)}}_applyOptimized(t,e,s,i){if(this._uniforms.uStrength=this._calculateInitialStrength(),this.passes===1)t.applyFilter(this,e,s,i);else{const n=_t.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer,u=l.type===Ot.WEBGPU,h=u?l.renderPipes.uniformBatch:null;for(let c=0;c<this.passes-1;c++){h&&this.groups[1].setResource(h.getUboResource(this._blurUniforms),0),t.applyFilter(this,o,a,u);const d=a;a=o,o=d,this._uniforms.uStrength*=.5}h&&this.groups[1].setResource(h.getUboResource(this._blurUniforms),0),this._state.blend=!0,t.applyFilter(this,o,s,i),_t.returnTexture(n)}}_calculateInitialStrength(){let t=1,e=.5;for(let s=1;s<this.passes;s++)t+=e*e,e*=.5;return this.strength/Math.sqrt(t)}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};I_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let Qi=I_;var rC=Object.defineProperty,sC=Object.defineProperties,iC=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,B_=Object.prototype.hasOwnProperty,F_=Object.prototype.propertyIsEnumerable,D_=(r,t,e)=>t in r?rC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gs=(r,t)=>{for(var e in t||(t={}))B_.call(t,e)&&D_(r,e,t[e]);if(Ji)for(var e of Ji(t))F_.call(t,e)&&D_(r,e,t[e]);return r},nC=(r,t)=>sC(r,iC(t)),oC=(r,t)=>{var e={};for(var s in r)B_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ji)for(var s of Ji(r))t.indexOf(s)<0&&F_.call(r,s)&&(e[s]=r[s]);return e};class U_ extends ye{constructor(...t){var e;let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={strength:s},t[1]!==void 0&&(s.quality=t[1]),t[2]!==void 0&&(s.resolution=t[2]||"inherit"),t[3]!==void 0&&(s.kernelSize=t[3])),s=Gs(Gs({},Qi.defaultOptions),s);const i=s,{strength:n,strengthX:o,strengthY:a,quality:l}=i,u=oC(i,["strength","strengthX","strengthY","quality"]);super(nC(Gs({},u),{compatibleRenderers:Ot.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new Qi(Gs({horizontal:!0},s)),this.blurYFilter=new Qi(Gs({horizontal:!1},s)),this.quality=l,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,s,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=_t.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,s,i),_t.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,s,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,s,i))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}U_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var k_=`
in vec2 vTextureCoord;
in vec4 vColor;

out vec4 finalColor;

uniform float uColorMatrix[20];
uniform float uAlpha;

uniform sampler2D uTexture;

float rand(vec2 co)
{
    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}

void main()
{
    vec4 color = texture(uTexture, vTextureCoord);
    float randomValue = rand(gl_FragCoord.xy * 0.2);
    float diff = (randomValue - 0.5) *  0.5;

    if (uAlpha == 0.0) {
        finalColor = color;
        return;
    }

    if (color.a > 0.0) {
        color.rgb /= color.a;
    }

    vec4 result;

    result.r = (uColorMatrix[0] * color.r);
        result.r += (uColorMatrix[1] * color.g);
        result.r += (uColorMatrix[2] * color.b);
        result.r += (uColorMatrix[3] * color.a);
        result.r += uColorMatrix[4];

    result.g = (uColorMatrix[5] * color.r);
        result.g += (uColorMatrix[6] * color.g);
        result.g += (uColorMatrix[7] * color.b);
        result.g += (uColorMatrix[8] * color.a);
        result.g += uColorMatrix[9];

    result.b = (uColorMatrix[10] * color.r);
       result.b += (uColorMatrix[11] * color.g);
       result.b += (uColorMatrix[12] * color.b);
       result.b += (uColorMatrix[13] * color.a);
       result.b += uColorMatrix[14];

    result.a = (uColorMatrix[15] * color.r);
       result.a += (uColorMatrix[16] * color.g);
       result.a += (uColorMatrix[17] * color.b);
       result.a += (uColorMatrix[18] * color.a);
       result.a += uColorMatrix[19];

    vec3 rgb = mix(color.rgb, result.rgb, uAlpha);

    // Premultiply alpha again.
    rgb *= result.a;

    finalColor = vec4(rgb, result.a);
}
`,Dl=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct ColorMatrixUniforms {
  uColorMatrix:array<vec4<f32>, 5>,
  uAlpha:f32,
};


@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> colorMatrixUniforms : ColorMatrixUniforms;


struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
  };
  
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
  return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
  );
}


@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {


  var c = textureSample(uTexture, uSampler, uv);
  
  if (colorMatrixUniforms.uAlpha == 0.0) {
    return c;
  }

 
    // Un-premultiply alpha before applying the color matrix. See issue #3539.
    if (c.a > 0.0) {
      c.r /= c.a;
      c.g /= c.a;
      c.b /= c.a;
    }

    var cm = colorMatrixUniforms.uColorMatrix;


    var result = vec4<f32>(0.);

    result.r = (cm[0][0] * c.r);
    result.r += (cm[0][1] * c.g);
    result.r += (cm[0][2] * c.b);
    result.r += (cm[0][3] * c.a);
    result.r += cm[1][0];

    result.g = (cm[1][1] * c.r);
    result.g += (cm[1][2] * c.g);
    result.g += (cm[1][3] * c.b);
    result.g += (cm[2][0] * c.a);
    result.g += cm[2][1];

    result.b = (cm[2][2] * c.r);
    result.b += (cm[2][3] * c.g);
    result.b += (cm[3][0] * c.b);
    result.b += (cm[3][1] * c.a);
    result.b += cm[3][2];

    result.a = (cm[3][3] * c.r);
    result.a += (cm[4][0] * c.g);
    result.a += (cm[4][1] * c.b);
    result.a += (cm[4][2] * c.a);
    result.a += cm[4][3];

    var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha);

    rgb.r *= result.a;
    rgb.g *= result.a;
    rgb.b *= result.a;

    return vec4(rgb, result.a);
}`,aC=Object.defineProperty,lC=Object.defineProperties,uC=Object.getOwnPropertyDescriptors,$_=Object.getOwnPropertySymbols,hC=Object.prototype.hasOwnProperty,cC=Object.prototype.propertyIsEnumerable,L_=(r,t,e)=>t in r?aC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dC=(r,t)=>{for(var e in t||(t={}))hC.call(t,e)&&L_(r,e,t[e]);if($_)for(var e of $_(t))cC.call(t,e)&&L_(r,e,t[e]);return r},pC=(r,t)=>lC(r,uC(t));class fC extends ye{constructor(t={}){const e=new At({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),s=Nt.from({vertex:{source:Dl,entryPoint:"mainVertex"},fragment:{source:Dl,entryPoint:"mainFragment"}}),i=Ht.from({vertex:ls,fragment:k_,name:"color-matrix-filter"});super(pC(dC({},t),{gpuProgram:s,glProgram:i,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){if(e){const s=[...t];this._multiply(s,this.matrix,t),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=s}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t;this.resources.colorMatrixUniforms.update()}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,i,n]=rt.shared.setValue(t).toArray(),o=[s,0,0,0,0,0,i,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),i=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=s+(1-s)*o,u=o*(1-s)-a*i,h=o*(1-s)+a*i,c=o*(1-s)+a*i,d=s+o*(1-s),p=o*(1-s)-a*i,f=o*(1-s)-a*i,m=o*(1-s)+a*i,g=s+o*(1-s),_=[l,u,h,0,0,c,d,p,0,0,f,m,g,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const s=(t||0)+1,i=-.5*(s-1),n=[s,0,0,0,i,0,s,0,0,i,0,0,s,0,i,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,i=(s-1)*-.5,n=[s,i,i,0,0,i,s,i,0,0,i,i,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,.046249425232852304,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.2758903984886823,-.231103377548616,-.7501899197440212,1.847597816108189,0,.12137623870388682,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,.24991995145868634,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,.09698983488904393,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,.13972481597886063,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,.1860075629647401,-.037703249837783157,.8609577587992641,.15059552388459913,0,-.14497417640467167,.24113635128153335,-.07441037908422492,.44972182064877153,0,-.029655197167024642,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,.037848179746251466,.02578397704808868,.6441188644374771,.03259127616149294,0,.029265996770472907,.0466055556782719,-.0851232987247891,.5241648018700465,0,.020232119953863904,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,i,n){t||(t=.2),e||(e=.15),s||(s=16770432),i||(i=3375104);const o=rt.shared,[a,l,u]=o.setValue(s).toArray(),[h,c,d]=o.setValue(i).toArray(),p=[.3,.59,.11,0,0,a,l,u,t,0,h,c,d,e,0,a-h,l-c,u-d,0,0];this._loadMatrix(p,n)}night(t,e){t||(t=.1);const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(s,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var N_=`
in vec2 vTextureCoord;
in vec2 vFilterUv;

out vec4 finalColor;

uniform sampler2D uTexture;
uniform sampler2D uMapTexture;

uniform vec4 uInputClamp;
uniform highp vec4 uInputSize;
uniform mat2 uRotation;
uniform vec2 uScale;

void main()
{
    vec4 map = texture(uMapTexture, vFilterUv);
    
    vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale; 

    finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw));
}
`,X_=`in vec2 aPosition;
out vec2 vTextureCoord;
out vec2 vFilterUv;


uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;

uniform mat3 uFilterMatrix;

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);
}

vec2 getFilterCoord( void )
{
  return ( uFilterMatrix * vec3( filterTextureCoord(), 1.0)  ).xy;
}


void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
    vFilterUv = getFilterCoord();
}
`,Ul=`
struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct DisplacementUniforms {
  uFilterMatrix:mat3x3<f32>,
  uScale:vec2<f32>,
  uRotation:mat2x2<f32>
};



@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> filterUniforms : DisplacementUniforms;
@group(1) @binding(1) var uMapTexture: texture_2d<f32>;
@group(1) @binding(2) var uMapSampler : sampler;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) filterUv : vec2<f32>,
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}

fn getSize() -> vec2<f32>
{

  
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
   getFilterCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) filterUv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var map = textureSample(uMapTexture, uMapSampler, filterUv);

    var offset =  gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale; 
   
    return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw));
}`,mC=Object.defineProperty,gC=Object.defineProperties,_C=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,H_=Object.prototype.hasOwnProperty,j_=Object.prototype.propertyIsEnumerable,z_=(r,t,e)=>t in r?mC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xC=(r,t)=>{for(var e in t||(t={}))H_.call(t,e)&&z_(r,e,t[e]);if(tn)for(var e of tn(t))j_.call(t,e)&&z_(r,e,t[e]);return r},vC=(r,t)=>gC(r,_C(t)),bC=(r,t)=>{var e={};for(var s in r)H_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&tn)for(var s of tn(r))t.indexOf(s)<0&&j_.call(r,s)&&(e[s]=r[s]);return e};class yC extends ye{constructor(...t){let e=t[0];e instanceof pe&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=bC(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new lt(a,a));const l=new At({uFilterMatrix:{value:new D,type:"mat3x3<f32>"},uScale:{value:a,type:"vec2<f32>"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2<f32>"}}),u=Ht.from({vertex:X_,fragment:N_,name:"displacement-filter"}),h=Nt.from({vertex:{source:Ul,entryPoint:"mainVertex"},fragment:{source:Ul,entryPoint:"mainFragment"}}),c=i.texture.source;super(vC(xC({},o),{gpuProgram:h,glProgram:u,resources:{filterUniforms:l,uMapTexture:c,uMapSampler:c.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,s,i){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),l=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&l!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/l,n.uRotation[3]=o.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,s,i)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var W_=`
in vec2 vTextureCoord;
in vec4 vColor;

out vec4 finalColor;

uniform float uNoise;
uniform float uSeed;
uniform sampler2D uTexture;

float rand(vec2 co)
{
    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}

void main()
{
    vec4 color = texture(uTexture, vTextureCoord);
    float randomValue = rand(gl_FragCoord.xy * uSeed);
    float diff = (randomValue - 0.5) *  uNoise;

    // Un-premultiply alpha before applying the color matrix. See issue #3539.
    if (color.a > 0.0) {
        color.rgb /= color.a;
    }

    color.r += diff;
    color.g += diff;
    color.b += diff;

    // Premultiply alpha again.
    color.rgb *= color.a;

    finalColor = color;
}
`,kl=`

struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct NoiseUniforms {
  uNoise:f32,
  uSeed:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}

fn rand(co:vec2<f32>) -> f32
{
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}



@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var pixelPosition =  globalTextureCoord(position.xy);// / (getSize());//-  gfu.uOutputFrame.xy);
  
    
    var sample = textureSample(uTexture, uSampler, uv);
    var randomValue =  rand(pixelPosition.xy * noiseUniforms.uSeed);
    var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
  
    // Un-premultiply alpha before applying the color matrix. See issue #3539.
    if (sample.a > 0.0) {
      sample.r /= sample.a;
      sample.g /= sample.a;
      sample.b /= sample.a;
    }

    sample.r += diff;
    sample.g += diff;
    sample.b += diff;

    // Premultiply alpha again.
    sample.r *= sample.a;
    sample.g *= sample.a;
    sample.b *= sample.a;
    
    return sample;
}`,TC=Object.defineProperty,SC=Object.defineProperties,wC=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,V_=Object.prototype.hasOwnProperty,Y_=Object.prototype.propertyIsEnumerable,K_=(r,t,e)=>t in r?TC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$l=(r,t)=>{for(var e in t||(t={}))V_.call(t,e)&&K_(r,e,t[e]);if(en)for(var e of en(t))Y_.call(t,e)&&K_(r,e,t[e]);return r},EC=(r,t)=>SC(r,wC(t)),AC=(r,t)=>{var e={};for(var s in r)V_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&en)for(var s of en(r))t.indexOf(s)<0&&Y_.call(r,s)&&(e[s]=r[s]);return e};const q_=class dT extends ye{constructor(t={}){t=$l($l({},dT.defaultOptions),t);const e=Nt.from({vertex:{source:kl,entryPoint:"mainVertex"},fragment:{source:kl,entryPoint:"mainFragment"}}),s=Ht.from({vertex:ls,fragment:W_,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=AC(i,["noise","seed"]);super(EC($l({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new At({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};q_.defaultOptions={noise:.5};let PC=q_;var Z_=`in vec2 vMaskCoord;
in vec2 vTextureCoord;

uniform sampler2D uTexture;
uniform sampler2D uMaskTexture;

uniform float uAlpha;
uniform vec4 uMaskClamp;
uniform float uInverse;

out vec4 finalColor;

void main(void)
{
    float clip = step(3.5,
        step(uMaskClamp.x, vMaskCoord.x) +
        step(uMaskClamp.y, vMaskCoord.y) +
        step(vMaskCoord.x, uMaskClamp.z) +
        step(vMaskCoord.y, uMaskClamp.w));

    // TODO look into why this is needed
    float npmAlpha = uAlpha;
    vec4 original = texture(uTexture, vTextureCoord);
    vec4 masky = texture(uMaskTexture, vMaskCoord);
    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);

    float a = alphaMul * masky.r * npmAlpha * clip;

    if (uInverse == 1.0) {
        a = 1.0 - a;
    }

    finalColor = original * a;
}
`,Q_=`in vec2 aPosition;

out vec2 vTextureCoord;
out vec2 vMaskCoord;


uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;

vec4 filterVertexPosition(  vec2 aPosition )
{
    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(  vec2 aPosition )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

vec2 getFilterCoord( vec2 aPosition )
{
    return  ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}   

void main(void)
{
    gl_Position = filterVertexPosition(aPosition);
    vTextureCoord = filterTextureCoord(aPosition);
    vMaskCoord = getFilterCoord(aPosition);
}
`,Ll=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct MaskUniforms {
  uFilterMatrix:mat3x3<f32>,
  uMaskClamp:vec4<f32>,
  uAlpha:f32,
  uInverse:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) filterUv : vec2<f32>,
};

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    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<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}

fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}

@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>,
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
   getFilterCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) filterUv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var maskClamp = filterUniforms.uMaskClamp;
    var uAlpha = filterUniforms.uAlpha;

    var clip = step(3.5,
      step(maskClamp.x, filterUv.x) +
      step(maskClamp.y, filterUv.y) +
      step(filterUv.x, maskClamp.z) +
      step(filterUv.y, maskClamp.w));

    var mask = textureSample(uMaskTexture, uSampler, filterUv);
    var source = textureSample(uTexture, uSampler, uv);
    var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);

    var a: f32 = alphaMul * mask.r * uAlpha * clip;

    if (filterUniforms.uInverse == 1.0) {
        a = 1.0 - a;
    }

    return source * a;
}
`,CC=Object.defineProperty,RC=Object.defineProperties,MC=Object.getOwnPropertyDescriptors,rn=Object.getOwnPropertySymbols,J_=Object.prototype.hasOwnProperty,tx=Object.prototype.propertyIsEnumerable,ex=(r,t,e)=>t in r?CC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,OC=(r,t)=>{for(var e in t||(t={}))J_.call(t,e)&&ex(r,e,t[e]);if(rn)for(var e of rn(t))tx.call(t,e)&&ex(r,e,t[e]);return r},GC=(r,t)=>RC(r,MC(t)),IC=(r,t)=>{var e={};for(var s in r)J_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&rn)for(var s of rn(r))t.indexOf(s)<0&&tx.call(r,s)&&(e[s]=r[s]);return e};class rx extends ye{constructor(t){const e=t,{sprite:s}=e,i=IC(e,["sprite"]),n=new Bo(s.texture),o=new At({uFilterMatrix:{value:new D,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),a=Nt.from({vertex:{source:Ll,entryPoint:"mainVertex"},fragment:{source:Ll,entryPoint:"mainFragment"}}),l=Ht.from({vertex:Q_,fragment:Z_,name:"mask-filter"});super(GC(OC({},i),{gpuProgram:a,glProgram:l,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,s,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,i)}}var BC=`fn getLuminosity(c: vec3<f32>) -> f32 {
  return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
}

fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32> {
  let d: f32 = lum - getLuminosity(c);
  let newColor: vec3<f32> = c.rgb + vec3<f32>(d, d, d);

  // clip back into legal range
  let newLum: f32 = getLuminosity(newColor);
  let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b));
  let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b));

  let t1: f32 = newLum / (newLum - cMin);
  let t2: f32 = (1.0 - newLum) / (cMax - newLum);

  let finalColor = mix(vec3<f32>(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0));

  return finalColor;
}

fn getSaturation(c: vec3<f32>) -> f32 {
  return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}

// Set saturation if color components are sorted in ascending order.
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32> {
  var result: vec3<f32>;
  if (cSorted.z > cSorted.x) {
    let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x));
    result = vec3<f32>(0.0, newY, s);
  } else {
    result = vec3<f32>(0.0, 0.0, 0.0);
  }
  return vec3<f32>(result.x, result.y, result.z);
}

fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32> {
    var result: vec3<f32> = c;

    if (c.r <= c.g && c.r <= c.b) {
        if (c.g <= c.b) {
            result = setSaturationMinMidMax(result, s);
        } else {
            var temp: vec3<f32> = vec3<f32>(result.r, result.b, result.g);
            temp = setSaturationMinMidMax(temp, s);
            result = vec3<f32>(temp.r, temp.b, temp.g);
        }
    } else if (c.g <= c.r && c.g <= c.b) {
        if (c.r <= c.b) {
            var temp: vec3<f32> = vec3<f32>(result.g, result.r, result.b);
            temp = setSaturationMinMidMax(temp, s);
            result = vec3<f32>(temp.g, temp.r, temp.b);
        } else {
            var temp: vec3<f32> = vec3<f32>(result.g, result.b, result.r);
            temp = setSaturationMinMidMax(temp, s);
            result = vec3<f32>(temp.g, temp.b, temp.r);
        }
    } else {
        if (c.r <= c.g) {
            var temp: vec3<f32> = vec3<f32>(result.b, result.r, result.g);
            temp = setSaturationMinMidMax(temp, s);
            result = vec3<f32>(temp.b, temp.r, temp.g);
        } else {
            var temp: vec3<f32> = vec3<f32>(result.b, result.g, result.r);
            temp = setSaturationMinMidMax(temp, s);
            result = vec3<f32>(temp.b, temp.g, temp.r);
        }
    }

    return result;
}`;const sx=class pT{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let s=0;for(;e.length&&s<pT.uploadsPerFrame;){const i=e.shift();this.uploadQueueItem(i),s++}e.length?Rt.system.addOnce(this._tick,this,_e.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const s of e)s instanceof pt?this._addContainer(s):this.resolveQueueItem(s,this.queue);return this}_addContainer(t){this.resolveQueueItem(t,this.queue);for(const e of t.children)this._addContainer(e)}upload(t){return t&&this.add(t),new Promise(e=>{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),Rt.system.addOnce(this._tick,this,_e.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;s<this.queue.length;s++){const i=this.queue[s];t[i.uid]||(t[i.uid]=!0,this.queue[e++]=i)}this.queue.length=e}destroy(){this._destroyed=!0,clearTimeout(this.timeout)}_resolve(){const{resolves:t}=this,e=t.slice(0);t.length=0;for(const s of e)s()}};sx.uploadsPerFrame=4;let ix=sx,FC=class{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}},DC=class{constructor(){this.instructions=new ri}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}};const Nl=class gc{constructor(t){this._renderer=t,this._managedContexts=new Bt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;gc.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:gc.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],i=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&i.reset(),i.isBatchable=!1,t.dirty=!1),i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new DC,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new FC;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Nl.extension={type:[S.CanvasSystem],name:"graphicsContext"},Nl.defaultOptions={bezierSmoothness:.5};let nx=Nl;class Xl{constructor(t,e){this.state=jt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Bt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Xl.extension={type:[S.CanvasPipes],name:"graphics"};function UC(r,t,e,s){e[s++]=(r>>16&255)/255,e[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function Dr(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class ox{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Et.return(t)}),this.batches.length=0}}class Hl{constructor(t,e){this.state=jt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Bt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let s=0;s<e.length;s++){const i=e[s];i._batcher.updateElement(i)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const i=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=i.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,Dr(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),s=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),s.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,i=this._getGpuDataForRenderable(t).batches;for(let n=0;n<i.length;n++){const o=i[n];s.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new ox;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,i=this.renderer.graphicsContext.getGpuContext(s),n=this.renderer._roundPixels|t._roundPixels;e.batches=i.batches.map(o=>{const a=Et.get(Fi);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Hl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"graphics"},N.add(Xl),N.add(Hl),N.add(nx),N.add(ki);var kC=Object.defineProperty,sn=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,lx=Object.prototype.propertyIsEnumerable,ux=(r,t,e)=>t in r?kC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$C=(r,t)=>{for(var e in t||(t={}))ax.call(t,e)&&ux(r,e,t[e]);if(sn)for(var e of sn(t))lx.call(t,e)&&ux(r,e,t[e]);return r},LC=(r,t)=>{var e={};for(var s in r)ax.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&sn)for(var s of sn(r))t.indexOf(s)<0&&lx.call(r,s)&&(e[s]=r[s]);return e};class hr extends xe{constructor(t){t instanceof kt&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=LC(e,["context","roundPixels"]);super($C({label:"Graphics"},n)),this.renderPipeId="graphics",s?this.context=s:(this.context=this._ownedContext=new kt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i!=null?i:!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new hr(this._context.clone()):(this._ownedContext=null,new hr(this._context))}lineStyle(t,e,s){const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==kt.defaultStrokeStyle.width||t.color!==kt.defaultStrokeStyle.color||t.alpha!==kt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}var NC=Object.defineProperty,hx=Object.getOwnPropertySymbols,XC=Object.prototype.hasOwnProperty,HC=Object.prototype.propertyIsEnumerable,cx=(r,t,e)=>t in r?NC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dx=(r,t)=>{for(var e in t||(t={}))XC.call(t,e)&&cx(r,e,t[e]);if(hx)for(var e of hx(t))HC.call(t,e)&&cx(r,e,t[e]);return r};const px=class fT extends qe{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=dx(dx({},fT.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=s.uvs;n||(s.positions?n=new Float32Array(i.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,l=new zt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:ot.VERTEX|ot.COPY_DST}),u=new zt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:ot.VERTEX|ot.COPY_DST}),h=new zt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:ot.INDEX|ot.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:8,offset:0},aUV:{buffer:u,format:"float32x2",stride:8,offset:0}},indexBuffer:h,topology:s.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};px.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Ue=px;class nn{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let s=e;const i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length<e.length)&&(s=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=i._updateID,this._uvUpdateId=t._updateID,i.multiplyUvs(e,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class jl{destroy(){}}class zl{constructor(t,e){this.localUniforms=new At({uTransformMatrix:{value:new D,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new be({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),s=e.batched,i=t.batched;if(e.batched=i,s!==i)return!0;if(i){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){var s,i;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(s=t._geometry.indices)==null?void 0:s.length,o.vertexSize=(i=t._geometry.positions)==null?void 0:i.length),o.batched){const a=this._getBatchableMesh(t);a.setTexture(t._texture),a.geometry=t._geometry,n.addToBatch(a,e)}else n.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=Tr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Dr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new jl),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new jl),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new nn;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}zl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"mesh"},N.add(zl);var jC=Object.defineProperty,on=Object.getOwnPropertySymbols,fx=Object.prototype.hasOwnProperty,mx=Object.prototype.propertyIsEnumerable,gx=(r,t,e)=>t in r?jC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zC=(r,t)=>{for(var e in t||(t={}))fx.call(t,e)&&gx(r,e,t[e]);if(on)for(var e of on(t))mx.call(t,e)&&gx(r,e,t[e]);return r},WC=(r,t)=>{var e={};for(var s in r)fx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&on)for(var s of on(r))t.indexOf(s)<0&&mx.call(r,s)&&(e[s]=r[s]);return e};class Ur extends xe{constructor(...t){var e;let s=t[0];s instanceof qe&&(s={geometry:s,shader:t[1]},t[3]&&(s.geometry.topology=t[3]));const i=s,{geometry:n,shader:o,texture:a,roundPixels:l,state:u}=i,h=WC(i,["geometry","shader","texture","roundPixels","state"]);super(zC({label:"Mesh"},h)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=o!=null?o:null,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:F.WHITE,this.state=u!=null?u:jt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=F.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||(this.state.data&12)!==0?!1:this._geometry instanceof Ue?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:s}=t;if(!this.bounds.containsPoint(e,s))return!1;const i=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){const u=o[l]*2,h=o[l+1]*2,c=o[l+2]*2;if(_a(e,s,i[u],i[u+1],i[h],i[h+1],i[c],i[c+1]))return!0}}else{const o=i.length/2;for(let a=0;a+2<o;a+=n){const l=a*2,u=(a+1)*2,h=(a+2)*2;if(_a(e,s,i[l],i[l+1],i[u],i[u+1],i[h],i[h+1]))return!0}}return!1}destroy(t){var e;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}(e=this._geometry)==null||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}var VC=Object.defineProperty,YC=Object.defineProperties,KC=Object.getOwnPropertyDescriptors,an=Object.getOwnPropertySymbols,_x=Object.prototype.hasOwnProperty,xx=Object.prototype.propertyIsEnumerable,vx=(r,t,e)=>t in r?VC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qC=(r,t)=>{for(var e in t||(t={}))_x.call(t,e)&&vx(r,e,t[e]);if(an)for(var e of an(t))xx.call(t,e)&&vx(r,e,t[e]);return r},ZC=(r,t)=>YC(r,KC(t)),QC=(r,t)=>{var e={};for(var s in r)_x.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&an)for(var s of an(r))t.indexOf(s)<0&&xx.call(r,s)&&(e[s]=r[s]);return e};class Ws extends pe{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const s=e,{animationSpeed:i=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:h=null,textures:c,updateAnchor:d=!1}=s,p=QC(s,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[f]=c;super(ZC(qC({},p),{texture:f instanceof F?f:f.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=a,this.updateAnchor=d,this.onComplete=l,this.onFrameChange=u,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Rt.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Rt.shared.add(this.update,this,_e.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=s/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<i||this.animationSpeed<0&&this.currentFrame>i)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(s=>{this.texture!==s&&s.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;s<t.length;++s)e.push(F.from(t[s]));return new Ws(e)}static fromImages(t){const e=[];for(let s=0;s<t.length;++s)e.push(F.from(t[s]));return new Ws(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof F)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Rt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Rt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class bx{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new D,this.observer=e,this.position=new xt(this,0,0),this.scale=new xt(this,1,1),this.pivot=new xt(this,0,0),this.skew=new xt(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}let kr;function yx(r){const t=H.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function Wl(){if(kr!==void 0)return kr;try{const r=yx("#ff00ff"),t=yx("#ffff00"),e=H.get().createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const s=e.getImageData(2,0,1,1);if(!s)kr=!1;else{const i=s.data;kr=i[0]===255&&i[1]===0&&i[2]===0}}catch(r){kr=!1}return kr}const Q={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Wl(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{var t,e;const s=r.source,i=s==null?void 0:s.resource;if(!i)return null;const n=s.alphaMode==="premultiplied-alpha",o=(t=s.resourceWidth)!=null?t:s.pixelWidth,a=(e=s.resourceHeight)!=null?e:s.pixelHeight,l=o!==s.pixelWidth||a!==s.pixelHeight;if(n){if((i instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&i instanceof OffscreenCanvas)&&!l)return i;const u=Q._unpremultipliedCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas}if(i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int8Array||i instanceof Uint16Array||i instanceof Int16Array||i instanceof Uint32Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof ArrayBuffer){const u=Q._canvasSourceCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas;const h=H.get().createCanvas(s.pixelWidth,s.pixelHeight),c=h.getContext("2d"),d=c.createImageData(s.pixelWidth,s.pixelHeight),p=d.data,f=i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength);if(s.format==="bgra8unorm")for(let m=0;m<p.length&&m+3<f.length;m+=4)p[m]=f[m+2],p[m+1]=f[m+1],p[m+2]=f[m],p[m+3]=f[m+3];else p.set(f.subarray(0,p.length));return c.putImageData(d,0,0),Q._canvasSourceCache.set(s,{canvas:h,resourceId:s._resourceId}),h}if(n){const u=H.get().createCanvas(s.pixelWidth,s.pixelHeight),h=u.getContext("2d",{willReadFrequently:!0});u.width=s.pixelWidth,u.height=s.pixelHeight,h.drawImage(i,0,0);const c=h.getImageData(0,0,u.width,u.height),d=c.data;for(let p=0;p<d.length;p+=4){const f=d[p+3];if(f>0){const m=255/f;d[p]=Math.min(255,d[p]*m+.5),d[p+1]=Math.min(255,d[p+1]*m+.5),d[p+2]=Math.min(255,d[p+2]*m+.5)}}return h.putImageData(c,0,0),Q._unpremultipliedCache.set(s,{canvas:u,resourceId:s._resourceId}),u}if(l){const u=Q._canvasSourceCache.get(s);if((u==null?void 0:u.resourceId)===s._resourceId)return u.canvas;const h=H.get().createCanvas(s.pixelWidth,s.pixelHeight),c=h.getContext("2d");return h.width=s.pixelWidth,h.height=s.pixelHeight,c.drawImage(i,0,0),Q._canvasSourceCache.set(s,{canvas:h,resourceId:s._resourceId}),h}return i},getTintedCanvas:(r,t)=>{const e=r.texture,s=rt.shared.setValue(t).toHex(),i=e.tintCache||(e.tintCache={}),n=i[s],o=e.source._resourceId;if((n==null?void 0:n.tintId)===o)return n;const a=n&&"getContext"in n?n:H.get().createCanvas();if(Q.tintMethod(e,t,a),a.tintId=o,Q.convertTintToImage&&a.toDataURL!==void 0){const l=H.get().createImage();l.src=a.toDataURL(),l.tintId=o,i[s]=l}else i[s]=a;return i[s]},getTintedPattern:(r,t)=>{const e=rt.shared.setValue(t).toHex(),s=r.patternCache||(r.patternCache={}),i=r.source._resourceId;let n=s[e];return(n==null?void 0:n.tintId)===i||(Q.canvas||(Q.canvas=H.get().createCanvas()),Q.tintMethod(r,t,Q.canvas),n=Q.canvas.getContext("2d").createPattern(Q.canvas,"repeat"),n.tintId=i,s[e]=n),n},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const s=r;if(!s.setTransform)return;const i=globalThis.DOMMatrix;if(!i)return;const n=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(e?n.inverse():n)},tintWithMultiply:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=j.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),n.fillStyle=rt.shared.setValue(t).toHex(),n.fillRect(0,0,h,c),n.globalCompositeOperation="multiply";const d=Q.getCanvasSource(r);if(!d){n.restore();return}l&&Q._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.globalCompositeOperation="destination-atop",n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.restore()},tintWithOverlay:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=j.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),n.globalCompositeOperation="copy",n.fillStyle=rt.shared.setValue(t).toHex(),n.fillRect(0,0,h,c),n.globalCompositeOperation="destination-atop";const d=Q.getCanvasSource(r);if(!d){n.restore();return}l&&Q._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.restore()},tintWithPerPixel:(r,t,e)=>{var s,i;const n=e.getContext("2d"),o=r.frame.clone(),a=(i=(s=r.source._resolution)!=null?s:r.source.resolution)!=null?i:1,l=r.rotate;o.x*=a,o.y*=a,o.width*=a,o.height*=a;const u=j.isVertical(l),h=u?o.height:o.width,c=u?o.width:o.height;e.width=Math.ceil(h),e.height=Math.ceil(c),n.save(),n.globalCompositeOperation="copy";const d=Q.getCanvasSource(r);if(!d){n.restore();return}l&&Q._applyInverseRotation(n,l,o.width,o.height),n.drawImage(d,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n.restore();const p=t>>16&255,f=t>>8&255,m=t&255,g=n.getImageData(0,0,h,c),_=g.data;for(let x=0;x<_.length;x+=4)_[x]=_[x]*p/255,_[x+1]=_[x+1]*f/255,_[x+2]=_[x+2]*m/255;n.putImageData(g,0,0)},_applyInverseRotation:(r,t,e,s)=>{const i=j.inv(t),n=j.uX(i),o=j.uY(i),a=j.vX(i),l=j.vY(i),u=-Math.min(0,n*e,a*s,n*e+a*s),h=-Math.min(0,o*e,l*s,o*e+l*s);r.transform(n,o,a,l,u,h)}};Q.tintMethod=Q.canUseMultiply?Q.tintWithMultiply:Q.tintWithPerPixel;const ln=new D,Is=new D,Te=[new lt,new lt,new lt,new lt];class Vl{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,s,i,n,o,a;const l=this._renderer,u=l.canvasContext,h=u.activeContext;h.save(),u.setBlendMode(t.groupBlendMode);const c=(s=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?s:4294967295,d=t.groupColorAlpha,p=(c>>>24&255)/255,f=(d>>>24&255)/255,m=(n=(i=l.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,g=p*f*m;if(g<=0){h.restore();return}h.globalAlpha=g;const _=c&16777215,x=d&16777215,v=ge(Ae(x,_)),b=t.texture,T=Q.getTintedPattern(b,v),y=t.width,w=t.height,A=t.groupTransform,R=(a=(o=b.source._resolution)!=null?o:b.source.resolution)!=null?a:1;Is.copyFrom(t._tileTransform.matrix),t.applyAnchorToTexture||Is.translate(-t.anchor.x*y,-t.anchor.y*w),Is.scale(1/R,1/R),ln.identity(),ln.prepend(Is),ln.prepend(A);const C=l._roundPixels|t._roundPixels;u.setContextTransform(ln,C===1),h.fillStyle=T;const E=t.anchor.x*-y,G=t.anchor.y*-w;Te[0].set(E,G),Te[1].set(E+y,G),Te[2].set(E+y,G+w),Te[3].set(E,G+w);for(let I=0;I<4;I++)Is.applyInverse(Te[I],Te[I]);h.beginPath(),h.moveTo(Te[0].x,Te[0].y);for(let I=1;I<4;I++)h.lineTo(Te[I].x,Te[I].y);h.closePath(),h.fill(),h.restore()}destroy(){this._renderer=null}}Vl.extension={type:[S.CanvasPipes],name:"tilingSprite"};var JC=Object.defineProperty,tR=Object.defineProperties,eR=Object.getOwnPropertyDescriptors,Tx=Object.getOwnPropertySymbols,rR=Object.prototype.hasOwnProperty,sR=Object.prototype.propertyIsEnumerable,Sx=(r,t,e)=>t in r?JC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wx=(r,t)=>{for(var e in t||(t={}))rR.call(t,e)&&Sx(r,e,t[e]);if(Tx)for(var e of Tx(t))sR.call(t,e)&&Sx(r,e,t[e]);return r},Ex=(r,t)=>tR(r,eR(t));const $r={name:"local-uniform-bit",vertex:{header:`

            struct LocalUniforms {
                uTransformMatrix:mat3x3<f32>,
                uColor:vec4<f32>,
                uRound:f32,
            }

            @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `}},Ax=Ex(wx({},$r),{vertex:Ex(wx({},$r.vertex),{header:$r.vertex.header.replace("group(1)","group(2)")})}),un={name:"local-uniform-bit",vertex:{header:`

            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix = uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `}},Px={name:"tiling-bit",vertex:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`
            uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;

            position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
        `},fragment:{header:`
            struct TilingUniforms {
                uMapCoord:mat3x3<f32>,
                uClampFrame:vec4<f32>,
                uClampOffset:vec2<f32>,
                uTextureTransform:mat3x3<f32>,
                uSizeAnchor:vec4<f32>
            };

            @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
            @group(2) @binding(1) var uTexture: texture_2d<f32>;
            @group(2) @binding(2) var uSampler: sampler;
        `,main:`

            var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
            coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
            var unclamped = coord;
            coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);

            var bias = 0.;

            if(unclamped.x == coord.x && unclamped.y == coord.y)
            {
                bias = -32.;
            }

            outColor = textureSampleBias(uTexture, uSampler, coord, bias);
        `}},Cx={name:"tiling-bit",vertex:{header:`
            uniform mat3 uTextureTransform;
            uniform vec4 uSizeAnchor;

        `,main:`
            uv = (uTextureTransform * vec3(aUV, 1.0)).xy;

            position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
        `},fragment:{header:`
            uniform sampler2D uTexture;
            uniform mat3 uMapCoord;
            uniform vec4 uClampFrame;
            uniform vec2 uClampOffset;
        `,main:`

        vec2 coord = vUV + ceil(uClampOffset - vUV);
        coord = (uMapCoord * vec3(coord, 1.0)).xy;
        vec2 unclamped = coord;
        coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);

        outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0

        `}};let Yl,Kl;class Rx extends Jt{constructor(){Yl!=null||(Yl=wr({name:"tiling-sprite-shader",bits:[$r,Px,Ar]})),Kl!=null||(Kl=Er({name:"tiling-sprite-shader",bits:[un,Cx,Pr]}));const t=new At({uMapCoord:{value:new D,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new D,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Kl,gpuProgram:Yl,resources:{localUniforms:new At({uTransformMatrix:{value:new D,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:F.EMPTY.source,uSampler:F.EMPTY.source.style}})}updateUniforms(t,e,s,i,n,o){const a=this.resources.tilingUniforms,l=o.width,u=o.height,h=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(s.a*l/t,s.b*l/e,s.c*u/t,s.d*u/e,s.tx/t,s.ty/e),c.invert(),a.uniforms.uMapCoord=h.mapCoord,a.uniforms.uClampFrame=h.uClampFrame,a.uniforms.uClampOffset=h.uClampOffset,a.uniforms.uTextureTransform=c,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class Mx extends Ue{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function Ox(r,t){const e=r.anchor.x,s=r.anchor.y;t[0]=-e*r.width,t[1]=-s*r.height,t[2]=(1-e)*r.width,t[3]=-s*r.height,t[4]=(1-e)*r.width,t[5]=(1-s)*r.height,t[6]=-e*r.width,t[7]=(1-s)*r.height}function Gx(r,t,e,s){let i=0;const n=r.length/(t||2),o=s.a,a=s.b,l=s.c,u=s.d,h=s.tx,c=s.ty;for(e*=t;i<n;){const d=r[e],p=r[e+1];r[e]=o*d+l*p+h,r[e+1]=a*d+u*p+c,e+=t,i++}}function Ix(r,t){const e=r.texture,s=e.frame.width,i=e.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-o,t[5]=t[7]=1-o;const a=D.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/s,r.height/i),Gx(t,2,0,a)}const hn=new Mx;class Bx{constructor(){this.canBatch=!0,this.geometry=new Ue({indices:hn.indices.slice(),positions:hn.positions.slice(),uvs:hn.uvs.slice()})}destroy(){var t;this.geometry.destroy(),(t=this.shader)==null||t.destroy()}}class ql{constructor(t){this._state=jt.default2d,this._renderer=t,this._managedTilingSprites=new Bt({renderer:t,type:"renderable",name:"tilingSprite"})}validateRenderable(t){const e=this._getTilingSpriteData(t),s=e.canBatch;this._updateCanBatch(t);const i=e.canBatch;if(i&&i===s){const{batchableMesh:n}=e;return!n._batcher.checkAndUpdateTexture(n,t.texture)}return s!==i}addRenderable(t,e){const s=this._renderer.renderPipes.batch;this._updateCanBatch(t);const i=this._getTilingSpriteData(t),{geometry:n,canBatch:o}=i;if(o){i.batchableMesh||(i.batchableMesh=new nn);const a=i.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=n,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,s.addToBatch(a,e)}else s.break(e),i.shader||(i.shader=new Rx),this.updateRenderable(t),e.add(t)}execute(t){const e=this._renderer,{shader:s}=this._getTilingSpriteData(t);s.groups[0]=e.globalUniforms.bindGroup;const i=s.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=e._roundPixels|t._roundPixels,Dr(t.groupColorAlpha,i.uColor,0),this._state.blendMode=Tr(t.groupBlendMode,t.texture._source),e.encoder.draw({geometry:hn,shader:s,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:s}=e;if(s){const{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){const{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new Bx;return e.renderable=t,t._gpuData[this._renderer.uid]=e,this._managedTilingSprites.add(t),e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:s}=e,i=t.texture.source.style;i.addressMode!=="repeat"&&(i.addressMode="repeat",i.update()),Ix(t,s.uvs),Ox(t,s.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),s=t.texture;let i=!0;return this._renderer.type===Ot.WEBGL&&(i=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=s.textureMatrix.isSimple&&(i||s.source.isPowerOfTwo),e.canBatch}}ql.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"tilingSprite"},N.add(Vl),N.add(ql);var iR=Object.defineProperty,cn=Object.getOwnPropertySymbols,Fx=Object.prototype.hasOwnProperty,Dx=Object.prototype.propertyIsEnumerable,Ux=(r,t,e)=>t in r?iR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bs=(r,t)=>{for(var e in t||(t={}))Fx.call(t,e)&&Ux(r,e,t[e]);if(cn)for(var e of cn(t))Dx.call(t,e)&&Ux(r,e,t[e]);return r},nR=(r,t)=>{var e={};for(var s in r)Fx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&cn)for(var s of cn(r))t.indexOf(s)<0&&Dx.call(r,s)&&(e[s]=r[s]);return e};const kx=class no extends xe{constructor(...t){let e=t[0]||{};e instanceof F&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Bs(Bs({},no.defaultOptions),e);const s=e!=null?e:{},{texture:i,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:h,applyAnchorToTexture:c,roundPixels:d}=s,p=nR(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Bs({label:"TilingSprite"},p)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new xt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=i,this._width=u!=null?u:i.width,this._height=h!=null?h:i.height,this._tileTransform=new bx({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=d!=null?d:!1}static from(t,e={}){return typeof t=="string"?new no(Bs({texture:st.get(t)},e)):new no(Bs({texture:t},e))}get uvRespectAnchor(){return vs(Ua,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){vs(Ua,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){typeof t=="number"?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=F.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var s;typeof t=="object"&&(e=(s=t.height)!=null?s:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}containsPoint(t){const e=this._width,s=this._height,i=-e*this._anchor._x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this._anchor._y,t.y>=n&&t.y<=n+s)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};kx.defaultOptions={texture:F.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let $x=kx;var oR=Object.defineProperty,dn=Object.getOwnPropertySymbols,Lx=Object.prototype.hasOwnProperty,Nx=Object.prototype.propertyIsEnumerable,Xx=(r,t,e)=>t in r?oR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aR=(r,t)=>{for(var e in t||(t={}))Lx.call(t,e)&&Xx(r,e,t[e]);if(dn)for(var e of dn(t))Nx.call(t,e)&&Xx(r,e,t[e]);return r},lR=(r,t)=>{var e={};for(var s in r)Lx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&dn)for(var s of dn(r))t.indexOf(s)<0&&Nx.call(r,s)&&(e[s]=r[s]);return e};class pn extends xe{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:h}=s,c=lR(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(aR({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i!=null?i:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new xt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=h!=null?h:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,i=-e*this.anchor.x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function fn(r,t){var e;let s=(e=r[0])!=null?e:{};return(typeof s=="string"||r[1])&&(s={text:s,style:r[1]}),s}class Hx{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=H.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=He(t),e=He(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,i),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const he=new Hx;Xe.register(he);let ir=null,Re=null;function uR(r,t){ir||(ir=H.get().createCanvas(256,128),Re=ir.getContext("2d",{willReadFrequently:!0}),Re.globalCompositeOperation="copy",Re.globalAlpha=1),(ir.width<r||ir.height<t)&&(ir.width=He(r),ir.height=He(t))}function jx(r,t,e){for(let s=0,i=4*e*t;s<t;++s,i+=4)if(r[i+3]!==0)return!1;return!0}function zx(r,t,e,s,i){const n=4*t;for(let o=s,a=s*n+4*e;o<=i;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Wx(...r){var t,e,s;let i=r[0];i.canvas||(i={canvas:r[0],resolution:r[1]});const{canvas:n}=i,o=Math.min((t=i.resolution)!=null?t:1,1),a=(e=i.width)!=null?e:n.width,l=(s=i.height)!=null?s:n.height;let u=i.output;if(uR(a,l),!Re)throw new TypeError("Failed to get canvas 2D context");Re.drawImage(n,0,0,a,l,0,0,a*o,l*o);const h=Re.getImageData(0,0,a,l).data;let c=0,d=0,p=a-1,f=l-1;for(;d<l&&jx(h,a,d);)++d;if(d===l)return ut.EMPTY;for(;jx(h,a,f);)--f;for(;zx(h,a,c,d,f);)++c;for(;zx(h,a,p,d,f);)--p;return++p,++f,Re.globalCompositeOperation="source-over",Re.strokeRect(c,d,p-c,f-d),Re.globalCompositeOperation="copy",u!=null||(u=new ut),u.set(c/o,d/o,(p-c)/o,(f-d)/o),u}/**
 * tiny-lru
 *
 * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
 * @license BSD-3-Clause
 * @version 11.4.7
 */class hR{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++){const i=t[s];e[s]=[i,this.get(i)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,s=0;for(;e!==null;)t[s++]=e.key,e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let i=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(i=Oc({},this.first),this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return i}set(t,e,s=!1,i=this.resetTtl){let n=this.items[t];return s||n!==void 0?(n.value=e,s===!1&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=this.get(t[s]);return e}}function Vx(r=1e3,t=0,e=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new hR(r,t,e)}function mn(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function gn(r){return r.includes("<")}function cR(r,t){return r.clone().assign(t)}function Zl(r,t){const e=[],s=t.tagStyles;if(!mn(t)||!gn(r))return e.push({text:r,style:t}),e;const i=[t],n=[];let o="",a=0;for(;a<r.length;){const l=r[a];if(l==="<"){const u=r.indexOf(">",a);if(u===-1){o+=l,a++;continue}const h=r.slice(a+1,u);if(h.startsWith("/")){const c=h.slice(1).trim();if(n.length>0&&n[n.length-1]===c){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o=""),i.pop(),n.pop(),a=u+1;continue}else{o+=r.slice(a,u+1),a=u+1;continue}}else{const c=h.trim();if(s[c]){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o="");const d=i[i.length-1],p=cR(d,s[c]);i.push(p),n.push(c),a=u+1;continue}else{o+=r.slice(a,u+1),a=u+1;continue}}}else o+=l,a++}return o.length>0&&e.push({text:o,style:i[i.length-1]}),e}function dR(r,t){return!mn(t)||!gn(r)?r:Zl(r,t).map(e=>e.text).join("")}const Yx=[10,13],Kx=new Set(Yx),qx=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Zx=new Set(qx),Qx=[9,32],Jx=new Set(Qx),tv=[45,8208,8211,8212,173],ev=new Set(tv),rv=/(\r\n|\r|\n)/,sv=/(?:\r\n|\r|\n)/;function Fs(r){return typeof r!="string"?!1:Kx.has(r.charCodeAt(0))}function Kt(r,t){return typeof r!="string"?!1:Zx.has(r.charCodeAt(0))}function Ql(r){return typeof r!="string"?!1:Jx.has(r.charCodeAt(0))}function Jl(r){return typeof r!="string"?!1:ev.has(r.charCodeAt(0))}function _n(r){return r==="normal"||r==="pre-line"}function xn(r){return r==="normal"}function Se(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Kt(r[t]);)t--;return t<r.length-1?r.slice(0,t+1):r}function tu(r){const t=[],e=[];if(typeof r!="string")return t;for(let s=0;s<r.length;s++){const i=r[s],n=r[s+1];if(Kt(i,n)||Fs(i)){e.length>0&&(t.push(e.join("")),e.length=0),i==="\r"&&n===`
`?(t.push(`\r
`),s++):t.push(i);continue}e.push(i),Jl(i)&&n&&!Kt(n)&&!Fs(n)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function eu(r,t,e,s){const i=e(r),n=[];for(let o=0;o<i.length;o++){let a=i[o],l=a,u=1;for(;i[o+u];){const h=i[o+u];if(!s(l,h,r,o,t))a+=h,l=h,u++;else break}o+=u-1,n.push(a)}return n}const pR=/\r\n|\r|\n/g;function iv(r,t,e,s,i,n,o,a){var l,u;const h=Zl(r,t);if(xn(t.whiteSpace))for(let M=0;M<h.length;M++){const B=h[M];h[M]={text:B.text.replace(pR," "),style:B.style}}const c=[];let d=[];for(const M of h){const B=M.text.split(rv);for(let P=0;P<B.length;P++){const O=B[P];O===`\r
`||O==="\r"||O===`
`?(c.push(d),d=[]):O.length>0&&d.push({text:O,style:M.style})}}(d.length>0||c.length===0)&&c.push(d);const p=e?nv(c,t,s,i,o,a):c,f=[],m=[],g=[],_=[],x=[];let v=0;const b=t._fontString,T=n(b);T.fontSize===0&&(T.fontSize=t.fontSize,T.ascent=t.fontSize);let y="",w=!!t.dropShadow,A=((l=t._stroke)==null?void 0:l.width)||0;for(const M of p){let B=0,P=T.ascent,O=T.descent,q="";for(const K of M){const X=K.style._fontString,W=n(X);X!==y&&(s.font=X,y=X);const U=i(K.text,K.style.letterSpacing,s);B+=U,P=Math.max(P,W.ascent),O=Math.max(O,W.descent),q+=K.text;const L=((u=K.style._stroke)==null?void 0:u.width)||0;L>A&&(A=L),!w&&K.style.dropShadow&&(w=!0)}M.length===0&&(P=T.ascent,O=T.descent),f.push(B),m.push(P),g.push(O),x.push(q);const k=t.lineHeight||P+O;_.push(k+t.leading),v=Math.max(v,B)}const R=A,C=(e&&t.align!=="left"?Math.max(v,t.wordWrapWidth):v)+R+(t.dropShadow?t.dropShadow.distance:0);let E=0;for(let M=0;M<_.length;M++)E+=_[M];E=Math.max(E,_[0]+R);const G=E+(t.dropShadow?t.dropShadow.distance:0),I=t.lineHeight||T.fontSize;return{width:C,height:G,lines:x,lineWidths:f,lineHeight:I+t.leading,maxLineWidth:v,fontProperties:T,runsByLine:p,lineAscents:m,lineDescents:g,lineHeights:_,hasDropShadow:w}}function nv(r,t,e,s,i,n){var o,a,l;const{letterSpacing:u,whiteSpace:h,wordWrapWidth:c,breakWords:d}=t,p=_n(h),f=c+u,m={};let g="";const _=(v,b)=>{const T=`${v}|${b.styleKey}`;let y=m[T];if(y===void 0){const w=b._fontString;w!==g&&(e.font=w,g=w),y=s(v,b.letterSpacing,e)+b.letterSpacing,m[T]=y}return y},x=[];for(const v of r){const b=ov(v),T=x.length,y=M=>{let B=0,P=M;do{const{token:O,style:q}=b[P];B+=_(O,q),P++}while(P<b.length&&b[P].continuesFromPrevious);return B},w=M=>{const B=[];let P=M;do B.push({token:b[P].token,style:b[P].style}),P++;while(P<b.length&&b[P].continuesFromPrevious);return B};let A=[],R=0,C=!p,E=null;const G=()=>{E&&E.text.length>0&&A.push(E),E=null},I=()=>{if(G(),A.length>0){const M=A[A.length-1];M.text=Se(M.text),M.text.length===0&&A.pop()}x.push(A),A=[],R=0,C=!1};for(let M=0;M<b.length;M++){const{token:B,style:P,continuesFromPrevious:O}=b[M],q=_(B,P);if(p){const X=Kt(B),W=(l=(a=E==null?void 0:E.text[E.text.length-1])!=null?a:(o=A[A.length-1])==null?void 0:o.text.slice(-1))!=null?l:"",U=W?Kt(W):!1;if(X&&U)continue}const k=!O,K=k?y(M):q;if(K>f&&k)if(R>0&&I(),d){const X=w(M);for(let W=0;W<X.length;W++){const U=X[W].token,L=X[W].style,$=eu(U,d,n,i);for(const Z of $){const ht=_(Z,L);ht+R>f&&I(),!E||E.style!==L?(G(),E={text:Z,style:L}):E.text+=Z,R+=ht}}M+=X.length-1}else{const X=w(M);G(),x.push(X.map(W=>({text:W.token,style:W.style}))),C=!1,M+=X.length-1}else if(K+R>f&&k){if(Kt(B)){C=!1;continue}I(),E={text:B,style:P},R=q}else if(O&&!d)!E||E.style!==P?(G(),E={text:B,style:P}):E.text+=B,R+=q;else{const X=Kt(B);if(R===0&&X&&!C)continue;!E||E.style!==P?(G(),E={text:B,style:P}):E.text+=B,R+=q}}if(G(),A.length>0){const M=A[A.length-1];M.text=Se(M.text),M.text.length===0&&A.pop()}(A.length>0||x.length===T)&&x.push(A)}return x}function ov(r){const t=[];let e=!1;for(const s of r){const i=tu(s.text);let n=!0;for(const o of i){const a=Kt(o)||Fs(o),l=n&&e&&!a;t.push({token:o,style:s.style,continuesFromPrevious:l}),e=!a,n=!1}}return t}const fR={willReadFrequently:!0};function av(r,t,e,s,i){let n=e[r];return typeof n!="number"&&(n=i(r,t,s)+t,e[r]=n),n}function lv(r,t,e,s,i,n,o){const a=e.getContext("2d",fR);a.font=t._fontString;let l=0,u="";const h=[],c=Object.create(null),{letterSpacing:d,whiteSpace:p}=t,f=_n(p),m=xn(p);let g=!f;const _=t.wordWrapWidth+d,x=tu(r);for(let b=0;b<x.length;b++){let T=x[b];if(Fs(T)){if(!m){h.push(Se(u)),g=!f,u="",l=0;continue}T=" "}if(f){const w=Kt(T),A=Kt(u[u.length-1]);if(w&&A)continue}const y=av(T,d,c,a,s);if(y>_)if(u!==""&&(h.push(Se(u)),u="",l=0),i(T,t.breakWords)){const w=eu(T,t.breakWords,o,n);for(const A of w){const R=av(A,d,c,a,s);R+l>_&&(h.push(Se(u)),g=!1,u="",l=0),u+=A,l+=R}}else u.length>0&&(h.push(Se(u)),u="",l=0),h.push(Se(T)),g=!1,u="",l=0;else y+l>_&&(g=!1,h.push(Se(u)),u="",l=0),(u.length>0||!Kt(T)||g)&&(u+=T,l+=y)}const v=Se(u);return v.length>0&&h.push(v),h.join(`
`)}const uv={willReadFrequently:!0},Me=class V{static get experimentalLetterSpacingSupported(){let t=V._experimentalLetterSpacingSupported;if(t===void 0){const e=H.get().getCanvasRenderingContext2D().prototype;t=V._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,l,u,h){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u,h&&(this.runsByLine=h.runsByLine,this.lineAscents=h.lineAscents,this.lineDescents=h.lineDescents,this.lineHeights=h.lineHeights,this.hasDropShadow=h.hasDropShadow)}static measureText(t=" ",e,s=V._canvas,i=e.wordWrap){var n,o;const a=`${t}-${e.styleKey}-wordWrap-${i}`;if(V._measurementCache.has(a))return V._measurementCache.get(a);if(mn(e)&&gn(t)){const T=iv(t,e,i,V._context,V._measureText,V.measureFont,V.canBreakChars,V.wordWrapSplit),y=new V(t,e,T.width,T.height,T.lines,T.lineWidths,T.lineHeight,T.maxLineWidth,T.fontProperties,{runsByLine:T.runsByLine,lineAscents:T.lineAscents,lineDescents:T.lineDescents,lineHeights:T.lineHeights,hasDropShadow:T.hasDropShadow});return V._measurementCache.set(a,y),y}const l=e._fontString,u=V.measureFont(l);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize,u.descent=0);const h=V._context;h.font=l;const c=(i?V._wordWrap(t,e,s):t).split(sv),d=new Array(c.length);let p=0;for(let T=0;T<c.length;T++){const y=V._measureText(c[T],e.letterSpacing,h);d[T]=y,p=Math.max(p,y)}const f=(o=(n=e._stroke)==null?void 0:n.width)!=null?o:0,m=e.lineHeight||u.fontSize,g=V._getAlignWidth(p,e,i),_=V._adjustWidthForStyle(g,e),x=Math.max(m,u.fontSize+f)+(c.length-1)*(m+e.leading),v=V._adjustHeightForStyle(x,e),b=new V(t,e,_,v,c,d,m+e.leading,p,u);return V._measurementCache.set(a,b),b}static _adjustWidthForStyle(t,e){var s;const i=((s=e._stroke)==null?void 0:s.width)||0;let n=t+i;return e.dropShadow&&(n+=e.dropShadow.distance),n}static _adjustHeightForStyle(t,e){let s=t;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _getAlignWidth(t,e,s){return s&&e.align!=="left"?Math.max(t,e.wordWrapWidth):t}static _measureText(t,e,s){var i,n;let o=!1;V.experimentalLetterSpacingSupported&&(V.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,o=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const a=s.measureText(t);let l=a.width;const u=-((i=a.actualBoundingBoxLeft)!=null?i:0);let h=((n=a.actualBoundingBoxRight)!=null?n:0)-u;if(l>0)if(o)l-=e,h-=e;else{const c=(V.graphemeSegmenter(t).length-1)*e;l+=c,h+=c}return Math.max(l,h)}static _wordWrap(t,e,s=V._canvas){return lv(t,e,s,V._measureText,V.canBreakWords,V.canBreakChars,V.wordWrapSplit)}static isBreakingSpace(t,e){return Kt(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,i,n){return!0}static wordWrapSplit(t){return V.graphemeSegmenter(t)}static measureFont(t){var e,s;if(V._fonts[t])return V._fonts[t];const i=V._context;i.font=t;const n=i.measureText(V.METRICS_STRING+V.BASELINE_SYMBOL),o=(e=n.actualBoundingBoxAscent)!=null?e:0,a=(s=n.actualBoundingBoxDescent)!=null?s:0,l={ascent:o,descent:a,fontSize:o+a};return V._fonts[t]=l,l}static clearMetrics(t=""){t?delete V._fonts[t]:V._fonts={}}static get _canvas(){if(!V.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",uv);if(s!=null&&s.measureText)return V.__canvas=e,e;t=H.get().createCanvas()}catch(e){t=H.get().createCanvas()}t.width=t.height=10,V.__canvas=t}return V.__canvas}static get _context(){return V.__context||(V.__context=V._canvas.getContext("2d",uv)),V.__context}};Me.METRICS_STRING="|\xC9q\xC5",Me.BASELINE_SYMBOL="M",Me.BASELINE_MULTIPLIER=1.4,Me.HEIGHT_MULTIPLIER=2,Me.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),s=[];let i=0;for(const n of e)s[i++]=n.segment;return s}}return r=>[...r]})(),Me.experimentalLetterSpacing=!1,Me._fonts={},Me._measurementCache=Vx(1e3);let yt=Me;const mR=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Lr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!mR.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const hv=1e5;function nr(r,t,e,s=0,i=0,n=0){var o;if(r.texture===F.WHITE&&!r.fill)return rt.shared.setValue(r.color).setAlpha((o=r.alpha)!=null?o:1).toHexa();if(r.fill){if(r.fill instanceof Mr){const a=r.fill,l=t.createPattern(a.texture.source.resource,"repeat"),u=a.transform.copyTo(D.shared);return u.scale(a.texture.source.pixelWidth,a.texture.source.pixelHeight),l.setTransform(u),l}else if(r.fill instanceof Ut){const a=r.fill,l=a.type==="linear",u=a.textureSpace==="local";let h=1,c=1;u&&e&&(h=e.width+s,c=e.height+s);let d,p=!1;if(l){const{start:f,end:m}=a;d=t.createLinearGradient(f.x*h+i,f.y*c+n,m.x*h+i,m.y*c+n),p=Math.abs(m.x-f.x)<Math.abs((m.y-f.y)*.1)}else{const{center:f,innerRadius:m,outerCenter:g,outerRadius:_}=a;d=t.createRadialGradient(f.x*h+i,f.y*c+n,m*h,g.x*h+i,g.y*c+n,_*h)}if(p&&u&&e){const f=e.lineHeight/c;for(let m=0;m<e.lines.length;m++){const g=(m*e.lineHeight+s/2)/c;a.colorStops.forEach(_=>{let x=g+_.offset*f;x=Math.max(0,Math.min(1,x)),d.addColorStop(Math.floor(x*hv)/hv,rt.shared.setValue(_.color).toHex())})}}else a.colorStops.forEach(f=>{d.addColorStop(f.offset,rt.shared.setValue(f.color).toHex())});return d}}else{const a=t.createPattern(r.texture.source.resource,"repeat"),l=r.matrix.copyTo(D.shared);return l.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),a.setTransform(l),a}return"red"}const cv=new ut;function Nr(r){let t=0;for(let e=0;e<r.length;e++)r.charCodeAt(e)===32&&t++;return t}let gR=class{getCanvasAndContext(t){const{text:e,style:s,resolution:i=1}=t,n=s._getFinalPadding(),o=yt.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*i),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*i),u=he.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(s,n,i,u,o);const h=s.trim?Wx({canvas:u.canvas,width:a,height:l,resolution:1,output:cv}):cv.set(0,0,a,l);return{canvasAndContext:u,frame:h}}returnCanvasAndContext(t){he.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,i,n){var o,a,l,u,h,c;if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,t,e,s,i);return}const{canvas:d,context:p}=i,f=Lr(t),m=n.lines,g=n.lineHeight,_=n.lineWidths,x=n.maxLineWidth,v=n.fontProperties,b=d.height;if(p.resetTransform(),p.scale(s,s),p.textBaseline=t.textBaseline,(o=t._stroke)!=null&&o.width){const E=t._stroke;p.lineWidth=E.width,p.miterLimit=E.miterLimit,p.lineJoin=E.join,p.lineCap=E.cap}p.font=f;let T,y;const w=t.dropShadow?2:1,A=t.wordWrap?t.wordWrapWidth:x,R=((l=(a=t._stroke)==null?void 0:a.width)!=null?l:0)/2;let C=(g-v.fontSize)/2;g-v.fontSize<0&&(C=0);for(let E=0;E<w;++E){const G=t.dropShadow&&E===0,I=G?Math.ceil(Math.max(1,b)+e*2):0,M=I*s;if(G)this._setupDropShadow(p,t,s,M);else{const B=t._gradientBounds,P=t._gradientOffset;if(B){const O={width:B.width,height:B.height,lineHeight:B.height,lines:n.lines};this._setFillAndStrokeStyles(p,t,O,e,R,(u=P==null?void 0:P.x)!=null?u:0,(h=P==null?void 0:P.y)!=null?h:0)}else P?this._setFillAndStrokeStyles(p,t,n,e,R,P.x,P.y):this._setFillAndStrokeStyles(p,t,n,e,R);p.shadowColor="rgba(0,0,0,0)"}for(let B=0;B<m.length;B++){T=R,y=R+B*g+v.ascent+C,T+=this._getAlignmentOffset(_[B],A,t.align);let P=0;if(t.align==="justify"&&t.wordWrap&&B<m.length-1){const O=Nr(m[B]);O>0&&(P=(A-_[B])/O)}(c=t._stroke)!=null&&c.width&&this._drawLetterSpacing(m[B],t,i,T+e,y+e-I,!0,P),t._fill!==void 0&&this._drawLetterSpacing(m[B],t,i,T+e,y+e-I,!1,P)}}}_renderTaggedTextToCanvas(t,e,s,i,n){var o,a,l,u,h;const{canvas:c,context:d}=n,{runsByLine:p,lineWidths:f,maxLineWidth:m,lineAscents:g,lineHeights:_,hasDropShadow:x}=t,v=c.height;d.resetTransform(),d.scale(i,i),d.textBaseline=e.textBaseline;const b=x?2:1,T=e.wordWrap?e.wordWrapWidth:m;let y=(a=(o=e._stroke)==null?void 0:o.width)!=null?a:0;for(const R of p)for(const C of R){const E=(u=(l=C.style._stroke)==null?void 0:l.width)!=null?u:0;E>y&&(y=E)}const w=y/2,A=[];for(let R=0;R<p.length;R++){const C=p[R],E=[];for(const G of C){const I=Lr(G.style);d.font=I,E.push({width:yt._measureText(G.text,G.style.letterSpacing,d),font:I})}A.push(E)}for(let R=0;R<b;++R){const C=x&&R===0,E=C?Math.ceil(Math.max(1,v)+s*2):0,G=E*i;C||(d.shadowColor="rgba(0,0,0,0)");let I=w;for(let M=0;M<p.length;M++){const B=p[M],P=f[M],O=g[M],q=_[M],k=A[M];let K=w;K+=this._getAlignmentOffset(P,T,e.align);let X=0;if(e.align==="justify"&&e.wordWrap&&M<p.length-1){let L=0;for(const $ of B)L+=Nr($.text);L>0&&(X=(T-P)/L)}const W=I+O;let U=K+s;for(let L=0;L<B.length;L++){const $=B[L],{width:Z,font:ht}=k[L];if(d.font=ht,d.textBaseline=$.style.textBaseline,(h=$.style._stroke)!=null&&h.width){const tt=$.style._stroke;if(d.lineWidth=tt.width,d.miterLimit=tt.miterLimit,d.lineJoin=tt.join,d.lineCap=tt.cap,C)if($.style.dropShadow)this._setupDropShadow(d,$.style,i,G);else{const it=Nr($.text);U+=Z+it*X;continue}else{const it=yt.measureFont(ht),nt=$.style.lineHeight||it.fontSize,et={width:Z,height:nt,lineHeight:nt,lines:[$.text]};d.strokeStyle=nr(tt,d,et,s*2,U-s,I)}this._drawLetterSpacing($.text,$.style,n,U,W+s-E,!0,X)}const J=Nr($.text);U+=Z+J*X}U=K+s;for(let L=0;L<B.length;L++){const $=B[L],{width:Z,font:ht}=k[L];if(d.font=ht,d.textBaseline=$.style.textBaseline,$.style._fill!==void 0){if(C)if($.style.dropShadow)this._setupDropShadow(d,$.style,i,G);else{const tt=Nr($.text);U+=Z+tt*X;continue}else{const tt=yt.measureFont(ht),it=$.style.lineHeight||tt.fontSize,nt={width:Z,height:it,lineHeight:it,lines:[$.text]};d.fillStyle=nr($.style._fill,d,nt,s*2,U-s,I)}this._drawLetterSpacing($.text,$.style,n,U,W+s-E,!1,X)}const J=Nr($.text);U+=Z+J*X}I+=q}}}_setFillAndStrokeStyles(t,e,s,i,n,o=0,a=0){var l;if(t.fillStyle=e._fill?nr(e._fill,t,s,i*2,o,a):null,(l=e._stroke)!=null&&l.width){const u=n+i*2;t.strokeStyle=nr(e._stroke,t,s,u,o,a)}}_setupDropShadow(t,e,s,i){t.fillStyle="black",t.strokeStyle="black";const n=e.dropShadow,o=n.color,a=n.alpha;t.shadowColor=rt.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*s,u=n.distance*s;t.shadowBlur=l,t.shadowOffsetX=Math.cos(n.angle)*u,t.shadowOffsetY=Math.sin(n.angle)*u+i}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,i,n,o=!1,a=0){const{context:l}=s,u=e.letterSpacing;let h=!1;if(yt.experimentalLetterSpacingSupported&&(yt.experimentalLetterSpacing?(l.letterSpacing=`${u}px`,l.textLetterSpacing=`${u}px`,h=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(u===0||h)&&a===0){o?l.strokeText(t,i,n):l.fillText(t,i,n);return}if(a!==0&&(u===0||h)){const m=t.split(" ");let g=i;const _=l.measureText(" ").width;for(let x=0;x<m.length;x++)o?l.strokeText(m[x],g,n):l.fillText(m[x],g,n),g+=l.measureText(m[x]).width+_+a;return}let c=i;const d=yt.graphemeSegmenter(t);let p=l.measureText(t).width,f=0;for(let m=0;m<d.length;++m){const g=d[m];o?l.strokeText(g,c,n):l.fillText(g,c,n);let _="";for(let x=m+1;x<d.length;++x)_+=d[x];f=l.measureText(_).width,c+=p-f+u,g===" "&&(c+=a),p=f}}};const ce=new gR;var _R=Object.defineProperty,xR=Object.defineProperties,vR=Object.getOwnPropertyDescriptors,dv=Object.getOwnPropertySymbols,bR=Object.prototype.hasOwnProperty,yR=Object.prototype.propertyIsEnumerable,pv=(r,t,e)=>t in r?_R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ft=(r,t)=>{for(var e in t||(t={}))bR.call(t,e)&&pv(r,e,t[e]);if(dv)for(var e of dv(t))yR.call(t,e)&&pv(r,e,t[e]);return r},TR=(r,t)=>xR(r,vR(t));const ru=class lr extends Dt{constructor(t={}){var e;super(),this.uid=ct("textStyle"),this._tick=0,this._cachedFontString=null,SR(t),t instanceof lr&&(t=t._toObject());const s=Ft(Ft({},lr.defaultTextStyle),t);for(const i in s){const n=i;this[n]=s[i]}this._tagStyles=(e=t.tagStyles)!=null?e:void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Ft(Ft({},lr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Ft({},lr.defaultDropShadow)):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(Ft(Ft({},kt.defaultFillStyle),t),()=>{this._fill=Fe(Ft({},this._originalFill),kt.defaultFillStyle)})),this._fill=Fe(t===0?"black":t,kt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Ft(Ft({},kt.defaultStrokeStyle),t),()=>{this._stroke=Es(Ft({},this._originalStroke),kt.defaultStrokeStyle)})),this._stroke=Es(t,kt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=lr.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const s=e;this[s]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Lr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Ft({},this._dropShadow):null,fill:this._fill?Ft({},this._fill):void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?Ft({},this._stroke):void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?Ft({},this._tagStyles):void 0}}clone(){return new lr(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,s,i,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(o),(i=this._stroke)!=null&&i.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,i,n)=>(s[i]===n||(s[i]=n,e==null||e(i,n),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(rt.isColorLike(t)||t instanceof Ut||t instanceof Mr)}};ru.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},ru.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let $t=ru;function SR(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=$t.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(s=o.dropShadowBlur)!=null?s:a.blur,color:(i=o.dropShadowColor)!=null?i:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(rt.isColorLike(a))l.color=a;else if(a instanceof Ut||a instanceof Mr)l.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))l=a;else throw new Error("Invalid stroke value.");r.stroke=TR(Ft({},l),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(!Array.isArray(o.fill)||o.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length,o.fillGradientStops.length;const a=new Ut({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=o.fillGradientStops.slice(),u=o.fill.map(h=>rt.shared.setValue(h).toNumber());l.forEach((h,c)=>{a.addColorStop(h,u[c])}),r.fill={fill:a}}}function vn(r,t){const{texture:e,bounds:s}=r,i=t._style._getFinalPadding();Vo(s,t._anchor,e);const n=t._anchor._x*i*2,o=t._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class Ds{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class fv extends Ds{}class su{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Bt({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==i)&&this._updateGpuText(t),t._didTextUpdate=!1,vn(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new fv;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:s}=this._renderer;s.getReferenceCount(e.currentKey)>0?s.decreaseReferenceCount(e.currentKey):e.texture&&s.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}su.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};const wR=new Ct;function bn(r,t,e,s,i=!1){const n=wR;n.minX=0,n.minY=0,n.maxX=r.width/s|0,n.maxY=r.height/s|0;const o=_t.getOptimalTexture(n.width,n.height,s,!1,i);return o.source.uploadMethodId="image",o.source.resource=r,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/s,o.frame.height=e/s,o.source.emit("update",o.source),o.updateUvs(),o}class iu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,i){var n;typeof t=="string"&&(t={text:t,style:s,resolution:e}),t.style instanceof $t||(t.style=new $t(t.style)),t.textureStyle instanceof qt||(t.textureStyle=new qt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:a,textureStyle:l,autoGenerateMipmaps:u}=t,h=(n=t.resolution)!=null?n:this._renderer.resolution,{frame:c,canvasAndContext:d}=ce.getCanvasAndContext({text:o,style:a,resolution:h}),p=bn(d.canvas,c.width,c.height,h,u);if(l&&(p.source.style=l),a.trim&&(c.pad(a.padding),p.frame.copyFrom(c),p.frame.scale(1/h),p.updateUvs()),a.filters){const f=this._applyFilters(p,a.filters);return this.returnTexture(p),ce.returnCanvasAndContext(d),f}return this._renderer.texture.initSource(p._source),this._retainCanvasContext||ce.returnCanvasAndContext(d),p}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&s!=null&&s.getContext){const i=s.getContext("2d");i&&ce.returnCanvasAndContext({canvas:s,context:i})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",_t.returnTexture(t,!0)}renderTextToCanvas(){}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const s=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:s,usageCount:1},s}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e,s;return(s=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?s:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(s,!1),i}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class nu extends iu{constructor(t){super(t,!0)}}nu.extension={type:[S.CanvasSystem],name:"canvasText"};class ou extends iu{constructor(t){super(t,!1)}}ou.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"},N.add(nu),N.add(ou),N.add(su);class Us extends pn{constructor(...t){var e;const s=fn(t,"Text");super(s,$t),this.renderPipeId="text",s.textureStyle&&(this.textureStyle=s.textureStyle instanceof qt?s.textureStyle:new qt(s.textureStyle)),this.autoGenerateMipmaps=(e=s.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=ce.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ce.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=yt.measureText(this._text,this._style);s=n.width,i=n.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}}class mv extends ix{resolveQueueItem(t,e){return t instanceof pt?this.resolveContainerQueueItem(t,e):t instanceof ft||t instanceof F?e.push(t.source):t instanceof kt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof pe||t instanceof $x||t instanceof Ur?e.push(t.texture.source):t instanceof Us?e.push(t):t instanceof hr?e.push(t.context):t instanceof Ws&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;return i.source}else if(s.action==="fill"){const{texture:i}=s.data.style;return i.source}return null}}class au extends Dt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}var ER=Object.defineProperty,gv=Object.getOwnPropertySymbols,AR=Object.prototype.hasOwnProperty,PR=Object.prototype.propertyIsEnumerable,_v=(r,t,e)=>t in r?ER(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xv=(r,t)=>{for(var e in t||(t={}))AR.call(t,e)&&_v(r,e,t[e]);if(gv)for(var e of gv(t))PR.call(t,e)&&_v(r,e,t[e]);return r};const vv=class mT extends au{constructor(t){var e,s,i;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=xv(xv({},mT.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=F.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=Lr(o);n.overrideSize?(o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a),o.dropShadow&&(o.dropShadow.blur*=this.baseRenderedFontSize/a,o.dropShadow.distance*=this.baseRenderedFontSize/a)):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof qt?n.textureStyle:new qt(n.textureStyle)),this.fontMetrics=yt.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=yt.graphemeSegmenter(t).filter(T=>!this._currentChars.includes(T)).filter((T,y,w)=>w.indexOf(T)===y);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:l,context:u}=a.canvasAndContext,h=a.texture.source;const c=this._style;let d=this._currentX,p=this._currentY,f=this._currentMaxCharHeight;const m=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=((s=(e=c.dropShadow)==null?void 0:e.distance)!=null?s:0)+((n=(i=c._stroke)==null?void 0:i.width)!=null?n:0),_=this._padding+g;let x=!1;const v=l.width/this.resolution,b=l.height/this.resolution;for(let T=0;T<o.length;T++){const y=o[T],w=yt.measureText(y,c,l,!1);w.lineHeight=w.height;const A=w.width*m,R=Math.ceil((c.fontStyle==="italic"?2:1)*A),C=w.height*m,E=R+_*2,G=C+_*2;if(x=!1,y!==`
`&&y!=="\r"&&y!=="	"&&y!==" "&&(x=!0,f=Math.ceil(Math.max(G,f))),d+E>v&&(p+=f,f=G,d=0,p+f>b)){h.update();const M=this._nextPage();l=M.canvasAndContext.canvas,u=M.canvasAndContext.context,h=M.texture.source,d=0,p=0,f=0}const I=u.measureText(y).width/m;if(this.chars[y]={id:y.codePointAt(0),xOffset:-(_/m),yOffset:-(_/m),xAdvance:I,kerning:{}},x){this._drawGlyph(u,w,d+_,p+_,m,c);const M=h.width*m,B=h.height*m,P=new ut(d/M*h.width,p/B*h.height,E/M*h.width,G/B*h.height);this.chars[y].texture=new F({source:h,frame:P}),d+=Math.ceil(E)}}h.update(),this._currentX=d,this._currentY=p,this._currentMaxCharHeight=f,this._skipKerning||this._applyKerning(o,u,m)}get pageTextures(){return this.pages}_applyKerning(t,e,s){const i=this._measureCache;for(let n=0;n<t.length;n++){const o=t[n];for(let a=0;a<this._currentChars.length;a++){const l=this._currentChars[a];let u=i[o];u||(u=i[o]=e.measureText(o).width);let h=i[l];h||(h=i[l]=e.measureText(l).width);let c=e.measureText(o+l).width,d=c-(u+h);d&&this.chars[o]&&(this.chars[o].kerning[l]=d/s),c=e.measureText(o+l).width,d=c-(u+h),d&&this.chars[l]&&(this.chars[l].kerning[o]=d/s)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=he.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const s=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),i=new F({source:new Ie({resource:e.canvas,resolution:s,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(i.source.style=this._textureStyle);const n={canvasAndContext:e,texture:i};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,s){var i;e.fontSize=this.baseRenderedFontSize,t.scale(s,s),t.font=Lr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,o=(i=n==null?void 0:n.width)!=null?i:0;if(n&&(t.lineWidth=o,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=nr(n,t)),e._fill&&(t.fillStyle=nr(e._fill,t)),e.dropShadow){const a=e.dropShadow,l=rt.shared.setValue(a.color).toArray(),u=a.blur*s,h=a.distance*s;t.shadowColor=`rgba(${l[0]*255},${l[1]*255},${l[2]*255},${a.alpha})`,t.shadowBlur=u,t.shadowOffsetX=Math.cos(a.angle)*h,t.shadowOffsetY=Math.sin(a.angle)*h}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,s,i,n,o){var a;const l=e.text,u=e.fontProperties,h=o._stroke,c=((a=h==null?void 0:h.width)!=null?a:0)*n,d=s+c/2,p=i-c/2,f=u.descent*n,m=e.lineHeight*n;let g=!1;o.stroke&&c&&(g=!0,t.strokeText(l,d,p+m-f));const{shadowBlur:_,shadowOffsetX:x,shadowOffsetY:v}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(l,d,p+m-f)),g&&(t.shadowBlur=_,t.shadowOffsetX=x,t.shadowOffsetY=v)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:s}=this.pages[t];he.returnCanvasAndContext(e),s.destroy(!0)}this.pages=null}};vv.defaultOptions={textureSize:512,style:new $t,mipmap:!0};let lu=vv;function yn(r,t,e,s){var i,n;const o={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};o.offsetY=e.baseLineOffset;let a=o.lines[0],l=null,u=!0;const h={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*c,p=t.wordWrapWidth*c,f=t.lineHeight?t.lineHeight*c:e.lineHeight,m=t.wordWrap&&t.breakWords,g=_n(t.whiteSpace),_=xn(t.whiteSpace);if(g||_){const T=[];let y=g;for(let w=0;w<r.length;w++){let A=r[w];if(A==="\r"||A===`
`)if(_)A==="\r"&&r[w+1]===`
`&&w++,A=" ";else{g&&(y=!0),T.push(A);continue}if(Kt(A))if(g&&Ql(A)){if(y)continue;y=!0,T.push(" ")}else y=!1,T.push(A);else y=!1,T.push(A)}r=T}const x=T=>{const y=a.width;for(let w=0;w<h.index;w++){const A=T.positions[w];a.chars.push(T.chars[w]),a.charPositions.push(A+y)}a.width+=T.width,(h.index>0||!g)&&(u=!1),h.width=0,h.index=0,h.chars.length=0},v=()=>{let T=a.chars.length-1;if(s){let y=a.chars[T];for(;Ql(y);)a.width-=e.chars[y].xAdvance,a.spacesIndex.pop(),y=a.chars[--T]}o.width=Math.max(o.width,a.width),a={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},u=!0,o.lines.push(a),o.height+=f},b=T=>T-d>p;for(let T=0;T<r.length+1;T++){let y;const w=T===r.length;w||(y=r[T]);const A=e.chars[y];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||w){if(!u&&t.wordWrap&&b(a.width+h.width)?(v(),x(h),w||a.charPositions.push(0)):(h.start=a.width,x(h),w||a.charPositions.push(0)),y==="\r"||y===`
`)v();else if(!w&&A){const R=A.xAdvance+(((i=A.kerning)==null?void 0:i[l])||0)+d;a.width+=R,a.spaceWidth=R,a.spacesIndex.push(a.charPositions.length),a.chars.push(y)}}else if(A){const R=((n=A.kerning)==null?void 0:n[l])||0,C=A.xAdvance+R+d;m&&b(h.width+C)&&(u||v(),x(h),v()),h.positions[h.index++]=h.width+R,h.chars.push(y),h.width+=C,Jl(y)&&(!u&&t.wordWrap&&b(a.width+h.width)&&v(),x(h))}l=y}return v(),t.wordWrap&&t.align!=="left"&&(o.width=Math.max(o.width,p)),t.align==="center"?CR(o):t.align==="right"?RR(o):t.align==="justify"&&MR(o),o}function CR(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],s=r.width/2-e.width/2;for(let i=0;i<e.charPositions.length;i++)e.charPositions[i]+=s}}function RR(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],s=r.width-e.width;for(let i=0;i<e.charPositions.length;i++)e.charPositions[i]+=s}}function MR(r){const t=r.width;for(let e=0;e<r.lines.length-2;e++){const s=r.lines[e];let i=0,n=s.spacesIndex[i++],o=0;const a=s.spacesIndex.length,l=(t-s.width)/a;for(let u=0;u<s.charPositions.length;u++)u===n&&(n=s.spacesIndex[i++],o+=l),s.charPositions[u]+=o}}function bv(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,s=r.length;e<s;e++){const i=r[e];if(Array.isArray(i)){if(i.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);if(i[0].length===0||i[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=i[0].charCodeAt(0),o=i[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(i))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var OR=Object.defineProperty,yv=Object.getOwnPropertySymbols,GR=Object.prototype.hasOwnProperty,IR=Object.prototype.propertyIsEnumerable,Tv=(r,t,e)=>t in r?OR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uu=(r,t)=>{for(var e in t||(t={}))GR.call(t,e)&&Tv(r,e,t[e]);if(yv)for(var e of yv(t))IR.call(t,e)&&Tv(r,e,t[e]);return r};let Tn=0,BR=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=Vx(1e3)}getFont(t,e){var s,i;let n=`${e.fontFamily}-bitmap`,o=!0;if(st.has(n)){const l=st.get(n);return(s=l.ensureCharacters)==null||s.call(l,t),l}if(e._fill.fill&&!e._stroke?(n+=e._fill.fill.styleKey,o=!1):(e._stroke||e.dropShadow)&&(n=`${e.styleKey}-bitmap`,o=!1),n+=`-${e.fontStyle}`,n+=`-${e.fontVariant}`,n+=`-${e.fontWeight}`,!st.has(n)){const l=Object.create(e);l._lineHeight=0;const u=new lu(uu({style:l,overrideFill:o,overrideSize:!0},this.defaultOptions));Tn++,Tn>50&&ne("BitmapText",`You have dynamically created ${Tn} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Tn--,st.remove(n)}),st.set(n,u)}const a=st.get(n);return(i=a.ensureCharacters)==null||i.call(a,t),a}getLayout(t,e,s=!0){const i=this.getFont(t,e),n=`${t}-${e.styleKey}-${s}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=yt.graphemeSegmenter(t),a=yn(o,e,i,s);return this.measureCache.set(n,a),a}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var e,s,i,n,o;let a=t[0];typeof a=="string"&&(a={name:a,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(s=t[2])==null?void 0:s.resolution,padding:(i=t[2])==null?void 0:i.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const l=a==null?void 0:a.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");a=uu(uu({},this.defaultOptions),a);const u=a.style,h=u instanceof $t?u:new $t(u),c=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(h),d=new lu({style:h,overrideFill:c,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),p=bv(a.chars);return d.ensureCharacters(p.join("")),st.set(`${l}-bitmap`,d),d.once("destroy",()=>st.remove(`${l}-bitmap`)),d}uninstall(t){const e=`${t}-bitmap`,s=st.get(e);s&&s.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const Xr=new BR;class Sv extends hr{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class hu{constructor(t){this._renderer=t,this._managedBitmapTexts=new Bt({renderer:t,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);wv(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);wv(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=Xr.getFont(t.text,t._style);if(s.clear(),i.distanceField.type!=="none"){const _=this.getSdfShader();_&&(s.customShader||(s.customShader=_))}const n=yt.graphemeSegmenter(t.text),o=t._style;let a=i.baseLineOffset;const l=yn(n,o,i,!0),u=o.padding,h=l.scale;let c=l.width,d=l.height+l.offsetY;o._stroke&&(c+=o._stroke.width/h,d+=o._stroke.width/h),s.translate(-t._anchor._x*c-u,-t._anchor._y*d-u).scale(h,h);const p=i.applyFillAsTint?o._fill.color:16777215;let f=i.fontMetrics.fontSize,m=i.lineHeight;o.lineHeight&&(f=o.fontSize/h,m=o.lineHeight/h);let g=(m-f)/2;g-i.baseLineOffset<0&&(g=0);for(let _=0;_<l.lines.length;_++){const x=l.lines[_];for(let v=0;v<x.charPositions.length;v++){const b=x.chars[v],T=i.chars[b];if(T!=null&&T.texture){const y=T.texture;s.texture(y,p,Math.round(x.charPositions[v]+T.xOffset),Math.round(a+T.yOffset+g),y.orig.width,y.orig.height)}}a+=m}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Sv;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),this._managedBitmapTexts.add(t),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,s=t._style.fontFamily,i=st.get(`${s}-bitmap`),{a:n,b:o,c:a,d:l}=t.groupTransform,u=Math.sqrt(n*n+o*o),h=Math.sqrt(a*a+l*l),c=(Math.abs(u)+Math.abs(h))/2,d=i.baseRenderedFontSize/t._style.fontSize,p=c*i.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){this._managedBitmapTexts.destroy(),this._renderer=null,this._managedBitmapTexts=null}}function wv(r,t){t.groupTransform=r.groupTransform,t.groupColorAlpha=r.groupColorAlpha,t.groupColor=r.groupColor,t.groupBlendMode=r.groupBlendMode,t.globalDisplayStatus=r.globalDisplayStatus,t.groupTransform=r.groupTransform,t.localDisplayStatus=r.localDisplayStatus,t.groupAlpha=r.groupAlpha,t._roundPixels=r._roundPixels}class cu extends hu{getSdfShader(){return null}}cu.extension={type:[S.CanvasPipes],name:"bitmapText"};const Ev={name:"local-uniform-msdf-bit",vertex:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32,
                uRound:f32,
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `},fragment:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
         `,main:`
            outColor = vec4<f32>(calculateMSDFAlpha(outColor, vColor, localUniforms.uDistance));
        `}},Av={name:"local-uniform-msdf-bit",vertex:{header:`
            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix *= uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `},fragment:{header:`
            uniform float uDistance;
         `,main:`
            outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
        `}},Pv={name:"msdf-bit",fragment:{header:`
            fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {

                // MSDF
                var median = msdfColor.r + msdfColor.g + msdfColor.b -
                    min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                    max(msdfColor.r, max(msdfColor.g, msdfColor.b));

                // SDF
                median = min(median, msdfColor.a);

                var screenPxDistance = distance * (median - 0.5);
                var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
                var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
                var coverage: f32 = pow(shapeColor.a * alpha, gamma);

                return coverage;

            }
        `}},Cv={name:"msdf-bit",fragment:{header:`
            float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {

                // MSDF
                float median = msdfColor.r + msdfColor.g + msdfColor.b -
                                min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                                max(msdfColor.r, max(msdfColor.g, msdfColor.b));

                // SDF
                median = min(median, msdfColor.a);

                float screenPxDistance = distance * (median - 0.5);
                float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);

                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
                float gamma = mix(1.0, 1.0 / 2.2, luma);
                float coverage = pow(shapeColor.a * alpha, gamma);

                return coverage;
            }
        `}};let du,pu;class Rv extends Jt{constructor(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new D,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});du!=null||(du=wr({name:"sdf-shader",bits:[Ci,Mi(t),Ev,Pv,Ar]})),pu!=null||(pu=Er({name:"sdf-shader",bits:[Ri,Oi(t),Av,Cv,Pr]})),super({glProgram:pu,gpuProgram:du,resources:{localUniforms:e,batchSamplers:Gi(t)}})}}class fu extends hu{getSdfShader(){return new Rv(this._renderer.limits.maxBatchableTextures)}}fu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"bitmapText"},N.add(cu),N.add(fu);class mu extends pn{constructor(...t){var e,s,i;const n=fn(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,$t),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const s in this._gpuData)(e=this._gpuData[s])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,s=Xr.measureText(this.text,this._style),i=s.scale,n=s.offsetY*i;let o=s.width*i,a=s.height*i;const l=this._style._stroke;l&&(o+=l.width,a+=l.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}set resolution(t){}get resolution(){return this._resolution}}var FR=Object.defineProperty,Mv=Object.getOwnPropertySymbols,DR=Object.prototype.hasOwnProperty,UR=Object.prototype.propertyIsEnumerable,Ov=(r,t,e)=>t in r?FR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gu=(r,t)=>{for(var e in t||(t={}))DR.call(t,e)&&Ov(r,e,t[e]);if(Mv)for(var e of Mv(t))UR.call(t,e)&&Ov(r,e,t[e]);return r};function Gv(r){var t;const e=r._stroke,s=r._fill,i=[`div { ${[`color: ${rt.shared.setValue(s.color).setAlpha((t=s.alpha)!=null?t:1).toHexa()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-break: ${r.breakWords?"break-word":"normal"}`,`max-width: ${r.wordWrapWidth}px`]:[],...e?[Iv(e)]:[],...r.dropShadow?[_u(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return kR(r.tagStyles,i),i.join(" ")}function _u(r){var t;const e=gu({},r),s=rt.shared.setValue(e.color).setAlpha((t=e.alpha)!=null?t:1).toHexa(),i=Math.round(Math.cos(e.angle)*e.distance),n=Math.round(Math.sin(e.angle)*e.distance),o=`${i}px ${n}px`;return e.blur>0?`text-shadow: ${o} ${e.blur}px ${s}`:`text-shadow: ${o} ${s}`}function Iv(r){var t;const e=rt.shared.setValue(r.color).setAlpha((t=r.alpha)!=null?t:1).toHexa();return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${e}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${e}`,"paint-order: stroke"].join(";")}const Bv={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Fv={fill:r=>`color: ${rt.shared.setValue(r).toHexa()}`,breakWords:r=>`word-break: ${r?"break-all":"normal"}`,stroke:Iv,dropShadow:r=>r===!0?_u($t.defaultDropShadow):r&&typeof r=="object"?_u(gu(gu({},$t.defaultDropShadow),r)):""};function kR(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)Fv[n]?i.push(Fv[n](s[n])):Bv[n]&&i.push(Bv[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}var $R=Object.defineProperty,Dv=Object.getOwnPropertySymbols,LR=Object.prototype.hasOwnProperty,NR=Object.prototype.propertyIsEnumerable,Uv=(r,t,e)=>t in r?$R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kv=(r,t)=>{for(var e in t||(t={}))LR.call(t,e)&&Uv(r,e,t[e]);if(Dv)for(var e of Dv(t))NR.call(t,e)&&Uv(r,e,t[e]);return r};class fo extends $t{constructor(t={}){var e,s;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(s=t.tagStyles)!=null?s:{}}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:{},this.update())}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new fo({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?kv({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:kv({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=Gv(this)),this._cssStyle}addOverride(...t){const e=t.filter(s=>!this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(s=>this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(s=>!e.includes(s)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}const $v="http://www.w3.org/2000/svg",Lv="http://www.w3.org/1999/xhtml";class xu{constructor(){this.svgRoot=document.createElementNS($v,"svg"),this.foreignObject=document.createElementNS($v,"foreignObject"),this.domElement=document.createElementNS(Lv,"div"),this.styleElement=document.createElementNS(Lv,"style");const{foreignObject:t,svgRoot:e,styleElement:s,domElement:i}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(i),this.image=H.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}let Nv;function vu(r,t,e,s){s||(s=Nv||(Nv=new xu));const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${r}</div>`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);let a=i.scrollWidth,l=i.scrollHeight;if(o.remove(),t.dropShadow){const{distance:h,angle:c,blur:d}=t.dropShadow,p=Math.abs(Math.round(Math.cos(c)*h)),f=Math.abs(Math.round(Math.sin(c)*h));a+=p+d,l+=f+d}const u=t.padding*2;return{width:a-u,height:l-u}}class Xv extends Ds{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class bu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Bt({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"htmlText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const i=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t.resolution!==i)&&this._updateGpuText(t).catch(n=>{console.error(n)}),t._didTextUpdate=!1,vn(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const s=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let i=this._renderer.htmlText.getTexturePromise(t);s&&(i=i.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(s)})),e.texturePromise=i,e.currentKey=t.styleKey,e.texture=await i;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,vn(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Xv;return e.renderable=t,e.transform=t.groupTransform,e.texture=F.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{htmlText:s}=this._renderer;s.getReferenceCount(e.currentKey)===null?s.returnTexturePromise(e.texturePromise):s.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}bu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"htmlText"};function yu(){const{userAgent:r}=H.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}function Hv(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(l){i[l]||(s.push(l),i[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)a(e[l]);else a(e);o&&o.forEach(l=>{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return s}async function jv(r){const t=await(await H.get().fetch(r)).blob(),e=new FileReader;return await new Promise((s,i)=>{e.onloadend=()=>s(e.result),e.onerror=i,e.readAsDataURL(t)})}async function zv(r,t){const e=await jv(t);return`@font-face {
        font-family: "${r.fontFamily}";
        font-weight: ${r.fontWeight};
        font-style: ${r.fontStyle};
        src: url('${e}');
    }`}const Sn=new Map;async function Wv(r){const t=r.filter(e=>st.has(`${e}-and-url`)).map(e=>{if(!Sn.has(e)){const{entries:s}=st.get(`${e}-and-url`),i=[];s.forEach(n=>{const o=n.url,a=n.faces.map(l=>({weight:l.weight,style:l.style}));i.push(...a.map(l=>zv({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},o)))}),Sn.set(e,Promise.all(i).then(n=>n.join(`
`)))}return Sn.get(e)});return(await Promise.all(t)).join(`
`)}function Vv(r,t,e,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${r}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:l,height:u}=i.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function Yv(r,t){const e=he.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),e}function Kv(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}class Tu{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Ot.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const s=this._buildTexturePromise(t).then(i=>(this._activeTextures[e].texture=i,i));return this._activeTextures[e]={texture:null,promise:s,usageCount:1},s}getReferenceCount(t){var e,s;return(s=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?s:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(s=>{e.texture=s,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:s,resolution:i,textureStyle:n,autoGenerateMipmaps:o}=t,a=Et.get(xu),l=Hv(e,s),u=await Wv(l),h=vu(e,s,u,a),c=Math.ceil(Math.ceil(Math.max(1,h.width)+s.padding*2)*i),d=Math.ceil(Math.ceil(Math.max(1,h.height)+s.padding*2)*i),p=a.image,f=2;p.width=(c|0)+f,p.height=(d|0)+f;const m=Vv(e,s,i,u,a);await Kv(p,m,yu()&&l.length>0);const g=p;let _;this._createCanvas&&(_=Yv(p,i));const x=bn(_?_.canvas:g,p.width-f,p.height-f,i,o);return n&&(x.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(x.source),he.returnCanvasAndContext(_)),Et.return(a),x}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){_t.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Tu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"htmlText"},N.add(Tu),N.add(bu);class qv extends pn{constructor(...t){var e;const s=fn(t,"HtmlText");super(s,fo),this.renderPipeId="htmlText",s.textureStyle&&(this.textureStyle=s.textureStyle instanceof qt?s.textureStyle:new qt(s.textureStyle)),this.autoGenerateMipmaps=(e=s.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor,s=vu(this.text,this._style),{width:i,height:n}=s;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;"))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class Zv extends mv{uploadQueueItem(t){t instanceof ft?this.uploadTextureSource(t):t instanceof Us?this.uploadText(t):t instanceof qv?this.uploadHTMLText(t):t instanceof mu?this.uploadBitmapText(t):t instanceof kt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;this.uploadTextureSource(i.source)}else if(s.action==="fill"){const{texture:i}=s.data.style;this.uploadTextureSource(i.source)}return null}}class Qv extends Zv{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}Qv.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"prepare"};const Su=class ur{static _getPatternRepeat(t,e){const s=t&&t!=="clamp-to-edge",i=e&&e!=="clamp-to-edge";return s&&i?"repeat":s?"repeat-x":i?"repeat-y":"no-repeat"}start(t,e,s){}execute(t,e){var s,i,n,o,a,l,u,h,c,d;const p=e.elements;if(!p||!p.length)return;const f=t.renderer,m=f.canvasContext,g=m.activeContext;for(let _=0;_<p.length;_++){const x=p[_];if(!x.packAsQuad)continue;const v=x,b=v.texture,T=b?Q.getCanvasSource(b):null;if(!T)continue;const y=b.source.style,w=m.smoothProperty,A=y.scaleMode!=="nearest";g[w]!==A&&(g[w]=A),m.setBlendMode(e.blendMode);const R=(i=(s=f.globalUniforms.globalUniformData)==null?void 0:s.worldColor)!=null?i:4294967295,C=v.color,E=(R>>>24&255)/255,G=(C>>>24&255)/255,I=(o=(n=f.filter)==null?void 0:n.alphaMultiplier)!=null?o:1,M=E*G*I;if(M<=0)continue;g.globalAlpha=M;const B=R&16777215,P=C&16777215,O=ge(Ae(P,B)),q=b.frame,k=(a=y.addressModeU)!=null?a:y.addressMode,K=(l=y.addressModeV)!=null?l:y.addressMode,X=ur._getPatternRepeat(k,K),W=(h=(u=b.source._resolution)!=null?u:b.source.resolution)!=null?h:1,U=(d=(c=v.renderable)==null?void 0:c.renderGroup)==null?void 0:d.isCachedAsTexture,L=q.x*W,$=q.y*W,Z=q.width*W,ht=q.height*W,J=v.bounds,tt=f.renderTarget.renderTarget.isRoot,it=J.minX,nt=J.minY,et=J.maxX-J.minX,gt=J.maxY-J.minY,dt=b.rotate,z=b.uvs,Pt=Math.min(z.x0,z.x1,z.x2,z.x3,z.y0,z.y1,z.y2,z.y3),wt=Math.max(z.x0,z.x1,z.x2,z.x3,z.y0,z.y1,z.y2,z.y3),te=X!=="no-repeat"&&(Pt<0||wt>1),_o=dt&&!(!te&&(O!==16777215||dt));_o?(ur._tempPatternMatrix.copyFrom(v.transform),j.matrixAppendRotationInv(ur._tempPatternMatrix,dt,it,nt,et,gt),m.setContextTransform(ur._tempPatternMatrix,v.roundPixels===1,void 0,U&&tt)):m.setContextTransform(v.transform,v.roundPixels===1,void 0,U&&tt);const Vs=_o?0:it,Ys=_o?0:nt,xo=et,vo=gt;if(te){let Ne=T;const cr=O!==16777215&&!dt,OT=q.width<=b.source.width&&q.height<=b.source.height;cr&&OT&&(Ne=Q.getTintedCanvas({texture:b},O));const bo=g.createPattern(Ne,X);if(!bo)continue;const yc=xo,Tc=vo;if(yc===0||Tc===0)continue;const Sc=1/yc,wc=1/Tc,Ec=(z.x1-z.x0)*Sc,Ac=(z.y1-z.y0)*Sc,Pc=(z.x3-z.x0)*wc,Cc=(z.y3-z.y0)*wc,GT=z.x0-Ec*Vs-Pc*Ys,IT=z.y0-Ac*Vs-Cc*Ys,yo=b.source.pixelWidth,To=b.source.pixelHeight;ur._tempPatternMatrix.set(Ec*yo,Ac*To,Pc*yo,Cc*To,GT*yo,IT*To),Q.applyPatternTransform(bo,ur._tempPatternMatrix),g.fillStyle=bo,g.fillRect(Vs,Ys,xo,vo)}else{const Ne=O!==16777215||dt?Q.getTintedCanvas({texture:b},O):T,cr=Ne!==T;g.drawImage(Ne,cr?0:L,cr?0:$,cr?Ne.width:Z,cr?Ne.height:ht,Vs,Ys,xo,vo)}}}};Su._tempPatternMatrix=new D,Su.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let Jv=Su;class wu{constructor(){this._tempState=jt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,s){const i=t.renderer,n=this._didUploadHash[s.uid];i.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,s.glProgram)}execute(t,e){const s=t.renderer;this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const i=e.textures.textures;for(let n=0;n<e.textures.count;n++)s.texture.bind(i[n],n);s.geometry.draw(e.topology,e.size,e.start)}}wu.extension={type:[S.WebGLPipesAdaptor],name:"batch"};function XR(r){const t=[];let e=0;for(let s=0;s<r;s++)t[e]={texture:{sampleType:"float",viewDimension:"2d",multisampled:!1},binding:e,visibility:GPUShaderStage.FRAGMENT},e++,t[e]={sampler:{type:"filtering"},binding:e,visibility:GPUShaderStage.FRAGMENT},e++;return t}function HR(r){const t={};let e=0;for(let s=0;s<r;s++)t[`textureSource${s+1}`]=e++,t[`textureSampler${s+1}`]=e++;return t}const wn=jt.for2d();class Eu{start(t,e,s){const i=t.renderer,n=i.encoder,o=s.gpuProgram;this._shader=s,this._geometry=e,n.setGeometry(e,o),wn.blendMode="normal",i.pipeline.getPipeline(e,o,wn);const a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){const s=this._shader.gpuProgram,i=t.renderer,n=i.encoder;if(!e.bindGroup){const l=e.textures;e.bindGroup=Ei(l.textures,l.count,i.limits.maxBatchableTextures)}wn.blendMode=e.blendMode;const o=i.bindGroup.getBindGroup(e.bindGroup,s,1),a=i.pipeline.getPipeline(this._geometry,s,wn,e.topology);e.bindGroup._touch(i.gc.now,i.tick),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Eu.extension={type:[S.WebGPUPipesAdaptor],name:"batch"};const Au=class gT{constructor(t,e){this.state=jt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null);var s,i;this.renderer=t,this._adaptor=e,(i=(s=this._adaptor).init)==null||i.call(s,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Ii({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let s=this._activeBatches[t.batcherName];s||(s=this._activeBatches[t.batcherName]=gT.getBatcher(t.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const s in e){const i=e[s],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const s in e){const i=e[s],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(i.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,s=e.geometry,i=e.shader;this._adaptor.start(this,s,i)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Au.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"batch"},Au._availableBatchers=Object.create(null);let En=Au;N.handleByMap(S.Batcher,En._availableBatchers),N.add(Ii);function jR(r){const t=r.split(/([\n{}])/g).map(s=>s.trim()).filter(s=>s.length);let e="";return t.map(s=>{let i=e+s;return s==="{"?e+="    ":s==="}"&&(e=e.substr(0,e.length-4),i=e+s),i}).join(`
`)}const tb={name:"texture-bit",vertex:{header:`

        struct TextureUniforms {
            uTextureMatrix:mat3x3<f32>,
        }

        @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
        `,main:`
            uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
            @group(2) @binding(0) var uTexture: texture_2d<f32>;
            @group(2) @binding(1) var uSampler: sampler;


        `,main:`
            outColor = textureSample(uTexture, uSampler, vUV);
        `}},eb={name:"texture-bit",vertex:{header:`
            uniform mat3 uTextureMatrix;
        `,main:`
            uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
        uniform sampler2D uTexture;


        `,main:`
            outColor = texture(uTexture, vUV);
        `}},zR=new Ct;let WR=class extends Zr{constructor(){super(),this.filters=[new rx({sprite:new pe(F.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}};class An{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,n.collectRenderables(s,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=Et.get(WR);if(i.inverse=t.inverse,s){t.mask.mask.measurable=!0;const n=Qr(t.mask.mask,!0,zR);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=_t.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const l=i.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===Ot.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const i=this._activeMaskStage.pop();s&&_t.returnTexture(i.filterTexture),Et.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}An.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class Pu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Pu.extension={type:[S.CanvasPipes],name:"colorMask"};class Cu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Cu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};class VR{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){pi(this.mask,t,e)}addLocalBounds(t,e){fi(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}function YR(r,t,e,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(t+n,e),r.lineTo(t+s-n,e),r.quadraticCurveTo(t+s,e,t+s,e+n),r.lineTo(t+s,e+i-n),r.quadraticCurveTo(t+s,e+i,t+s-n,e+i),r.lineTo(t+n,e+i),r.quadraticCurveTo(t,e+i,t,e+i-n),r.lineTo(t,e+n),r.quadraticCurveTo(t,e,t+n,e)}function rb(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;YR(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.moveTo(e.x+e.radius,e.y),r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?(r.moveTo(e.x+e.halfWidth,e.y),r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;r.moveTo(s[0],s[1]);for(let i=2;i<s.length;i+=2)r.lineTo(s[i],s[i+1]);e.closePath&&r.closePath();break}}}function KR(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const i=s.transform,n=i&&!i.isIdentity();n&&(r.save(),r.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),rb(r,s.shape),n&&r.restore()}return!0}class Ru{constructor(t){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){var e,s,i;if(t.action!=="pushMaskBegin"&&t.action!=="popMaskEnd")return;const n=this._renderer,o=n.canvasContext,a=o==null?void 0:o.activeContext;if(!a)return;if(t.action==="popMaskEnd"){this._canvasMaskStack.pop()&&a.restore();return}t.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const l=t.mask.mask;if(!(l instanceof hr)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const u=l,h=(e=u.context)==null?void 0:e.instructions;if(!(h!=null&&h.length)){this._canvasMaskStack.push(!1);return}a.save(),o.setContextTransform(u.groupTransform,(n._roundPixels|u._roundPixels)===1),a.beginPath();let c=!1,d=!1;for(let p=0;p<h.length;p++){const f=h[p],m=f.action;if(m!=="fill"&&m!=="stroke")continue;const g=f.data,_=(s=g==null?void 0:g.path)==null?void 0:s.shapePath;if(!((i=_==null?void 0:_.shapePrimitives)!=null&&i.length))continue;const x=_.shapePrimitives;for(let v=0;v<x.length;v++){const b=x[v];if(!(b!=null&&b.shape))continue;const T=b.transform,y=T&&!T.isIdentity();y&&(a.save(),a.transform(T.a,T.b,T.c,T.d,T.tx,T.ty)),rb(a,b.shape),d=KR(a,b.holes)||d,c=!0,y&&a.restore()}}if(!c){a.restore(),this._canvasMaskStack.push(!1);return}d?a.clip("evenodd"):a.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(t,e){this._warnedMaskTypes.has(t)||(this._warnedMaskTypes.add(t),ne(e))}}Ru.extension={type:[S.CanvasPipes],name:"stencilMask"};class Mu{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var i,n;const o=t,a=this._renderer;a.renderPipes.batch.break(s),a.renderPipes.blendMode.setBlendMode(o.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=o.mask;l.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const u=this._maskHash.get(o);u.instructionsStart=s.instructionSize,l.collectRenderables(s,a,null),l.includeInBuild=!1,a.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=s.instructionSize-u.instructionsStart-1;u.instructionsLength=h;const c=a.renderTarget.renderTarget.uid;(n=(i=this._maskStackHash)[c])!=null||(i[c]=0)}pop(t,e,s){const i=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)s.instructions[s.instructionSize++]=s.instructions[o.instructionsStart++];s.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,s;const i=this._renderer,n=i,o=i.renderTarget.renderTarget.uid;let a=(s=(e=this._maskStackHash)[o])!=null?s:e[o]=0;t.action==="pushMaskBegin"?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(Tt.RENDERING_MASK_ADD,a),a++,n.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?n.stencil.setStencilMode(Tt.INVERSE_MASK_ACTIVE,a):n.stencil.setStencilMode(Tt.MASK_ACTIVE,a),n.colorMask.setMask(15)):t.action==="popMaskBegin"?(n.colorMask.setMask(0),a!==0?n.stencil.setStencilMode(Tt.RENDERING_MASK_REMOVE,a):(n.renderTarget.clear(null,Wt.STENCIL),n.stencil.setStencilMode(Tt.DISABLED,a)),a--):t.action==="popMaskEnd"&&(t.inverse?n.stencil.setStencilMode(Tt.INVERSE_MASK_ACTIVE,a):n.stencil.setStencilMode(Tt.MASK_ACTIVE,a),n.colorMask.setMask(15)),this._maskStackHash[o]=a}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Mu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"stencilMask"};const mt="source-over";function sb(){const r=Wl(),t=Object.create(null);return t.inherit=mt,t.none=mt,t.normal="source-over",t.add="lighter",t.multiply=r?"multiply":mt,t.screen=r?"screen":mt,t.overlay=r?"overlay":mt,t.darken=r?"darken":mt,t.lighten=r?"lighten":mt,t["color-dodge"]=r?"color-dodge":mt,t["color-burn"]=r?"color-burn":mt,t["hard-light"]=r?"hard-light":mt,t["soft-light"]=r?"soft-light":mt,t.difference=r?"difference":mt,t.exclusion=r?"exclusion":mt,t.saturation=r?"saturation":mt,t.color=r?"color":mt,t.luminosity=r?"luminosity":mt,t["linear-burn"]=r?"color-burn":mt,t["linear-dodge"]=r?"color-dodge":mt,t["linear-light"]=r?"hard-light":mt,t["pin-light"]=r?"hard-light":mt,t["vivid-light"]=r?"hard-light":mt,t["hard-mix"]=mt,t.negation=r?"difference":mt,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=mt,t.divide=mt,t.min=mt,t.max=mt,t}const qR=new D;class Ou{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=sb(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=t}resolutionChange(t){this.activeResolution=t}init(){const t=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,s,i){var n;const o=i?D.IDENTITY:((n=this._renderer.globalUniforms.globalUniformData)==null?void 0:n.worldTransformMatrix)||D.IDENTITY;let a=qR;a.copyFrom(o),a.append(t);const l=this._projTransform,u=this.activeResolution;if(s=s||u,l){const h=D.shared;h.copyFrom(a),h.prepend(l),a=h}e?this.activeContext.setTransform(a.a*s,a.b*s,a.c*s,a.d*s,a.tx*u|0,a.ty*u|0):this.activeContext.setTransform(a.a*s,a.b*s,a.c*s,a.d*s,a.tx*u,a.ty*u)}clear(t,e){const s=this.activeContext,i=this._renderer;if(s.clearRect(0,0,i.width,i.height),t){const n=rt.shared.setValue(t);s.globalAlpha=e!=null?e:n.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,i.width,i.height),s.globalAlpha=1}}setBlendMode(t){if(this._activeBlendMode===t)return;this._activeBlendMode=t,this._outerBlend=!1;const e=this.blendModes[t];if(!e){this._warnedBlendModes.has(t)||(console.warn(`CanvasRenderer: blend mode "${t}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(t)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=e}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ou.extension={type:[S.CanvasSystem],name:"canvasContext"};function Gu(r){return typeof r.getCanvasFilterString=="function"}let ZR=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Ct,this.cssFilterString=""}};class Iu{constructor(t){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=t}push(t){const e=this._pushFilterFrame(),s=t.filterEffect.filters;if(e.skip=!1,e.useClip=!1,e.filters=s,e.container=t.container,e.cssFilterString="",s.every(l=>!l.enabled)){e.skip=!0;return}const i=[],n=1;for(const l of s){if(!l.enabled)continue;if(!Gu(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(!Gu(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=Q.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=he.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,bn(p,h,c,u)}_calculateFilterArea(t,e){if(t.renderables?xa(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 ZR),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}}Iu.extension={type:[S.CanvasSystem],name:"filter"},N.add(Iu);class Bu{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Bu.extension={type:[S.CanvasSystem],name:"limits"};class Pn{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Pn.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"customRender"};function Cn(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i<e.instructionSize;i++){const n=s[i];t[n.renderPipeId].execute(n)}}class Rn{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(Et.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var s;const i=(s=t._batchableRenderGroup)!=null?s:t._batchableRenderGroup=Et.get(Ds);i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(i,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=new D().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),Cn(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),Cn(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}Rn.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"renderGroup"};const QR="#808080",Mn=new D,JR=new D,tM=new D,Fu=new D;function eM(r,t,e){r.beginPath();for(let s=0;s<e.length;s+=3){const i=e[s]*2,n=e[s+1]*2,o=e[s+2]*2;r.moveTo(t[i],t[i+1]),r.lineTo(t[n],t[n+1]),r.lineTo(t[o],t[o+1]),r.closePath()}r.fill()}function rM(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function sM(r,t,e,s,i,n){n=Math.max(0,Math.min(n,Math.min(s,i)/2)),r.moveTo(t+n,e),r.lineTo(t+s-n,e),r.quadraticCurveTo(t+s,e,t+s,e+n),r.lineTo(t+s,e+i-n),r.quadraticCurveTo(t+s,e+i,t+s-n,e+i),r.lineTo(t+n,e+i),r.quadraticCurveTo(t,e+i,t,e+i-n),r.lineTo(t,e+n),r.quadraticCurveTo(t,e,t+n,e)}function On(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;sM(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;r.moveTo(s[0],s[1]);for(let i=2;i<s.length;i+=2)r.lineTo(s[i],s[i+1]);e.closePath&&r.closePath();break}}}function iM(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const i=s.transform,n=i&&!i.isIdentity();n&&(r.save(),r.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),On(r,s.shape),n&&r.restore()}return!0}function nM(r,t,e,s){const i=r.fill;if(i instanceof Ut){i.buildGradient();const o=i.texture;if(o){const a=Q.getTintedPattern(o,t),l=e?Fu.copyFrom(e).scale(o.source.pixelWidth,o.source.pixelHeight):Fu.copyFrom(i.transform);return s&&!r.textureSpace&&l.append(s),Q.applyPatternTransform(a,l),a}}if(i instanceof Mr){const o=Q.getTintedPattern(i.texture,t);return Q.applyPatternTransform(o,i.transform),o}const n=r.texture;if(n&&n!==F.WHITE){if(!n.source.resource)return QR;const o=Q.getTintedPattern(n,t),a=e?Fu.copyFrom(e).scale(n.source.pixelWidth,n.source.pixelHeight):r.matrix;return Q.applyPatternTransform(o,a),o}return rM(t)}class Du{constructor(){this.shader=null}contextChange(t){}execute(t,e){var s,i,n,o,a,l,u,h,c,d,p,f;const m=t.renderer,g=m.canvasContext,_=g.activeContext,x=e.groupTransform,v=(i=(s=m.globalUniforms.globalUniformData)==null?void 0:s.worldColor)!=null?i:4294967295,b=e.groupColorAlpha,T=(v>>>24&255)/255,y=(b>>>24&255)/255,w=(o=(n=m.filter)==null?void 0:n.alphaMultiplier)!=null?o:1,A=T*y*w;if(A<=0)return;const R=v&16777215,C=b&16777215,E=ge(Ae(C,R)),G=m._roundPixels|e._roundPixels;_.save(),g.setContextTransform(x,G===1),g.setBlendMode(e.groupBlendMode);const I=e.context.instructions;for(let M=0;M<I.length;M++){const B=I[M];if(B.action==="texture"){const U=B.data,L=U.image,$=L?Q.getCanvasSource(L):null;if(!$)continue;const Z=U.alpha*A;if(Z<=0)continue;const ht=Ae(U.style,E);_.globalAlpha=Z;let J=$;ht!==16777215&&(J=Q.getTintedCanvas({texture:L},ht));const tt=L.frame,it=(l=(a=L.source._resolution)!=null?a:L.source.resolution)!=null?l:1;let nt=tt.x*it,et=tt.y*it;const gt=tt.width*it,dt=tt.height*it;J!==$&&(nt=0,et=0);const z=U.transform,Pt=z&&!z.isIdentity(),wt=L.rotate;Pt||wt?(Mn.copyFrom(x),Pt&&Mn.append(z),wt&&j.matrixAppendRotationInv(Mn,wt,U.dx,U.dy,U.dw,U.dh),g.setContextTransform(Mn,G===1)):g.setContextTransform(x,G===1),_.drawImage(J,nt,et,J===$?gt:J.width,J===$?dt:J.height,wt?0:U.dx,wt?0:U.dy,U.dw,U.dh),(Pt||wt)&&g.setContextTransform(x,G===1);continue}const P=B.data,O=(u=P==null?void 0:P.path)==null?void 0:u.shapePath;if(!((h=O==null?void 0:O.shapePrimitives)!=null&&h.length))continue;const q=P.style,k=Ae(q.color,E),K=q.alpha*A;if(K<=0)continue;const X=B.action==="stroke";if(_.globalAlpha=K,X){const U=q;_.lineWidth=U.width,_.lineCap=U.cap,_.lineJoin=U.join,_.miterLimit=U.miterLimit}const W=O.shapePrimitives;if(!X&&(p=(d=(c=P.hole)==null?void 0:c.shapePath)==null?void 0:d.shapePrimitives)!=null&&p.length){const U=W[W.length-1];U.holes=P.hole.shapePath.shapePrimitives}for(let U=0;U<W.length;U++){const L=W[U];if(!(L!=null&&L.shape))continue;const $=L.transform,Z=$&&!$.isIdentity(),ht=q.texture&&q.texture!==F.WHITE,J=q.textureSpace==="global"?$:null,tt=ht?tl(JR,q,L.shape,J):null,it=Z?tM.copyFrom(x).append($):x,nt=nM(q,k,tt,it);if(Z&&(_.save(),_.transform($.a,$.b,$.c,$.d,$.tx,$.ty)),X){const et=q;if(et.alignment!==.5&&!et.pixelLine){const gt=[],dt=[],z=[],Pt=rr[L.shape.type];if(Pt!=null&&Pt.build(L.shape,gt)){const wt=(f=L.shape.closePath)!=null?f:!0;Za(gt,et,!1,wt,dt,z),_.fillStyle=nt,eM(_,dt,z)}else _.strokeStyle=nt,_.beginPath(),On(_,L.shape),_.stroke()}else _.strokeStyle=nt,_.beginPath(),On(_,L.shape),_.stroke()}else _.fillStyle=nt,_.beginPath(),On(_,L.shape),iM(_,L.holes)?_.fill("evenodd"):_.fill();Z&&_.restore()}}_.restore()}destroy(){this.shader=null}}Du.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Gn{constructor(t){this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Ds;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Gn.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"sprite"};const ks={};N.handle(S.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");ks[r.name]=r.ref},r=>{delete ks[r.name]});class In{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,s){this._blendModeStack.push(e),this.setBlendMode(t,e,s)}popBlendMode(t){var e;this._blendModeStack.pop();const s=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,s,t)}setBlendMode(t,e,s){var i;const n=t instanceof ni;if(this._activeBlendMode===e){this._isAdvanced&&t&&!n&&((i=this._renderableList)==null||i.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=e,t&&(this._isAdvanced=!!ks[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,s))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const s=this._activeBlendMode;if(!ks[s])return;const i=this._ensureFilterEffect(s),n=t instanceof ni,o={renderPipeId:"filter",action:"pushFilter",filterEffect:i,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=o.renderables,e.add(o)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new Zr,e.filters=[new ks[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}In.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function Bn(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const oM=new pt,ib=pr|ts|ai;function Uu(r,t=!1){nb(r);const e=r.childrenToUpdate,s=r.updateTick++;for(const i in e){const n=Number(i),o=e[i],a=o.list,l=o.index;for(let u=0;u<l;u++){const h=a[u];h.parentRenderGroup===r&&h.relativeRenderGroupDepth===n&&ku(h,s,0)}Bn(a,l),o.index=0}if(t)for(let i=0;i<r.renderGroupChildren.length;i++)Uu(r.renderGroupChildren[i],t)}function nb(r){const t=r.root;let e;if(r.renderGroupParent){const s=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,s.worldTransform),r.worldColor=Jr(t.groupColor,s.worldColor),e=t.groupAlpha*s.worldAlpha}else r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function ku(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&ib&&ob(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&ib&&ob(r,oM,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u<o;u++)ku(n[u],t,e);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function ob(r,t,e){if(e&ts){r.groupColor=Jr(r.localColor,t.groupColor);let s=r.localAlpha*t.groupAlpha;s=s<0?0:s>1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&ai&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&pr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function ab(r,t){const{list:e}=r.childrenRenderablesToUpdate;let s=!1;for(let i=0;i<r.childrenRenderablesToUpdate.index;i++){const n=e[i];if(s=t[n.renderPipeId].validateRenderable(n),s)break}return r.structureDidChange=s,s}const aM=new D;class $u{constructor(t){this._renderer=t}render({container:t,transform:e}){const s=t.parent,i=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,o=aM;e&&(o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const a=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Cn(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=s,t.renderGroup.renderGroupParent=i}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var s,i;if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let n=t.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(t.renderGroupChildren[n],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const n=t.root.getLocalBounds(),o=this._renderer,a=t.textureOptions.resolution||o.view.resolution,l=(s=t.textureOptions.antialias)!=null?s:o.view.antialias,u=(i=t.textureOptions.scaleMode)!=null?i:"linear",h=t.texture;n.ceil(),t.texture&&_t.returnTexture(t.texture,!0);const c=_t.getOptimalTexture(n.width,n.height,a,l);c._source.style=new qt({scaleMode:u}),t.texture=c,t._textureBounds||(t._textureBounds=new Ct),t._textureBounds.copyFrom(n),h!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(_t.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,s=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=s,t.structureDidChange?Bn(t.childrenRenderablesToUpdate.list,0):ab(t,s),Uu(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let i=0;i<t.renderGroupChildren.length;i++)this._updateRenderGroups(t.renderGroupChildren[i])}_updateRenderables(t){const{list:e,index:s}=t.childrenRenderablesToUpdate;for(let i=0;i<s;i++){const n=e[i];n.didViewUpdate&&t.updateRenderable(n)}Bn(e,s)}_buildInstructions(t,e){const s=t.root,i=t.instructionSet;i.reset();const n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(i),o.blendMode.buildStart(),o.colorMask.buildStart(),s.sortableChildren&&s.sortChildren(),s.collectRenderablesWithEffects(i,n,null),o.batch.buildEnd(i),o.blendMode.buildEnd(i)}}$u.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderGroup"};var lM=Object.defineProperty,lb=Object.getOwnPropertySymbols,uM=Object.prototype.hasOwnProperty,hM=Object.prototype.propertyIsEnumerable,ub=(r,t,e)=>t in r?lM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hb=(r,t)=>{for(var e in t||(t={}))uM.call(t,e)&&ub(r,e,t[e]);if(lb)for(var e of lb(t))hM.call(t,e)&&ub(r,e,t[e]);return r};const Lu=class _T{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new rt(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=hb(hb({},_T.defaultOptions),t),this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Lu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0},Lu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let cb=Lu;var cM=Object.defineProperty,db=Object.getOwnPropertySymbols,dM=Object.prototype.hasOwnProperty,pM=Object.prototype.propertyIsEnumerable,pb=(r,t,e)=>t in r?cM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nu=(r,t)=>{for(var e in t||(t={}))dM.call(t,e)&&pb(r,e,t[e]);if(db)for(var e of db(t))pM.call(t,e)&&pb(r,e,t[e]);return r};const Xu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Hu=class xT{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof pt||t instanceof F?Nu({target:t},e):Nu(Nu({},e),t)}async image(t){const e=H.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,xT.defaultImageOptions);const{format:e,quality:s}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},Xu[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(Xu[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:Xu[e],quality:s});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer;if(e instanceof F)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof F?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof pt&&i.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof F?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const s=this.canvas(t),i=document.createElement("a");i.download=(e=t.filename)!=null?e:"image.png",i.href=s.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){var e;const s=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const i=this.canvas(t),n=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const o=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};Hu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"},Hu.defaultImageOptions={format:"png",quality:1};let fb=Hu;var mb=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,gM=(r,t)=>{var e={};for(var s in r)fM.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&mb)for(var s of mb(r))t.indexOf(s)<0&&mM.call(r,s)&&(e[s]=r[s]);return e};class mo extends F{static create(t){const e=t,{dynamic:s}=e,i=gM(e,["dynamic"]);return new mo({source:new ft(i),dynamic:s!=null?s:!1})}resize(t,e,s){return this.source.resize(t,e,s),this}}var _M=Object.defineProperty,xM=Object.defineProperties,vM=Object.getOwnPropertyDescriptors,gb=Object.getOwnPropertySymbols,bM=Object.prototype.hasOwnProperty,yM=Object.prototype.propertyIsEnumerable,_b=(r,t,e)=>t in r?_M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TM=(r,t)=>{for(var e in t||(t={}))bM.call(t,e)&&_b(r,e,t[e]);if(gb)for(var e of gb(t))yM.call(t,e)&&_b(r,e,t[e]);return r},SM=(r,t)=>xM(r,vM(t));const wM=new ut,EM=new Ct,AM=[0,0,0,0];class ju{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof pt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const s=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:rt.shared.setValue(o).toArray():o=AM;const a=((e=t.frame)==null?void 0:e.copyTo(wM))||ei(n,EM).rectangle;a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const l=mo.create(SM(TM({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i})),u=D.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:u,target:l,clearColor:o}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}ju.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function xb(r){let t=!1;for(const s in r)if(r[s]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const s in r){const i=r[s];i&&(e[s]=i)}return e}function vb(r){let t=0;for(let e=0;e<r.length;e++)r[e]==null?t++:r[e-t]=r[e];return r.length-=t,r}var PM=Object.defineProperty,bb=Object.getOwnPropertySymbols,CM=Object.prototype.hasOwnProperty,RM=Object.prototype.propertyIsEnumerable,yb=(r,t,e)=>t in r?PM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tb=(r,t)=>{for(var e in t||(t={}))CM.call(t,e)&&yb(r,e,t[e]);if(bb)for(var e of bb(t))RM.call(t,e)&&yb(r,e,t[e]);return r};const zu=class vT{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t=Tb(Tb({},vT.defaultOptions),t),this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:s,collection:i,type:n}=e;n==="hash"?s[i]=xb(s[i]):s[i]=vb(s[i])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(const s of t.renderGroupChildren)this._updateInstructionGCTick(s,e)}addCollection(t,e,s){this._managedCollections.push({context:t,collection:e,type:s})}addResource(t,e){var s,i;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(s=t._onTouch)==null||s.call(t,this.now);return}const n=this._managedResources.length;t._gcData={index:n,type:e},t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const s=e.index,i=this._managedResources.length-1;if(s!==i){const n=this._managedResources[i];this._managedResources[s]=n,n._gcData.index=s}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,s,i=0){this._managedResourceHashes.push({context:t,hash:e,type:s,priority:i}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const i of e)this.runOnHash(i,t);let s=0;for(let i=0;i<this._managedResources.length;i++){const n=this._managedResources[i];s=this.runOnResource(n,t,s)}this._managedResources.length=s}updateRenderableGCTick(t,e){var s,i,n,o,a;const l=(s=t.renderGroup)!=null?s:t.parentRenderGroup,u=(n=(i=l==null?void 0:l.instructionSet)==null?void 0:i.gcTick)!=null?n:-1;((o=l==null?void 0:l.gcTick)!=null?o:0)===u&&(t._gcLastUsed=e,(a=t._onTouch)==null||a.call(t,e))}runOnResource(t,e,s){const i=t._gcData;return i.type==="renderable"&&this.updateRenderableGCTick(t,e),e-t._gcLastUsed<this.maxUnusedTime||!t.autoGarbageCollect?(this._managedResources[s]=t,i.index=s,s++):(t.unload(),t._gcData=null,t._gcLastUsed=-1,t.off("unload",this.removeResource,this)),s}_createHashClone(t,e){const s=Object.create(null);for(const i in t){if(i===e)break;t[i]!==null&&(s[i]=t[i])}return s}runOnHash(t,e){var s,i;const{context:n,hash:o,type:a}=t,l=n[o];let u=null,h=0;for(const c in l){const d=l[c];if(d===null){h++,h===1e4&&!u&&(u=this._createHashClone(l,c));continue}if(d._gcLastUsed===-1){d._gcLastUsed=e,(s=d._onTouch)==null||s.call(d,e),u&&(u[c]=d);continue}if(a==="renderable"&&this.updateRenderableGCTick(d,e),!(e-d._gcLastUsed<this.maxUnusedTime)&&d.autoGarbageCollect){if(u||(h+1!==1e4?(l[c]=null,h++):u=this._createHashClone(l,c)),a==="renderable"){const p=d,f=(i=p.renderGroup)!=null?i:p.parentRenderGroup;f&&(f.structureDidChange=!0)}d.unload(),d._gcData=null,d._gcLastUsed=-1}else u&&(u[c]=d)}u&&(n[o]=u)}destroy(){this.enabled=!1,this._managedResources.forEach(t=>{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0},zu.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Sb=zu;class Wu{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:s,worldColor:i,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new D,worldColor:4294967295,offset:new lt},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:i||a.worldColor,offset:n||a.offset,bindGroup:null},u=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(u);const h=u.uniforms;h.uProjectionMatrix=l.projectionMatrix,h.uResolution=l.resolution,h.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),h.uWorldTransformMatrix.tx-=l.offset.x,h.uWorldTransformMatrix.ty-=l.offset.y,Dr(l.worldColor,h.uWorldColorAlpha,0),u.update();let c;this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(u,!1):(c=this._bindGroupPool.pop()||new be,this._activeBindGroups.push(c),c.setResource(u,0)),l.bindGroup=c,this._currentGlobalUniformData=l}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Ot.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new At({uProjectionMatrix:{value:new D,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new D,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Wu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let MM=1;class Vu{constructor(){this._tasks=[],this._offset=0}init(){Rt.system.add(this._update,this)}repeat(t,e,s=!0){const i=MM++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const s=this._tasks[e];if(t-s.offset-s.last>=s.duration){const i=t-s.start;s.func(i),s.last=t}}}destroy(){Rt.system.remove(this._update,this),this._tasks.length=0}}Vu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let wb=!1;function Eb(r){if(!wb){if(H.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c  %c  %c  %c  %c PixiJS %c v${_s} (${r}) http://www.pixijs.com/

`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${_s} - ${r} - http://www.pixijs.com/`);wb=!0}}class Fn{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Ot.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Eb(e)}}}Fn.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"hello",priority:-2},Fn.defaultOptions={hello:!1};var OM=Object.defineProperty,Ab=Object.getOwnPropertySymbols,GM=Object.prototype.hasOwnProperty,IM=Object.prototype.propertyIsEnumerable,Pb=(r,t,e)=>t in r?OM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cb=(r,t)=>{for(var e in t||(t={}))GM.call(t,e)&&Pb(r,e,t[e]);if(Ab)for(var e of Ab(t))IM.call(t,e)&&Pb(r,e,t[e]);return r};const Yu=class bT{constructor(t){this._renderer=t}init(t){t=Cb(Cb({},bT.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return this._renderer.gc.enabled}set enabled(t){this._renderer.gc.enabled=t}addManagedHash(t,e){this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){this._renderer.gc.addResource(t,"renderable")}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Yu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderableGC",priority:0},Yu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Rb=Yu;const Ku=class oo{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){}get active(){return this._renderer.gc.enabled}set active(t){this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==oo.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==oo.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==oo.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Ku.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"textureGC"},Ku.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Mb=Ku;var BM=Object.defineProperty,Ob=Object.getOwnPropertySymbols,FM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,Gb=(r,t,e)=>t in r?BM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ib=(r,t)=>{for(var e in t||(t={}))FM.call(t,e)&&Gb(r,e,t[e]);if(Ob)for(var e of Ob(t))DM.call(t,e)&&Gb(r,e,t[e]);return r};const Bb=class yT{constructor(t={}){if(this.uid=ct("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Ib(Ib({},yT.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new ft({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(s=>s.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof F||t.depthStencilTexture instanceof ft?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ft({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};Bb.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Dn=Bb;var UM=Object.defineProperty,Fb=Object.getOwnPropertySymbols,kM=Object.prototype.hasOwnProperty,$M=Object.prototype.propertyIsEnumerable,Db=(r,t,e)=>t in r?UM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LM=(r,t)=>{for(var e in t||(t={}))kM.call(t,e)&&Db(r,e,t[e]);if(Fb)for(var e of Fb(t))$M.call(t,e)&&Db(r,e,t[e]);return r};const or=new Map;Xe.register(or);function qu(r,t){if(!or.has(r)){const e=new F({source:new le(LM({resource:r},t))}),s=()=>{or.get(r)===e&&or.delete(r)};e.once("destroy",s),e.source.once("destroy",s),or.set(r,e)}return or.get(r)}function NM(r){return or.has(r)}var XM=Object.defineProperty,Ub=Object.getOwnPropertySymbols,HM=Object.prototype.hasOwnProperty,jM=Object.prototype.propertyIsEnumerable,kb=(r,t,e)=>t in r?XM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$b=(r,t)=>{for(var e in t||(t={}))HM.call(t,e)&&kb(r,e,t[e]);if(Ub)for(var e of Ub(t))jM.call(t,e)&&kb(r,e,t[e]);return r};const Zu=class TT{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t=$b($b({},TT.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new ut(0,0,t.width,t.height),this.canvas=t.canvas||H.get().createCanvas(),this.antialias=!!t.antialias,this.texture=qu(this.canvas,t),this.renderTarget=new Dn({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,s){this.texture.source.resize(t,e,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"view",priority:0},Zu.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Lb=Zu;const Un=[cb,Wu,Fn,Lb,$u,Sb,Mb,ju,fb,Ma,Rb,Vu],Qu=[In,En,Gn,Rn,An,Mu,Cu,Pn];function Nb(r,t,e,s,i,n){const o=n?1:-1;return r.identity(),r.a=1/s*2,r.d=o*(1/i*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}function Xb(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class kn{constructor(t){this.rootViewPort=new ut,this.viewport=new ut,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Aa("onRenderTargetChange"),this.projectionMatrix=new D,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:i,mipLevel:n,layer:o}){var a,l;this._renderTargetStack.length=0,this.push(t,e,s,i,n!=null?n:0,o!=null?o:0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Xb(this.rootRenderTarget),(l=(a=this.adaptor).prerender)==null||l.call(a,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,s,i,n=0,o=0){const a=this.getRenderTarget(t),l=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=t;const u=this.getGpuRenderTarget(a);(a.pixelWidth!==u.width||a.pixelHeight!==u.height)&&(this.adaptor.resizeGpuRenderTarget(a),u.width=a.pixelWidth,u.height=a.pixelHeight);const h=a.colorTexture,c=this.viewport,d=h.arrayLayerCount||1;if((o|0)!==o&&(o|=0),o<0||o>=d)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (arrayLayerCount=${d}).`);this.mipLevel=n|0,this.layer=o|0;const p=Math.max(h.pixelWidth>>n,1),f=Math.max(h.pixelHeight>>n,1);if(!i&&t instanceof F&&(i=t.frame),i){const m=h._resolution,g=1<<Math.max(n|0,0),_=i.x*m+.5|0,x=i.y*m+.5|0,v=i.width*m+.5|0,b=i.height*m+.5|0;let T=Math.floor(_/g),y=Math.floor(x/g),w=Math.ceil(v/g),A=Math.ceil(b/g);T=Math.min(Math.max(T,0),p-1),y=Math.min(Math.max(y,0),f-1),w=Math.min(Math.max(w,1),p-T),A=Math.min(Math.max(A,1),f-y),c.x=T,c.y=y,c.width=w,c.height=A}else c.x=0,c.y=0,c.width=p,c.height=f;return Nb(this.projectionMatrix,0,0,c.width/h.resolution,c.height/h.resolution,!a.isRoot),this.adaptor.startRenderPass(a,e,s,c,n,o),l&&this.onRenderTargetChange.emit(a),a}clear(t,e=Wt.ALL,s,i=this.mipLevel,n=this.layer){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport,i,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Wt.ALL,s,i,n=0,o=0){const a=this.bind(t,e,s,i,n,o);return this._renderTargetStack.push({renderTarget:a,frame:i,mipLevel:n,layer:o}),a}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame,t.mipLevel,t.layer)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,s,i,n){s.x<0&&(i.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(i.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(t,e,s,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return le.test(t)&&(t=qu(t).source),t instanceof Dn?e=t:t instanceof ft&&(e=new Dn({colorTextures:[t]}),t.source instanceof le&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Hb{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:s,context:i}=this._ensureCanvas(e);return{canvas:s,context:i,width:s.width,height:s.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:s}=this._ensureCanvas(e);s.width=t.pixelWidth,s.height=t.pixelHeight}startRenderPass(t,e,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,s,i)}clear(t,e,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t).context,o=i||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(n.setTransform(1,0,0,1,0,0),n.clearRect(o.x,o.y,o.width,o.height),s){const a=rt.shared.setValue(s);a.alpha>0&&(n.globalAlpha=a.alpha,n.fillStyle=a.toHex(),n.fillRect(o.x,o.y,o.width,o.height),n.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,s,i,n){var o,a;const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,u=e.source,{context:h}=this._ensureCanvas(u),c=(o=n==null?void 0:n.x)!=null?o:0,d=(a=n==null?void 0:n.y)!=null?a:0;return h.drawImage(l,s.x,s.y,i.width,i.height,c,d,i.width,i.height),u.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!le.test(e))&&(e=H.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const s=e.getContext("2d");return{canvas:e,context:s}}}class Ju extends kn{constructor(t){super(t),this.adaptor=new Hb,this.adaptor.init(t,this)}}Ju.extension={type:[S.CanvasSystem],name:"renderTarget"};class th{constructor(t){}init(){}initSource(t){}generateCanvas(t){var e,s;const i=H.get().createCanvas(),n=i.getContext("2d"),o=Q.getCanvasSource(t);if(!o)return i;const a=t.frame,l=(s=(e=t.source._resolution)!=null?e:t.source.resolution)!=null?s:1,u=a.x*l,h=a.y*l,c=a.width*l,d=a.height*l;return i.width=Math.ceil(c),i.height=Math.ceil(d),n.drawImage(o,u,h,c,d,0,0,c,d),i}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}th.extension={type:[S.CanvasSystem],name:"texture"};const zM=[...Un,Ou,Bu,th,Ju],WM=[In,En,Gn,Rn,An,Ru,Pu,Pn],VM=[Jv,Du],jb=[],zb=[],Wb=[];N.handleByNamedList(S.CanvasSystem,jb),N.handleByNamedList(S.CanvasPipes,zb),N.handleByNamedList(S.CanvasPipesAdaptor,Wb),N.add(...zM,...WM,...VM);class Vb extends xr{constructor(){const t={name:"canvas",type:Ot.CANVAS,systems:jb,renderPipes:zb,renderPipeAdaptors:Wb};super(t)}}var YM={__proto__:null,CanvasRenderer:Vb},$s=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))($s||{});class Yb{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class eh{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new Bt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,s.bindBufferBase(s.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let s=0,i=this._nextBindBaseIndex;for(;s<2;){i>=this._maxBindings&&(i=this._minBaseLocation,s++);const n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return e=i,this._nextBindBaseIndex=i+1,s>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,s,i){const{_gl:n}=this;s||(s=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,s*256,i||256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const i=t.data,n=t.descriptor.usage&ot.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return i?s.byteLength>=i.byteLength?e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT):(s.byteLength=i.byteLength,e.bufferData(s.type,i,n)):(s.byteLength=t.descriptor.size,e.bufferData(s.type,s.byteLength,n)),s}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||this._gl.deleteBuffer(s.buffer))}createGLBuffer(t){const{_gl:e}=this;let s=$s.ARRAY_BUFFER;t.descriptor.usage&ot.INDEX?s=$s.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&ot.UNIFORM&&(s=$s.UNIFORM_BUFFER);const i=new Yb(e.createBuffer(),s);return t._gpuData[this._renderer.uid]=i,this._managedBuffers.add(t),i}resetState(){this._boundBufferBases=Object.create(null)}}eh.extension={type:[S.WebGLSystem],name:"buffer"};var KM=Object.defineProperty,qM=Object.defineProperties,ZM=Object.getOwnPropertyDescriptors,Kb=Object.getOwnPropertySymbols,QM=Object.prototype.hasOwnProperty,JM=Object.prototype.propertyIsEnumerable,qb=(r,t,e)=>t in r?KM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$n=(r,t)=>{for(var e in t||(t={}))QM.call(t,e)&&qb(r,e,t[e]);if(Kb)for(var e of Kb(t))JM.call(t,e)&&qb(r,e,t[e]);return r},Zb=(r,t)=>qM(r,ZM(t));const rh=class ST{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,s;t=$n($n({},ST.defaultOptions),t);let i=this.multiView=t.multiView;if(t.context&&i&&(ne("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),i=!1),i?this.canvas=H.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const n=this._renderer.background.alpha<1,o=(e=t.premultipliedAlpha)!=null?e:!0,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:o,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(s=t.powerPreference)!=null?s:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&ne("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof H.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let s;const i=this.canvas;if(t===2&&(s=i.getContext("webgl2",e)),!s&&(s=i.getContext("webgl",e),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=Zb($n({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=Zb($n({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const s=t.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const s=this.supports,i=this.webGLVersion===2,n=this.extensions;s.uint32Indices=i||!!n.uint32ElementIndex,s.uniformBufferObject=i,s.vertexArrayObject=i||!!n.vertexArrayObject,s.srgbTextures=i||!!n.srgb,s.nonPowOf2wrapping=i,s.nonPowOf2mipmaps=i,s.msaa=i,s.uint32Indices}};rh.extension={type:[S.WebGLSystem],name:"context"},rh.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Qb=rh;function sh(r,t){var e,s,i;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(s=o.offset)!=null||(o.offset=a.offset),(i=o.instance)!=null||(o.instance=a.instance)):ne(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}tO(r)}function tO(r){var t,e;const{buffers:s,attributes:i}=r,n={},o={};for(const a in s){const l=s[a];n[l.uid]=0,o[l.uid]=0}for(const a in i){const l=i[a];n[l.buffer.uid]+=Ce(l.format).stride}for(const a in i){const l=i[a];(t=l.stride)!=null||(l.stride=n[l.buffer.uid]),(e=l.start)!=null||(l.start=o[l.buffer.uid]),o[l.buffer.uid]+=Ce(l.format).stride}}var Ln=(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))(Ln||{}),Nn=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(Nn||{}),Jb=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Jb||{}),at=(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))(at||{});const ty={uint8x2:at.UNSIGNED_BYTE,uint8x4:at.UNSIGNED_BYTE,sint8x2:at.BYTE,sint8x4:at.BYTE,unorm8x2:at.UNSIGNED_BYTE,unorm8x4:at.UNSIGNED_BYTE,snorm8x2:at.BYTE,snorm8x4:at.BYTE,uint16x2:at.UNSIGNED_SHORT,uint16x4:at.UNSIGNED_SHORT,sint16x2:at.SHORT,sint16x4:at.SHORT,unorm16x2:at.UNSIGNED_SHORT,unorm16x4:at.UNSIGNED_SHORT,snorm16x2:at.SHORT,snorm16x4:at.SHORT,float16x2:at.HALF_FLOAT,float16x4:at.HALF_FLOAT,float32:at.FLOAT,float32x2:at.FLOAT,float32x3:at.FLOAT,float32x4:at.FLOAT,uint32:at.UNSIGNED_INT,uint32x2:at.UNSIGNED_INT,uint32x3:at.UNSIGNED_INT,uint32x4:at.UNSIGNED_INT,sint32:at.INT,sint32x2:at.INT,sint32x3:at.INT,sint32x4:at.INT};function ey(r){var t;return(t=ty[r])!=null?t:ty.float32}const eO={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ry{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ih{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new Bt({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,l)=>{s.drawElementsInstancedANGLE(i,n,o,a,l)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const s=this.gl;this._activeGeometry=t;const i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s<t.buffers.length;s++){const i=t.buffers[s];e.updateBuffer(i)}t._gcLastUsed=this._renderer.gc.now}checkCompatibility(t,e){const s=t.attributes,i=e._attributeData;for(const n in i)if(!s[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const s=t.attributes,i=e._attributeData,n=["g",t.uid];for(const o in s)i[o]&&n.push(o,i[o].location);return n.join("-")}getVao(t,e){var s;return((s=t._gpuData[this._renderer.uid])==null?void 0:s.vaoCache[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,s=!0){const i=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e);let a=t._gpuData[this._renderer.uid];a||(a=new ry,t._gpuData[this._renderer.uid]=a,this._managedGeometries.add(t));const l=a.vaoCache;let u=l[o];if(u)return l[e._key]=u,u;sh(t,e._attributeData);const h=t.buffers;u=i.createVertexArray(),i.bindVertexArray(u);for(let c=0;c<h.length;c++){const d=h[c];n.bind(d)}return this.activateVao(t,e),l[e._key]=u,l[o]=u,i.bindVertexArray(null),u}onGeometryUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];if(!s)return;const i=s.vaoCache;if(!e)for(const n in i)this._activeVao!==i[n]&&this.resetState(),this.gl.deleteVertexArray(i[n])}destroyAll(t=!1){this._managedGeometries.removeAll(t)}activateVao(t,e){var s,i;const n=this._renderer.gl,o=this._renderer.buffer,a=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let l=null;for(const u in a){const h=a[u],c=h.buffer,d=o.getGlBuffer(c),p=e._attributeData[u];if(p){l!==d&&(o.bind(c),l=d);const f=p.location;n.enableVertexAttribArray(f);const m=Ce(h.format),g=ey(h.format);if(((s=p.format)==null?void 0:s.substring(1,4))==="int"?n.vertexAttribIPointer(f,m.size,g,h.stride,h.offset):n.vertexAttribPointer(f,m.size,g,m.normalised,h.stride,h.offset),h.instance)if(this.hasInstance){const _=(i=h.divisor)!=null?i:1;n.vertexAttribDivisor(f,_)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,s,i){const{gl:n}=this._renderer,o=this._activeGeometry,a=eO[t||o.topology];if(i!=null||(i=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,u=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;i!==1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,u,(s||0)*l,i):n.drawElements(a,e||o.indexBuffer.data.length,u,(s||0)*l)}else i!==1?n.drawArraysInstanced(a,s||0,e||o.getSize(),i):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ih.extension={type:[S.WebGLSystem],name:"geometry"};var rO=Object.defineProperty,sy=Object.getOwnPropertySymbols,sO=Object.prototype.hasOwnProperty,iO=Object.prototype.propertyIsEnumerable,iy=(r,t,e)=>t in r?rO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ny=(r,t)=>{for(var e in t||(t={}))sO.call(t,e)&&iy(r,e,t[e]);if(sy)for(var e of sy(t))iO.call(t,e)&&iy(r,e,t[e]);return r};const nO=new qe({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),nh=class wT{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=ny(ny({},wT.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(ne("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=jt.for2d();const i=new Ht({vertex:`
                attribute vec2 aPosition;
                out vec2 vUv;

                void main() {
                    gl_Position = vec4(aPosition, 0.0, 1.0);

                    vUv = (aPosition + 1.0) / 2.0;

                    // flip dem UVs
                    vUv.y = 1.0 - vUv.y;
                }`,fragment:`
                in vec2 vUv;
                out vec4 finalColor;

                uniform sampler2D uTexture;

                void main() {
                    finalColor = texture(uTexture, vUv);
                }`,name:"big-triangle"});this._bigTriangleShader=new Jt({glProgram:i,resources:{uTexture:F.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:nO,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new F({source:new ft({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};nh.extension={type:[S.WebGLSystem],name:"backBuffer",priority:1},nh.defaultOptions={useBackBuffer:!1};let oy=nh;class oh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}oh.extension={type:[S.WebGLSystem],name:"colorMask"};class ah{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:s,shader:i,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:h}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,h!=null?h:s.instanceCount)}destroy(){this._renderer=null}}ah.extension={type:[S.WebGLSystem],name:"encoder"};class lh{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=ka(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}lh.extension={type:[S.WebGLSystem],name:"limits"};class ay{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const Oe=[];Oe[Tt.NONE]=void 0,Oe[Tt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Oe[Tt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Oe[Tt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Oe[Tt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Oe[Tt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class uh{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Tt.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Tt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Tt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=Oe[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===Tt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}uh.extension={type:[S.WebGLSystem],name:"stencil"};class hh{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ta())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new zt({data:new Float32Array(e.layout.size/4),usage:ot.UNIFORM|ot.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const i=this.getUniformGroupData(t);t.buffer||(t.buffer=new zt({data:new Float32Array(i.layout.size/4),usage:ot.UNIFORM|ot.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),i.syncFunction(t.uniforms,e,n,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const ch={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function ly(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let s=0,i=0;for(let n=0;n<t.length;n++){const o=t[n];if(s=ch[o.data.type],!s)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(s=Math.max(s,e)*o.data.size);const a=s===12?16:s;o.size=s;const l=i%e;l>0&&e-l<a?i+=(e-l)%16:i+=(s-l%s)%s,o.offset=i,i+=s}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}const ke=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
            var matrix = uv[name].toArray(true);
            data[offset] = matrix[0];
            data[offset + 1] = matrix[1];
            data[offset + 2] = matrix[2];
            data[offset + 4] = matrix[3];
            data[offset + 5] = matrix[4];
            data[offset + 6] = matrix[5];
            data[offset + 8] = matrix[6];
            data[offset + 9] = matrix[7];
            data[offset + 10] = matrix[8];
        `,uniform:`
            gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
        `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
            data[offset + 2] = v.width;
            data[offset + 3] = v.height;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
                cv[0] = v.x;
                cv[1] = v.y;
                cv[2] = v.width;
                cv[3] = v.height;
                gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
            }
        `},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y) {
                cv[0] = v.x;
                cv[1] = v.y;
                gl.uniform2f(ud[name].location, v.x, v.y);
            }
        `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
            data[offset + 3] = v.alpha;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                cv[3] = v.alpha;
                gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
            }
        `},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
            }
        `}];function dh(r,t,e,s){const i=[`
        var v = null;
        var v2 = null;
        var t = 0;
        var index = 0;
        var name = null;
        var arrayOffset = null;
    `];let n=0;for(let a=0;a<r.length;a++){const l=r[a],u=l.data.name;let h=!1,c=0;for(let d=0;d<ke.length;d++)if(ke[d].test(l.data)){c=l.offset/4,i.push(`name = "${u}";`,`offset += ${c-n};`,ke[d][t]||ke[d].ubo),h=!0;break}if(!h)if(l.data.size>1)c=l.offset/4,i.push(e(l,c-n));else{const d=s[l.data.type];c=l.offset/4,i.push(`
                    v = uv.${u};
                    offset += ${c-n};
                    ${d};
                `)}n=c}const o=i.join(`
`);return new Function("uv","data","dataInt32","offset",o)}var oO=Object.defineProperty,aO=Object.defineProperties,lO=Object.getOwnPropertyDescriptors,uy=Object.getOwnPropertySymbols,uO=Object.prototype.hasOwnProperty,hO=Object.prototype.propertyIsEnumerable,hy=(r,t,e)=>t in r?oO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cO=(r,t)=>{for(var e in t||(t={}))uO.call(t,e)&&hy(r,e,t[e]);if(uy)for(var e of uy(t))hO.call(t,e)&&hy(r,e,t[e]);return r},dO=(r,t)=>aO(r,lO(t));function Hr(r,t){return`
        for (let i = 0; i < ${r*t}; i++) {
            data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
        }
    `}const ph={f32:`
        data[offset] = v;`,i32:`
        dataInt32[offset] = v;`,"vec2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];`,"vec3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];`,"vec4<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];`,"vec2<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];
        dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 4] = v[2];
        data[offset + 5] = v[3];`,"mat3x3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 4] = v[3];
        data[offset + 5] = v[4];
        data[offset + 6] = v[5];
        data[offset + 8] = v[6];
        data[offset + 9] = v[7];
        data[offset + 10] = v[8];`,"mat4x4<f32>":`
        for (let i = 0; i < 16; i++) {
            data[offset + i] = v[i];
        }`,"mat3x2<f32>":Hr(3,2),"mat4x2<f32>":Hr(4,2),"mat2x3<f32>":Hr(2,3),"mat4x3<f32>":Hr(4,3),"mat2x4<f32>":Hr(2,4),"mat3x4<f32>":Hr(3,4)},cy=dO(cO({},ph),{"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];
    `});function dy(r,t){const e=Math.max(ch[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
        v = uv.${r.data.name};
        offset += ${t};

        arrayOffset = offset;

        t = 0;

        for(var i=0; i < ${r.data.size*e}; i++)
        {
            for(var j = 0; j < ${s}; j++)
            {
                ${n}[arrayOffset++] = v[t++];
            }
            ${i!==0?`arrayOffset += ${i};`:""}
        }
    `}function py(r){return dh(r,"uboStd40",dy,ph)}class fh extends hh{constructor(){super({createUboElements:ly,generateUboSync:py})}}fh.extension={type:[S.WebGLSystem],name:"ubo"};class fy{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(s,i)=>t.COLOR_ATTACHMENT0+i)}copyToTexture(t,e,s,i,n){const o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(t),u=a.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),e}startRenderPass(t,e=!0,s,i,n=0,o=0){const a=this._renderTargetSystem,l=t.colorTexture,u=a.getGpuRenderTarget(t);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(u.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let h=i.y;t.isRoot&&(h=l.pixelHeight-i.height-i.y),t.colorTextures.forEach(p=>{this._renderer.texture.unbind(p)});const c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,u.framebuffer),!t.isRoot&&(u._attachedMipLevel!==n||u._attachedLayer!==o)&&(t.colorTextures.forEach((p,f)=>{const m=this._renderer.texture.getGlSource(p);if(m.target===c.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+f,c.TEXTURE_2D,m.texture,n)}else if(m.target===c.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");c.framebufferTextureLayer(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+f,m.texture,n,o)}else if(m.target===c.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+f,c.TEXTURE_CUBE_MAP_POSITIVE_X+o,m.texture,n)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),u._attachedMipLevel=n,u._attachedLayer=o),t.colorTextures.length>1&&this._setDrawBuffers(t,c);const d=this._viewPortCache;(d.x!==i.x||d.y!==h||d.width!==i.width||d.height!==i.height)&&(d.x=i.x,d.y=h,d.width=i.width,d.height=i.height,c.viewport(i.x,h,i.width,i.height)),!u.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(u),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,e.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,e.framebuffer),s.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,s=new ay;return s._attachedMipLevel=0,s._attachedLayer=0,t.colorTexture instanceof le?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),s.framebuffer=null,s):(this._initColor(t,s),e.bindFramebuffer(e.FRAMEBUFFER,null),s)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer=null}clear(t,e,s,i,n=0,o=0){if(!e)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const a=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Wt.ALL:Wt.NONE);const l=this._renderer.gl;if(e&Wt.COLOR){s!=null||(s=a.defaultClearColor);const u=this._clearColorCache,h=s;(u[0]!==h[0]||u[1]!==h[1]||u[2]!==h[2]||u[3]!==h[3])&&(u[0]=h[0],u[1]=h[1],u[2]=h[2],u[3]=h[3],l.clearColor(h[0],h[1],h[2],h[3]))}l.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const l=o.source;l.antialias&&(s.context.supports.msaa?e.msaa=!0:ne("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(l,0);const u=s.texture.getGlSource(l),h=u.texture;if(u.target===i.TEXTURE_2D)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,i.TEXTURE_2D,h,0);else if(u.target===i.TEXTURE_2D_ARRAY){if(s.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,h,0,0)}else if(u.target===i.TEXTURE_CUBE_MAP)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,i.TEXTURE_CUBE_MAP_POSITIVE_X,h,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const o=i.createFramebuffer();e.framebuffer=o,i.bindFramebuffer(i.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=i.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(s.width,s.height,s._resolution)}),e.msaa){const i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=a.source;i.texture.bindSource(u,0);const h=i.texture.getGlSource(u).internalFormat,c=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,h,u.pixelWidth,u.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,c)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&le.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&le.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,s=t.colorTexture;s.context2D.drawImage(e,0,s.pixelHeight-e.height)}}_setDrawBuffers(t,e){const s=t.colorTextures.length,i=this._drawBuffersCache[s];if(this._renderer.context.webGLVersion===1){const n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):ne("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(i)}}class mh extends kn{constructor(t){super(t),this.adaptor=new fy,this.adaptor.init(t,this)}}mh.extension={type:[S.WebGLSystem],name:"renderTarget"};class Xn extends Dt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=ct("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ct("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=ct("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function my(r,t){const e=[],s=[`
        var g = s.groups;
        var sS = r.shader;
        var p = s.glProgram;
        var ugS = r.uniformGroup;
        var resources;
    `];let i=!1,n=0;const o=t._getProgramData(r.glProgram);for(const l in r.groups){const u=r.groups[l];e.push(`
            resources = g[${l}].resources;
        `);for(const h in u.resources){const c=u.resources[h];if(c instanceof At)if(c.ubo){const d=r._uniformBindMap[l][Number(h)];e.push(`
                        sS.bindUniformBlock(
                            resources[${h}],
                            '${d}',
                            ${r.glProgram._uniformBlockData[d].index}
                        );
                    `)}else e.push(`
                        ugS.updateUniformGroup(resources[${h}], p, sD);
                    `);else if(c instanceof Xn){const d=r._uniformBindMap[l][Number(h)];e.push(`
                    sS.bindUniformBlock(
                        resources[${h}],
                        '${d}',
                        ${r.glProgram._uniformBlockData[d].index}
                    );
                `)}else if(c instanceof ft){const d=r._uniformBindMap[l][h],p=o.uniformData[d];p&&(i||(i=!0,s.push(`
                        var tS = r.texture;
                        `)),t._gl.uniform1i(p.location,n),e.push(`
                        tS.bind(resources[${h}], ${n});
                    `),n++)}}}const a=[...s,...e].join(`
`);return new Function("r","s","sD",a)}class pO{}class gy{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function gh(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function _h(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function xh(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return _h(2*t);case"bvec3":return _h(3*t);case"bvec4":return _h(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Hn=null;const _y={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},fO={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function vh(r,t){if(!Hn){const e=Object.keys(_y);Hn={};for(let s=0;s<e.length;++s){const i=e[s];Hn[r[i]]=_y[i]}}return Hn[t]}function xy(r,t){const e=vh(r,t);return fO[e]||"float32"}function vy(r,t,e=!1){const s={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<i;o++){const a=t.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const l=xy(t,a.type);s[a.name]={location:0,format:l,stride:Ce(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(s);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)s[n[o]].location=o,t.bindAttribLocation(r,o,n[o]);t.linkProgram(r)}else for(let o=0;o<n.length;o++)s[n[o]].location=t.getAttribLocation(r,n[o]);return s}function by(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},s=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<s;i++){const n=t.getActiveUniformBlockName(r,i),o=t.getUniformBlockIndex(r,n),a=t.getActiveUniformBlockParameter(r,i,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function yy(r,t){const e={},s=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let i=0;i<s;i++){const n=t.getActiveUniform(r,i),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=vh(t,n.type);e[o]={name:o,index:i,type:l,size:n.size,isArray:a,value:xh(l,n.size)}}return e}function Ty(r,t){const e=r.getShaderSource(t).split(`
`).map((u,h)=>`${h}: ${u}`),s=r.getShaderInfoLog(t),i=s.split(`
`),n={},o=i.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!n[u]?(n[u]=!0,!0):!1),a=[""];o.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
`);a[0]=l,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Sy(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Ty(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||Ty(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function wy(r,t){const e=gh(r,r.VERTEX_SHADER,t.vertex),s=gh(r,r.FRAGMENT_SHADER,t.fragment),i=r.createProgram();r.attachShader(i,e),r.attachShader(i,s);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||Sy(r,i,e,s),t._attributeData=vy(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=yy(i,r),t._uniformBlockData=by(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const a in t._uniformData){const l=t._uniformData[a];o[a]={location:r.getUniformLocation(i,a),value:xh(l.type,l.size)}}return new gy(i,o)}const jn={textureCount:0,blockIndex:0};class bh{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;jn.textureCount=0,jn.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),s(this._renderer,t,jn)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,jn)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,l=i.updateBuffer(a),u=i.freeLocationForBufferBase(l);if(o){const{offset:c,size:d}=t;c===0&&d===a.data.byteLength?i.bindBufferBase(l,u):i.bindBufferRange(l,u,c)}else i.getLastBindBaseLocation(l)!==u&&i.bindBufferBase(l,u);const h=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==u&&(n.uniformBlockBindings[s]=u,this._renderer.gl.uniformBlockBinding(n.program,h,u))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=wy(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return my(t,e)}resetState(){this._activeProgram=null}}bh.extension={type:[S.WebGLSystem],name:"shader"};const Ey={f32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1f(location, v);
        }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2f(location, v[0], v[1]);
        }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3f(location, v[0], v[1], v[2]);
        }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4f(location, v[0], v[1], v[2], v[3]);
        }`,i32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,u32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1ui(location, v);
        }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2ui(location, v[0], v[1]);
        }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3ui(location, v[0], v[1], v[2]);
        }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
        }`,bool:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Ay={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function Py(r,t){const e=[`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
        var name = null;
    `];for(const s in r.uniforms){if(!t[s]){r.uniforms[s]instanceof At?r.uniforms[s].ubo?e.push(`
                        renderer.shader.bindUniformBlock(uv.${s}, "${s}");
                    `):e.push(`
                        renderer.shader.updateUniformGroup(uv.${s});
                    `):r.uniforms[s]instanceof Xn&&e.push(`
                        renderer.shader.bindBufferResource(uv.${s}, "${s}");
                    `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o<ke.length;o++){const a=ke[o];if(i.type===a.type&&a.test(i)){e.push(`name = "${s}";`,ke[o].uniform),n=!0;break}}if(!n){const o=(i.size===1?Ey:Ay)[i.type].replace("location",`ud["${s}"].location`);e.push(`
            cu = ud["${s}"];
            cv = cu.value;
            v = uv["${s}"];
            ${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
`))}class yh{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,s){const i=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==i.uniformDirtyGroups[t.uid])&&(i.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(i.uniformData,t.uniforms,this._renderer,s))}_getUniformSyncFunction(t,e){var s;return((s=this._uniformGroupSyncHash[t._signature])==null?void 0:s[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const s=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),i=this._getSignature(t,e._uniformData,"u");return this._cache[i]||(this._cache[i]=this._generateUniformsSync(t,e._uniformData)),s[e._key]=this._cache[i],s[e._key]}_generateUniformsSync(t,e){return Py(t,e)}_getSignature(t,e,s){const i=t.uniforms,n=[`${s}-`];for(const o in i)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}yh.extension={type:[S.WebGLSystem],name:"uniformGroup"};function mO(r){return r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in"),r=`
        out vec4 finalColor;
    ${r}
    `,r}const gO={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function _O(r){return gO[r]}function Cy(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof H.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const xO=0,vO=1,bO=2,yO=3,TO=4,SO=5,Ry=class _c{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[xO]=this.setBlend,this.map[vO]=this.setOffset,this.map[bO]=this.setCullFace,this.map[yO]=this.setDepthTest,this.map[TO]=this.setFrontFace,this.map[SO]=this.setDepthMask,this.checks=[],this.defaultState=jt.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=Cy(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,s=0;for(;e;)e&1&&this.map[s].call(this,!!(t.data&1<<s)),e>>=1,s++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(_c._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(_c._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],s=this.gl;e.length===2?s.blendFunc(e[0],e[1]):s.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,s.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,s.blendEquationSeparate(s.FUNC_ADD,s.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const s=this.checks.indexOf(t);e&&s===-1?this.checks.push(t):!e&&s!==-1&&this.checks.splice(s,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Ry.extension={type:[S.WebGLSystem],name:"state"};let My=Ry;class Th{constructor(t){this.target=Nn.TEXTURE_2D,this._layerInitMask=0,this.texture=t,this.width=-1,this.height=-1,this.type=at.UNSIGNED_BYTE,this.internalFormat=Ln.RGBA,this.format=Ln.RGBA,this.samplerType=0}destroy(){}}const Oy={id:"buffer",upload(r,t,e,s,i,n=!1){const o=i||t.target;!n&&t.width===r.width&&t.height===r.height?e.texSubImage2D(o,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(o,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},wO={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Gy={id:"compressed",upload(r,t,e,s,i,n){const o=i!=null?i:t.target;e.pixelStorei(e.UNPACK_ALIGNMENT,4);let a=r.pixelWidth,l=r.pixelHeight;const u=!!wO[r.format];for(let h=0;h<r.resource.length;h++){const c=r.resource[h];u?e.compressedTexImage2D(o,h,t.internalFormat,a,l,0,c):e.texImage2D(o,h,t.internalFormat,a,l,0,t.format,t.type,c),a=Math.max(a>>1,1),l=Math.max(l>>1,1)}}},Iy=["right","left","top","bottom","front","back"];function By(r){return{id:"cube",upload(t,e,s,i){const n=t.faces;for(let o=0;o<Iy.length;o++){const a=Iy[o],l=n[a];(r[l.uploadMethodId]||r.image).upload(l,e,s,i,Nn.TEXTURE_CUBE_MAP_POSITIVE_X+o,(e._layerInitMask&1<<o)===0),e._layerInitMask|=1<<o}e.width=t.pixelWidth,e.height=t.pixelHeight}}}const Sh={id:"image",upload(r,t,e,s,i,n=!1){const o=i||t.target,a=r.pixelWidth,l=r.pixelHeight,u=r.resourceWidth,h=r.resourceHeight,c=s===2,d=n||t.width!==a||t.height!==l,p=u>=a&&h>=l,f=r.resource;(c?EO:AO)(e,o,t,a,l,u,h,f,d,p),t.width=a,t.height=l}};function EO(r,t,e,s,i,n,o,a,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,n,o,e.format,e.type,a);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,a)}function AO(r,t,e,s,i,n,o,a,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,s,i,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,a);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,a)}const PO=yu(),Fy={id:"video",upload(r,t,e,s,i,n=PO){if(!r.isValid){const o=i!=null?i:t.target;e.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Sh.upload(r,t,e,s,i,n)}},wh={linear:9729,nearest:9728},Dy={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},zn={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Uy={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Eh(r,t,e,s,i,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=zn[o?"clamp-to-edge":r.addressModeU],h=zn[o?"clamp-to-edge":r.addressModeV],c=zn[o?"clamp-to-edge":r.addressModeW];t[i](l,t.TEXTURE_WRAP_S,u),t[i](l,t.TEXTURE_WRAP_T,h),t.TEXTURE_WRAP_R&&t[i](l,t.TEXTURE_WRAP_R,c)}if((!a||r.magFilter!=="linear")&&t[i](l,t.TEXTURE_MAG_FILTER,wh[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const u=Dy[r.minFilter][r.mipmapFilter];t[i](l,t.TEXTURE_MIN_FILTER,u)}}else t[i](l,t.TEXTURE_MIN_FILTER,wh[r.minFilter]);if(s&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](l,s.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[i](l,t.TEXTURE_COMPARE_FUNC,Uy[r.compare])}function ky(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}var CO=Object.defineProperty,RO=Object.defineProperties,MO=Object.getOwnPropertyDescriptors,$y=Object.getOwnPropertySymbols,OO=Object.prototype.hasOwnProperty,GO=Object.prototype.propertyIsEnumerable,Ly=(r,t,e)=>t in r?CO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ar=(r,t)=>{for(var e in t||(t={}))OO.call(t,e)&&Ly(r,e,t[e]);if($y)for(var e of $y(t))GO.call(t,e)&&Ly(r,e,t[e]);return r},IO=(r,t)=>RO(r,MO(t));function Ny(r,t){let e={},s=r.RGBA;return r instanceof H.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},s=r.RGBA8),ar(ar(ar(ar(ar(ar(IO(ar({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:s,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function Xy(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Hy(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}function BO(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e<t;e+=4){const s=r[e+3];if(s!==0){const i=255.001/s;r[e]=r[e]*i+.5,r[e+1]=r[e+1]*i+.5,r[e+2]=r[e+2]*i+.5}}}var FO=Object.defineProperty,DO=Object.defineProperties,UO=Object.getOwnPropertyDescriptors,jy=Object.getOwnPropertySymbols,kO=Object.prototype.hasOwnProperty,$O=Object.prototype.propertyIsEnumerable,zy=(r,t,e)=>t in r?FO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LO=(r,t)=>{for(var e in t||(t={}))kO.call(t,e)&&zy(r,e,t[e]);if(jy)for(var e of jy(t))$O.call(t,e)&&zy(r,e,t[e]);return r},NO=(r,t)=>DO(r,UO(t));const XO=4;class Ah{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new Bt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e={image:Sh,buffer:Oy,video:Fy,compressed:Gy};this._uploads=NO(LO({},e),{cube:By(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Ny(t,this._renderer.context.extensions),this._mapFormatToType=Xy(t),this._mapFormatToFormat=ky(t),this._mapViewDimensionToGlTarget=Hy(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(F.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const s=t.source;t?(this.bindSource(s,e),this._useSeparateSamplers&&this._bindSampler(s.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const s=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=F.EMPTY.source);const i=this.getGlSource(t);s.bindTexture(i.target,i.texture)}}_bindSampler(t,e=0){const s=this._gl;if(!t){this._boundSamplers[e]=null,s.bindSampler(e,null);return}const i=this._getGlSampler(t);this._boundSamplers[e]!==i&&(this._boundSamplers[e]=i,s.bindSampler(e,i))}unbind(t){const e=t.source,s=this._boundTextures,i=this._gl;for(let n=0;n<s.length;n++)if(s[n]===e){this._activateLocation(n);const o=this.getGlSource(e);i.bindTexture(o.target,null),s[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,s=new Th(e.createTexture());if(s.type=this._mapFormatToType[t.format],s.internalFormat=this._mapFormatToInternalFormat[t.format],s.format=this._mapFormatToFormat[t.format],s.target=this._mapViewDimensionToGlTarget[t.viewDimension],s.target===null)throw new Error(`Unsupported view dimension: ${t.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(t.uploadMethodId==="cube"&&(s.target=e.TEXTURE_CUBE_MAP),t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const i=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(i))+1}return t._gpuData[this._renderer.uid]=s,this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),this.updateStyle(t,!1),s}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const s=this._gl,i=this.getGlSource(t);s.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t,Eh(t.style,s,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const s=t._gpuData[this._renderer.uid];s&&(e||(this.unbind(t),this._gl.deleteTexture(s.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,s=this.getGlSource(t);e.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=t;const i=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion);else if(s.target===e.TEXTURE_2D)this._initEmptyTexture2D(s,t);else if(s.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(s,t);else if(s.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(s,t),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(t,e){const s=this._gl;s.texImage2D(s.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let i=Math.max(e.pixelWidth>>1,1),n=Math.max(e.pixelHeight>>1,1);for(let o=1;o<e.mipLevelCount;o++)s.texImage2D(s.TEXTURE_2D,o,t.internalFormat,i,n,0,t.format,t.type,null),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const s=this._gl,i=Math.max(e.arrayLayerCount|0,1);s.texImage3D(s.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,i,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++)s.texImage3D(s.TEXTURE_2D_ARRAY,a,t.internalFormat,n,o,i,0,t.format,t.type,null),n=Math.max(n>>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(t,e){const s=this._gl,i=6;for(let a=0;a<i;a++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++){for(let l=0;l<i;l++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+l,a,t.internalFormat,n,o,0,t.format,t.type,null);n=Math.max(n>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2)return;const s=this._gl,i=Math.max((e.mipLevelCount|0)-1,0);s.texParameteri(t.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(t.target,s.TEXTURE_MAX_LEVEL,i)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,Eh(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:i}=this.getPixels(t),n=H.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,i=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array(XO*i*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),h=a.gl;return h.bindFramebuffer(h.FRAMEBUFFER,u.resolveTargetFramebuffer),h.readPixels(Math.round(s.x*e),Math.round(s.y*e),i,n,h.RGBA,h.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,height:n}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(F.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Ah.extension={type:[S.WebGLSystem],name:"texture"};class Ph{contextChange(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new D,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),s=t.limits.maxBatchableTextures,i=Er({name:"graphics",bits:[Ri,Oi(s),un,Pr]});this.shader=new Jt({glProgram:i,resources:{localUniforms:e,batchSamplers:Gi(s)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);const u=l.instructions;for(let h=0;h<l.instructionSize;h++){const c=u[h];if(c.size){for(let d=0;d<c.textures.count;d++)n.texture.bind(c.textures.textures[d],d);n.geometry.draw(c.topology,c.size,c.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Ph.extension={type:[S.WebGLPipesAdaptor],name:"graphics"};class Ch{init(){const t=Er({name:"mesh",bits:[un,eb,Pr]});this._shader=new Jt({glProgram:t,resources:{uTexture:F.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new D}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(i){if(!i.glProgram)return}else{i=this._shader;const n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=s.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ch.extension={type:[S.WebGLPipesAdaptor],name:"mesh"};const HO=[...Un,fh,oy,Qb,lh,eh,Ah,mh,ih,yh,bh,ah,My,uh,oh],jO=[...Qu],zO=[wu,Ch,Ph],Wy=[],Vy=[],Yy=[];N.handleByNamedList(S.WebGLSystem,Wy),N.handleByNamedList(S.WebGLPipes,Vy),N.handleByNamedList(S.WebGLPipesAdaptor,Yy),N.add(...HO,...jO,...zO);class Ky extends xr{constructor(){const t={name:"webgl",type:Ot.WEBGL,systems:Wy,renderPipes:Vy,renderPipeAdaptors:Yy};super(t)}}var WO={__proto__:null,WebGLRenderer:Ky};class Rh{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){var i;const n=this._gpu.device,o=e.layout[s],a=[],l=this._renderer;for(const c in o){const d=(i=t.resources[c])!=null?i:t.resources[o[c]];let p;if(d._resourceType==="uniformGroup"){const f=d;l.ubo.updateUniformGroup(f);const m=f.buffer;p={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(d._resourceType==="buffer"){const f=d;p={buffer:l.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="bufferResource"){const f=d;p={buffer:l.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(d._resourceType==="textureSampler"){const f=d;p=l.texture.getGpuSampler(f)}else if(d._resourceType==="textureSource"){const f=d;p=l.texture.getTextureView(f)}a.push({binding:o[c],resource:p})}const u=l.shader.getProgramData(e).bindGroups[s],h=n.createBindGroup({layout:u,entries:a});return this._hash[t._key]=h,h}destroy(){this._hash=null,this._renderer=null}}Rh.extension={type:[S.WebGPUSystem],name:"bindGroup"};class qy{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Mh{constructor(t){this._renderer=t,this._managedBuffers=new Bt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(t),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=ct("resource"),t.data&&(Ai(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new qy(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Mh.extension={type:[S.WebGPUSystem],name:"buffer"};class Zy{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;s<t.length;s++)this.data[e/4+s]=t[s];return e}destroy(){this.data=null}}class Oh{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}Oh.extension={type:[S.WebGPUSystem],name:"colorMask"};class Wn{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await H.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:i}}destroy(){this.gpu=null,this._renderer=null}}Wn.extension={type:[S.WebGPUSystem],name:"device"},Wn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var VO=Object.defineProperty,Qy=Object.getOwnPropertySymbols,YO=Object.prototype.hasOwnProperty,KO=Object.prototype.propertyIsEnumerable,Jy=(r,t,e)=>t in r?VO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,t0=(r,t)=>{for(var e in t||(t={}))YO.call(t,e)&&Jy(r,e,t[e]);if(Qy)for(var e of Qy(t))KO.call(t,e)&&Jy(r,e,t[e]);return r};class Gh{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,i){const n=this._renderer.pipeline.getPipeline(t,e,s,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);const i=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t,e){const s=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const i in s)this._setVertexBuffer(parseInt(i,10),t.attributes[s[i]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const i=t.groups[s];e||this._syncBindGroup(i),this.setBindGroup(s,i,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:i,topology:n,size:o,start:a,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,i,n),this.setGeometry(e,s.gpuProgram),this._setShaderBindGroups(s,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,l!=null?l:e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),l!=null?l:e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,s=t0({},this._boundVertexBuffer),i=this._boundIndexBuffer,n=t0({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}Gh.extension={type:[S.WebGPUSystem],name:"encoder",priority:1};class Ih{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Ih.extension={type:[S.WebGPUSystem],name:"limits"};class Bh{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Tt.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Bh.extension={type:[S.WebGPUSystem],name:"stencil"};const Ls={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function e0(r){const t=r.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s<t.length;s++){const i=t[s];let n=Ls[i.data.type].size;const o=Ls[i.data.type].align;if(!Ls[i.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${i.data.type}`);i.data.size>1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function r0(r,t){const{size:e,align:s}=Ls[r.data.type],i=(s-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
         v = uv.${r.data.name};
         ${t!==0?`offset += ${t};`:""}

         arrayOffset = offset;

         t = 0;

         for(var i=0; i < ${r.data.size*(e/4)}; i++)
         {
             for(var j = 0; j < ${e/4}; j++)
             {
                 ${n}[arrayOffset++] = v[t++];
             }
             ${i!==0?`arrayOffset += ${i};`:""}
         }
     `}function s0(r){return dh(r,"uboWgsl",r0,cy)}class Fh extends hh{constructor(){super({createUboElements:e0,generateUboSync:s0})}}Fh.extension={type:[S.WebGPUSystem],name:"ubo"};const $e=128;class Dh{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new Zy({minUniformOffsetAlignment:$e});const e=256/$e;for(let s=0;s<e;s++){let i=ot.UNIFORM|ot.COPY_DST;s===0&&(i|=ot.COPY_SRC),this._buffers.push(new zt({data:this._batchBuffer.data,usage:i}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const s=t.buffer.data,i=this._batchBuffer.addEmptyGroup(s.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,i/4),this._bindGroupHash[t.uid]=this._getBindGroup(i/$e),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,s=this._batchBuffer.addGroup(e);return this._getBufferResource(s/$e)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/$e)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/$e;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Xn({buffer:e,offset:(t/2|0)*256,size:$e})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new be({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const s=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){const n=this._buffers[i];s.copyBufferToBuffer(t.getGPUBuffer(e),$e,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([s.finish()])}destroy(){var t;for(let e=0;e<this._bindGroups.length;e++)(t=this._bindGroups[e])==null||t.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}Dh.extension={type:[S.WebGPUPipes],name:"uniformBatch"};var qO=Object.defineProperty,ZO=Object.defineProperties,QO=Object.getOwnPropertyDescriptors,i0=Object.getOwnPropertySymbols,JO=Object.prototype.hasOwnProperty,t3=Object.prototype.propertyIsEnumerable,n0=(r,t,e)=>t in r?qO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e3=(r,t)=>{for(var e in t||(t={}))JO.call(t,e)&&n0(r,e,t[e]);if(i0)for(var e of i0(t))t3.call(t,e)&&n0(r,e,t[e]);return r},r3=(r,t)=>ZO(r,QO(t));const s3={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function i3(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function n3(r,t,e,s,i){return e<<8|r<<5|s<<3|i<<1|t}class Uh{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(Tt.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Oe[t],this._updatePipeHash())}setPipeline(t,e,s,i){const n=this.getPipeline(t,e,s);i.setPipeline(n)}getPipeline(t,e,s,i){t._layoutKey||(sh(t,e.attributeData),this._generateBufferKey(t)),i||(i=t.topology);const n=i3(t._layoutKey,e._layoutKey,s.data,s._blendModeId,s3[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,i),this._pipeCache[n])}_createPipeline(t,e,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(s,this._colorTargetCount),l=this._stencilMode===Tt.RENDERING_MASK_ADD?0:this._colorMask;for(let c=0;c<a.length;c++)a[c].writeMask=l;const u=this._renderer.shader.getProgramData(e).pipeline,h={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:i,cullMode:s.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(h.depthStencil=r3(e3({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.depthTest?"less":"always"})),n.createRenderPipeline(h)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o<i.length;o++){const a=t.attributes[i[o]];e[s++]=a.offset,e[s++]=a.format,e[s++]=a.stride,e[s++]=a.instance}const n=e.join("|");return t._layoutKey=gr(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let s=0;const i=Object.keys(t.attributeData).sort();for(let o=0;o<i.length;o++){const a=t.attributeData[i[o]];e[s++]=a.location}const n=e.join("|");return t._attributeLocationsKey=gr(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[s])return this._bindingNamesCache[s];const i=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<i.length;a++){const l=Object.values(i[a].attributes)[0].shaderLocation;for(const u in o)if(o[u].location===l){n[a]=u;break}}return this._bindingNamesCache[s]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const s=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[s])return this._bufferLayoutsCache[s];const i=[];return t.buffers.forEach(n=>{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){const h=t.attributes[u];((o=h.divisor)!=null?o:1)!==1&&ne(`Attribute ${u} has an invalid divisor value of '${h.divisor}'. WebGPU only supports a divisor value of 1`),h.buffer===n&&(a.arrayStride=h.stride,a.stepMode=h.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:h.offset,format:h.format}))}l.length&&i.push(a)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){const t=n3(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Uh.extension={type:[S.WebGPUSystem],name:"pipeline"};class o0{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class a0{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:l,origin:n},i),e}startRenderPass(t,e=!0,s,i,n=0,o=0){var a,l;const u=this._renderTargetSystem.getGpuRenderTarget(t);if(o!==0&&(a=u.msaaTextures)!=null&&a.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&(l=u.msaaTextures)!=null&&l.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const h=this.getDescriptor(t,e,s,n,o);u.descriptor=h,this._renderer.pipeline.setRenderTarget(u),this._renderer.encoder.beginRenderPass(u),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s,i=0,n=0){typeof e=="boolean"&&(e=e?Wt.ALL:Wt.NONE);const o=this._renderTargetSystem,a=o.getGpuRenderTarget(t),l=t.colorTextures.map((h,c)=>{const d=a.contexts[c];let p,f;if(d){if(n!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");p=d.getCurrentTexture().createView()}else p=this._renderer.texture.getGpuSource(h).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1});a.msaaTextures[c]&&(f=p,p=this._renderer.texture.getTextureView(a.msaaTextures[c]));const m=e&Wt.COLOR?"clear":"load";return s!=null||(s=o.defaultClearColor),{view:p,resolveTarget:f,clearValue:s,storeOp:"store",loadOp:m}});let u;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=a.msaa?4:1),t.depthStencilTexture){const h=e&Wt.STENCIL?"clear":"load",c=e&Wt.DEPTH?"clear":"load";u={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:h,depthClearValue:1,depthLoadOp:c,depthStoreOp:"store"}}return{colorAttachments:l,depthStencilAttachment:u}}clear(t,e=!0,s,i,n=0,o=0){if(!e)return;const{gpu:a,encoder:l}=this._renderer,u=a.device;if(l.commandEncoder===null){const h=u.createCommandEncoder(),c=this.getDescriptor(t,e,s,n,o),d=h.beginRenderPass(c);d.setViewport(i.x,i.y,i.width,i.height,0,1),d.end();const p=h.finish();u.queue.submit([p])}else this.startRenderPass(t,e,s,i,n,o)}initGpuRenderTarget(t){t.isRoot=!0;const e=new o0;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((s,i)=>{if(s instanceof le){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new ft({width:0,height:0,sampleCount:4,arrayLayerCount:s.source.arrayLayerCount});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,i)=>{const n=e.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class kh extends kn{constructor(t){super(t),this.adaptor=new a0,this.adaptor.init(t,this)}}kh.extension={type:[S.WebGPUSystem],name:"renderTarget"};class $h{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}$h.extension={type:[S.WebGPUSystem],name:"shader"};const Lt={};Lt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Lt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Lt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Lt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Lt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Lt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Lt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Lt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Lt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Lt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Lt.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Lt.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Lh{constructor(){this.defaultState=new jt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const s=Lt[t.blendMode]||Lt.normal,i=[],n={format:"bgra8unorm",writeMask:0,blend:s};for(let o=0;o<e;o++)i[o]=n;return i}destroy(){this.gpu=null}}Lh.extension={type:[S.WebGPUSystem],name:"state"};const l0={type:"image",upload(r,t,e,s=0){const i=r.resource,n=(r.pixelWidth|0)*(r.pixelHeight|0),o=i.byteLength/n;e.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:s}},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*o},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},Nh={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},o3={blockBytes:4,blockWidth:1,blockHeight:1},u0={type:"compressed",upload(r,t,e,s=0){let i=r.pixelWidth,n=r.pixelHeight;const o=Nh[r.format]||o3;for(let a=0;a<r.resource.length;a++){const l=r.resource[a],u=Math.ceil(i/o.blockWidth)*o.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:s}},l,{offset:0,bytesPerRow:u},{width:Math.ceil(i/o.blockWidth)*o.blockWidth,height:Math.ceil(n/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}}},h0=["right","left","top","bottom","front","back"];function c0(r){return{type:"cube",upload(t,e,s){const i=t.faces;for(let n=0;n<h0.length;n++){const o=h0[n],a=i[o];(r[a.uploadMethodId]||r.image).upload(a,e,s,n)}}}}const Xh={type:"image",upload(r,t,e,s=0){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const l=H.get().createCanvas(i.width,i.height);l.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=l}const n=Math.min(t.width,r.resourceWidth||r.pixelWidth),o=Math.min(t.height,r.resourceHeight||r.pixelHeight),a=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,origin:{x:0,y:0,z:s},premultipliedAlpha:a},{width:n,height:o})}},d0={type:"video",upload(r,t,e,s){Xh.upload(r,t,e,s)}};class p0{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
                        var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
                        vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));

                        struct VertexOutput {
                        @builtin(position) position : vec4<f32>,
                        @location(0) texCoord : vec2<f32>,
                        };

                        @vertex
                        fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
                        var output : VertexOutput;
                        output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
                        output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
                        return output;
                        }

                        @group(0) @binding(0) var imgSampler : sampler;
                        @group(0) @binding(1) var img : texture_2d<f32>;

                        @fragment
                        fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
                        return textureSample(img, imgSampler, texCoord);
                        }
                    `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let s=t;const i=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=this.device.createTexture(l)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let l=0;l<i;++l){let u=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),h=n?1:0;for(let c=1;c<t.mipLevelCount;++c){const d=s.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),p=o.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),f=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:u}]});p.setPipeline(e),p.setBindGroup(0,f),p.draw(3,1,0,0),p.end(),u=d}}if(!n){const l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i};for(let u=1;u<t.mipLevelCount;++u)o.copyTextureToTexture({texture:s,mipLevel:u-1},{texture:t,mipLevel:u},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this.device.queue.submit([o.finish()]),n||s.destroy(),t}}var a3=Object.defineProperty,l3=Object.defineProperties,u3=Object.getOwnPropertyDescriptors,f0=Object.getOwnPropertySymbols,h3=Object.prototype.hasOwnProperty,c3=Object.prototype.propertyIsEnumerable,m0=(r,t,e)=>t in r?a3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d3=(r,t)=>{for(var e in t||(t={}))h3.call(t,e)&&m0(r,e,t[e]);if(f0)for(var e of f0(t))c3.call(t,e)&&m0(r,e,t[e]);return r},p3=(r,t)=>l3(r,u3(t));class Hh{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class jh{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new Bt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e={image:Xh,buffer:l0,video:d0,compressed:u0};this._uploads=p3(d3({},e),{cube:c0(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const s=Nh[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},i=Math.ceil(t.pixelWidth/s.blockWidth)*s.blockWidth,n=Math.ceil(t.pixelHeight/s.blockHeight)*s.blockHeight,o={label:t.label,size:{width:i,height:n,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return t._gpuData[this._renderer.uid]=new Hh(a),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),a}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new p0(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],s=e==null?void 0:e.gpuTexture;s?(s.width!==t.pixelWidth||s.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]||this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new be({0:e,1:e.style,2:new At({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let s=e._gpuData[this._renderer.uid];return s||(this.initSource(e),s=e._gpuData[this._renderer.uid]),s.textureView||(s.textureView=s.gpuTexture.createView({dimension:e.viewDimension})),s.textureView}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=H.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:H.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([s.finish()]),i}getPixels(t){const e=this.generateCanvas(t),s=he.getOptimalCanvasAndContext(e.width,e.height),i=s.context;i.drawImage(e,0,0);const{width:n,height:o}=e,a=i.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return he.returnCanvasAndContext(s),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),s=this._bindGroupHash[e];s==null||s.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}jh.extension={type:[S.WebGPUSystem],name:"texture"};class zh{constructor(){this._maxTextures=0}contextChange(t){const e=new At({uTransformMatrix:{value:new D,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const s=wr({name:"graphics",bits:[Ci,Mi(this._maxTextures),Ax,Ar]});this.shader=new Jt({gpuProgram:s,resources:{localUniforms:e}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(s),u=n.encoder;u.setGeometry(a.geometry,i.gpuProgram);const h=n.globalUniforms.bindGroup;u.setBindGroup(0,h,i.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);u.setBindGroup(2,c,i.gpuProgram);const d=l.instructions;let p=null;for(let f=0;f<l.instructionSize;f++){const m=d[f];if(m.topology!==p&&(p=m.topology,u.setPipelineFromGeometryProgramAndState(a.geometry,i.gpuProgram,t.state,m.topology)),i.groups[1]=m.bindGroup,!m.gpuBindGroup){const g=m.textures;m.bindGroup=Ei(g.textures,g.count,this._maxTextures),m.gpuBindGroup=n.bindGroup.getBindGroup(m.bindGroup,i.gpuProgram,1)}u.setBindGroup(1,m.bindGroup,i.gpuProgram),u.renderPassEncoder.drawIndexed(m.size,1,m.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}zh.extension={type:[S.WebGPUPipesAdaptor],name:"graphics"};class Wh{init(){const t=wr({name:"mesh",bits:[$r,tb,Ar]});this._shader=new Jt({gpuProgram:t,resources:{uTexture:F.EMPTY._source,uSampler:F.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new D}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.groups[2]=s.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram)return;const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Wh.extension={type:[S.WebGPUPipesAdaptor],name:"mesh"};const f3=[...Un,Fh,Gh,Wn,Ih,Mh,jh,kh,$h,Lh,Uh,Oh,Bh,Rh],m3=[...Qu,Dh],g3=[Eu,Wh,zh],g0=[],_0=[],x0=[];N.handleByNamedList(S.WebGPUSystem,g0),N.handleByNamedList(S.WebGPUPipes,_0),N.handleByNamedList(S.WebGPUPipesAdaptor,x0),N.add(...f3,...m3,...g3);class v0 extends xr{constructor(){const t={name:"webgpu",type:Ot.WEBGPU,systems:g0,renderPipes:_0,renderPipeAdaptors:x0};super(t)}}var _3={__proto__:null,WebGPURenderer:v0};const x3={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},v3=new Proxy(x3,{get(r,t){return r[t]}});var Vh=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Vh||{});const b3=new Proxy(Vh,{get(r,t){return r[t]}});var Yh=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Yh||{});const y3=new Proxy(Yh,{get(r,t){return r[t]}});var T3=Object.defineProperty,S3=Object.defineProperties,w3=Object.getOwnPropertyDescriptors,Vn=Object.getOwnPropertySymbols,b0=Object.prototype.hasOwnProperty,y0=Object.prototype.propertyIsEnumerable,T0=(r,t,e)=>t in r?T3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E3=(r,t)=>{for(var e in t||(t={}))b0.call(t,e)&&T0(r,e,t[e]);if(Vn)for(var e of Vn(t))y0.call(t,e)&&T0(r,e,t[e]);return r},A3=(r,t)=>S3(r,w3(t)),P3=(r,t)=>{var e={};for(var s in r)b0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Vn)for(var s of Vn(r))t.indexOf(s)<0&&y0.call(r,s)&&(e[s]=r[s]);return e};class Vr extends ft{constructor(t){const e=t,{faces:s}=e,i=P3(e,["faces"]);Vr._validateFaces(s);const n=s.right,o=n.resolution,a=n.format,l=n.alphaMode;super(A3(E3({},i),{resource:s,width:n.width,height:n.height,dimensions:"2d",viewDimension:"cube",arrayLayerCount:6,resolution:o,format:a,alphaMode:l})),this.uploadMethodId="cube",this.faces=s;for(const u of Object.keys(s)){const h=s[u];h.on("update",this._onFaceUpdate,this),h.on("resize",this._onFaceResize,this),h.on("unload",this._onFaceUpdate,this)}}destroy(){const t=this.faces;if(t)for(const e of Object.keys(t)){const s=t[e];s.off("update",this._onFaceUpdate,this),s.off("resize",this._onFaceResize,this),s.off("unload",this._onFaceUpdate,this)}super.destroy()}_onFaceUpdate(){this.emit("update",this)}_onFaceResize(t){Vr._validateFaces(this.faces),this.resize(t.width,t.height,t.resolution)}static _validateFaces(t){if(!t.right||!t.left||!t.top||!t.bottom||!t.front||!t.back)throw new Error("[CubeTextureSource] Requires { left, right, top, bottom, front, back } faces.");const e=t.right,s=e.pixelWidth,i=e.pixelHeight,n=e.format,o=e.alphaMode,a=e.resolution;for(const l of Object.keys(t)){const u=t[l];if(u.pixelWidth!==s||u.pixelHeight!==i)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different size. All faces must match.`);if(u.format!==n)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different format. All faces must match.`);if(u.alphaMode!==o)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different alphaMode. All faces must match.`);if(u.resolution!==a)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different resolution. All faces must match.`)}}}var C3=Object.defineProperty,R3=Object.defineProperties,M3=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,w0=Object.prototype.propertyIsEnumerable,E0=(r,t,e)=>t in r?C3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,A0=(r,t)=>{for(var e in t||(t={}))S0.call(t,e)&&E0(r,e,t[e]);if(Yn)for(var e of Yn(t))w0.call(t,e)&&E0(r,e,t[e]);return r},O3=(r,t)=>R3(r,M3(t)),G3=(r,t)=>{var e={};for(var s in r)S0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Yn)for(var s of Yn(r))t.indexOf(s)<0&&w0.call(r,s)&&(e[s]=r[s]);return e};const Kh=["left","right","top","bottom","front","back"];function I3(r,t){const e=t?A0({},t):{};delete e.label;const s=Object.keys(e).sort(),i=s.length?`|${s.map(n=>`${n}=${String(e[n])}`).join("&")}`:"";return`cube:${Kh.map(n=>r[n]).join(",")}${i}`}class go extends Dt{constructor(t){var e;super(),this.uid=ct("cubeTexture"),this.destroyed=!1;const{label:s,source:i}=t;this.label=s,this.source=i,this.source.label=(e=this.label)!=null?e:this.source.label}static from(t,e=!1){if(t instanceof Vr)return new go({source:t});const s=t,{faces:i}=s,n=G3(s,["faces"]);let o=null;const a=Kh.every(c=>typeof i[c]=="string");if(!e&&a&&(o=I3(i,n),st.has(o)))return st.get(o);const l=c=>c.isTexture?c:F.from(c),u={};for(const c of Kh)u[c]=l(i[c]).source;const h=new go({source:new Vr(O3(A0({},n),{faces:u})),label:n.label});return o&&(st.set(o,h),h.once("destroy",()=>{st.has(o)&&st.remove(o)})),h}destroy(t=!1){this.destroyed||(this.destroyed=!0,t&&this.source.destroy(),this.emit("destroy",this),this.removeAllListeners())}}const qh=Object.create(null),Zh=Object.create(null);function B3(r){var t;if(r.type===Ot.WEBGPU)return Zh[t=r.uid]||(Zh[t]=r.gpu.device.createTexture({label:"ExternalSource placeholder",size:{width:1,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST})),Zh[r.uid];if(!qh[r.uid]){const e=r.gl,s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null),qh[r.uid]=s}return qh[r.uid]}class F3 extends ft{constructor({resource:t,renderer:e,label:s,width:i,height:n}){var o,a;t||(t=B3(e)),i||(i=(o=i!=null?i:t==null?void 0:t.width)!=null?o:1),n||(n=(a=n!=null?n:t==null?void 0:t.height)!=null?a:1),super({resource:t,width:i,height:n,label:s,autoGarbageCollect:!1}),this._renderer=e,this._initGpuData(t)}static test(t){return globalThis.GPUTexture&&t instanceof GPUTexture||globalThis.WebGLTexture&&t instanceof WebGLTexture}_validateTexture(t){const e=this._renderer,s=!!e.gpu,i=globalThis.GPUTexture&&t instanceof GPUTexture,n=globalThis.WebGLTexture&&t instanceof WebGLTexture;if(s&&n)throw new Error("Cannot use WebGLTexture with a WebGPU renderer");if(!s&&i)throw new Error("Cannot use GPUTexture with a WebGL renderer");if(!s){const o=e.gl;if(o&&!o.isTexture(t))throw new Error("WebGLTexture does not belong to this renderer's WebGL context")}}_initGpuData(t){const e=this._renderer;this._validateTexture(t),e.gpu?this._gpuData[e.uid]=new Hh(t):this._gpuData[e.uid]=new Th(t)}updateGPUTexture(t,e,s){const i=this._renderer,n=this._gpuData[i.uid];if(this.resource=t,i.gpu){this._validateTexture(t);const o=n;if(o.gpuTexture!==t){o.gpuTexture=t,o.textureView=null;const u=i.texture;u!=null&&u._bindGroupHash&&(u._bindGroupHash[this.uid]=null)}const a=e!=null?e:t.width,l=s!=null?s:t.height;this.resize(a,l)}else{this._validateTexture(t);const o=n;o.texture=t,e!==void 0&&s!==void 0&&this.resize(e,s)}this.emit("update",this)}destroy(){const t=this._renderer;delete this._gpuData[t.uid],super.destroy()}}class D3{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const i=e.width,n=e.height;if(s){const o=t.width/2/i,a=t.height/2/n,l=t.x/i+o,u=t.y/n+a;s=j.add(s,j.NW),this.x0=l+o*j.uX(s),this.y0=u+a*j.uY(s),s=j.add(s,2),this.x1=l+o*j.uX(s),this.y1=u+a*j.uY(s),s=j.add(s,2),this.x2=l+o*j.uX(s),this.y2=u+a*j.uY(s),s=j.add(s,2),this.x3=l+o*j.uX(s),this.y3=u+a*j.uY(s)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function U3(r){const t=r.toString(),e=t.indexOf("{"),s=t.lastIndexOf("}");if(e===-1||s===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,s).trim()}function k3(r,t){return r.getFastGlobalBounds(!0,t)}var $3=Object.defineProperty,Kn=Object.getOwnPropertySymbols,P0=Object.prototype.hasOwnProperty,C0=Object.prototype.propertyIsEnumerable,R0=(r,t,e)=>t in r?$3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L3=(r,t)=>{for(var e in t||(t={}))P0.call(t,e)&&R0(r,e,t[e]);if(Kn)for(var e of Kn(t))C0.call(t,e)&&R0(r,e,t[e]);return r},N3=(r,t)=>{var e={};for(var s in r)P0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Kn)for(var s of Kn(r))t.indexOf(s)<0&&C0.call(r,s)&&(e[s]=r[s]);return e};class X3 extends xe{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=N3(i,["render"]);super(L3({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:(()=>!1),this.addBounds=(s=t.addBounds)!=null?s:(()=>!1)}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function H3(r,t,e){const s=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,s,null)}function j3(r,t){const e=t._scale,s=t._pivot,i=t._position,n=e._x,o=e._y,a=s._x,l=s._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=i._x-(a*r.a+l*r.c),r.ty=i._y-(a*r.b+l*r.d)}function z3(r,t,e){const s=r.a,i=r.b,n=r.c,o=r.d,a=r.tx,l=r.ty,u=t.a,h=t.b,c=t.c,d=t.d;e.a=s*u+i*c,e.b=s*h+i*d,e.c=n*u+o*c,e.d=n*h+o*d,e.tx=a*u+l*c+t.tx,e.ty=a*h+l*d+t.ty}function W3(r){r instanceof de&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],s=[],i=r.path.shapePath,n=r.textureMatrix;i.shapePrimitives.forEach(({shape:a,transform:l})=>{const u=s.length,h=t.length/2,c=[],d=rr[a.type];d.build(a,c),l&&Bi(c,l),d.triangulate(c,t,2,h,s,u);const p=e.length/2;n?(l&&n.append(l.clone().invert()),Va(t,2,h,e,p,2,t.length/2-h,n)):Ya(e,p,2,t.length/2-h)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(s),o):new Ue({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(s)})}var V3=Object.defineProperty,M0=Object.getOwnPropertySymbols,Y3=Object.prototype.hasOwnProperty,K3=Object.prototype.propertyIsEnumerable,O0=(r,t,e)=>t in r?V3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,G0=(r,t)=>{for(var e in t||(t={}))Y3.call(t,e)&&O0(r,e,t[e]);if(M0)for(var e of M0(t))K3.call(t,e)&&O0(r,e,t[e]);return r};const I0=class ET extends pt{constructor(t={}){t=G0(G0({},ET.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;e<t.length;e++){const s=t[e];if(s.parentRenderLayer){if(s.parentRenderLayer===this)continue;s.parentRenderLayer.detach(s)}this.renderLayerChildren.push(s),s.parentRenderLayer=this;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){const s=t[e],i=this.renderLayerChildren.indexOf(s);i!==-1&&this.renderLayerChildren.splice(i,1),s.parentRenderLayer=null;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0)}return t[0]}detachAll(){const t=this.renderLayerChildren;for(let e=0;e<t.length;e++)t[e].parentRenderLayer=null;this.renderLayerChildren.length=0}collectRenderables(t,e,s){const i=this.renderLayerChildren,n=i.length;this.sortableChildren&&this.sortRenderLayerChildren();for(let o=0;o<n;o++)i[o].parent||ne("Container must be added to both layer and scene graph. Layers only handle render order - the scene graph is required for transforms (addChild)",i[o]),i[o].collectRenderables(t,e,this)}sortRenderLayerChildren(){this.renderLayerChildren.sort(this.sortFunction)}_getGlobalBoundsRecursive(t,e,s){if(!t)return;const i=this.renderLayerChildren;for(let n=0;n<i.length;n++)i[n]._getGlobalBoundsRecursive(!0,e,this)}getFastGlobalBounds(t,e){return super.getFastGlobalBounds(t,e)}addChild(...t){throw new Error("RenderLayer.addChild() is not available. Please use RenderLayer.attach()")}removeChild(...t){throw new Error("RenderLayer.removeChild() is not available. Please use RenderLayer.detach()")}removeChildren(t,e){throw new Error("RenderLayer.removeChildren() is not available. Please use RenderLayer.detach()")}removeChildAt(t){throw new Error("RenderLayer.removeChildAt() is not available")}getChildAt(t){throw new Error("RenderLayer.getChildAt() is not available")}setChildIndex(t,e){throw new Error("RenderLayer.setChildIndex() is not available")}getChildIndex(t){throw new Error("RenderLayer.getChildIndex() is not available")}addChildAt(t,e){throw new Error("RenderLayer.addChildAt() is not available")}swapChildren(t,e){throw new Error("RenderLayer.swapChildren() is not available")}reparentChild(...t){throw new Error("RenderLayer.reparentChild() is not available with the render layer")}reparentChildAt(t,e){throw new Error("RenderLayer.reparentChildAt() is not available with the render layer")}};I0.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex};let q3=I0;var Z3=Object.defineProperty,B0=Object.getOwnPropertySymbols,Q3=Object.prototype.hasOwnProperty,J3=Object.prototype.propertyIsEnumerable,F0=(r,t,e)=>t in r?Z3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,D0=(r,t)=>{for(var e in t||(t={}))Q3.call(t,e)&&F0(r,e,t[e]);if(B0)for(var e of B0(t))J3.call(t,e)&&F0(r,e,t[e]);return r};const U0=class AT extends Ue{constructor(...t){var e;super({});let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={width:s,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(s)}build(t){var e,s,i,n;t=D0(D0({},AT.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(s=this.verticesY)!=null?s:t.verticesY,this.width=(i=this.width)!=null?i:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],l=[],u=[],h=this.verticesX-1,c=this.verticesY-1,d=this.width/h,p=this.height/c;for(let m=0;m<o;m++){const g=m%this.verticesX,_=m/this.verticesX|0;a.push(g*d,_*p),l.push(g/h,_/c)}const f=h*c;for(let m=0;m<f;m++){const g=m%h,_=m/h|0,x=_*this.verticesX+g,v=_*this.verticesX+g+1,b=(_+1)*this.verticesX+g,T=(_+1)*this.verticesX+g+1;u.push(x,v,b,v,T,b)}this.buffers[0].data=new Float32Array(a),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(u),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};U0.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let qn=U0;function k0(r,t,e,s){const i=e.buffers[0],n=i.data,{verticesX:o,verticesY:a}=e,l=r/(o-1),u=t/(a-1);let h=0;const c=s[0],d=s[1],p=s[2],f=s[3],m=s[4],g=s[5],_=s[6],x=s[7],v=s[8];for(let b=0;b<n.length;b+=2){const T=h%o*l,y=(h/o|0)*u,w=c*T+d*y+p,A=f*T+m*y+g,R=_*T+x*y+v;n[b]=w/R,n[b+1]=A/R,h++}i.update()}function $0(r,t){const e=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],l=t[6],u=t[7],h=t[8];return r[0]=o*h-a*u,r[1]=i*u-s*h,r[2]=s*a-i*o,r[3]=a*l-n*h,r[4]=e*h-i*l,r[5]=i*n-e*a,r[6]=n*u-o*l,r[7]=s*l-e*u,r[8]=e*o-s*n,r}function L0(r,t,e){const s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],l=t[5],u=t[6],h=t[7],c=t[8],d=e[0],p=e[1],f=e[2],m=e[3],g=e[4],_=e[5],x=e[6],v=e[7],b=e[8];return r[0]=d*s+p*o+f*u,r[1]=d*i+p*a+f*h,r[2]=d*n+p*l+f*c,r[3]=m*s+g*o+_*u,r[4]=m*i+g*a+_*h,r[5]=m*n+g*l+_*c,r[6]=x*s+v*o+b*u,r[7]=x*i+v*a+b*h,r[8]=x*n+v*l+b*c,r}function tG(r,t,e){const s=e[0],i=e[1],n=e[2];return r[0]=t[0]*s+t[1]*i+t[2]*n,r[1]=t[3]*s+t[4]*i+t[5]*n,r[2]=t[6]*s+t[7]*i+t[8]*n,r}const eG=[0,0,0,0,0,0,0,0,0],rG=[0,0,0],Zn=[0,0,0];function N0(r,t,e,s,i,n,o,a,l){const u=eG;u[0]=t,u[1]=s,u[2]=n,u[3]=e,u[4]=i,u[5]=o,u[6]=1,u[7]=1,u[8]=1;const h=$0(r,u);Zn[0]=a,Zn[1]=l,Zn[2]=1;const c=tG(rG,h,Zn),d=r;return r[0]=c[0],r[1]=0,r[2]=0,r[3]=0,r[4]=c[1],r[5]=0,r[6]=0,r[7]=0,r[8]=c[2],L0(r,d,u)}const sG=[0,0,0,0,0,0,0,0,0],iG=[0,0,0,0,0,0,0,0,0];function X0(r,t,e,s,i,n,o,a,l,u,h,c,d,p,f,m,g){const _=N0(sG,t,e,n,o,u,h,p,f),x=N0(iG,s,i,a,l,c,d,m,g);return L0(r,$0(_,_),x)}class H0 extends qn{constructor(t){super(t),this._projectionMatrix=[0,0,0,0,0,0,0,0,0];const{width:e,height:s}=t;this.corners=[0,0,e,0,e,s,0,s]}setCorners(t,e,s,i,n,o,a,l){const u=this.corners;u[0]=t,u[1]=e,u[2]=s,u[3]=i,u[4]=n,u[5]=o,u[6]=a,u[7]=l,this.updateProjection()}updateProjection(){const{width:t,height:e}=this,s=this.corners,i=X0(this._projectionMatrix,0,0,s[0],s[1],t,0,s[2],s[3],t,e,s[4],s[5],0,e,s[6],s[7]);k0(t,e,this,i)}}var nG=Object.defineProperty,oG=Object.defineProperties,aG=Object.getOwnPropertyDescriptors,Qn=Object.getOwnPropertySymbols,j0=Object.prototype.hasOwnProperty,z0=Object.prototype.propertyIsEnumerable,W0=(r,t,e)=>t in r?nG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qh=(r,t)=>{for(var e in t||(t={}))j0.call(t,e)&&W0(r,e,t[e]);if(Qn)for(var e of Qn(t))z0.call(t,e)&&W0(r,e,t[e]);return r},lG=(r,t)=>oG(r,aG(t)),uG=(r,t)=>{var e={};for(var s in r)j0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Qn)for(var s of Qn(r))t.indexOf(s)<0&&z0.call(r,s)&&(e[s]=r[s]);return e};const V0=class PT extends Ur{constructor(t){t=Qh(Qh({},PT.defaultOptions),t);const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=uG(e,["texture","verticesX","verticesY"]),a=new H0(oe({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(oe(lG(Qh({},o),{geometry:a}))),this._texture=s,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:s}=this.texture;(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,s,i,n,o,a,l){this.geometry.setCorners(t,e,s,i,n,o,a,l)}};V0.defaultOptions={texture:F.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let hG=V0;var cG=Object.defineProperty,dG=Object.defineProperties,pG=Object.getOwnPropertyDescriptors,Jn=Object.getOwnPropertySymbols,Y0=Object.prototype.hasOwnProperty,K0=Object.prototype.propertyIsEnumerable,q0=(r,t,e)=>t in r?cG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fG=(r,t)=>{for(var e in t||(t={}))Y0.call(t,e)&&q0(r,e,t[e]);if(Jn)for(var e of Jn(t))K0.call(t,e)&&q0(r,e,t[e]);return r},mG=(r,t)=>dG(r,pG(t)),gG=(r,t)=>{var e={};for(var s in r)Y0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Jn)for(var s of Jn(r))t.indexOf(s)<0&&K0.call(r,s)&&(e[s]=r[s]);return e};class _G extends Ur{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=gG(e,["texture","verticesX","verticesY"]),a=new qn(oe({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(oe(mG(fG({},o),{geometry:a,texture:s}))),this.texture=s,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:s}=this.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var xG=Object.defineProperty,Z0=Object.getOwnPropertySymbols,vG=Object.prototype.hasOwnProperty,bG=Object.prototype.propertyIsEnumerable,Q0=(r,t,e)=>t in r?xG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,J0=(r,t)=>{for(var e in t||(t={}))vG.call(t,e)&&Q0(r,e,t[e]);if(Z0)for(var e of Z0(t))bG.call(t,e)&&Q0(r,e,t[e]);return r};const t1=class CT extends Ue{constructor(t){const{width:e,points:s,textureScale:i}=J0(J0({},CT.defaultOptions),t);super({positions:new Float32Array(s.length*4),uvs:new Float32Array(s.length*4),indices:new Uint32Array((s.length-1)*6)}),this.points=s,this._width=e,this.textureScale=i,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),s=this.getBuffer("aUV"),i=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),s.data=new Float32Array(t.length*4),i.data=new Uint16Array((t.length-1)*6));const n=s.data,o=i.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];const u=this._width*this.textureScale,h=t.length;for(let d=0;d<h;d++){const p=d*4;if(this.textureScale>0){const f=l.x-t[d].x,m=l.y-t[d].y,g=Math.sqrt(f*f+m*m);l=t[d],a+=g/u}else a=d/(h-1);n[p]=a,n[p+1]=0,n[p+2]=a,n[p+3]=1}let c=0;for(let d=0;d<h-1;d++){const p=d*2;o[c++]=p,o[c++]=p+1,o[c++]=p+2,o[c++]=p+2,o[c++]=p+1,o[c++]=p+3}s.update(),i.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],s,i=0,n=0;const o=this.buffers[0].data,a=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let u=0;u<a;u++){const h=t[u],c=u*4;u<t.length-1?s=t[u+1]:s=h,n=-(s.x-e.x),i=s.y-e.y;let d=(1-u/(a-1))*10;d>1&&(d=1);const p=Math.sqrt(i*i+n*n);p<1e-6?(i=0,n=0):(i/=p,n/=p,i*=l,n*=l),o[c]=h.x+i,o[c+1]=h.y+n,o[c+2]=h.x-i,o[c+3]=h.y-n,e=h}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};t1.defaultOptions={width:200,points:[],textureScale:0};let e1=t1;var yG=Object.defineProperty,TG=Object.defineProperties,SG=Object.getOwnPropertyDescriptors,to=Object.getOwnPropertySymbols,r1=Object.prototype.hasOwnProperty,s1=Object.prototype.propertyIsEnumerable,i1=(r,t,e)=>t in r?yG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jh=(r,t)=>{for(var e in t||(t={}))r1.call(t,e)&&i1(r,e,t[e]);if(to)for(var e of to(t))s1.call(t,e)&&i1(r,e,t[e]);return r},wG=(r,t)=>TG(r,SG(t)),EG=(r,t)=>{var e={};for(var s in r)r1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&to)for(var s of to(r))t.indexOf(s)<0&&s1.call(r,s)&&(e[s]=r[s]);return e};const n1=class RT extends Ur{constructor(t){const e=Jh(Jh({},RT.defaultOptions),t),{texture:s,points:i,textureScale:n}=e,o=EG(e,["texture","points","textureScale"]),a=new e1(oe({width:s.height,points:i,textureScale:n}));n>0&&(s.source.style.addressMode="repeat"),super(oe(wG(Jh({},o),{texture:s,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};n1.defaultOptions={textureScale:0};let AG=n1;var PG=Object.defineProperty,CG=Object.defineProperties,RG=Object.getOwnPropertyDescriptors,eo=Object.getOwnPropertySymbols,o1=Object.prototype.hasOwnProperty,a1=Object.prototype.propertyIsEnumerable,l1=(r,t,e)=>t in r?PG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MG=(r,t)=>{for(var e in t||(t={}))o1.call(t,e)&&l1(r,e,t[e]);if(eo)for(var e of eo(t))a1.call(t,e)&&l1(r,e,t[e]);return r},OG=(r,t)=>CG(r,RG(t)),GG=(r,t)=>{var e={};for(var s in r)o1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&eo)for(var s of eo(r))t.indexOf(s)<0&&a1.call(r,s)&&(e[s]=r[s]);return e};class IG extends Ur{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,l=GG(e,["texture","vertices","uvs","indices","topology"]),u=new Ue(oe({positions:i,uvs:n,indices:o,topology:a}));super(oe(OG(MG({},l),{texture:s,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function BG(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}class u1{execute(t,e){var s,i,n;const o=t.renderer,a=o.canvasContext.activeContext,l=e.particleChildren,u=e.texture;a.save(),o.canvasContext.setContextTransform(e.worldTransform,e.roundPixels),o.canvasContext.setBlendMode(e.groupBlendMode);const h=e.groupColorAlpha,c=(i=(s=o.filter)==null?void 0:s.alphaMultiplier)!=null?i:1,d=(h>>>24&255)/255*c;for(let p=0;p<l.length;p++){const f=l[p],m=f.texture||u;if(!((n=m==null?void 0:m.source)!=null&&n.resource))continue;const g=f.color,_=(g>>>24&255)/255*d;if(_<=0)continue;const x=g&16777215,v=((x&255)<<16)+(x&65280)+(x>>16&255);let b=m.source.resource;v!==16777215&&(b=Q.getTintedCanvas({texture:m},v));const T=m.frame,y=m.source.resolution,w=T.x*y,A=T.y*y,R=T.width*y,C=T.height*y;a.globalAlpha=_;const E=-f.anchorX*T.width,G=-f.anchorY*T.height;f.rotation!==0||f.scaleX!==1||f.scaleY!==1?(a.save(),a.translate(f.x,f.y),a.rotate(f.rotation),a.scale(f.scaleX,f.scaleY),a.drawImage(b,w,A,R,C,E,G,T.width,T.height),a.restore()):a.drawImage(b,w,A,R,C,f.x+E,f.y+G,T.width,T.height)}a.restore()}}function tc(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,i=0;s<e;s+=6,i+=4)t[s+0]=i+0,t[s+1]=i+1,t[s+2]=i+2,t[s+3]=i+0,t[s+4]=i+2,t[s+5]=i+3;return t}function h1(r){return{dynamicUpdate:c1(r,!0),staticUpdate:c1(r,!1)}}function c1(r,t){const e=[];e.push(`

        var index = 0;

        for (let i = 0; i < ps.length; ++i)
        {
            const p = ps[i];

            `);let s=0;for(const n in r){const o=r[n];if(t!==o.dynamic)continue;e.push(`offset = index + ${s}`),e.push(o.code);const a=Ce(o.format);s+=a.stride/4}e.push(`
            index += stride * 4;
        }
    `),e.unshift(`
        var stride = ${s};
    `);const i=e.join(`
`);return new Function("ps","f32v","u32v",i)}class d1{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const s=this._size=(e=t.size)!=null?e:1e3,i=t.properties;let n=0,o=0;for(const c in i){const d=i[c],p=Ce(d.format);d.dynamic?o+=p.stride:n+=p.stride}this._dynamicStride=o/4,this._staticStride=n/4,this.staticAttributeBuffer=new Je(s*4*n),this.dynamicAttributeBuffer=new Je(s*4*o),this.indexBuffer=tc(s);const a=new qe;let l=0,u=0;this._staticBuffer=new zt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:ot.VERTEX|ot.COPY_DST}),this._dynamicBuffer=new zt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:ot.VERTEX|ot.COPY_DST});for(const c in i){const d=i[c],p=Ce(d.format);d.dynamic?(a.addAttribute(d.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:d.format}),l+=p.size):(a.addAttribute(d.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:d.format}),u+=p.size)}a.addIndex(this.indexBuffer);const h=this.getParticleUpdate(i);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=a}getParticleUpdate(t){const e=FG(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return h1(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Je(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Je(this._size*this._dynamicStride*4*4),this.indexBuffer=tc(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const i=this.staticAttributeBuffer;this._staticUpload(t,i.float32View,i.uint32View),this._staticBuffer.setDataWithSize(i.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function FG(r){const t=[];for(const e in r){const s=r[e];t.push(e,s.code,s.dynamic?"d":"s")}return t.join("_")}var p1=`varying vec2 vUV;
varying vec4 vColor;

uniform sampler2D uTexture;

void main(void){
    vec4 color = texture2D(uTexture, vUV) * vColor;
    gl_FragColor = color;
}`,f1=`attribute vec2 aVertex;
attribute vec2 aUV;
attribute vec4 aColor;

attribute vec2 aPosition;
attribute float aRotation;

uniform mat3 uTranslationMatrix;
uniform float uRound;
uniform vec2 uResolution;
uniform vec4 uColor;

varying vec2 vUV;
varying vec4 vColor;

vec2 roundPixels(vec2 position, vec2 targetSize)
{       
    return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}

void main(void){
    float cosRotation = cos(aRotation);
    float sinRotation = sin(aRotation);
    float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
    float y = aVertex.x * sinRotation + aVertex.y * cosRotation;

    vec2 v = vec2(x, y);
    v = v + aPosition;

    gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);

    if(uRound == 1.0)
    {
        gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
    }

    vUV = aUV;
    vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
}
`,ec=`
struct ParticleUniforms {
  uTranslationMatrix:mat3x3<f32>,
  uColor:vec4<f32>,
  uRound:f32,
  uResolution:vec2<f32>,
};

fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
{
  return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}

@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;

@group(1) @binding(0) var uTexture: texture_2d<f32>;
@group(1) @binding(1) var uSampler : sampler;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) color : vec4<f32>,
  };
@vertex
fn mainVertex(
  @location(0) aVertex: vec2<f32>,
  @location(1) aPosition: vec2<f32>,
  @location(2) aUV: vec2<f32>,
  @location(3) aColor: vec4<f32>,
  @location(4) aRotation: f32,
) -> VSOutput {
  
   let v = vec2(
       aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
       aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
   ) + aPosition;

   var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);

   if(uniforms.uRound == 1.0) {
       position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
   }

    let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;

  return VSOutput(
   position,
   aUV,
   vColor,
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) color: vec4<f32>,
  @builtin(position) position: vec4<f32>,
) -> @location(0) vec4<f32> {

    var sample = textureSample(uTexture, uSampler, uv) * color;
   
    return sample;
}`;class m1 extends Jt{constructor(){const t=Ht.from({vertex:f1,fragment:p1}),e=Nt.from({fragment:{source:ec,entryPoint:"mainFragment"},vertex:{source:ec,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:F.WHITE.source,uSampler:new qt({}),uniforms:{uTranslationMatrix:{value:new D,type:"mat3x3<f32>"},uColor:{value:new rt(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Ns{constructor(t,e){this.state=jt.for2d(),this.localUniforms=new At({uTranslationMatrix:{value:new D,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new m1,this.state=jt.for2d(),this._managedContainers=new Bt({renderer:t,type:"renderable",name:"particleContainer"})}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new d1({size:t.particleChildren.length,properties:t._properties}),this._managedContainers.add(t),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const s=this.renderer,i=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;i.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=Tr(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a);const l=s.globalUniforms.globalUniformData;a.tx-=l.offset.x,a.ty-=l.offset.y,a.prepend(l.projectionMatrix),o.uResolution=l.resolution,o.uRound=s._roundPixels|t._roundPixels,Dr(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}Ns.extension={type:[S.CanvasPipes],name:"particle"};class rc extends Ns{constructor(t){super(t,new u1)}}rc.extension={type:[S.CanvasPipes],name:"particle"};class g1{execute(t,e){const s=t.state,i=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=i.gl,a=t.getBuffers(e);i.shader.bind(n),i.state.set(s),i.geometry.bind(a.geometry,n.glProgram);const l=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,l,0)}}class sc extends Ns{constructor(t){super(t,new g1)}}sc.extension={type:[S.WebGLPipes],name:"particle"};class _1{execute(t,e){const s=t.renderer,i=e.shader||t.defaultShader;i.groups[0]=s.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),i.groups[1]=s.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);s.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class ic extends Ns{constructor(t){super(t,new _1)}}ic.extension={type:[S.WebGPUPipes],name:"particle"};var DG=Object.defineProperty,x1=Object.getOwnPropertySymbols,UG=Object.prototype.hasOwnProperty,kG=Object.prototype.propertyIsEnumerable,v1=(r,t,e)=>t in r?DG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b1=(r,t)=>{for(var e in t||(t={}))UG.call(t,e)&&v1(r,e,t[e]);if(x1)for(var e of x1(t))kG.call(t,e)&&v1(r,e,t[e]);return r};const y1=class xc{constructor(t){if(t instanceof F)this.texture=t,oi(this,xc.defaultOptions,{});else{const e=b1(b1({},xc.defaultOptions),t);oi(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return ge(this._tint)}set tint(t){this._tint=rt.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};y1.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let $G=y1;const nc={vertex:{attributeName:"aVertex",format:"float32x2",code:`
            const texture = p.texture;
            const sx = p.scaleX;
            const sy = p.scaleY;
            const ax = p.anchorX;
            const ay = p.anchorY;
            const trim = texture.trim;
            const orig = texture.orig;

            if (trim)
            {
                w1 = trim.x - (ax * orig.width);
                w0 = w1 + trim.width;

                h1 = trim.y - (ay * orig.height);
                h0 = h1 + trim.height;
            }
            else
            {
                w1 = -ax * (orig.width);
                w0 = w1 + orig.width;

                h1 = -ay * (orig.height);
                h0 = h1 + orig.height;
            }

            f32v[offset] = w1 * sx;
            f32v[offset + 1] = h1 * sy;

            f32v[offset + stride] = w0 * sx;
            f32v[offset + stride + 1] = h1 * sy;

            f32v[offset + (stride * 2)] = w0 * sx;
            f32v[offset + (stride * 2) + 1] = h0 * sy;

            f32v[offset + (stride * 3)] = w1 * sx;
            f32v[offset + (stride * 3) + 1] = h0 * sy;
        `,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:`
            var x = p.x;
            var y = p.y;

            f32v[offset] = x;
            f32v[offset + 1] = y;

            f32v[offset + stride] = x;
            f32v[offset + stride + 1] = y;

            f32v[offset + (stride * 2)] = x;
            f32v[offset + (stride * 2) + 1] = y;

            f32v[offset + (stride * 3)] = x;
            f32v[offset + (stride * 3) + 1] = y;
        `,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:`
            var rotation = p.rotation;

            f32v[offset] = rotation;
            f32v[offset + stride] = rotation;
            f32v[offset + (stride * 2)] = rotation;
            f32v[offset + (stride * 3)] = rotation;
        `,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:`
            var uvs = p.texture.uvs;

            f32v[offset] = uvs.x0;
            f32v[offset + 1] = uvs.y0;

            f32v[offset + stride] = uvs.x1;
            f32v[offset + stride + 1] = uvs.y1;

            f32v[offset + (stride * 2)] = uvs.x2;
            f32v[offset + (stride * 2) + 1] = uvs.y2;

            f32v[offset + (stride * 3)] = uvs.x3;
            f32v[offset + (stride * 3) + 1] = uvs.y3;
        `,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:`
            const c = p.color;

            u32v[offset] = c;
            u32v[offset + stride] = c;
            u32v[offset + (stride * 2)] = c;
            u32v[offset + (stride * 3)] = c;
        `,dynamic:!1}};N.add(sc),N.add(ic),N.add(rc);var LG=Object.defineProperty,NG=Object.defineProperties,XG=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,T1=Object.prototype.hasOwnProperty,S1=Object.prototype.propertyIsEnumerable,w1=(r,t,e)=>t in r?LG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jr=(r,t)=>{for(var e in t||(t={}))T1.call(t,e)&&w1(r,e,t[e]);if(ro)for(var e of ro(t))S1.call(t,e)&&w1(r,e,t[e]);return r},E1=(r,t)=>NG(r,XG(t)),HG=(r,t)=>{var e={};for(var s in r)T1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ro)for(var s of ro(r))t.indexOf(s)<0&&S1.call(r,s)&&(e[s]=r[s]);return e};const jG=new Ct(0,0,0,0),A1=class vc extends xe{constructor(t={}){t=E1(jr(jr({},vc.defaultOptions),t),{dynamicProperties:jr(jr({},vc.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:s,shader:i,roundPixels:n,texture:o,particles:a}=e,l=HG(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(jr({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=i,this._properties={};for(const u in nc){const h=nc[u],c=s[u];this._properties[u]=E1(jr({},h),{dynamic:c})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e<t.length;e++)this.particleChildren.push(t[e]);return this.onViewUpdate(),t[0]}removeParticle(...t){let e=!1;for(let s=0;s<t.length;s++){const i=this.particleChildren.indexOf(t[s]);i>-1&&(this.particleChildren.splice(i,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return jG}updateBounds(){}destroy(t=!1){var e,s,i;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const n=typeof t=="boolean"?t:t==null?void 0:t.textureSource,o=(s=this.texture)!=null?s:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(i=this.shader)==null||i.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const s=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),s}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};A1.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let zG=A1;class oc{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,s,i,n,o,a;const l=this._renderer,u=l.canvasContext,h=u.activeContext;h.save();const c=t.groupTransform,d=l._roundPixels|t._roundPixels;u.setContextTransform(c,d===1),u.setBlendMode(t.groupBlendMode);const p=(s=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?s:4294967295,f=t.groupColorAlpha,m=(p>>>24&255)/255,g=(f>>>24&255)/255,_=(n=(i=l.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,x=m*g*_;if(x<=0){h.restore();return}h.globalAlpha=x;const v=p&16777215,b=f&16777215,T=ge(Ae(b,v)),y=t.texture,w=Q.getCanvasSource(y);if(!w){h.restore();return}const A=u.smoothProperty,R=y.source.style.scaleMode!=="nearest";h[A]!==R&&(h[A]=R);const C=T!==16777215||y.rotate!==0,E=C?Q.getTintedCanvas({texture:y},T):w,{leftWidth:G,topHeight:I,rightWidth:M,bottomHeight:B,width:P,height:O}=t,q=G+M,k=I+B,K=Math.min(q>P?P/q:1,k>O?O/k:1,1),X=G*K,W=M*K,U=I*K,L=B*K,$=Math.max(0,P-X-W),Z=Math.max(0,O-U-L),ht=t.anchor,J=(a=(o=y.source._resolution)!=null?o:y.source.resolution)!=null?a:1;let tt=y.frame.x*J,it=y.frame.y*J;const nt=-ht.x*P,et=-ht.y*O,gt=G*J,dt=I*J,z=M*J,Pt=B*J;let wt=y.frame.width*J,te=y.frame.height*J;C&&(tt=0,it=0,wt=E.width,te=E.height),h.drawImage(E,tt,it,gt,dt,nt,et,X,U),h.drawImage(E,tt+gt,it,wt-gt-z,dt,nt+X,et,$,U),h.drawImage(E,tt+wt-z,it,z,dt,nt+P-W,et,W,U),h.drawImage(E,tt,it+dt,gt,te-dt-Pt,nt,et+U,X,Z),h.drawImage(E,tt+gt,it+dt,wt-gt-z,te-dt-Pt,nt+X,et+U,$,Z),h.drawImage(E,tt+wt-z,it+dt,z,te-dt-Pt,nt+P-W,et+U,W,Z),h.drawImage(E,tt,it+te-Pt,gt,Pt,nt,et+O-L,X,L),h.drawImage(E,tt+gt,it+te-Pt,wt-gt-z,Pt,nt+X,et+O-L,$,L),h.drawImage(E,tt+wt-z,it+te-Pt,z,Pt,nt+P-W,et+O-L,W,L),h.restore()}destroy(){this._renderer=null}}oc.extension={type:[S.CanvasPipes],name:"nineSliceSprite"};var WG=Object.defineProperty,P1=Object.getOwnPropertySymbols,VG=Object.prototype.hasOwnProperty,YG=Object.prototype.propertyIsEnumerable,C1=(r,t,e)=>t in r?WG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,R1=(r,t)=>{for(var e in t||(t={}))VG.call(t,e)&&C1(r,e,t[e]);if(P1)for(var e of P1(t))YG.call(t,e)&&C1(r,e,t[e]);return r};const M1=class ao extends qn{constructor(t={}){var e,s;t=R1(R1({},ao.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this._trimX=0,this._trimY=0,this._trimWidth=(e=t.originalWidth)!=null?e:ao.defaultOptions.originalWidth,this._trimHeight=(s=t.originalHeight)!=null?s:ao.defaultOptions.originalHeight,this.update(t)}update(t){var e,s,i,n,o,a,l,u,h,c,d,p,f,m,g,_,x,v;this.width=(e=t.width)!=null?e:this.width,this.height=(s=t.height)!=null?s:this.height,this._originalWidth=(i=t.originalWidth)!=null?i:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(h=t.anchor)==null?void 0:h.x,this._anchorY=(c=t.anchor)==null?void 0:c.y,t.trim!==void 0?(this._trimX=(p=(d=t.trim)==null?void 0:d.x)!=null?p:0,this._trimY=(m=(f=t.trim)==null?void 0:f.y)!=null?m:0,this._trimWidth=(_=(g=t.trim)==null?void 0:g.width)!=null?_:this._originalWidth,this._trimHeight=(v=(x=t.trim)==null?void 0:x.height)!=null?v:this._originalHeight):(this._trimWidth=this._originalWidth,this._trimHeight=this._originalHeight),this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:s,_leftWidth:i,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,h=i+n,c=e>h?1:e/h,d=o+a,p=s>d?1:s/d,f=Math.min(c,p),m=l*e,g=u*s;t[0]=t[8]=t[16]=t[24]=-m,t[2]=t[10]=t[18]=t[26]=i*f-m,t[4]=t[12]=t[20]=t[28]=e-n*f-m,t[6]=t[14]=t[22]=t[30]=e-m,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=o*f-g,t[17]=t[19]=t[21]=t[23]=s-a*f-g,t[25]=t[27]=t[29]=t[31]=s-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs,e=this._originalWidth,s=this._originalHeight,i=this._trimX/e,n=this._trimY/s,o=(this._trimX+this._trimWidth)/e,a=(this._trimY+this._trimHeight)/s;t[0]=t[8]=t[16]=t[24]=i,t[1]=t[3]=t[5]=t[7]=n,t[6]=t[14]=t[22]=t[30]=o,t[25]=t[27]=t[29]=t[31]=a;const l=1/e,u=1/s;t[2]=t[10]=t[18]=t[26]=i+l*this._leftWidth,t[9]=t[11]=t[13]=t[15]=n+u*this._topHeight,t[4]=t[12]=t[20]=t[28]=o-l*this._rightWidth,t[17]=t[19]=t[21]=t[23]=a-u*this._bottomHeight,this.getBuffer("aUV").update()}};M1.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Le=M1;class O1 extends nn{constructor(){super(),this.geometry=new Le}destroy(){this.geometry.destroy()}}class ac{constructor(t){this._renderer=t,this._managedSprites=new Bt({renderer:t,type:"renderable",name:"nineSliceSprite"})}addRenderable(t,e){const s=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new O1,s=e;return s.renderable=t,s.transform=t.groupTransform,s.texture=t._texture,s.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,s),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}ac.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"nineSliceSprite"},N.add(oc),N.add(ac);var KG=Object.defineProperty,so=Object.getOwnPropertySymbols,G1=Object.prototype.hasOwnProperty,I1=Object.prototype.propertyIsEnumerable,B1=(r,t,e)=>t in r?KG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qG=(r,t)=>{for(var e in t||(t={}))G1.call(t,e)&&B1(r,e,t[e]);if(so)for(var e of so(t))I1.call(t,e)&&B1(r,e,t[e]);return r},ZG=(r,t)=>{var e={};for(var s in r)G1.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&so)for(var s of so(r))t.indexOf(s)<0&&I1.call(r,s)&&(e[s]=r[s]);return e};const F1=class MT extends xe{constructor(t){var e,s,i,n,o,a,l,u,h,c;t instanceof F&&(t={texture:t});const d=t,{width:p,height:f,anchor:m,leftWidth:g,rightWidth:_,topHeight:x,bottomHeight:v,texture:b,roundPixels:T}=d,y=ZG(d,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(qG({label:"NineSliceSprite"},y)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(s=g!=null?g:(e=b==null?void 0:b.defaultBorders)==null?void 0:e.left)!=null?s:Le.defaultOptions.leftWidth,this._topHeight=(n=x!=null?x:(i=b==null?void 0:b.defaultBorders)==null?void 0:i.top)!=null?n:Le.defaultOptions.topHeight,this._rightWidth=(a=_!=null?_:(o=b==null?void 0:b.defaultBorders)==null?void 0:o.right)!=null?a:Le.defaultOptions.rightWidth,this._bottomHeight=(u=v!=null?v:(l=b==null?void 0:b.defaultBorders)==null?void 0:l.bottom)!=null?u:Le.defaultOptions.bottomHeight,this._width=(h=p!=null?p:b.width)!=null?h:Le.defaultOptions.width,this._height=(c=f!=null?f:b.height)!=null?c:Le.defaultOptions.height,this.allowChildren=!1,this.texture=b!=null?b:MT.defaultOptions.texture,this.roundPixels=T!=null?T:!1,this._anchor=new xt({_onUpdate:()=>{this.onViewUpdate()}}),m?this.anchor=m:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var s;typeof t=="object"&&(e=(s=t.height)!=null?s:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=F.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}get trim(){var t;return(t=this._texture.trim)!=null?t:null}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}};F1.defaultOptions={texture:F.EMPTY};let D1=F1;class QG extends D1{constructor(...t){let e=t[0];e instanceof F&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}class U1 extends au{constructor(t,e){var s;super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],l=i[a.id];this.pages.push({texture:l})}),Object.keys(n.chars).forEach(o=>{var a;const l=n.chars[o],{frame:u,source:h,rotate:c}=i[l.page],d=j.transformRectCoords(l,u,c,new ut),p=new F({frame:d,orig:new ut(0,0,l.width,l.height),source:h,rotate:c});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(a=l.kerning)!=null?a:{},texture:p}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(s=n.distanceField)!=null?s:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Xr.install(t)}static uninstall(t){Xr.uninstall(t)}}var JG={__proto__:null,BitmapFont:U1};function k1(r){const{text:t,style:e,chars:s}=r,i=e,n=Xr.getFont(t,i),o=yt.graphemeSegmenter(t),a=yn(o,i,n,!0),l=a.scale,u=[],h=[],c=[],d=e.lineHeight?e.lineHeight:n.lineHeight*l;let p=0;for(const f of a.lines){if(f.chars.length===0)continue;const m=new pt({label:"line"});m.y=p,c.push(m);let g=new pt({label:"word"}),_=0;for(let x=0;x<f.chars.length;x++){const v=f.chars[x];if(!v||!n.chars[v])continue;const b=v===" ",T=x===f.chars.length-1;let y;s.length>0?(y=s.shift(),y.text=v,y.style=i,y.label=`char-${v}`,y.x=f.charPositions[x]*l-f.charPositions[_]*l):y=new mu({text:v,style:i,label:`char-${v}`,x:f.charPositions[x]*l-f.charPositions[_]*l}),b||(u.push(y),g.addChild(y)),(b||T)&&g.children.length>0&&(g.x=f.charPositions[_]*l,h.push(g),m.addChild(g),g=new pt({label:"word"}),_=x+1)}p+=d}return{chars:u,lines:c,words:h}}var $1=Object.getOwnPropertySymbols,tI=Object.prototype.hasOwnProperty,eI=Object.prototype.propertyIsEnumerable,rI=(r,t)=>{var e={};for(var s in r)tI.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&$1)for(var s of $1(r))t.indexOf(s)<0&&eI.call(r,s)&&(e[s]=r[s]);return e};class lc extends pt{constructor(t){const e=t,{text:s,style:i,autoSplit:n,lineAnchor:o,wordAnchor:a,charAnchor:l}=e,u=rI(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=s,this._autoSplit=n,this._lineAnchor=o,this._wordAnchor=a,this._charAnchor=l,this.style=i}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,s){let i;typeof t=="number"?i={x:t,y:t}:i={x:t.x,y:t.y},e.forEach(n=>{const o=n.getLocalBounds(),a=o.minX+o.width*i.x,l=o.minY+o.height*i.y;n.origin.set(a,l)}),this[s]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new $t(t),this.styleChanged()}styleChanged(){this.words.forEach(t=>t.destroy()),this.words.length=0,this.lines.forEach(t=>t.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var sI=Object.defineProperty,iI=Object.defineProperties,nI=Object.getOwnPropertyDescriptors,L1=Object.getOwnPropertySymbols,oI=Object.prototype.hasOwnProperty,aI=Object.prototype.propertyIsEnumerable,N1=(r,t,e)=>t in r?sI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xs=(r,t)=>{for(var e in t||(t={}))oI.call(t,e)&&N1(r,e,t[e]);if(L1)for(var e of L1(t))aI.call(t,e)&&N1(r,e,t[e]);return r},lI=(r,t)=>iI(r,nI(t));const X1=class lo extends lc{constructor(t){var e,s,i;const n=Xs(Xs({},lo.defaultOptions),t);(e=n.style)!=null||(n.style={}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n)}static from(t,e){const s=lI(Xs(Xs({},lo.defaultOptions),e),{text:t.text,style:new $t(t.style)});t.style.tagStyles&&(t.style._tagStyles=void 0);const i=new lo(Xs({},s)),n=t.anchor;return(n.x!==0||n.y!==0)&&i.pivot.set(i.width*n.x,i.height*n.y),i}splitFn(){return k1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};X1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let uI=X1;function H1(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;default:return 0}}function uc(r){return r==="\r"||r===`
`||r===`\r
`}const hI=/^\s*$/;function cI(r,t){const e=[];let s=t.lines[0],i="",n=[],o=0;return r.forEach(a=>{const l=hI.test(a),u=uc(a),h=i.length===0&&l;l&&!u&&h||(u||(i+=a),n.push(a),i.length>=s.length&&(e.push({line:i,chars:n}),n=[],i="",o++,s=t.lines[o]))}),e}function j1(r){var t,e;const{text:s,style:i,chars:n}=r,o=i,a=yt.measureText(s,o);if(a.runsByLine&&a.runsByLine.length>0)return dI(a,o,n,s);const l=yt.graphemeSegmenter(s),u=cI(l,a),h=o.align,c=a.lineWidths.reduce((M,B)=>Math.max(M,B),0),d=a.lines.length!==1&&o.wordWrap?o.wordWrapWidth:c,p=(t=o._fill)==null?void 0:t.fill,f=(e=o._stroke)==null?void 0:e.fill,m=p instanceof Ut,g=f instanceof Ut,_=m||g,x=m&&p.textureSpace==="local"||g&&f.textureSpace==="local",v=a.width,b=a.height,T=o.clone();T.align="left";let y=0,w=0;if(T.trim){const{frame:M,canvasAndContext:B}=ce.getCanvasAndContext({text:s,style:o,resolution:1});ce.returnCanvasAndContext(B),y=-M.x,w=-M.y,T.trim=!1}const A=[],R=[],C=[];let E=0,G=0;const I=x?{width:v,height:b}:null;return u.forEach((M,B)=>{const P=new pt({label:`line-${B}`});P.y=E+w,R.push(P);const O=a.lineWidths[B];let q=H1(h,O,d),k=new pt({label:"word"});k.x=q+y;const K=yt._context;K.font=T._fontString,yt.experimentalLetterSpacingSupported&&(K.letterSpacing="0px",K.textLetterSpacing="0px");let X=M.line,W=K.measureText(X).width;if(M.chars.forEach(U=>{if(uc(U))return;X=X.slice(U.length);const L=X.length>0?K.measureText(X).width:0,$=W-L;if(W=L,$!==0)if(U===" ")k.children.length>0&&(C.push(k),P.addChild(k)),q+=$+o.letterSpacing,k=new pt({label:"word"}),k.x=q+y;else{let Z=T;_&&(Z=T.clone(),Z._gradientOffset={x:-q,y:-E},I&&(Z._gradientBounds=I));let ht;G<n.length?(ht=n[G++],ht.text=U,ht.style=Z,ht.setFromMatrix(D.IDENTITY),ht.x=q-k.x+y):ht=new Us({text:U,style:Z,x:q-k.x+y}),A.push(ht),k.addChild(ht),q+=$+o.letterSpacing}}),k.children.length>0&&(C.push(k),P.addChild(k)),h==="justify"&&o.wordWrap&&B<u.length-1){const U=P.children,L=U.length-1;if(L>0){const $=(d-O)/L;for(let Z=1;Z<U.length;Z++)U[Z].x+=Z*$}}E+=a.lineHeight}),{chars:A,lines:R,words:C}}function dI(r,t,e,s){const{runsByLine:i}=r,n=t.align,o=r.lineWidths.reduce((m,g)=>Math.max(m,g),0),a=r.lines.length!==1&&t.wordWrap?t.wordWrapWidth:o;let l=0,u=0;if(t.trim){const{frame:m,canvasAndContext:g}=ce.getCanvasAndContext({text:s,style:t,resolution:1});ce.returnCanvasAndContext(g),l=-m.x,u=-m.y}const h=[],c=[],d=[];let p=0,f=0;return i.forEach((m,g)=>{var _,x,v,b;const T=new pt({label:`line-${g}`});T.y=p+u,c.push(T);const y=r.lineWidths[g];let w=H1(n,y,a),A=new pt({label:"word"});A.x=w+l;for(const C of m){const E=C.style,G=(_=E._fill)==null?void 0:_.fill,I=(x=E._stroke)==null?void 0:x.fill,M=G instanceof Ut,B=I instanceof Ut,P=M||B,O=M&&G.textureSpace==="local"||B&&I.textureSpace==="local",q=yt.graphemeSegmenter(C.text),k=E.clone();k.align="left",k.wordWrap=!1,k.trim&&(k.trim=!1),k.tagStyles=void 0;const K=yt._context;K.font=k._fontString,yt.experimentalLetterSpacingSupported&&(K.letterSpacing="0px",K.textLetterSpacing="0px");let X=C.text,W=K.measureText(X).width;const U=w,L=W,$=yt.measureFont(k._fontString),Z=E.lineHeight||$.fontSize,ht=O?{width:L,height:Z}:null;for(const J of q){X=X.slice(J.length);const tt=X.length>0?K.measureText(X).width:0,it=W-tt;if(W=tt,!uc(J)&&it!==0)if(J===" ")A.children.length>0&&(d.push(A),T.addChild(A)),w+=it+E.letterSpacing,A=new pt({label:"word"}),A.x=w+l;else{let nt=k;P&&(nt=k.clone(),O?(nt._gradientOffset={x:-(w-U),y:0},nt._gradientBounds=ht):nt._gradientOffset={x:-(w-U),y:0});let et;f<e.length?(et=e[f++],et.text=J,et.style=nt,et.setFromMatrix(D.IDENTITY),et.x=w-A.x+l):et=new Us({text:J,style:nt,x:w-A.x+l}),h.push(et),A.addChild(et),w+=it+E.letterSpacing}}}if(A.children.length>0&&(d.push(A),T.addChild(A)),n==="justify"&&t.wordWrap&&g<i.length-1){const C=T.children,E=C.length-1;if(E>0){const G=(a-y)/E;for(let I=1;I<C.length;I++)C[I].x+=I*G}}const R=(b=(v=r.lineHeights)==null?void 0:v[g])!=null?b:r.lineHeight;p+=R}),{chars:h,lines:c,words:d}}var pI=Object.defineProperty,fI=Object.defineProperties,mI=Object.getOwnPropertyDescriptors,z1=Object.getOwnPropertySymbols,gI=Object.prototype.hasOwnProperty,_I=Object.prototype.propertyIsEnumerable,W1=(r,t,e)=>t in r?pI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hs=(r,t)=>{for(var e in t||(t={}))gI.call(t,e)&&W1(r,e,t[e]);if(z1)for(var e of z1(t))_I.call(t,e)&&W1(r,e,t[e]);return r},xI=(r,t)=>fI(r,mI(t));const V1=class uo extends lc{constructor(t){const e=Hs(Hs({},uo.defaultOptions),t);super(e)}static from(t,e){const s=xI(Hs(Hs({},uo.defaultOptions),e),{text:t.text,style:new $t(t.style)}),i=new uo(Hs({},s)),n=t.anchor;return(n.x!==0||n.y!==0)&&i.pivot.set(i.width*n.x,i.height*n.y),i}splitFn(){return j1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};V1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let vI=V1;const Y1=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function bI(r){const t=[];let e=0;for(let s=0;s<Y1.length;s++){const i=`_${Y1[s]}`;t[e++]=r[i]}return e=K1(r._fill,t,e),e=TI(r._stroke,t,e),e=SI(r.dropShadow,t,e),e=yI(r.filters,t,e),t.join("-")}function yI(r,t,e){if(!r)return e;for(const s of r)t[e++]=s.uid;return e}function K1(r,t,e){var s;return r&&(t[e++]=r.color,t[e++]=r.alpha,t[e++]=(s=r.fill)==null?void 0:s.styleKey),e}function TI(r,t,e){return r&&(e=K1(r,t,e),t[e++]=r.width,t[e++]=r.alignment,t[e++]=r.cap,t[e++]=r.join,t[e++]=r.miterLimit),e}function SI(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=rt.shared.setValue(r.color).toNumber()),e}async function wI(r,t,e=200){const s=await t.extract.base64(r);t.type!==Ot.CANVAS&&await t.encoder.commandFinished;const i=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var EI=Object.defineProperty,AI=Object.defineProperties,PI=Object.getOwnPropertyDescriptors,q1=Object.getOwnPropertySymbols,CI=Object.prototype.hasOwnProperty,RI=Object.prototype.propertyIsEnumerable,Z1=(r,t,e)=>t in r?EI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Q1=(r,t)=>{for(var e in t||(t={}))CI.call(t,e)&&Z1(r,e,t[e]);if(q1)for(var e of q1(t))RI.call(t,e)&&Z1(r,e,t[e]);return r},MI=(r,t)=>AI(r,PI(t));const OI=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let GI=0;function J1(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=OI[GI++]);let s="";for(let o=0;o<t;o++)s+="    ";let i=r.label;!i&&r instanceof pe&&(i=`sprite:${r.texture.label}`);let n=`%c ${s}|- ${i} (worldX:${r.worldTransform.tx}, relativeRenderX:${r.relativeGroupTransform.tx}, renderX:${r.groupTransform.tx}, localX:${r.x})`;r.renderGroup&&(n+=" (RenderGroup)"),r.filters&&(n+="(*filters)"),console.log(n,`color:${e.color}; font-weight:bold;`),t++;for(let o=0;o<r.children.length;o++){const a=r.children[o];J1(a,t,Q1({},e))}}function tT(r,t=0,e={index:0,color:"#000000"}){let s="";for(let n=0;n<t;n++)s+="    ";const i=`%c ${s}- ${e.index}: ${r.root.label} worldX:${r.worldTransform.tx}`;console.log(i,`color:${e.color}; font-weight:bold;`),t++;for(let n=0;n<r.renderGroupChildren.length;n++){const o=r.renderGroupChildren[n];tT(o,t,MI(Q1({},e),{index:n}))}}export{au as AbstractBitmapFont,hu as AbstractBitmapTextPipe,xr as AbstractRenderer,lc as AbstractSplitText,pn as AbstractText,iu as AbstractTextSystem,ip as AccessibilitySystem,qP as AlphaFilter,Yo as AlphaMask,An as AlphaMaskPipe,Ws as AnimatedSprite,Mf as Application,Ra as ApplicationInitHook,As as Assets,Vg as AssetsClass,rm as BLEND_TO_NPM,qx as BREAKING_SPACES,Zx as BREAKING_SPACES_SET,tv as BREAK_AFTER_CHARS,ev as BREAK_AFTER_CHARS_SET,$s as BUFFER_TYPE,If as BackgroundLoader,cb as BackgroundSystem,lm as Batch,pm as BatchGeometry,im as BatchTextureArray,Fi as BatchableGraphics,Xv as BatchableHTMLText,nn as BatchableMesh,Ds as BatchableSprite,fv as BatchableText,dm as Batcher,En as BatcherPipe,Et as BigPool,be as BindGroup,Rh as BindGroupSystem,U1 as BitmapFont,Xr as BitmapFontManager,mu as BitmapText,Sv as BitmapTextGraphics,fu as BitmapTextPipe,XP as BlendModeFilter,In as BlendModePipe,U_ as BlurFilter,Qi as BlurFilterPass,Ct as Bounds,pp as BrowserAdapter,zt as Buffer,ii as BufferImageSource,Xn as BufferResource,ot as BufferUsage,Wt as CLEAR,Qx as COLLAPSIBLE_SPACES,Jx as COLLAPSIBLE_SPACES_SET,st as Cache,Jv as CanvasBatchAdaptor,cu as CanvasBitmapTextPipe,Pu as CanvasColorMaskPipe,Ou as CanvasContextSystem,Iu as CanvasFilterSystem,Du as CanvasGraphicsAdaptor,nx as CanvasGraphicsContextSystem,Xl as CanvasGraphicsPipe,Bu as CanvasLimitsSystem,oc as CanvasNineSliceSpritePipe,$o as CanvasObserver,u1 as CanvasParticleContainerAdaptor,rc as CanvasParticleContainerPipe,he as CanvasPool,Hx as CanvasPoolClass,Hb as CanvasRenderTargetAdaptor,Ju as CanvasRenderTargetSystem,Vb as CanvasRenderer,nu as CanvasRendererTextSystem,le as CanvasSource,Ru as CanvasStencilMaskPipe,ce as CanvasTextGenerator,yt as CanvasTextMetrics,su as CanvasTextPipe,ou as CanvasTextSystem,th as CanvasTextureSystem,Vl as CanvasTilingSpritePipe,ho as Circle,rt as Color,Ko as ColorMask,Cu as ColorMaskPipe,fC as ColorMatrixFilter,Ps as CompressedSource,pt as Container,go as CubeTexture,Vr as CubeTextureSource,d_ as Culler,p_ as CullerPlugin,Pn as CustomRenderPipe,Cl as D3D10_RESOURCE_DIMENSION,Vt as D3DFMT,bw as DATA_URI,Y as DDS,Jc as DEG_TO_RAD,Yh as DEPRECATED_SCALE_MODES,Vh as DEPRECATED_WRAP_MODES,H as DOMAdapter,ZS as DOMContainer,Ho as DOMPipe,v3 as DRAW_MODES,Pl as DXGI_FORMAT,Yt as DXGI_TO_TEXTURE_FORMAT,Ii as DefaultBatcher,Wa as DefaultShader,yC as DisplacementFilter,lu as DynamicBitmapFont,co as Ellipse,up as EventBoundary,Dt as EventEmitter,zo as EventSystem,ve as EventsTicker,S as ExtensionType,F3 as ExternalSource,fb as ExtractSystem,Rl as FOURCC_TO_TEXTURE_FORMAT,dp as FederatedContainer,zr as FederatedEvent,es as FederatedMouseEvent,re as FederatedPointerEvent,Ye as FederatedWheelEvent,Ut as FillGradient,Mr as FillPattern,ye as Filter,Zr as FilterEffect,ra as FilterPipe,va as FilterSystem,Sn as FontStylePromiseCache,Bl as GAUSSIAN_VALUES,Bt as GCManagedHash,Sb as GCSystem,Ln as GL_FORMATS,s_ as GL_INTERNAL_FORMAT,Nn as GL_TARGETS,at as GL_TYPES,Jb as GL_WRAP_MODES,Hh as GPUTextureGpuData,ju as GenerateTextureSystem,qe as Geometry,oy as GlBackBufferSystem,wu as GlBatchAdaptor,Yb as GlBuffer,eh as GlBufferSystem,oh as GlColorMaskSystem,Qb as GlContextSystem,ah as GlEncoderSystem,ry as GlGeometryGpuData,ih as GlGeometrySystem,Ph as GlGraphicsAdaptor,lh as GlLimitsSystem,Ch as GlMeshAdaptor,g1 as GlParticleContainerAdaptor,sc as GlParticleContainerPipe,Ht as GlProgram,gy as GlProgramData,ay as GlRenderTarget,fy as GlRenderTargetAdaptor,mh as GlRenderTargetSystem,bh as GlShaderSystem,My as GlStateSystem,uh as GlStencilSystem,Th as GlTexture,Ah as GlTextureSystem,fh as GlUboSystem,yh as GlUniformGroupSystem,Xe as GlobalResourceRegistry,Wu as GlobalUniformSystem,Eu as GpuBatchAdaptor,Lt as GpuBlendModesToPixi,qy as GpuBufferData,Mh as GpuBufferSystem,Oh as GpuColorMaskSystem,Wn as GpuDeviceSystem,Gh as GpuEncoderSystem,zh as GpuGraphicsAdaptor,Km as GpuGraphicsContext,Ih as GpuLimitsSystem,Wh as GpuMeshAdapter,p0 as GpuMipmapGenerator,_1 as GpuParticleContainerAdaptor,ic as GpuParticleContainerPipe,Nt as GpuProgram,o0 as GpuRenderTarget,a0 as GpuRenderTargetAdaptor,kh as GpuRenderTargetSystem,$h as GpuShaderSystem,Lh as GpuStateSystem,Oe as GpuStencilModesToPixi,Bh as GpuStencilSystem,jh as GpuTextureSystem,Fh as GpuUboSystem,Dh as GpuUniformBatchPipe,hr as Graphics,kt as GraphicsContext,qm as GraphicsContextRenderData,ki as GraphicsContextSystem,ox as GraphicsGpuData,de as GraphicsPath,Hl as GraphicsPipe,qv as HTMLText,bu as HTMLTextPipe,xu as HTMLTextRenderData,fo as HTMLTextStyle,Tu as HTMLTextSystem,Fn as HelloSystem,pO as IGLUniformData,Ie as ImageSource,ri as InstructionSet,St as KTX,zf as Loader,Zt as LoaderParserPriority,Qs as MaskEffectManager,nd as MaskEffectManagerClass,rx as MaskFilter,D as Matrix,Ur as Mesh,Ue as MeshGeometry,jl as MeshGpuData,zl as MeshPipe,_G as MeshPlane,AG as MeshRope,IG as MeshSimple,Yx as NEWLINES,Kx as NEWLINES_SET,sv as NEWLINE_MATCH_REGEX,rv as NEWLINE_SPLIT_REGEX,Io as NOOP,Le as NineSliceGeometry,QG as NineSlicePlane,D1 as NineSliceSprite,O1 as NineSliceSpriteGpuData,ac as NineSliceSpritePipe,PC as NoiseFilter,xt as ObservablePoint,Zc as PI_2,$G as Particle,d1 as ParticleBuffer,zG as ParticleContainer,Ns as ParticleContainerPipe,m1 as ParticleShader,hf as PassthroughFilter,hG as PerspectiveMesh,H0 as PerspectivePlaneGeometry,Uh as PipelineSystem,qn as PlaneGeometry,lt as Point,Wr as Polygon,td as Pool,ed as PoolGroupClass,ix as PrepareBase,mv as PrepareQueue,Qv as PrepareSystem,Zv as PrepareUpload,Mx as QuadGeometry,Qc as RAD_TO_DEG,ut as Rectangle,X3 as RenderContainer,ni as RenderGroup,Rn as RenderGroupPipe,$u as RenderGroupSystem,q3 as RenderLayer,Dn as RenderTarget,kn as RenderTargetSystem,mo as RenderTexture,Rb as RenderableGCSystem,Ma as RendererInitHook,Ot as RendererType,Oa as ResizePlugin,Ge as Resolver,e1 as RopeGeometry,po as RoundedRectangle,y3 as SCALE_MODES,Tt as STENCIL_MODES,pg as SVGParser,Vu as SchedulerSystem,VR as ScissorMask,Rv as SdfShader,Jt as Shader,Be as ShaderStage,ig as ShapePath,Qu as SharedRenderPipes,Un as SharedSystems,uI as SplitBitmapText,vI as SplitText,pe as Sprite,Gn as SpritePipe,Wo as Spritesheet,jt as State,qo as StencilMask,Mu as StencilMaskPipe,Aa as SystemRunner,e_ as TEXTURE_FORMAT_BLOCK_SIZE,Us as Text,$t as TextStyle,F as Texture,Mb as TextureGCSystem,Bo as TextureMatrix,_t as TexturePool,Dd as TexturePoolClass,ft as TextureSource,qt as TextureStyle,D3 as TextureUvs,Rt as Ticker,li as TickerListener,Ga as TickerPlugin,$x as TilingSprite,Bx as TilingSpriteGpuData,ql as TilingSpritePipe,Rx as TilingSpriteShader,bx as Transform,bc as Triangle,Ay as UNIFORM_TO_ARRAY_SETTERS,Ey as UNIFORM_TO_SINGLE_SETTERS,Kp as UNIFORM_TYPES_MAP,oa as UNIFORM_TYPES_VALUES,ai as UPDATE_BLEND,ts as UPDATE_COLOR,_e as UPDATE_PRIORITY,DS as UPDATE_TRANSFORM,pr as UPDATE_VISIBLE,Zy as UboBatch,hh as UboSystem,At as UniformGroup,_s as VERSION,mr as VideoSource,xe as ViewContainer,Lb as ViewSystem,Je as ViewableBuffer,Ls as WGSL_ALIGN_SIZE_DATA,ch as WGSL_TO_STD40_SIZE,b3 as WRAP_MODES,Ky as WebGLRenderer,v0 as WebGPURenderer,_l as WorkerManager,np as accessibilityTarget,$a as addBits,pi as addMaskBounds,fi as addMaskLocalBounds,Ip as addProgramDefines,y_ as alphaFrag,Gl as alphaWgsl,pl as appendSVGPath,Gx as applyMatrix,k0 as applyProjectiveTransformationToPlane,Eh as applyStyleParams,oi as assignWithIgnore,Z2 as autoDetectEnvironment,Af as autoDetectRenderer,C2 as autoDetectSource,Vi as basisTranscoderUrls,ge as bgr2rgb,Of as bitmapFontCachePlugin,wi as bitmapFontTextParser,Ia as bitmapFontXMLParser,Ba as bitmapFontXMLStringParser,k1 as bitmapTextSplit,f_ as blendTemplateFrag,m_ as blendTemplateVert,g_ as blendTemplateWgsl,Nh as blockDataMap,R_ as blurTemplateWgsl,me as boundsPool,kP as browserExt,sl as buildAdaptiveBezier,Qm as buildAdaptiveQuadratic,ol as buildArc,Jm as buildArcTo,eg as buildArcToSvg,Cr as buildCircle,Vm as buildContextBatches,Im as buildEllipse,W3 as buildGeometryFromPath,Za as buildLine,Um as buildPixelLine,km as buildPolygon,$m as buildRectangle,Bm as buildRoundedRectangle,Ya as buildSimpleUvs,Lm as buildTriangle,Va as buildUvs,rd as cacheAsTextureMixin,Bf as cacheTextureArray,hg as calculatePathArea,Nb as calculateProjection,Wl as canUseNewCanvasBlendModes,j1 as canvasTextSplit,Q as canvasUtils,Mo as checkChildrenDidChange,Qe as checkDataUrl,ie as checkExtension,lg as checkForNestedPattern,ka as checkMaxIfStatementsInShader,sd as childrenHelperMixin,vb as cleanArray,xb as cleanHash,Bn as clearList,Ka as closePointEps,xn as collapseNewlines,_n as collapseSpaces,H3 as collectAllRenderables,id as collectRenderablesMixin,Dr as color32BitToUniform,Ci as colorBit,Ri as colorBitGl,k_ as colorMatrixFilterFrag,Dl as colorMatrixFilterWgsl,UC as colorToUniform,Uy as compareModeToGlCompare,_m as compileHighShader,xm as compileHighShaderGl,Er as compileHighShaderGlProgram,wr as compileHighShaderGpuProgram,La as compileHooks,Na as compileInputs,gm as compileOutputs,gh as compileShader,X0 as compute2DProjection,AP as convertFormatIfRequired,se as convertToList,ci as copySearchParams,By as createGlUploadCubeTextureResource,c0 as createGpuUploadCubeTextureResource,gr as createIdFromString,tc as createIndicesForQuads,qA as createLevelBuffers,PP as createLevelBuffersFromKTX,gp as createStringVariations,De as createTexture,ly as createUboElementsSTD40,e0 as createUboElementsWGSL,dh as createUboSyncFunction,py as createUboSyncFunctionSTD40,s0 as createUboSyncFunctionWGSL,$g as crossOrigin,qc as cullingMixin,qa as curveEps,ls as defaultFilterVert,xh as defaultValue,oe as definedProps,vs as deprecation,Ff as detectAvif,kA as detectBasis,BP as detectCompressed,Uf as detectDefaults,kf as detectMp4,$f as detectOgv,Qo as detectVideoAlphaMode,Lf as detectWebm,Nf as detectWebp,Ng as determineCrossOrigin,N_ as displacementFrag,X_ as displacementVert,Ul as displacementWgsl,vf as earcut,ud as effectsMixin,sh as ensureAttributes,ga as ensureIsBuffer,Bp as ensurePrecision,fn as ensureTextOptions,Cn as executeInstructions,N as extensions,vy as extractAttributesFromGlProgram,zp as extractAttributesFromGpuProgram,Hv as extractFontFamilies,_i as extractStructAndGroups,ug as extractSubpaths,hl as extractSvgUrlId,Ai as fastCopy,hd as findMixin,Lr as fontStringFromTextStyle,jR as formatShader,Tm as fragmentGPUTemplate,wm as fragmentGlTemplate,dy as generateArraySyncSTD40,r0 as generateArraySyncWGSL,A_ as generateBlurFragSource,C_ as generateBlurGlProgram,M_ as generateBlurProgram,P_ as generateBlurVertSource,XR as generateGPULayout,Wp as generateGpuLayoutGroups,HR as generateLayout,Vp as generateLayoutHash,h1 as generateParticleUpdateFunction,wy as generateProgram,my as generateShaderSyncCode,bI as generateTextStyleKey,Mi as generateTextureBatchBit,Oi as generateTextureBatchBitGl,tl as generateTextureMatrix,Py as generateUniformsSync,Tr as getAdjustedBlendModeBlend,Ce as getAttributeInfoFromFormat,Gi as getBatchSamplersUniformGroup,yn as getBitmapTextLayout,Wx as getCanvasBoundingBox,nr as getCanvasFillStyle,qu as getCanvasTexture,eu as getCharacterGroups,qp as getDefaultUniformValue,k3 as getFastGlobalBounds,dd as getFastGlobalBoundsMixin,ZE as getFillInstructionData,Wv as getFontCss,qf as getFontFamilyName,cf as getGeometryBounds,ey as getGlTypeFromFormat,Qr as getGlobalBounds,md as getGlobalMixin,xa as getGlobalRenderableBounds,ei as getLocalBounds,Gp as getMaxFragmentPrecision,Sg as getMaxMiterRatio,sm as getMaxTexturesPerBatch,Fm as getOrientationOfPoints,dR as getPlainText,bn as getPo2TextureFromSource,Xi as getResolutionOfUrl,Vv as getSVGUrl,Al as getSupportedCompressedTextureFormats,wl as getSupportedGPUCompressedTextureFormats,Sl as getSupportedGlCompressedTextureFormats,Cs as getSupportedTextureFormats,Yv as getTemporaryCanvasFromImage,ia as getTestContext,Ei as getTextureBatchBindGroup,BG as getTextureDefaultMatrix,MP as getTextureFormatFromKTXTexture,by as getUboData,yy as getUniformData,vp as getUrlExtension,h_ as glFormatToGPUFormat,Oy as glUploadBufferImageResource,Gy as glUploadCompressedTextureResource,Sh as glUploadImageResource,Fy as glUploadVideoResource,Em as globalUniformsBit,Am as globalUniformsBitGl,pE as globalUniformsUBOBitGl,QA as gpuFormatToBasisTranscoderFormat,GP as gpuFormatToKTXBasisTranscoderFormat,l0 as gpuUploadBufferImageResource,u0 as gpuUploadCompressedTextureResource,Xh as gpuUploadImageResource,d0 as gpuUploadVideoResource,j as groupD8,NM as hasCachedCanvasTexture,gn as hasTagMarkup,mn as hasTagStyles,BC as hslWgsl,HP as hslgl,jP as hslgpu,Xa as injectBits,Fp as insertVersion,Jl as isBreakAfterChar,Kt as isBreakingSpace,Gu as isCanvasFilterCapable,Ql as isCollapsibleSpace,Zd as isMobile,Fs as isNewline,Oo as isPow2,Xb as isRenderingToScreen,yu as isSafari,is as isSingleItem,ms as isWebGLSupported,gs as isWebGPUSupported,Yi as ktxTranscoderUrls,KA as loadBasis,t_ as loadBasisOnWorker,Gf as loadBitmapFont,nP as loadDDS,ya as loadEnvironmentExtensions,jv as loadFontAsBase64,zv as loadFontCSS,Fg as loadImageBitmap,Wf as loadJson,yP as loadKTX,EP as loadKTX2,l_ as loadKTX2onWorker,Kv as loadSVGImage,Mg as loadSvg,xl as loadTextures,Vf as loadTxt,Xg as loadVideoTextures,Zf as loadWebFont,$r as localUniformBit,un as localUniformBitGl,Ax as localUniformBitGroup2,Ev as localUniformMSDFBit,Av as localUniformMSDFBitGl,dS as log2,wI as logDebugTexture,Sy as logProgramError,tT as logRenderGroupScene,J1 as logScene,Pv as mSDFBit,Cv as mSDFBitGl,sb as mapCanvasBlendModesToPixi,ky as mapFormatToGlFormat,Ny as mapFormatToGlInternalFormat,Xy as mapFormatToGlType,xy as mapGlToVertexFormat,_O as mapSize,vh as mapType,Hy as mapViewDimensionToGlTarget,Cy as mapWebGLBlendModesToPixi,Z_ as maskFrag,Q_ as maskVert,Ll as maskWgsl,It as matrixPool,vu as measureHtmlText,_d as measureMixin,iv as measureTaggedText,mO as migrateFragmentFromV7toV8,Dy as mipmapScaleModeToGlFilter,Jr as multiplyColors,Ae as multiplyHexColors,He as nextPow2,W_ as noiseFrag,kl as noiseWgsl,Zg as nonCompressedFormats,Yr as normalizeExtensionPriority,xd as onRenderMixin,r_ as parseDDS,U3 as parseFunctionBody,i_ as parseKTX,og as parseSVGDefinitions,bt as parseSVGFloatAttribute,Jf as parseSVGPath,dl as parseSVGStyle,Zl as parseTaggedText,nc as particleData,p1 as particlesFrag,f1 as particlesVert,ec as particlesWgsl,uf as passthroughFrag,ma as passthroughWgsl,Xt as path,_a as pointInTriangle,Lg as preloadVideo,Ro as removeItems,Yp as removeStructAndGroupDuplicates,nS as resetUids,bv as resolveCharacters,IP as resolveCompressedTextureUrl,Hg as resolveJsonUrl,Tl as resolveTextureUrl,Rp as resourceToTexture,Ar as roundPixelsBit,Pr as roundPixelsBitGl,rg as roundedShapeArc,sg as roundedShapeQuadraticCurve,Eb as sayHello,wh as scaleModeToGlFilter,VA as setBasisTranscoderPath,SP as setKTXTranscoderPath,Ox as setPositions,Dp as setProgramName,Ix as setUvs,rr as shapeBuilders,vd as sortMixin,Tp as spritesheetAsset,us as squaredDistanceToLineSegment,Up as stripVersion,cl as styleAttributes,Fa as testImageFormat,xs as testVideoFormat,Gv as textStyleToCSS,tb as textureBit,eb as textureBitGl,Mp as textureFrom,Px as tilingBit,Cx as tilingBitGl,Fe as toFillStyle,bd as toLocalGlobalMixin,Es as toStrokeStyle,tu as tokenize,ov as tokenizeTaggedRuns,Bi as transformVertices,Qa as triangulateWithHoles,Se as trimRight,ph as uboSyncFunctionsSTD40,cy as uboSyncFunctionsWGSL,ct as uid,ke as uniformParsers,BO as unpremultiplyAlpha,Ta as unsafeEvalSupported,j3 as updateLocalTransform,Vo as updateQuadBounds,nb as updateRenderGroupTransform,Uu as updateRenderGroupTransforms,vn as updateTextBounds,ku as updateTransformAndChildren,ti as updateTransformBackwards,z3 as updateWorldTransform,Ua as v8_0_0,tE as v8_3_4,Ki as validFormats,ab as validateRenderables,ym as vertexGPUTemplate,Sm as vertexGlTemplate,c_ as vkFormatToGPUFormat,ne as warn,lv as wordWrap,nv as wordWrapTaggedLines,zn as wrapModeToGlAddress};
//# sourceMappingURL=pixi.min.mjs.map
