untitled-rhythm-game/js/libpixi_v891gl.prod.min.js
2025-04-18 21:15:14 +08:00

2238 lines
650 KiB
JavaScript

/*!
* PixiJS - v8.9.1
* Compiled Thu, 27 Mar 2025 12:09:55 UTC
*
* PixiJS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/window.PIXI=function(h){"use strict";var hx=Object.defineProperty,dx=Object.defineProperties,px=Object.getOwnPropertyDescriptors,Lu=Object.getOwnPropertySymbols,fx=Object.prototype.hasOwnProperty,mx=Object.prototype.propertyIsEnumerable,Nu=(r,t,e)=>t in r?hx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hu=(r,t)=>{for(var e in t=t||{})fx.call(t,e)&&Nu(r,e,t[e]);if(Lu)for(var e of Lu(t))mx.call(t,e)&&Nu(r,e,t[e]);return r},r={Application:"application",WebGLPipes:"webgl-pipes",WebGLPipesAdaptor:"webgl-pipes-adaptor",WebGLSystem:"webgl-system",WebGPUPipes:"webgpu-pipes",WebGPUPipesAdaptor:"webgpu-pipes-adaptor",WebGPUSystem:"webgpu-system",CanvasSystem:"canvas-system",CanvasPipesAdaptor:"canvas-pipes-adaptor",CanvasPipes:"canvas-pipes",Asset:"asset",LoadParser:"load-parser",ResolveParser:"resolve-parser",CacheParser:"cache-parser",DetectionParser:"detection-parser",MaskEffect:"mask-effect",BlendMode:"blend-mode",TextureSource:"texture-source",Environment:"environment",ShapeBuilder:"shape-builder",Batcher:"batcher"};const on=r=>{var t;if(("function"==typeof r||"object"==typeof r&&r.extension)&&(t="object"!=typeof r.extension?{type:r.extension}:r.extension,r=((r,t)=>dx(r,px(t)))(Hu({},t),{ref:r})),"object"!=typeof r)throw new Error("Invalid extension type");return"string"==typeof(r=Hu({},r)).type&&(r.type=[r.type]),r},lr=(r,t)=>null!=(r=on(r).priority)?r:t,B={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(on).forEach(t=>{t.type.forEach(e=>{var i;return null==(e=(i=this._removeHandlers)[e])?void 0:e.call(i,t)})}),this},add(...r){return r.map(on).forEach(t=>{t.type.forEach(e=>{var s,n=this._addHandlers,o=this._queue;n[e]?null!=(s=n[e])&&s.call(n,t):(o[e]=o[e]||[],null!=(s=o[e])&&s.push(t))})}),this},handle(r,t,e){var s=this._addHandlers,n=this._removeHandlers;return s[r]=t,n[r]=e,(s=this._queue)[r]&&(null!=(n=s[r])&&n.forEach(a=>t(a)),delete s[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,i=>{0<=t.findIndex(s=>s.name===i.name)||(t.push({name:i.name,value:i.ref}),t.sort((s,n)=>lr(n.value,e)-lr(s.value,e)))},i=>{var s=t.findIndex(n=>n.name===i.name);-1!==s&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>lr(n,e)-lr(s,e)))},i=>{-1!==(i=t.indexOf(i.ref))&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};function an(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Vt(r){return"string"==typeof r?0<r.length:"number"==typeof r}function ot(r,t,e){return void 0===t&&(t=0),void 0===e&&(e=Math.pow(10,t)),Math.round(e*r)/e+0}function Rt(r,t,e){return void 0===t&&(t=0),(e=void 0===e?1:e)<r?e:t<r?r:t}function Xu(r){return 0<(r=isFinite(r)?r%360:0)?r:r+360}function ju(r){return{r:Rt(r.r,0,255),g:Rt(r.g,0,255),b:Rt(r.b,0,255),a:Rt(r.a)}}function un(r){return{r:ot(r.r),g:ot(r.g),b:ot(r.b),a:ot(r.a,3)}}function ni(r){return(r=r.toString(16)).length<2?"0"+r:r}function zu(r){var t=r.r,e=r.g,i=r.b,r=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i);return{h:60*((i=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0)<0?6+i:i),s:n?o/n*100:0,v:n/255*100,a:r}}function Vu(r){var t=r.h,e=r.s,i=r.v,r=r.a,t=t/360*6,n=(e/=100,i/=100,Math.floor(t)),o=i*(1-e),a=i*(1-(t-n)*e);return{r:255*[i,a,o,o,t=i*(1-(1-t+n)*e),i][e=n%6],g:255*[t,i,i,a,o,o][e],b:255*[o,o,t,i,i,a][e],a:r}}function Wu(r){return{h:Xu(r.h),s:Rt(r.s,0,100),l:Rt(r.l,0,100),a:Rt(r.a)}}function Yu(r){return{h:ot(r.h),s:ot(r.s),l:ot(r.l),a:ot(r.a,3)}}function Ku(r){return Vu((e=r.s,{h:r.h,s:0<(e*=((i=r.l)<50?i:100-i)/100)?2*e/(i+e)*100:0,v:i+e,a:r.a}));var e,i}function ur(r){return{h:(r=zu(r)).h,s:0<(s=(200-(e=r.s))*(i=r.v)/100)&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:r.a};var e,i,s}function hn(r,t){return{h:(r=ur(r)).h,s:Rt(r.s+100*t,0,100),l:r.l,a:r.a}}function dn(r){return(299*r.r+587*r.g+114*r.b)/1e3/255}function Qu(r,t){return{h:(r=ur(r)).h,s:r.s,l:Rt(r.l+100*t,0,100),a:r.a}}function qu(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]}!function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}function s(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function n(l,u,c,d,p){if("function"!=typeof c)throw new TypeError("The listener must be a function");return c=new s(c,d||l,p),d=e?e+u:u,l._events[d]?l._events[d].fn?l._events[d]=[l._events[d],c]:l._events[d].push(c):(l._events[d]=c,l._eventsCount++),l}function o(l,u){0==--l._eventsCount?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(e=!1)),a.prototype.eventNames=function(){var c,d,u=[];if(0===this._eventsCount)return u;for(d in c=this._events)t.call(c,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var u=e?e+u:u,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var p=0,f=d.length,m=new Array(f);p<f;p++)m[p]=d[p].fn;return m},a.prototype.listenerCount=function(u){return u=e?e+u:u,(u=this._events[u])?u.fn?1:u.length:0},a.prototype.emit=function(u,c,d,p,f,m){var _=e?e+u:u;if(!this._events[_])return!1;var x,g=this._events[_],b=arguments.length;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),b){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,d),!0;case 4:return g.fn.call(g.context,c,d,p),!0;case 5:return g.fn.call(g.context,c,d,p,f),!0;case 6:return g.fn.call(g.context,c,d,p,f,m),!0}for(y=1,x=new Array(b-1);y<b;y++)x[y-1]=arguments[y];g.fn.apply(g.context,x)}else for(var A,T=g.length,y=0;y<T;y++)switch(g[y].once&&this.removeListener(u,g[y].fn,void 0,!0),b){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,d);break;case 4:g[y].fn.call(g[y].context,c,d,p);break;default:if(!x)for(A=1,x=new Array(b-1);A<b;A++)x[A-1]=arguments[A];g[y].fn.apply(g[y].context,x)}return!0},a.prototype.on=function(u,c,d){return n(this,u,c,d,!1)},a.prototype.once=function(u,c,d){return n(this,u,c,d,!0)},a.prototype.removeListener=function(u,c,d,p){if(u=e?e+u:u,this._events[u])if(c){var m=this._events[u];if(m.fn)m.fn!==c||p&&!m.once||d&&m.context!==d||o(this,u);else{for(var _=0,g=[],b=m.length;_<b;_++)(m[_].fn!==c||p&&!m[_].once||d&&m[_].context!==d)&&g.push(m[_]);g.length?this._events[u]=1===g.length?g[0]:g:o(this,u)}}else o(this,u);return this},a.prototype.removeAllListeners=function(u){return u?(u=e?e+u:u,this._events[u]&&o(this,u)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,r.exports=a.EventEmitter=a}(ln={exports:{}});var ft=an(ln.exports),bx={grad:.9,turn:360,rad:360/(2*Math.PI)},vx=/^#([0-9a-f]{3,8})$/i,yx=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xx=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Tx=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sx=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cn={string:[[function(r){var t=vx.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:4===r.length?ot(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?ot(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){return(r=Tx.exec(r)||Sx.exec(r))&&r[2]===r[4]&&r[4]===r[6]?ju({r:Number(r[1])/(r[2]?100/255:1),g:Number(r[3])/(r[4]?100/255:1),b:Number(r[5])/(r[6]?100/255:1),a:void 0===r[7]?1:Number(r[7])/(r[8]?100:1)}):null},"rgb"],[function(r){var i,e;return(r=yx.exec(r)||xx.exec(r))?Ku(Wu({h:(e=r[1],void 0===(i=r[2])&&(i="deg"),Number(e)*(bx[i]||1)),s:Number(r[3]),l:Number(r[4]),a:void 0===r[5]?1:Number(r[5])/(r[6]?100:1)})):null},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,r=void 0===(r=r.a)?1:r;return Vt(t)&&Vt(e)&&Vt(i)?ju({r:Number(t),g:Number(e),b:Number(i),a:Number(r)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,r=void 0===(r=r.a)?1:r;return Vt(t)&&Vt(e)&&Vt(i)?Ku(Wu({h:Number(t),s:Number(e),l:Number(i),a:Number(r)})):null},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,r=void 0===(r=r.a)?1:r;return Vt(t)&&Vt(e)&&Vt(i)?Vu({h:Xu((t={h:Number(t),s:Number(e),v:Number(i),a:Number(r)}).h),s:Rt(t.s,0,100),v:Rt(t.v,0,100),a:Rt(t.a)}):null},"hsv"]]},oi=function(){function r(t){this.parsed=("string"==typeof t?qu(t.trim(),cn.string):"object"==typeof t&&null!==t?qu(t,cn.object):[null,void 0])[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return ot(dn(this.rgba),2)},r.prototype.isDark=function(){return dn(this.rgba)<.5},r.prototype.isLight=function(){return.5<=dn(this.rgba)},r.prototype.toHex=function(){return e=(t=un(this.rgba)).r,i=t.g,s=t.b,t=(t=t.a)<1?ni(ot(255*t)):"","#"+ni(e)+ni(i)+ni(s)+t;var e,i,s,t},r.prototype.toRgb=function(){return un(this.rgba)},r.prototype.toRgbString=function(){return e=(t=un(this.rgba)).r,i=t.g,s=t.b,(t=t.a)<1?"rgba("+e+", "+i+", "+s+", "+t+")":"rgb("+e+", "+i+", "+s+")";var e,i,s,t},r.prototype.toHsl=function(){return Yu(ur(this.rgba))},r.prototype.toHslString=function(){return e=(t=Yu(ur(this.rgba))).h,i=t.s,s=t.l,(t=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+t+")":"hsl("+e+", "+i+"%, "+s+"%)";var e,i,s,t},r.prototype.toHsv=function(){return{h:ot((t=zu(this.rgba)).h),s:ot(t.s),v:ot(t.v),a:ot(t.a,3)};var t},r.prototype.invert=function(){return kt({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 kt(hn(this.rgba,t=void 0===t?.1:t))},r.prototype.desaturate=function(t){return kt(hn(this.rgba,-(t=void 0===t?.1:t)))},r.prototype.grayscale=function(){return kt(hn(this.rgba,-1))},r.prototype.lighten=function(t){return kt(Qu(this.rgba,t=void 0===t?.1:t))},r.prototype.darken=function(t){return kt(Qu(this.rgba,-(t=void 0===t?.1:t)))},r.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return"number"==typeof t?kt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ot(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=ur(this.rgba);return"number"==typeof t?kt({h:t,s:e.s,l:e.l,a:e.a}):ot(e.h)},r.prototype.isEqual=function(t){return this.toHex()===kt(t).toHex()},r}(),kt=function(r){return r instanceof oi?r:new oi(r)},Ju=[],Px=Object.defineProperty,tc=Object.getOwnPropertySymbols,wx=Object.prototype.hasOwnProperty,Rx=Object.prototype.propertyIsEnumerable,ec=(r,t,e)=>t in r?Px(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;(function(r){r.forEach(function(t){Ju.indexOf(t)<0&&(t(oi,cn),Ju.push(t))})})([function(r,t){var s,e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var u=i[this.toHex()];if(u)return u;if(null!=o&&o.closest){var m,c=this.toRgb(),d=1/0,p="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(m in e){var a=c,l=n[m];(a=Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2))<d&&(d=a,p=m)}return p}},t.string.push([function(o){return(o="transparent"===(o=o.toLowerCase())?"#0000":e[o])?new r(o).toRgb():null},"name"])}]),(ln=class ii{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 ii)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(null===t)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,t)||(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?((r,t)=>{for(var e in t=t||{})wx.call(t,e)&&ec(r,e,t[e]);if(tc)for(var e of tc(t))Rx.call(t,e)&&ec(r,e,t[e]);return r})({},t):t}_isSourceEqual(t,e){var n,i=typeof t;return i==typeof e&&("number"==i||"string"==i||t instanceof Number?t===e:Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)?t.length===e.length&&t.every((s,n)=>s===e[n]):null!==t&&null!==e?(i=Object.keys(t),n=Object.keys(e),i.length===n.length&&i.every(o=>t[o]===e[o])):t===e)}toRgba(){var[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){var[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){var[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){var[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),(t=t||this._arrayRgb)[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*s),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;var[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;var[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){var[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){var t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(t){var[t,i,s,n]=ii._temp.setValue(t)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=s,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(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=255&this._int;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(255*t<<24)+(i<<16)+(s<<8)+n}toHex(){var t=this._int.toString(16);return"#"+("000000".substring(0,6-t.length)+t)}toHexa(){var t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,s,n;var a;if(("number"==typeof t||t instanceof Number)&&0<=t&&t<=16777215?(e=(t>>16&255)/255,i=(t>>8&255)/255,s=(255&t)/255,n=1):(Array.isArray(t)||t instanceof Float32Array)&&3<=t.length&&t.length<=4?(t=this._clamp(t),[e,i,s,n=1]=t):(t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&3<=t.length&&t.length<=4?(t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255):"string"!=typeof t&&"object"!=typeof t||("string"==typeof t&&(a=ii.HEX_PATTERN.exec(t))&&(t="#"+a[2]),(a=kt(t)).isValid()&&({r:e,g:i,b:s,a:n}=a.rgba,e/=255,i/=255,s/=255)),void 0===e)throw new Error("Unable to convert color "+t);this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt()}_refreshInt(){this._clamp(this._components);var[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return"number"==typeof t||"string"==typeof t||t instanceof Number||t instanceof ii||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||void 0!==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}}).shared=new ln,ln._temp=new ln,ln.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let X=ln;const rc={cullArea:null,cullable:!1,cullableChildren:!0},ic=2*Math.PI,sc=180/Math.PI,nc=Math.PI/180;class V{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new V(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 pn.x=0,pn.y=0,pn}}const pn=new V;class M{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,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,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){return this.array||(this.array=new Float32Array(9)),e=e||this.array,t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0),e[8]=1,e}apply(t,e){e=e||new V;var i=t.x,t=t.y;return e.x=this.a*i+this.c*t+this.tx,e.y=this.b*i+this.d*t+this.ty,e}applyInverse(t,e){e=e||new V;var i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(i*o+n*-s),c=t.x,t=t.y;return e.x=o*u*c+-n*u*t+(l*n-a*o)*u,e.y=i*u*t+-s*u*c+(-l*i+a*s)*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){var e=Math.cos(t),t=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*t,this.b=s*t+this.b*e,this.c=n*e-this.d*t,this.d=n*t+this.d*e,this.tx=o*e-this.ty*t,this.ty=o*t+this.ty*e,this}append(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){var i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,t=t.ty,u=e.a,c=e.b,d=e.c,p=e.d;return this.a=i*u+s*d,this.b=i*c+s*p,this.c=n*u+o*d,this.d=n*c+o*p,this.tx=a*u+t*d+e.tx,this.ty=a*c+t*p+e.ty,this}setTransform(t,e,i,s,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-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){var i,s,e=this.tx;return 1===t.a&&0===t.b&&0===t.c&&1===t.d||(i=this.a,s=this.c,this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d),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){var e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),u=Math.abs(a+l);return u<1e-5||Math.abs(ic-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+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){var t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){var t=new M;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 Ox.identity()}static get shared(){return Cx.identity()}}const Cx=new M,Ox=new M;class rt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new rt(null!=t?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 cr={default:-1};function K(r="default"){return void 0===cr[r]&&(cr[r]=-1),++cr[r]}class ai{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,i;return null!=(e=(i=0<this._index?this._pool[--this._index]:new this._classType).init)&&e.call(i,t),i}return(t){var e;null!=(e=t.reset)&&e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class oc{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 ai(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{var i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const N=new oc,ac={get isCachedAsTexture(){var r;return!(null==(r=this.renderGroup)||!r.isCachedAsTexture)},cacheAsTexture(r){"boolean"==typeof r&&!1===r?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===r?{}:r))},updateCacheTexture(){var r;null!=(r=this.renderGroup)&&r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function fn(r,t,e){var i=r.length;let s;if(!(i<=t||0===e)){var n=i-(e=i<t+e?i-t:e);for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}}var ln={allowChildren:!0,removeChildren(r=0,t){var i=(t=null!=t?t:this.children.length)-r,s=[];if(0<i&&i<=t){for(let o=t-1;o>=r;o--){var a=this.children[o];a&&(s.push(a),a.parent=null)}fn(this.children,r,t),(t=this.renderGroup||this.parentRenderGroup)&&t.removeChildren(s);for(let o=0;o<s.length;++o)this.emit("childRemoved",s[o],this,o),s[o].emit("removed",this);return 0<s.length&&this._didViewChangeTick++,s}if(0==i&&0===this.children.length)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){return r=this.getChildAt(r),this.removeChild(r)},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){if(-1===(r=this.children.indexOf(r)))throw new Error("The supplied Container must be a child of the caller");return r},addChildAt(r,t){var e=this.children;if(t<0||t>e.length)throw new Error(r+`addChildAt: The index ${t} supplied is out of bounds `+e.length);if(r.parent){var s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;-1!==s&&r.parent.children.splice(s,1)}return t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15,(s=this.renderGroup||this.parentRenderGroup)&&s.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){var i,e;r!==t&&(e=this.getChildIndex(r),i=this.getChildIndex(t),this.children[e]=t,this.children[i]=r,(e=this.renderGroup||this.parentRenderGroup)&&(e.structureDidChange=!0),this._didContainerChangeTick++)},removeFromParent(){var r;null!=(r=this.parent)&&r.removeChild(this)},reparentChild(...r){return 1===r.length?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){var e;return r.parent===this?this.setChildIndex(r,t):(e=r.worldTransform.clone(),r.removeFromParent(),this.addChildAt(r,t),(t=this.worldTransform.clone()).invert(),e.prepend(t),r.setFromMatrix(e)),r}},uc={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){var i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){var i=t.renderPipes;for(let s=0;s<this.effects.length;s++){var n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let s=this.effects.length-1;0<=s;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class hr{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 cc{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++){var i=this._tests[e];if(i.test(t))return N.get(i.maskClass,t)}return t}returnMaskEffect(t){N.return(t)}}const li=new cc;B.handleByList(r.MaskEffect,li._effectClasses);var Bx=Object.defineProperty,hc=Object.getOwnPropertySymbols,Ix=Object.prototype.hasOwnProperty,Fx=Object.prototype.propertyIsEnumerable,dc=(r,t,e)=>t in r?Bx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pc=(r,t)=>{for(var e in t=t||{})Ix.call(t,e)&&dc(r,e,t[e]);if(hc)for(var e of hc(t))Fx.call(t,e)&&dc(r,e,t[e]);return r};const fc={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){var r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){-1===this.effects.indexOf(r)&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){-1!==(r=this.effects.indexOf(r))&&(this.effects.splice(r,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){var t=this._maskEffect;(null==t?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),li.returnMaskEffect(t),this._maskEffect=null),null!=r)&&(this._maskEffect=li.getMaskEffect(r),this.addEffect(this._maskEffect))},setMask(r){this._maskOptions=pc(pc({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},get mask(){var r;return null==(r=this._maskEffect)?void 0:r.mask},set filters(r){Array.isArray(r)||(r=r&&[r]);var e=this._filterEffect||(this._filterEffect=new hr),i=0<(null==r?void 0:r.length),t=i!=0<(null==(t=e.filters)?void 0:t.length);r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),t&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=null!=r?r:null))},get filters(){var r;return null==(r=this._filterEffect)?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new hr),this._filterEffect.filterArea=r},get filterArea(){var r;return null==(r=this._filterEffect)?void 0:r.filterArea}},mc={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){var e=this.children;for(let i=0;i<e.length;i++){var s=e[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(t)for(let i=0;i<e.length;i++){const s=e[i].getChildByLabel(r,!0);if(s)return s}return null},getChildrenByLabel(r,t=!1,e=[]){var i=this.children;for(let s=0;s<i.length;s++){var n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,e);return e}},ui=[new V,new V,new V,new V];class z{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}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 z(0,0,0,0)}clone(){return new z(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)&&t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){var a,l,{width:n,height:o}=this;return!(n<=0||o<=0)&&(a=this.x,l=this.y,s=i-(i*=1-s),a-i<=t)&&t<=a+n+i&&l-i<=e&&e<=l+o+i&&!(a+s<t&&t<a+n-s&&l+s<e&&e<l+o-s)}intersects(t,e){var i,s,n,o,a,u,c,d,m,_,g,b,l;return e?(i=this.left,s=this.right,n=this.top,o=this.bottom,!(s<=i||o<=n||(a=ui[0].set(t.left,t.top),l=ui[1].set(t.left,t.bottom),u=ui[2].set(t.right,t.top),c=ui[3].set(t.right,t.bottom),u.x<=a.x)||l.y<=a.y||0===(d=Math.sign(e.a*e.d-e.b*e.c))||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(c,c),Math.max(a.x,l.x,u.x,c.x)<=i)||Math.min(a.x,l.x,u.x,c.x)>=s||Math.max(a.y,l.y,u.y,c.y)<=n||Math.min(a.y,l.y,u.y,c.y)>=o||(m=(e=d*(l.y-a.y))*i+(l=d*(a.x-l.x))*n,_=e*s+l*n,g=e*i+l*o,b=e*s+l*o,Math.max(m,_,g,b)<=e*a.x+l*a.y)||Math.min(m,_,g,b)>=e*c.x+l*c.y||(g=(m=d*(a.y-u.y))*i+(_=d*(u.x-a.x))*n,b=m*s+_*n,e=m*i+_*o,l=m*s+_*o,Math.max(g,b,e,l)<=m*a.x+_*a.y)||Math.min(g,b,e,l)>=m*c.x+_*c.y)):(d=(this.x<t.x?t:this).x,!((this.right>t.right?t:this).right<=d)&&(u=(this.y<t.y?t:this).y,(this.bottom>t.bottom?t:this).bottom>u))}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){var e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),t=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(t-s,0),this}ceil(t=1,e=.001){var i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){var e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),t=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=t-s,this}getBounds(t){return(t=t||new z).copyFrom(this),t}containsRect(t){var e,i,s;return!(this.width<=0||this.height<=0)&&(e=t.x,i=t.y,s=t.x+t.width,t=t.y+t.height,e>=this.x)&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&t>=this.y&&t<this.y+this.height}}const gc=new M;class nt{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=gc,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new z);var 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=gc,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){var o=(n=n||this.matrix).a,a=n.b,l=n.c,u=n.d,c=n.tx,n=n.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY,g=o*t+l*e+c,b=a*t+u*e+n;g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),b=a*i+u*e+n,(g=o*i+l*e+c)<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),b=a*t+u*s+n,(g=o*t+l*s+c)<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),b=a*i+u*s+n,(g=o*i+l*s+c)<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}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:t).minX,this.minY=(this.minY>t.minY?this:t).minY,this.maxX=(this.maxX<t.maxX?this:t).maxX,this.maxY=(this.maxY<t.maxY?this:t).maxY}applyMatrix(t){var e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:t,b:a,c:l,d:u,tx:c,ty:d}=t,p=t*e+l*i+c,f=a*e+u*i+d;this.minX=p,this.minY=f,this.maxX=p,this.maxY=f,f=a*s+u*i+d,this.minX=(p=t*s+l*i+c)<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,f=a*e+u*n+d,this.minX=(p=t*e+l*n+c)<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,f=a*s+u*n+d,this.minX=(p=t*s+l*n+c)<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f: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,i,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),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 nt(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){var e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){var 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 0<this.maxX-this.minX&&0<this.maxY-this.minY}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,s){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;var u=(s=s||this.matrix).a,c=s.b,d=s.c,p=s.d,f=s.tx,m=s.ty;for(let _=e;_<i;_+=2){var g=t[_],b=t[_+1],x=u*g+d*b+f,g=c*g+p*b+m;n=x<n?x:n,o=g<o?g:o,a=x>a?x:a,l=g>l?g: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 ct=new ai(M),$t=new ai(nt),Dx=new M,_c={getFastGlobalBounds(r,t){return(t=t||new nt).clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0),r=this.renderGroup||this.parentRenderGroup,t.applyMatrix(r.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(!(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||7!==this.localDisplayStatus)&&this.measurable){var s=!!this.effects.length;if((this.renderGroup||s)&&(i=$t.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{this.renderPipeId&&(o=this.bounds,i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform));var o,n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,e)}if(s){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,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&(i.applyMatrix(o.worldTransform.copyTo(Dx).invert()),t.addBounds(i,this.relativeGroupTransform)),t.addBounds(i),$t.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),$t.return(i))}}};function dr(r,t,e){e.clear();let s;return mn(r,e,r.parent?t?r.parent.worldTransform:ci(r,s=ct.get().identity()):M.IDENTITY,t),s&&ct.return(s),e.isValid||e.set(0,0,0,0),e}function mn(r,t,e,i){var s,n;if(r.visible&&r.measurable){let o;i?o=r.worldTransform:(r.updateLocalTransform(),(o=ct.get()).appendFrom(r.localTransform,e));var e=t,l=!!r.effects.length;if(l&&(t=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.bounds&&(t.matrix=o,t.addBounds(r.bounds));for(let u=0;u<r.children.length;u++)mn(r.children[u],t,o,i)}if(l){for(let u=0;u<r.effects.length;u++)null!=(n=(s=r.effects[u]).addBounds)&&n.call(s,t);e.addBounds(t,M.IDENTITY),$t.return(t)}i||ct.return(o)}}function ci(r,t){return(r=r.parent)&&(ci(r,t),r.updateLocalTransform(),t.append(r.localTransform)),t}function gn(r,t){return 16777215!==r&&t?16777215!==t&&r?(((r>>16&255)*(t>>16&255)/255|0)<<16)+(((r>>8&255)*(t>>8&255)/255|0)<<8)+((255&r)*(255&t)/255|0):r:t}const bc=16777215;function pr(r,t){return r===bc?t:t===bc?r:gn(r,t)}function Be(r){return((255&r)<<16)+(65280&r)+(r>>16&255)}var vc={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,t){return t?r.copyFrom(this.worldTransform):(this.updateLocalTransform(),t=ci(this,ct.get().identity()),r.appendFrom(this.localTransform,t),ct.return(t),r)},getGlobalTint(r){if(r)return this.renderGroup?Be(this.renderGroup.worldColor):this.parentRenderGroup?Be(pr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=pr(t,e.localColor),e=e.parent;return Be(t)}};function hi(r,t,e){return t.clear(),function yc(r,t,e,i,s){var n,o;let a;if(s)a=ct.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform(),s=r.localTransform,(a=ct.get()).appendFrom(s,e)}if(s=t,(e=!!r.effects.length)&&(t=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));var c=r.children;for(let d=0;d<c.length;d++)yc(c[d],t,a,i,!1)}if(e){for(let c=0;c<r.effects.length;c++)null!=(o=(n=r.effects[c]).addLocalBounds)&&o.call(n,t,i);s.addBounds(t,M.IDENTITY),$t.return(t)}ct.return(a)}(r,t,e=e||M.IDENTITY,r,!0),t.isValid||t.set(0,0,0,0),t}function _n(r,t){var e=r.children;for(let i=0;i<e.length;i++){var s=e[i],n=s.uid,o=(65535&s._didViewChangeTick)<<16|65535&s._didContainerChangeTick,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,s.children.length&&_n(s,t)}return t.didChange}const Ux=new M,Tc={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){var e=Math.sign(this.scale.x)||1;this.scale.x=0!==t?r/t*e:e},_setHeight(r,t){var e=Math.sign(this.scale.y)||1;this.scale.y=0!==t?r/t*e:e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new nt});var r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),_n(this,r),r.didChange&&hi(this,r.localBounds,Ux),r.localBounds},getBounds(r,t){return dr(this,r,t||new nt)}},Sc={_onRender:null,set onRender(r){var t=this.renderGroup||this.parentRenderGroup;r?(this._onRender||null==t||t.addOnRender(this),this._onRender=r):(this._onRender&&null!=t&&t.removeOnRender(this),this._onRender=null)},get onRender(){return this._onRender}},Ec={_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(kx))}};function kx(r,t){return r._zIndex-t._zIndex}var Ac={getGlobalPosition(r=new V,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){return t=(e=this.getGlobalTransform(ct.get(),e)).apply(r,t),ct.return(e),t},toLocal(r,t,e,i){return t&&(r=t.toGlobal(r,e,i)),e=(t=this.getGlobalTransform(ct.get(),i)).applyInverse(r,e),ct.return(t),e}};class bn{constructor(){this.uid=K("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}function de(r){return r+=0===r?1:0,--r,1+((r=(r=(r=(r|=r>>>1)|r>>>2)|r>>>4)|r>>>8)|r>>>16)}function vn(r){return!(r&r-1||!r)}function Bt(r){var t={};for(const e in r)void 0!==r[e]&&(t[e]=r[e]);return t}var Lx=Object.defineProperty,Pc=Object.getOwnPropertySymbols,Nx=Object.prototype.hasOwnProperty,Hx=Object.prototype.propertyIsEnumerable,wc=(r,t,e)=>t in r?Lx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rc=(r,t)=>{for(var e in t=t||{})Nx.call(t,e)&&wc(r,e,t[e]);if(Pc)for(var e of Pc(t))Hx.call(t,e)&&wc(r,e,t[e]);return r};const Mc=Object.create(null);(Cc=class Fy extends ft{constructor(t={}){var e;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Rc(Rc({},Fy.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=null!=(e=t.addressModeU)?e:this.addressModeU,this.addressModeV=null!=(e=t.addressModeV)?e:this.addressModeV,this.addressModeW=null!=(e=t.addressModeW)?e:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=null!=(e=t.magFilter)?e:this.magFilter,this.minFilter=null!=(e=t.minFilter)?e:this.minFilter,this.mipmapFilter=null!=(e=t.mipmapFilter)?e:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=null!=(e=t.maxAnisotropy)?e: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),1<this._maxAnisotropy&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){var t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-`+this._maxAnisotropy;return this._sharedResourceId=function(r){var t=Mc[r];return void 0===t&&(Mc[r]=K("resource")),t}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}}).defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let yn=Cc;var jx=Object.defineProperty,Oc=Object.getOwnPropertySymbols,zx=Object.prototype.hasOwnProperty,Vx=Object.prototype.propertyIsEnumerable,Gc=(r,t,e)=>t in r?jx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bc=(r,t)=>{for(var e in t=t||{})zx.call(t,e)&&Gc(r,e,t[e]);if(Oc)for(var e of Oc(t))Vx.call(t,e)&&Gc(r,e,t[e]);return r};(Cc=class Dy extends ft{constructor(t={}){var e;super(),this.options=t,this.uid=K("textureSource"),this._resourceType="textureSource",this._resourceId=K("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Bc(Bc({},Dy.defaultOptions),t),this.label=null!=(e=t.label)?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&&null!=(e=this.resourceWidth)?e:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&null!=(e=this.resourceHeight)?e:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new yn(Bt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e;this.style!==t&&(null!=(e=this._style)&&e.off("change",this._onStyleChange,this),this._style=t,null!=(e=this._style)&&e.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){var t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=K("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){var t=this.resource;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){var t=this.resource;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){return i=i||this._resolution,t=t||this.width,e=e||this.height,t=Math.round(t*i),e=Math.round(e*i),this.width=t/i,this.height=e/i,this._resolution=i,(this.pixelWidth!==t||this.pixelHeight!==e)&&(this._refreshPOT(),this.pixelWidth=t,this.pixelHeight=e,this.emit("resize",this),this._resourceId=K("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&1<this.mipLevelCount&&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=vn(this.pixelWidth)&&vn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}}).defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Q=Cc;const pe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],fe=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],me=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ge=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],xn=[],Fc=[],di=Math.sign;for(let r=0;r<16;r++){var t=[];xn.push(t);for(let e=0;e<16;e++){var i=di(pe[r]*pe[e]+me[r]*fe[e]),s=di(fe[r]*pe[e]+ge[r]*fe[e]),n=di(pe[r]*me[e]+me[r]*ge[e]),o=di(fe[r]*me[e]+ge[r]*ge[e]);for(let a=0;a<16;a++)if(pe[a]===i&&fe[a]===s&&me[a]===n&&ge[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new M;t.set(pe[r],fe[r],me[r],ge[r],0,0),Fc.push(t)}const $={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=>pe[r],uY:r=>fe[r],vX:r=>me[r],vY:r=>ge[r],inv:r=>8&r?15&r:7&-r,add:(r,t)=>xn[r][t],sub:(r,t)=>xn[r][$.inv(t)],rotate180:r=>4^r,isVertical:r=>2==(3&r),byDirection:(r,t)=>2*Math.abs(r)<=Math.abs(t)?0<=t?$.S:$.N:2*Math.abs(t)<=Math.abs(r)?0<r?$.E:$.W:0<t?0<r?$.SE:$.SW:0<r?$.NE:$.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{(t=Fc[$.inv(t)]).tx=e,t.ty=i,r.append(t)}},Tn=()=>{};var Yx=Object.defineProperty,Kx=Object.defineProperties,qx=Object.getOwnPropertyDescriptors,Dc=Object.getOwnPropertySymbols,Zx=Object.prototype.hasOwnProperty,Qx=Object.prototype.propertyIsEnumerable,Uc=(r,t,e)=>t in r?Yx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class pi extends Q{constructor(t){var e=t.resource||new Float32Array(t.width*t.height*4),i=t.format||(e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(0 instanceof Int8Array,"bgra8unorm"));super((t=((r,t)=>{for(var e in t=t||{})Zx.call(t,e)&&Uc(r,e,t[e]);if(Dc)for(var e of Dc(t))Qx.call(t,e)&&Uc(r,e,t[e]);return r})({},t),Kx(t,qx({resource:e,format:i})))),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}pi.extension=r.TextureSource;const kc=new M;class Sn{constructor(t,e){this.mapCoord=new M,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&(null!=(e=this._texture)&&e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);var i=this.mapCoord;for(let s=0;s<t.length;s+=2){var n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(){var t=this._texture,e=(this._updateID++,t.uvs),e=(this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0),t.orig),e=((s=t.trim)&&(kc.set(e.width/s.width,0,0,e.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(kc)),t.source),s=this.uClampFrame,a=this.clampMargin/e._resolution,l=this.clampOffset/e._resolution;return s[0]=(t.frame.x+a+l)/e.width,s[1]=(t.frame.y+a+l)/e.height,s[2]=(t.frame.x+t.frame.width-a+l)/e.width,s[3]=(t.frame.y+t.frame.height-a+l)/e.height,this.uClampOffset[0]=this.clampOffset/e.pixelWidth,this.uClampOffset[1]=this.clampOffset/e.pixelHeight,this.isSimple=t.frame.width===e.width&&t.frame.height===e.height&&0===t.rotate,!0}}class P extends ft{constructor({source:t,label:e,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:u}={}){super(),this.uid=K("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new z,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=null!=(e=null==t?void 0:t.source)?e:new Q,this.noFrame=!i,i?this.frame.copyFrom(i):({width:t,height:e}=this._source,this.frame.width=t,this.frame.height=e),this.orig=s||this.frame,this.trim=n,this.rotate=null!=l?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).on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Sn(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){var c,d,p,f,{uvs:t,frame:e}=this,{width:i,height:s}=this._source,n=e.x/i,o=e.y/s,i=e.width/i,e=e.height/s;(s=this.rotate)?(p=n+(c=i/2),f=o+(d=e/2),s=$.add(s,$.NW),t.x0=p+c*$.uX(s),t.y0=f+d*$.uY(s),s=$.add(s,2),t.x1=p+c*$.uX(s),t.y1=f+d*$.uY(s),s=$.add(s,2),t.x2=p+c*$.uX(s),t.y2=f+d*$.uY(s),s=$.add(s,2),t.x3=p+c*$.uX(s),t.y3=f+d*$.uY(s)):(t.x0=n,t.y0=o,t.x1=n+i,t.y1=o,t.x2=n+i,t.y2=o+e,t.x3=n,t.y3=o+e)}destroy(t=!1){this._source&&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}}P.EMPTY=new P({label:"EMPTY",source:new Q({label:"EMPTY"})}),P.EMPTY.destroy=Tn,P.WHITE=new P({source:new pi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),P.WHITE.destroy=Tn;var e0=Object.defineProperty,r0=Object.defineProperties,i0=Object.getOwnPropertyDescriptors,$c=Object.getOwnPropertySymbols,s0=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable,Lc=(r,t,e)=>t in r?e0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;let l0=0;class Nc{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,i){return t=new Q(((r,t)=>r0(r,i0(t)))(((r,t)=>{for(var e in t=t||{})s0.call(t,e)&&Lc(r,e,t[e]);if($c)for(var e of $c(t))n0.call(t,e)&&Lc(r,e,t[e]);return r})({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1})),new P({source:t,label:"texturePool_"+l0++})}getOptimalTexture(t,e,i=1,s){var n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6),a=((n=de(n))<<17)+((o=de(o))<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return(l=l||this.createTexture(n,o,s)).source._resolution=i,l.source.width=n/i,l.source.height=o/i,l.source.pixelWidth=n,l.source.pixelHeight=o,l.frame.x=0,l.frame.y=0,l.frame.width=t,l.frame.height=e,l.updateUvs(),this._poolKeyHash[l.uid]=a,l}getSameSizeTexture(t,e=!1){var i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t){var e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=!1!==t)for(const e in this._texturePool){var i=this._texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const it=new Nc;class Hc{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new M,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 bn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){(this.root=t)._onRender&&this.addOnRender(t),t.didChange=!0;var e=t.children;for(let i=0;i<e.length;i++){var s=e[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(it.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){var 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).renderGroupChildren.push(t)}_removeRenderGroupChild(t){var e=this.renderGroupChildren.indexOf(t);-1<e&&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);else{t._onRender&&this.addOnRender(t);var e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}}removeChild(t){if(this.structureDidChange=!0,t._onRender&&!t.renderGroup&&this.removeOnRender(t),t.parentRenderGroup=null,t.renderGroup)this._removeRenderGroupChild(t.renderGroup);else{var e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}}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:[]})).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 7===this.root.localDisplayStatus&&0<this.worldAlpha}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=[]){var e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),!t.renderGroup){var i=t.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],e)}return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new M),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new M),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;var t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new M),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function fi(r,t,e={}){for(const i in t)e[i]||void 0===t[i]||(r[i]=t[i])}const En=new rt(null),An=new rt(null),Pn=new rt(null,1,1),fr=1,mi=2,Ie=4;class lt extends ft{constructor(t={}){var e;super(),this.uid=K("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.updateTick=-1,this.localTransform=new M,this.relativeGroupTransform=new M,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new rt(this,0,0),this._scale=Pn,this._pivot=An,this._skew=En,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=[],fi(this,t,{children:!0,parent:!0,effects:!0}),null!=(e=t.children)&&e.forEach(s=>this.addChild(s)),null!=(e=t.parent)&&e.addChild(this)}static mixin(t){B.mixin(lt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(1<t.length){for(let s=0;s<t.length;s++)this.addChild(t[s]);return t[0]}var e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0)):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified()),e}removeChild(...t){if(1<t.length){for(let s=0;s<t.length;s++)this.removeChild(t[s]);return t[0]}var e=t[0],i=this.children.indexOf(e);return-1<i&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup)&&this.parentRenderGroup.onChildUpdate(this)}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){var t;this.renderGroup||(null!=(t=this.parentRenderGroup)&&t.removeChild(this),this.renderGroup=N.get(Hc,this),this.groupTransform=M.IDENTITY,null!=t&&t.addChild(this),this._updateIsSimple())}disableRenderGroup(){var t;this.renderGroup&&(null!=(t=this.parentRenderGroup)&&t.removeChild(this),N.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,null!=t&&t.addChild(this),this._updateIsSimple())}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new M),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*sc}set angle(t){this.rotation=t*nc}get pivot(){return this._pivot===An&&(this._pivot=new rt(this,0,0)),this._pivot}set pivot(t){this._pivot===An&&(this._pivot=new rt(this,0,0)),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===En&&(this._skew=new rt(this,0,0)),this._skew}set skew(t){this._skew===En&&(this._skew=new rt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Pn&&(this._scale=new rt(this,1,1)),this._scale}set scale(t){this._scale===Pn&&(this._scale=new rt(this,0,0)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){var e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){var e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t=t||{};var 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 i,s=this.getLocalBounds();"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null==e&&(e=t),void 0!==t&&this._setWidth(t,s.width),void 0!==e&&this._setHeight(e,s.height)}_updateSkew(){var 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(("number"==typeof t.x?t:this.position).x,("number"==typeof t.y?t:this.position).y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation=("number"==typeof t.rotation?t:this).rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){var n,o,i,l,s,t=this._didContainerChangeTick;this._didLocalTransformChangeId!==t&&(this._didLocalTransformChangeId=t,t=this.localTransform,i=this._scale,s=this._pivot,n=this._position,o=i._x,i=i._y,l=s._x,s=s._y,t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*i,t.d=this._sy*i,t.tx=n._x-(l*t.a+s*t.c),t.ty=n._y-(l*t.b+s*t.d))}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=fr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){(t=X.shared.setValue(null!=t?t:16777215).toBgrNumber())!==this.localColor&&(this.localColor=t,this._updateFlags|=fr,this._onUpdate())}get tint(){return Be(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=mi,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){(2&this.localDisplayStatus)!=(t?2:0)&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ie,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){(4&this.localDisplayStatus)!=(t?0:4)&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ie,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){(1&this.localDisplayStatus)!=(t?1:0)&&(this._updateFlags|=Ie,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&0<this.groupAlpha}destroy(t=!1){var e;if(!this.destroyed){this.destroyed=!0;let i;if(this.children.length&&(i=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._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:null!=t&&t.children)&&i)for(let s=0;s<i.length;++s)i[s].destroy(t);null!=(e=this.renderGroup)&&e.destroy(),this.renderGroup=null}}}B.mixin(lt,ln,_c,Ac,Sc,Tc,fc,mc,Ec,rc,ac,vc,uc);class Fe{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Fe.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new V,this.page=new V,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,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,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}}function Jc(r){return void 0!==r&&"MacIntel"===r.platform&&"number"==typeof r.maxTouchPoints&&1<r.maxTouchPoints&&"undefined"==typeof MSStream}var wn=/iPhone/i,Xc=/iPod/i,jc=/iPad/i,zc=/\biOS-universal(?:.+)Mac\b/i,Rn=/\bAndroid(?:.+)Mobile\b/i,Vc=/Android/i,De=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,gi=/Silk/i,Wt=/Windows Phone/i,Wc=/\bWindows(?:.+)ARM\b/i,Yc=/BlackBerry/i,Kc=/BB10/i,qc=/Opera Mini/i,Zc=/\b(CriOS|Chrome)(?:.+)Mobile/i,Qc=/Mobile(?:.+)Firefox\b/i;function th(r){var t={userAgent:"",platform:"",maxTouchPoints:0},i=(r||"undefined"==typeof navigator?"string"==typeof r?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0}):t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0},(r=t.userAgent).split("[FBAN"));return(r={apple:{phone:(i=function(r){return function(t){return t.test(r)}}(r=void 0!==(i=(r=void 0!==i[1]?i[0]:r).split("Twitter"))[1]?i[0]:r))(wn)&&!i(Wt),ipod:i(Xc),tablet:!i(wn)&&(i(jc)||Jc(t))&&!i(Wt),universal:i(zc),device:(i(wn)||i(Xc)||i(jc)||i(zc)||Jc(t))&&!i(Wt)},amazon:{phone:i(De),tablet:!i(De)&&i(gi),device:i(De)||i(gi)},android:{phone:!i(Wt)&&i(De)||!i(Wt)&&i(Rn),tablet:!i(Wt)&&!i(De)&&!i(Rn)&&(i(gi)||i(Vc)),device:!i(Wt)&&(i(De)||i(gi)||i(Rn)||i(Vc))||i(/\bokhttp\b/i)},windows:{phone:i(Wt),tablet:i(Wc),device:i(Wt)||i(Wc)},other:{blackberry:i(Yc),blackberry10:i(Kc),opera:i(qc),firefox:i(Qc),chrome:i(Zc),device:i(Yc)||i(Kc)||i(qc)||i(Qc)||i(Zc)},any:!1,phone:!1,tablet:!1}).any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}const rh=(null!=(Cc=th.default)?Cc:th)(globalThis.navigator);var h0=Object.defineProperty,ih=Object.getOwnPropertySymbols,d0=Object.prototype.hasOwnProperty,p0=Object.prototype.propertyIsEnumerable,sh=(r,t,e)=>t in r?h0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nh=(r,t)=>{for(var e in t=t||{})d0.call(t,e)&&sh(r,e,t[e]);if(ih)for(var e of ih(t))p0.call(t,e)&&sh(r,e,t[e]);return r},Cc=((Mn=class Uy{constructor(t,e=rh){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,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}_createTouchHook(){var t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..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){this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.width="100px",this._div.style.height="100px",this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.zIndex=2..toString(),this._div.style.pointerEvents="none"),this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._deactivateOnMouseMove&&(this._onMouseMove=this._onMouseMove.bind(this),globalThis.document.addEventListener("mousemove",this._onMouseMove,!0));const t=this._renderer.view.canvas;if(t.parentNode)t.parentNode.appendChild(this._div),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(t.parentNode.appendChild(this._div),e.disconnect(),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(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;this._pool.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pool=[],this._children=[]}}_updateAccessibleObjects(t){if(t.visible&&t.accessibleChildren){t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);var e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}}init(t){var e=Uy.defaultOptions,e={accessibilityOptions:nh(nh({},e),(null==t?void 0:t.accessibilityOptions)||{})};this.debug=e.accessibilityOptions.debug,this._activateOnTab=e.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=e.accessibilityOptions.deactivateOnMouseMove,e.accessibilityOptions.enabledByDefault?this._activate():this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._renderer.runners.postrender.remove(this)}postrender(){var t=performance.now();if(!(this._mobileInfo.android.device&&t<this._androidUpdateCount)&&(this._androidUpdateCount=t+this._androidUpdateFrequency,this._renderer.renderingToScreen)&&this._renderer.view.canvas){var e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&e.add(this._children.indexOf(i))}for(let i=this._children.length-1;0<=i;i--){var s=this._children[i];e.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._pool.push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,fn(this._children,i,1))}if(this._renderer.renderingToScreen){const{x:i,y:s,width:n,height:o}=this._renderer.screen,a=this._div;a.style.left=i+"px",a.style.top=s+"px",a.style.width=n+"px",a.style.height=o+"px"}for(let i=0;i<this._children.length;i++){const s=this._children[i];if(s._accessibleActive&&s._accessibleDiv){var n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){var a=s.worldTransform,l=this._renderer.resolution,u=this._renderer.resolution;n.style.left=(a.tx+o.x*a.a)*l+"px",n.style.top=(a.ty+o.y*a.d)*u+"px",n.style.width=o.width*a.a*l+"px",n.style.height=o.height*a.d*u+"px"}else{this._capHitArea(o);const a=this._renderer.resolution,l=this._renderer.resolution;n.style.left=o.x*a+"px",n.style.top=o.y*l+"px",n.style.width=o.width*a+"px",n.style.height=o.height*l+"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);var{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||("button"===t.accessibleType?e=document.createElement("button"):((e=document.createElement(t.accessibleType)).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="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..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&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title="container "+t.tabIndex),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,(t._accessibleDiv=e).container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t.interactive&&(t._accessibleDiv.tabIndex=t.tabIndex)}_dispatchEvent(t,e){const i=t.target.container,s=this._renderer.events.rootBoundary,n=Object.assign(new Fe(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>s.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){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._div=null,this._pool=null,this._children=null,this._renderer=null,this._activateOnTab&&globalThis.removeEventListener("keydown",this._onKeyDown)}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}}).extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"accessibility"},Mn.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0},Mn),Mn={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};B.add(Cc),B.mixin(lt,Mn);class Cn{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),(this._resizeTo=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){this._cancelResize();let e,i;var s,n;i=this._resizeTo===globalThis.window?(e=globalThis.innerWidth,globalThis.innerHeight):({clientWidth:s,clientHeight:n}=this._resizeTo,e=s,n),this.renderer.resize(e,i),this.render()}},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Cn.extension=r.Application;var Yt=(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))({});class bi{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=s}match(t,e=null){return this._fn===t&&this._context===e}emit(t){return this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t)),t=this.next,this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(t){(this.previous=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);var e=this.next;return this.next=t?null:e,this.previous=null,e}}var ch=class wt{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 bi(null,null,1/0),this.deltaMS=1/wt.targetFPMS,this.elapsedMS=1/wt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started)&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Yt.NORMAL){return this._addListener(new bi(t,e,i))}addOnce(t,e,i=Yt.NORMAL){return this._addListener(new bi(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}e=(i=e).next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if((e=this.elapsedMS=t-this.lastTime)>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){var n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*wt.targetFPMS;let s=(n=this._head).next;for(;s;)s=s.emit(this);n.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){t=Math.min(this.maxFPS,t),t=Math.min(Math.max(0,t)/1e3,wt.targetFPMS),this._maxElapsedMS=1/t}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){0===t?this._minElapsedMS=0:(t=Math.max(this.minFPS,t),this._minElapsedMS=1/(t/1e3))}static get shared(){var t;return wt._shared||((t=wt._shared=new wt).autoStart=!0,t._protected=!0),wt._shared}static get system(){var t;return wt._system||((t=wt._system=new wt).autoStart=!0,t._protected=!0),wt._system}};ch.targetFPMS=.06;let ut=ch;class On{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),(this._ticker=e)&&e.add(this.render,this,Yt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ut.shared:new ut,t.autoStart&&this.start()}static destroy(){var t;this._ticker&&(t=this._ticker,this.ticker=null,t.destroy())}}On.extension=r.Application,B.add(Cn),B.add(On);const Kt=new 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&&(ut.system.add(this._tickerUpdate,this,Yt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ut.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){var t;this.domElement&&!this._pauseUpdate&&(this._didMove?this._didMove=!1:(t=this.events._rootPointerEvent,this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}))))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class mr extends Fe{constructor(){super(...arguments),this.client=new V,this.movement=new V,this.offset=new V,this.global=new V,this.screen=new V}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,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,u,c,d,p,f,m,_){throw new Error("Method not implemented.")}}class Mt extends mr{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class _e extends mr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}_e.DOM_DELTA_PIXEL=0,_e.DOM_DELTA_LINE=1,_e.DOM_DELTA_PAGE=2;const T0=new V,gr=new V;class hh{constructor(t){this.dispatch=new ft,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((i,s)=>i.priority-s.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){var e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t)}}hitTest(t,e){return Kt.pauseUpdate=!0,(t=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,T0.set(t,e),this.hitTestFn,this.hitPruneFn))&&t[0]}propagate(t,e){if(t.target){var i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],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 s=i.length-2;0<=s;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}}all(t,e,i=this._allInteractiveElements){if(0!==i.length){t.eventPhase=t.BUBBLING_PHASE;var s=Array.isArray(e)?e:[e];for(let n=i.length-1;0<=n;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}}propagationPath(t){var e=[t];for(let i=0;i<2048&&t!==this.rootTarget&&t.parent;i++){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,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(Kt.pauseUpdate=!1),t.interactiveChildren&&t.children){var c=t.children;for(let d=c.length-1;0<=d;d--){var m,p=c[d];!(p=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,s,n,o||n(t,i)))||0<p.length&&!p[p.length-1].parent||(m=t.isInteractive(),(0<p.length||m)&&(m&&this._allInteractiveElements.push(t),p.push(t)),0===this._hitElements.length&&(this._hitElements=p),a=!0)}}var l=this._isInteractive(e),u=t.isInteractive();return u&&this._allInteractiveElements.push(t),o||0<this._hitElements.length?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(Kt.pauseUpdate=!1),t.interactiveChildren&&t.children){var l=t.children,u=i;for(let c=l.length-1;0<=c;c--){var f,d=l[c];if((d=this.hitTestRecursive(d,this._isInteractive(e)?e:d.eventMode,u,s,n))&&(!(0<d.length)||d[d.length-1].parent))return f=t.isInteractive(),(0<d.length||f)&&d.push(t),d}}var o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||"none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,gr),!t.hitArea.contains(gr.x,gr.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){var s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!(null==t||!t.containsPoint)&&(t.worldTransform.applyInverse(e,gr),t.containsPoint(gr))}notifyTarget(t,e){var i,s;t.currentTarget.isInteractive()&&(null==e&&(e=t.type),null!=(s=(i=t.currentTarget)["on"+e])&&s.call(i,t),s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?e+"capture":e,this._notifyListeners(t,s),t.eventPhase===t.AT_TARGET)&&this._notifyListeners(t,e)}mapPointerDown(t){var e,s;t instanceof Mt&&(e=this.createPointerEvent(t),this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType?this.dispatchEvent(e,"touchstart"):"mouse"!==e.pointerType&&"pen"!==e.pointerType||(s=2===e.button,this.dispatchEvent(e,s?"rightdown":"mousedown")),this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e))}mapPointerMove(t){if(t instanceof Mt){this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;var n=this.createPointerEvent(t),o=(this._isPointerMoveEvent=!1,"mouse"===n.pointerType||"pen"===n.pointerType),a=this.trackingData(t.pointerId),l=this.findMountedTarget(a.overTargets);if(0<(null==(e=a.overTargets)?void 0:e.length)&&l!==n.target){var e="mousemove"===t.type?"mouseout":"pointerout",e=this.createPointerEvent(t,e,l);if(this.dispatchEvent(e,"pointerout"),o&&this.dispatchEvent(e,"mouseout"),!n.composedPath().includes(l)){var f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!n.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(e)}if(l!==n.target){var d="mousemove"===t.type?"mouseover":"pointerover",d=this.clonePointerEvent(n,d);this.dispatchEvent(d,"pointerover"),o&&this.dispatchEvent(d,"mouseover");let f=null==l?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){var m=this.clonePointerEvent(n,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),o&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(d)}e=[],t=null==(t=this.enableGlobalMoveEvents)||t,this.moveOnAll?e.push("pointermove"):this.dispatchEvent(n,"pointermove"),t&&e.push("globalpointermove"),"touch"===n.pointerType&&(this.moveOnAll?e.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),t)&&e.push("globaltouchmove"),o&&(this.moveOnAll?e.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),t&&e.push("globalmousemove"),this.cursor=null==(t=n.target)?void 0:t.cursor),0<e.length&&this.all(n,e),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}}mapPointerOver(t){var e;if(t instanceof Mt){var i=this.trackingData(t.pointerId),n="mouse"===(t=this.createPointerEvent(t)).pointerType||"pen"===t.pointerType,o=(this.dispatchEvent(t,"pointerover"),n&&this.dispatchEvent(t,"mouseover"),"mouse"===t.pointerType&&(this.cursor=null==(e=t.target)?void 0:e.cursor),this.clonePointerEvent(t,"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;i.overTargets=t.composedPath(),this.freeEvent(t),this.freeEvent(o)}}mapPointerOut(t){if(t instanceof Mt){var e=this.trackingData(t.pointerId);if(e.overTargets){var i="mouse"===t.pointerType||"pen"===t.pointerType,s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s),o=(this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout"),this.createPointerEvent(t,"pointerleave",s));for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&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 Mt){var a,l,e=performance.now(),i=this.createPointerEvent(t),s=(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType?this.dispatchEvent(i,"touchend"):"mouse"!==i.pointerType&&"pen"!==i.pointerType||(a=2===i.button,this.dispatchEvent(i,a?"rightup":"mouseup")),this.trackingData(t.pointerId)),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);)i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType?this.notifyTarget(i,"touchendoutside"):"mouse"!==i.pointerType&&"pen"!==i.pointerType||(l=2===i.button,this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")),a=a.parent;delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click"),l=(a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e}),s.clicksByButton[t.button]);l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,"mouse"===a.pointerType?(n=2===a.button,this.dispatchEvent(a,n?"rightclick":"click")):"touch"===a.pointerType&&this.dispatchEvent(a,"tap"),this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}}mapPointerUpOutside(t){if(t instanceof Mt){var e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),"touch"===s.pointerType?this.notifyTarget(s,"touchendoutside"):"mouse"!==s.pointerType&&"pen"!==s.pointerType||this.notifyTarget(s,2===s.button?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}}mapWheel(t){t instanceof _e&&(t=this.createWheelEvent(t),this.dispatchEvent(t),this.freeEvent(t))}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){var n=this.allocateEvent(Mt);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=null!=(t=null!=i?i:this.hitTest(n.global.x,n.global.y))?t:this._hitElements[0],"string"==typeof e&&(n.type=e),n}createWheelEvent(t){var e=this.allocateEvent(_e);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){var i=this.allocateEvent(Mt);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=null!=e?e:i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Mt&&e instanceof Mt&&(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 mr&&e instanceof mr&&(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){return this.eventPool.has(t)||this.eventPool.set(t,[]),(t=this.eventPool.get(t).pop()||new t(this)).eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");var e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){var i=t.currentTarget._events[e];if(i)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}var S0=Object.defineProperty,dh=Object.getOwnPropertySymbols,E0=Object.prototype.hasOwnProperty,A0=Object.prototype.propertyIsEnumerable,ph=(r,t,e)=>t in r?S0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const R0={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Gn=class Ou{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new hh(null),Kt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Mt(null),this._rootWheelEvent=new _e(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(((r,t)=>{for(var e in t=Ou.defaultEventFeatures||{})E0.call(t,e)&&ph(r,e,t[e]);if(dh)for(var e of dh(t))A0.call(t,e)&&ph(r,e,t[e]);return r})({}),{set:(e,i,s)=>("globalMove"===i&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!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{canvas:s,resolution:n}=this.renderer;this.setTargetElement(s),this.resolution=n,Ou._defaultEventMode=null!=(s=t.eventMode)?s:"passive",Object.assign(this.features,null!=(n=t.eventFeatures)?n:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}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){this._currentCursor=t;var i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(this.features.click){this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;var e=this._normalizeToPointerData(t);!this.autoPreventDefault||!e[0].isNormalized||!t.cancelable&&"cancelable"in t||t.preventDefault();for(let i=0,s=e.length;i<s;i++){var n=e[i],n=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}}_onPointerMove(t){if(this.features.move){this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Kt.pointerMoved();var e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){var n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}}_onPointerUp(t){if(this.features.click){this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;var e=t.target,i=(t.composedPath&&0<t.composedPath().length?t.composedPath()[0]:e)!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){var a=this._bootstrapEvent(this._rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}}_onPointerOverOut(t){if(this.features.click){this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;var e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){var n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}}onWheel(t){this.features.wheel&&(t=this.normalizeWheelEvent(t),this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t))}setTargetElement(t){this._removeEvents(),this.domElement=t,Kt.domElement=t,this._addEvents()}_addEvents(){var t;!this._eventsAdded&&this.domElement&&(Kt.addTickerListener(),(t=this.domElement.style)&&(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(){var t;this._eventsAdded&&this.domElement&&(Kt.removeTickerListener(),(t=this.domElement.style)&&(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,i){var s=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-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(t){var i,e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){var n=t.changedTouches[i];void 0===n.button&&(n.button=0),void 0===n.buttons&&(n.buttons=1),void 0===n.isPrimary&&(n.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===n.width&&(n.width=n.radiusX||1),void 0===n.height&&(n.height=n.radiusY||1),void 0===n.tiltX&&(n.tiltX=0),void 0===n.tiltY&&(n.tiltY=0),void 0===n.pointerType&&(n.pointerType="touch"),void 0===n.pointerId&&(n.pointerId=n.identifier||0),void 0===n.pressure&&(n.pressure=n.force||.5),void 0===n.twist&&(n.twist=0),void 0===n.tangentialPressure&&(n.tangentialPressure=0),void 0===n.layerX&&(n.layerX=n.offsetX=n.clientX),void 0===n.layerY&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else!globalThis.MouseEvent||t instanceof MouseEvent&&!(this.supportsPointerEvents&&t instanceof globalThis.PointerEvent)?(void 0===(i=t).isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)):e.push(t);return e}normalizeWheelEvent(t){var 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,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=R0[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}};Gn.extension={name:"events",type:[r.WebGLSystem,r.CanvasSystem,r.WebGPUSystem],priority:-1},Gn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Bn=Gn;ch={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"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){var r;return null!=(r=this._internalEventMode)?r:Bn.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i="boolean"==typeof e&&e||"object"==typeof e&&e.capture,s="object"==typeof e?e.signal:void 0,n="object"==typeof e&&!0===e.once,o="function"==typeof t?void 0:t,a=(r=i?r+"capture":r,"function"==typeof t?t:t.handleEvent),l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){var e="boolean"==typeof e&&e||"object"==typeof e&&e.capture,s="function"==typeof t?void 0:t;t="function"==typeof t?t:t.handleEvent,this.off(r=e?r+"capture":r,t,s)},dispatchEvent(r){if(r instanceof Fe)return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented;throw new Error("Container cannot propagate events outside of the Federated Events API")}},B.add(Bn),B.mixin(lt,ch);class In{constructor(t){this._destroyRenderableBound=this.destroyRenderable.bind(this),this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.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"}addRenderable(t,e){this._attachedDomElements.includes(t)||(this._attachedDomElements.push(t),t.on("destroyed",this._destroyRenderableBound))}updateRenderable(t){}validateRenderable(t){return!0}destroyRenderable(t){var e=this._attachedDomElements.indexOf(t);-1!==e&&this._attachedDomElements.splice(e,1),t.off("destroyed",this._destroyRenderableBound)}postrender(){var t,e=this._attachedDomElements;if(0===e.length)this._domElement.remove();else{var i=this._renderer.view.canvas;this._domElement.parentNode!==i.parentNode&&null!=(t=i.parentNode)&&t.appendChild(this._domElement),this._domElement.style.transform=`translate(${i.offsetLeft}px, ${i.offsetTop}px)`;for(let s=0;s<e.length;s++){var a,u,l,n=e[s],o=n.element;!n.parent||n.globalDisplayStatus<7?(o.remove(),e.splice(s,1),s--):(this._domElement.contains(o)||(o.style.position="absolute",o.style.pointerEvents="auto",this._domElement.appendChild(o)),a=n.worldTransform,l=n._anchor,u=n.width*l.x,l=n.height*l.y,o.style.transformOrigin=u+`px ${l}px`,o.style.transform=`matrix(${a.a}, ${a.b}, ${a.c}, ${a.d}, ${a.tx-u}, ${a.ty-l})`,o.style.opacity=n.groupAlpha.toString())}}}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){var e=this._attachedDomElements[t];e.off("destroyed",this._destroyRenderableBound),e.element.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._renderer=null}}In.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"dom"};class Lt extends lt{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._bounds=new nt(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty&&(this.updateBounds(),this._boundsDirty=!1),this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){var e=this.bounds,{x:t,y:s}=t;return t>=e.minX&&t<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){var t;this._didViewChangeTick++,this._boundsDirty=!0,!this.didViewUpdate&&(this.didViewUpdate=!0,t=this.renderGroup||this.parentRenderGroup)&&t.onChildViewUpdate(this)}destroy(t){super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){var{renderPipes:s,renderableGC:n}=e,o=(s.blendMode.setBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),n.addRenderable(this),this.didViewUpdate=!1,this.children),a=o.length;for(let l=0;l<a;l++)o[l].collectRenderables(t,e,i)}}var M0=Object.defineProperty,vi=Object.getOwnPropertySymbols,mh=Object.prototype.hasOwnProperty,gh=Object.prototype.propertyIsEnumerable,_h=(r,t,e)=>t in r?M0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class G0 extends Lt{constructor(t={}){var s=t.anchor;super(((r,t)=>{for(var e in t=t||{})mh.call(t,e)&&_h(r,e,t[e]);if(vi)for(var e of vi(t))gh.call(t,e)&&_h(r,e,t[e]);return r})({label:"DOMContainer"},((r,t)=>{var e={};for(i in r)mh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&vi)for(var i of vi(r))t.indexOf(i)<0&&gh.call(r,i)&&(e[i]=r[i]);return e})(t,["element","anchor"]))),this.renderPipeId="dom",this.batched=!1,this._anchor=new V(0,0),s&&(this.anchor=s),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?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(){var s,t=this._bounds,e=this._element;e?({offsetWidth:e,offsetHeight:s}=e,t.minX=0,t.maxX=e,t.minY=0,t.maxY=s):(t.minX=0,t.minY=0,t.maxX=0,t.maxY=0)}destroy(t=!1){super.destroy(t),null!=(t=null==(t=this._element)?void 0:t.parentNode)&&t.removeChild(this._element),this._element=null,this._anchor=null}}B.add(In);var xt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))({}),bh={createCanvas:(r,t)=>{var e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return null!=(r=document.baseURI)?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>(new DOMParser).parseFromString(r,"text/xml")};let vh=bh;const H={get(){return vh},set(r){vh=r}};function It(r){if("string"!=typeof r)throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function _r(r){return r.split("?")[0].split("#")[0]}const mt={toPosix(r){return r.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/")},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){return It(r),r=this.toPosix(r),(r=/^file:\/\/\//.exec(r)||/^[^/:]+:\/{0,2}/.exec(r))?r[0]:""},toAbsolute(r,t,e){return It(r),this.isDataUrl(r)||this.isBlobUrl(r)?r:(t=_r(this.toPosix(null!=t?t:H.get().getBaseUrl())),e=_r(this.toPosix(null!=e?e:this.rootname(t))),(r=this.toPosix(r)).startsWith("/")?mt.join(e,r.slice(1)):this.isAbsolute(r)?r:this.join(t,r))},normalize(r){if(It(r),0===r.length)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;let t="";var e=(r=this.toPosix(r)).startsWith("/"),i=(this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length)),r.endsWith("/"));return 0<(r=function(r){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(47===o)break;o=47}if(47===o){if(s!==a-1&&1!==n)if(s!==a-1&&2===n){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(2<e.length){var l=e.lastIndexOf("/");if(l!==e.length-1){i=-1===l?(e="",0):(e=e.slice(0,l)).length-1-e.lastIndexOf("/"),s=a,n=0;continue}}else if(2===e.length||1===e.length){e="",i=0,s=a,n=0;continue}}else 0<e.length?e+="/"+r.slice(s+1,a):e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else 46===o&&-1!==n?++n:n=-1}return e}(r)).length&&i&&(r+="/"),e?"/"+r:t+r},isAbsolute(r){return It(r),r=this.toPosix(r),!!this.hasProtocol(r)||r.startsWith("/")},join(...r){if(0===r.length)return".";let e;for(let i=0;i<r.length;++i){var t,s=r[i];It(s),0<s.length&&(void 0===e?e=s:(t=null!=(t=r[i-1])?t:"",this.joinExtensions.includes(this.extname(t).toLowerCase())?e+="/../"+s:e+="/"+s))}return void 0===e?".":this.normalize(e)},dirname(r){if(It(r),0===r.length)return".";var e=47===(r=this.toPosix(r)).charCodeAt(0);let i=-1,s=!0;var n=this.getProtocol(r),o=r;for(let a=(r=r.slice(n.length)).length-1;1<=a;--a)if(47===r.charCodeAt(a)){if(!s){i=a;break}}else s=!1;return-1===i?e?"/":this.isUrl(o)?n+r:n:e&&1===i?"//":n+r.slice(0,i)},rootname(r){It(r),r=this.toPosix(r);let t="";var e;return t=r.startsWith("/")?"/":this.getProtocol(r),this.isUrl(r)&&(e=r.indexOf("/",t.length),(t=-1!==e?r.slice(0,e):r).endsWith("/")||(t+="/")),t},basename(r,t){It(r),t&&It(t),r=_r(this.toPosix(r));let e=0,i=-1,s=!0,n;if(void 0!==t&&0<t.length&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;0<=n;--n){var l=r.charCodeAt(n);if(47===l){if(!s){e=n+1;break}}else-1===a&&(s=!1,a=n+1),0<=o&&(l===t.charCodeAt(o)?-1==--o&&(i=n):(o=-1,i=a))}return e===i?i=a:-1===i&&(i=r.length),r.slice(e,i)}for(n=r.length-1;0<=n;--n)if(47===r.charCodeAt(n)){if(!s){e=n+1;break}}else-1===i&&(s=!1,i=n+1);return-1===i?"":r.slice(e,i)},extname(r){It(r);let t=-1,e=0,i=-1,s=!0,n=0;for(let o=(r=_r(this.toPosix(r))).length-1;0<=o;--o){var a=r.charCodeAt(o);if(47===a){if(s)continue;e=o+1;break}-1===i&&(s=!1,i=o+1),46===a?-1===t?t=o:1!==n&&(n=1):-1!==t&&(n=-1)}return-1===t||-1===i||0===n||1===n&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){It(r);var t={root:"",dir:"",base:"",ext:"",name:""};if(0!==r.length){(r=_r(this.toPosix(r))).charCodeAt(0);var e,s,i=this.isAbsolute(r);t.root=this.rootname(r),s=i||this.hasProtocol(r)?1:0;let o=-1,a=0,l=-1,u=!0,c=r.length-1,d=0;for(;c>=s;--c){if(47===(e=r.charCodeAt(c))){if(u)continue;a=c+1;break}-1===l&&(u=!1,l=c+1),46===e?-1===o?o=c:1!==d&&(d=1):-1!==o&&(d=-1)}-1===o||-1===l||0===d||1===d&&o===l-1&&o===a+1?-1!==l&&(0===a&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(0===a&&i?(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)}return t},sep:"/",delimiter:":",joinExtensions:[".html"]},Ct=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>"string"==typeof i||e?t(i):i):r);function xh(r){var e=r.match(/\{(.*?)\}/g),i=[];if(e){const s=[];e.forEach(n=>{n=n.substring(1,n.length-1).split(","),s.push(n)}),function yh(r,t,e,i,s){var n=t[e];for(let o=0;o<n.length;o++){var a=n[o];e<t.length-1?yh(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}(r,s,0,e,i)}else i.push(r);return i}const br=r=>!Array.isArray(r);var D0=Object.defineProperty,U0=Object.defineProperties,k0=Object.getOwnPropertyDescriptors,Th=Object.getOwnPropertySymbols,$0=Object.prototype.hasOwnProperty,L0=Object.prototype.propertyIsEnumerable,Sh=(r,t,e)=>t in r?D0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ue=(r,t)=>{for(var e in t=t||{})$0.call(t,e)&&Sh(r,e,t[e]);if(Th)for(var e of Th(t))L0.call(t,e)&&Sh(r,e,t[e]);return r};class re{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;if(this._bundleIdConnector=null!=(e=t.connector)?e:this._bundleIdConnector,this._createBundleAssetId=null!=(e=t.createBundleAssetId)?e:this._createBundleAssetId,this._extractAssetIdFromBundle=null!=(e=t.extractAssetIdFromBundle)?e:this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","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("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>encodeURIComponent(i)+"="+encodeURIComponent(e[i])).join("&")}}getAlias(t){var{alias:t,src:i}=t;return Ct(t||i,s=>"string"==typeof s?s:Array.isArray(s)?s.map(n=>{var o;return null!=(o=null==n?void 0:n.src)?o:n}):null!=s&&s.src?s.src:s,!0)}addManifest(t){this._manifest,(this._manifest=t).bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;(s=Array.isArray(e)?s:Object.entries(e).map(([n,o])=>"string"==typeof o||Array.isArray(o)?{alias:n,src:o}:Ue({alias:n},o))).forEach(n=>{var o=n.src,a=n.alias;let l;if("string"==typeof a){var u=this._createBundleAssetId(t,a);i.push(u),l=[a,u]}else{const u=a.map(c=>this._createBundleAssetId(t,c));i.push(...u),l=[...a,...u]}this.add(((r,t)=>U0(r,k0(t)))(Ue({},n),{alias:l,src:o}))}),this._bundles[t]=i}add(t){var e=[];Array.isArray(t)?e.push(...t):e.push(t),Ct(e).forEach(s=>{var n=s.src;let{data:o,format:a,loadParser:l}=s;const u=Ct(n).map(p=>"string"==typeof p?xh(p):Array.isArray(p)?p:[p]),c=this.getAlias(s),d=[];u.forEach(p=>{p.forEach(f=>{var m;let b={};if("object"!=typeof f){b.src=f;for(let x=0;x<this._parsers.length;x++){var y=this._parsers[x];if(y.test(f)){b=y.parse(f);break}}}else o=null!=(m=f.data)?m:o,a=null!=(m=f.format)?m:a,l=null!=(m=f.loadParser)?m:l,b=Ue(Ue({},b),f);if(!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}),d.push(b)})}),c.forEach(p=>{this._assetMap[p]=d})})}resolveBundle(t){var e=br(t);t=Ct(t);const i={};return t.forEach(s=>{var n=this._bundles[s];if(n){var o=this.resolve(n),a={};for(const l in o){var u=o[l];a[this._extractAssetIdFromBundle(s,l)]=u}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){var e=this.resolve(t);if("string"==typeof t)return e.src;var i={};for(const s in e)i[s]=e[s].src;return i}resolve(t){var e=br(t);t=Ct(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);null!=o&&o.priority.forEach(a=>{o.params[a].forEach(l=>{var u=n.filter(c=>!!c[a]&&c[a]===l);u.length&&(n=u)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){return this._defaultSearchParams?t+(/\?/.test(t)?"&":"?")+this._defaultSearchParams:t}_buildResolvedAsset(t,e){var{aliases:e,data:o,loadParser:a,format:l}=e;return(this._basePath||this._rootPath)&&(t.src=mt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=null!=(e=null!=e?e:t.alias)?e:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Ue(Ue({},o||{}),t.data),t.loadParser=null!=a?a:t.loadParser,t.format=null!=(e=null!=l?l:t.format)?e:Eh(t.src),t}}function Eh(r){return r.split(".").pop().split("?").shift().split("#").shift()}re.RETINA_PREFIX=/@([0-9\.]+)x/;const yi=(r,t)=>((t=t.split("?")[1])&&(r+="?"+t),r),Ah=class si{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof P?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e,(e=parseFloat(e.meta.scale))?(this.resolution=e,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=si.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;for(var i=si.BATCH_SIZE;e-t<i&&e<this._frameKeys.length;){var s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a,l=null;var u=!1!==n.trimmed&&n.sourceSize?n.sourceSize:n.frame,u=new z(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);a=n.rotated?new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),!1!==n.trimmed&&n.spriteSourceSize&&(l=new z(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new P({source:this.textureSource,frame:a,orig:u,trim:l,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:s.toString()})}e++}}_processAnimations(){var t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){var s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){var t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*si.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*si.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(null!=(t=this._texture)&&t.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Ah.BATCH_SIZE=1e3;let Fn=Ah;const H0=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];var wh={extension:r.Asset,cache:{test:r=>r instanceof Fn,getCacheableAssets:(r,t)=>function Ph(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=mt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{o=Ph([s+"/"+t.data.meta.related_multi_packs[o]],n,!0),Object.assign(i,o)})}return i}(r,t,!1)},resolver:{extension:{type:r.ResolveParser,name:"resolveSpritesheet"},test:r=>{var e=(r=r.split("?")[0].split(".")).pop(),r=r.pop();return"json"===e&&H0.includes(r)},parse:r=>{var t,i=r.split(".");return{resolution:parseFloat(null!=(t=null==(t=re.RETINA_PREFIX.exec(r))?void 0:t[1])?t:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:r.LoadParser,priority:xt.Normal,name:"spritesheetLoader"},async testParse(r,t){return".json"===mt.extname(t.src).toLowerCase()&&!!r.frames},async parse(r,t,e){var n,c,{texture:i,imageFilename:a,textureOptions:l}=null!=(i=null==t?void 0:t.data)?i:{};let u=mt.dirname(t.src);u&&u.lastIndexOf("/")!==u.length-1&&(u+="/"),c=i instanceof P?i:(i=yi(u+(null!=a?a:r.meta.image),t.src),(await e.load([{src:i,data:l}]))[i]);const d=new Fn(c.source,r);await d.parse();var g,i=null==(a=null==r?void 0:r.meta)?void 0:a.related_multi_packs;if(Array.isArray(i)){var f=[];for(const _ of i)"string"!=typeof _||(g=u+_,null!=(n=t.data)&&n.ignoreMultiPack)||(g=yi(g,t.src),f.push(e.load({src:g,data:{textureOptions:l,ignoreMultiPack:!0}})));r=await Promise.all(f),(d.linkedSheets=r).forEach(_=>{_.linkedSheets=[d].concat(d.linkedSheets.filter(g=>g!==_))})}return d},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};function Dn(r,t,e){var o,a,{width:i,height:s}=e.orig;(e=e.trim)?(o=e.width,a=e.height,r.minX=e.x-t._x*i,r.maxX=r.minX+o,r.minY=e.y-t._y*s,r.maxY=r.minY+a):(r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*s,r.maxY=r.minY+s)}B.add(wh);var X0=Object.defineProperty,xi=Object.getOwnPropertySymbols,Rh=Object.prototype.hasOwnProperty,Mh=Object.prototype.propertyIsEnumerable,Ch=(r,t,e)=>t in r?X0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Ft extends Lt{constructor(t=P.EMPTY){var t=t instanceof P?{texture:t}:t,{texture:i=P.EMPTY,anchor:s,roundPixels:n,width:o,height:a}=t;super(((r,t)=>{for(var e in t=t||{})Rh.call(t,e)&&Ch(r,e,t[e]);if(xi)for(var e of xi(t))Mh.call(t,e)&&Ch(r,e,t[e]);return r})({label:"Sprite"},((r,t)=>{var e={};for(i in r)Rh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&xi)for(var i of xi(r))t.indexOf(i)<0&&Mh.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","anchor","roundPixels","width","height"]))),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=null!=n&&n,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}static from(t,e=!1){return t instanceof P?new Ft(t):new Ft(P.from(t,e))}set texture(t){t=t||P.EMPTY;var 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 Dn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){var t=this._anchor,e=this._texture,i=this._bounds,{width:e,height:n}=e.orig;i.minX=-t._x*e,i.maxX=i.minX+e,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){super.destroy(t),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,this._texture.destroy(t)),this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?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||{}).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 i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null==e&&(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const V0=new nt;function Ti(r,t,e){var i=V0;r.measurable=!0,dr(r,e,i),t.addBoundsMask(i),r.measurable=!1}function Si(r,t,e){var i=$t.get(),s=(r.measurable=!0,ct.get().identity());hi(r,i,Un(r,e,s)),r.measurable=!1,t.addBoundsMask(i),ct.return(s),$t.return(i)}function Un(r,t,e){return r&&r!==t&&(Un(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class kn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",null!=t&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Ft),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Ti(this.mask,t,e)}addLocalBounds(t,e){Si(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Ft}}kn.extension=r.MaskEffect;class $n{constructor(t){this.priority=0,this.pipe="colorMask",null!=t&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}$n.extension=r.MaskEffect;class Ln{constructor(t){this.priority=0,this.pipe="stencilMask",null!=t&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Ti(this.mask,t,e)}addLocalBounds(t,e){Si(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof lt}}Ln.extension=r.MaskEffect;class Nt extends Q{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,i=this._resolution){return(t=super.resize(t,e,i))&&this.resizeCanvas(),t}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"))}}Nt.extension=r.TextureSource;class ie extends Q{constructor(t){var e;t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement&&((e=H.get().createCanvas(t.resource.width,t.resource.height)).getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e),super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ie.extension=r.TextureSource;let Nn;async function Hn(){return Nn=null==Nn?(async()=>{var i,s,e,t=document.createElement("canvas").getContext("webgl");return t&&(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()}))&&(i=t.createTexture(),t.bindTexture(t.TEXTURE_2D,i),s=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),e=new Uint8Array(4),t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,e),t.deleteFramebuffer(s),t.deleteTexture(i),null!=(s=t.getExtension("WEBGL_lose_context"))&&s.loseContext(),e[0]<=e[3])?"premultiplied-alpha":"premultiply-alpha-on-upload"})():Nn}var W0=Object.defineProperty,Y0=Object.defineProperties,K0=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,q0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,Gh=(r,t,e)=>t in r?W0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xn=(r,t)=>{for(var e in t=t||{})q0.call(t,e)&&Gh(r,e,t[e]);if(Oh)for(var e of Oh(t))Z0.call(t,e)&&Gh(r,e,t[e]);return r},Ei=class ky extends Q{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=Xn(Xn({},ky.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==t.autoPlay,this.alphaMode=null!=(e=t.alphaMode)?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),!1!==t.autoLoad&&this.load()}updateFrame(){var t;this.destroyed||(this._updateFPS&&(t=ut.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){const t=this.resource,e=this.options;(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 Hn(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,void 0!==e.preloadTimeoutMs&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())})}return 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(){var t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return 2<this.resource.readyState}_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(){var 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();var 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&&(ut.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ut.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ut.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ei.extension=r.TextureSource,Ei.defaultOptions=(r=>Y0(r,K0({autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1})))(Xn({},Q.defaultOptions)),Ei.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let vr=Ei;const W=new 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){var i=Ct(t);let s;for(let l=0;l<this.parsers.length;l++){var u=this.parsers[l];if(u.test(e)){s=u.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{})),o=(s||i.forEach(l=>{n.set(l,e)}),[...n.keys()]),a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{s&&s[l],this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){this._cacheMap.has(t)&&((t=this._cacheMap.get(t)).cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)}))}get parsers(){return this._parsers}},jn=[];function zn(r={}){var t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s<jn.length;s++){var n=jn[s];if(n.test(e))return new n(i)}throw new Error("Could not find a source type for resource: "+i.resource)}function Bh(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,s=e?r:{resource:r};return!t&&W.has(i)?W.get(i):((r=new P({source:zn(s)})).on("destroy",()=>{W.has(i)&&W.remove(i)}),t||W.set(i,r),r)}function Ih(r,t=!1){return"string"==typeof r?W.get(r):r instanceof Q?new P({source:r}):Bh(r,t)}B.handleByList(r.TextureSource,jn),P.from=Ih,Q.from=zn,B.add(kn,$n,Ln,vr,ie,Nt,pi);class Ht{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){var s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(this._dirty){this._dirty=!1;var t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}}setResource(t,e){var n=this.resources[e];t!==n&&(n&&null!=(n=t.off)&&n.call(t,"change",this.onResourceChange,this),null!=(n=t.on)&&n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){var e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t,e=this.resources;for(const i in e){var s=e[i];null!=(t=s.off)&&t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){var e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}let yr;function Vn(){return yr=!yr||null!=yr&&yr.isContextLost()?H.get().createCanvas().getContext("webgl",{}):yr}const e1=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function Fh(r,t){if(0===r)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");var e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){var i=e1.replace(/%forloop%/gi,function(r){let t="";for(let e=0;e<r;++e)0<e&&(t+=`
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}(r));if(t.shaderSource(e,i),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS))break;r=r/2|0}}finally{t.deleteShader(e)}return r}let ke=null;function be(){var t;return ke||(t=Vn(),ke=Fh(ke=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),t),null!=(t=t.getExtension("WEBGL_lose_context"))&&t.loseContext()),ke}const Dh={};function Ai(r,t){let e=2166136261;for(let i=0;i<t;i++)e^=r[i].uid,e=Math.imul(e,16777619),e>>>=0;return Dh[e]||function(r,t,e){var i={};let s=0;Wn=Wn||be();for(let o=0;o<Wn;o++){var a=o<t?r[o]:P.EMPTY.source;i[s++]=a.source,i[s++]=a.style}var n=new Ht(i);return Dh[e]=n}(r,t,e)}let Wn=0;class ve{constructor(t){"number"==typeof t?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._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=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")}}}function Pi(r,t){var e=r.byteLength/8|0,i=new Float64Array(r,0,e);new Float64Array(t,0,e).set(i),0<(i=r.byteLength-8*e)&&(r=new Uint8Array(r,8*e,i),new Uint8Array(t,8*e,i).set(r))}const Uh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var J=(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))({});function $e(r,t){return"no-premultiply-alpha"===t.alphaMode&&Uh[r]||r}class kh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){var e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}var s1=Object.defineProperty,$h=Object.getOwnPropertySymbols,n1=Object.prototype.hasOwnProperty,o1=Object.prototype.propertyIsEnumerable,Lh=(r,t,e)=>t in r?s1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nh=(r,t)=>{for(var e in t=t||{})n1.call(t,e)&&Lh(r,e,t[e]);if($h)for(var e of $h(t))o1.call(t,e)&&Lh(r,e,t[e]);return r};class Hh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new kh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Xh=[];let Yn=0;function jh(){return 0<Yn?Xh[--Yn]:new Hh}function zh(r){Xh[Yn++]=r}let xr=0;(Ei=class sn{constructor(t={}){this.uid=K("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],sn.defaultOptions.maxTextures=null!=(e=sn.defaultOptions.maxTextures)?e:be();var{maxTextures:e,attributesInitialSize:t,indicesInitialSize:n}=t=Nh(Nh({},sn.defaultOptions),t);this.attributeBuffer=new ve(4*t),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0;for(let t=this.attributeSize=0;t<this.batchIndex;t++)zh(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){(this._elements[this.elementSize++]=t)._indexStart=this.indexSize,t._attributeStart=this.attributeSize,(t._batcher=this).indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){var i=t._batch.textures.ids[e._source.uid];return!(!i&&0!==i||(t._textureId=i,t.texture=e,0))}updateElement(t){this.dirty=!0;var 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){var e=this._elements;if(e[this.elementStart]){let i=jh(),s=i.textures;s.clear();var n=e[this.elementStart];let o=$e(n.blendMode,n.texture._source),a=n.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);var l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer;let d=this._batchIndexSize,p=this._batchIndexStart,f="startBatch";var m=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){var g=e[_],b=(e[_]=null,g.texture._source),x=$e(g.blendMode,b),y=o!==x||a!==g.topology;b._batchTick!==xr||y?(b._batchTick=xr,(s.count>=m||y)&&(this._finishBatch(i,p,d-p,s,o,a,t,f),f="renderBatch",p=d,o=x,a=g.topology,i=jh(),(s=i.textures).clear(),++xr),g._textureId=b._textureBindLocation=s.count,s.ids[b.uid]=s.count,s.textures[s.count++]=b,g._batch=i,d+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize))):(g._textureId=b._textureBindLocation,d+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=i)}0<s.count&&(this._finishBatch(i,p,d-p,s,o,a,t,f),p=d,++xr),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=d}}_finishBatch(t,e,i,s,n,o,a,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++xr,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){t=Math.max(t,2*this.attributeBuffer.size),t=new ve(t),Pi(this.attributeBuffer.rawBinaryData,t.rawBinaryData),this.attributeBuffer=t}_resizeIndexBuffer(t){var e=this.indexBuffer,t=Math.max(t,1.5*e.length),s=new(65535<(t+=t%2)?Uint32Array:Uint16Array)(t);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)s[n]=e[n];else Pi(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,s){var n=t.indices,o=t.indexSize,a=t.indexOffset,l=t.attributeOffset;for(let u=0;u<o;u++)e[i++]=s+n[u+a]-l}destroy(){for(let t=0;t<this.batches.length;t++)zh(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}).defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};var L=(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))({});class ht extends ft{constructor(t){let{data:e,size:i}=t;var{usage:t,label:n,shrinkToFit:o}=t,a=(super(),this.uid=K("buffer"),this._resourceType="buffer",this._resourceId=K("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,null==i&&(i=null==e?void 0:e.byteLength),!!e);this.descriptor={size:i,usage:t,mappedAtCreation:a,label:n},this.shrinkToFit=null==o||o}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&L.STATIC)}set static(t){t?this.descriptor.usage|=L.STATIC:this.descriptor.usage&=~L.STATIC}setDataWithSize(t,e,i){this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t||(e=this._data,this._data=t,this._dataInt32=null,e&&e.length===t.length)||!this.shrinkToFit&&e&&t.byteLength<e.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=K("resource"),this.emit("change",this))}update(t){this._updateSize=null!=t?t:this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Kn(r,t){if(!(r instanceof ht)){let e=t?L.INDEX:L.VERTEX;r instanceof Array&&(e=t?(r=new Uint32Array(r),L.INDEX|L.COPY_DST):(r=new Float32Array(r),L.VERTEX|L.COPY_DST)),r=new ht({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function Yh(r,t,e){if(r=r.getAttribute(t)){var s=r.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;var t=s.BYTES_PER_ELEMENT,c=(r.offset||0)/t,d=(r.stride||8)/t;for(let p=c;p<s.length;p+=d){var f=s[p],m=s[p+1];f>a&&(a=f),m>l&&(l=m),f<n&&(n=f),m<o&&(o=m)}e.minX=n,e.minY=o,e.maxX=a,e.maxY=l}else e.minX=0,e.minY=0,e.maxX=0,e.maxY=0;return e}class ye extends ft{constructor(t={}){super(),this.uid=K("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new nt,this._boundsDirty=!0;var{attributes:i,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},i)for(const o in i)this.addAttribute(o,i[o]);this.instanceCount=null!=(t=t.instanceCount)?t:1,s&&this.addIndex(s),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){var e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){(e=e instanceof ht||Array.isArray(e)||e.BYTES_PER_ELEMENT?{buffer:e}:e).buffer=Kn(e.buffer,!1),-1===this.buffers.indexOf(e.buffer)&&(this.buffers.push(e.buffer),e.buffer.on("update",this.onBufferUpdate,this),e.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=e}addIndex(t){this.indexBuffer=Kn(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Yh(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const l1=new Float32Array(1),u1=new Uint32Array(1);class Kh extends ye{constructor(){var t=new ht({data:l1,label:"attribute-batch-buffer",usage:L.VERTEX|L.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new ht({data:u1,label:"index-batch-buffer",usage:L.INDEX|L.COPY_DST,shrinkToFit:!1})})}}const qn=Object.create(null),qh=Object.create(null);function Le(r,t){let e=qh[r];return void 0===e&&(void 0===qn[t]&&(qn[t]=1),qh[r]=e=qn[t]++),e}let wi;function Zh(){var r;return wi||(wi="mediump",(r=Vn())&&r.getShaderPrecisionFormat&&(wi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")),wi}function Qh(r,t,e){return t?r:e?`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${r=r.replace("out vec4 finalColor;","")}
`:`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${r}
`}function Jh(r,t,e){var i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;return"precision"===r.substring(0,9)?"highp"!==i&&"precision highp"===r.substring(0,15)?r.replace("precision highp","precision mediump"):r:`precision ${e="highp"===(e=e?t.requestedFragmentPrecision:t.requestedVertexPrecision)&&"highp"!==i?"mediump":e} float;
`+r}function td(r,t){return t?`#version 300 es
`+r:r}const c1={},h1={};function ed(r,{name:t="pixi-program"},e=!0){return t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex",(e=e?c1:h1)[t]?(e[t]++,t+="-"+e[t]):e[t]=1,-1!==r.indexOf("#define SHADER_NAME")?r:"#define SHADER_NAME "+t+`
`+r}function rd(r,t){return t?r.replace("#version 300 es",""):r}var d1=Object.defineProperty,id=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,sd=(r,t,e)=>t in r?d1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nd=(r,t)=>{for(var e in t=t||{})p1.call(t,e)&&sd(r,e,t[e]);if(id)for(var e of id(t))f1.call(t,e)&&sd(r,e,t[e]);return r};const Zn={stripVersion:rd,ensurePrecision:Jh,addProgramDefines:Qh,setProgramName:ed,insertVersion:td},Qn=Object.create(null),od=class Gu{constructor(t){const e=-1!==(t=nd(nd({},Gu.defaultOptions),t)).fragment.indexOf("#version 300 es"),i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Zh()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(Zn).forEach(o=>{var a=i[o];s=Zn[o](s,a,!0),n=Zn[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Le(this.vertex+":"+this.fragment,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){var e=t.vertex+":"+t.fragment;return Qn[e]||(Qn[e]=new Gu(t)),Qn[e]}};od.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Tt=od;const ad={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 qt(r){return null!=(r=ad[r])?r:ad.float32}const m1={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",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function ld({source:r,entryPoint:t}){var i={};if(-1!==(t=r.indexOf("fn "+t))){var n=r.indexOf("->",t);if(-1!==n)for(var l,o=r.substring(t,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;null!==(l=a.exec(o));){var e=null!=(e=m1[l[3]])?e:"float32";i[l[2]]={location:parseInt(l[1],10),format:e,stride:qt(e).stride,offset:0,instance:!1,start:0}}}return i}function Ri(r){var t;const n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*(\w+)/,c=/(\w+)\s*:\s*([\w\<\>]+)/g,d=/struct\s+(\w+)/,p=null==(t=r.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g))?void 0:t.map(m=>({group:parseInt(m.match(n)[1],10),binding:parseInt(m.match(o)[1],10),name:m.match(a)[2],isUniform:"<uniform>"===m.match(a)[1],type:m.match(l)[1]}));return p?(t=null!=(r=null==(t=r.match(/struct\s+(\w+)\s*{([^}]+)}/g))?void 0:t.map(m=>{var _=m.match(d)[1];return(m=m.match(c).reduce((b,x)=>{var[x,T]=x.split(":");return b[x.trim()]=T.trim(),b},{}))?{name:_,members:m}:null}).filter(({name:m})=>p.some(_=>_.type===m)))?r:[],{groups:p,structs:t}):{groups:[],structs:[]}}var Ne=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))({});function ud({groups:r}){var t=[];for(let e=0;e<r.length;e++){var i=r[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ne.VERTEX|Ne.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===i.type?t[i.group].push({binding:i.binding,visibility:Ne.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===i.type&&t[i.group].push({binding:i.binding,visibility:Ne.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function cd({groups:r}){var t=[];for(let e=0;e<r.length;e++){var i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function hd(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>!e.has(o.name)&&(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>(o=o.name+"-"+o.binding,!i.has(o)&&(i.add(o),!0)));return{structs:s,groups:n}}const Jn=Object.create(null);class gt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var u,{fragment:t,vertex:n,layout:o,gpuLayout:a,name:l}=t;this.name=l,this.fragment=t,this.vertex=n,t.source===n.source?(l=Ri(t.source),this.structsAndGroups=l):(u=Ri(n.source),t=Ri(t.source),this.structsAndGroups=hd(u,t)),this.layout=null!=o?o:cd(this.structsAndGroups),this.gpuLayout=null!=a?a:ud(this.structsAndGroups),this.autoAssignGlobalUniforms=void 0!==(null==(l=this.layout[0])?void 0:l.globalUniforms),this.autoAssignLocalUniforms=void 0!==(null==(n=this.layout[1])?void 0:n.localUniforms),this._generateProgramKey()}_generateProgramKey(){var{vertex:t,fragment:e}=this,t=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Le(t,"program")}get attributeData(){return null==this._attributeData&&(this._attributeData=ld(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){var e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:`+t.vertex.entryPoint;return Jn[e]||(Jn[e]=new gt(t)),Jn[e]}}function to(r,t,e){if(r)for(const i in r){var n=t[i.toLocaleLowerCase()];if(n){let o=r[i];"header"===i&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const dd=/\{\{(.*?)\}\}/g;function eo(r){const i={};return(null!=(r=null==(r=r.match(dd))?void 0:r.map(s=>s.replace(/[{()}]/g,"")))?r:[]).forEach(s=>{i[s]=[]}),i}function pd(r,t){for(var e,i=/@in\s+([^;]+);/g;null!==(e=i.exec(r));)t.push(e[1])}function ro(r,t,e=!1){const i=[];pd(t,i),r.forEach(a=>{a.header&&pd(a.header,i)}),r=i,e&&r.sort(),e=r.map((a,l)=>` @location(${l}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${e}
`)}function fd(r,t){for(var e,i=/@out\s+([^;]+);/g;null!==(e=i.exec(r));)t.push(e[1])}function md(r,t){const e=[];fd(t,e),r.forEach(l=>{l.header&&fd(l.header,e)});let i=0;var r=e.sort().map(l=>-1<l.indexOf("builtin")?l:`@location(${i++}) `+l).join(`,
`),n=e.sort().map(l=>` var ${l.replace(/@.*?\s+/g,"")};`).join(`
`),o=`return VSOutput(
${e.sort().map(l=>" "+((l=/\b(\w+)\s*:/g.exec(l))?l[1]:"")).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=(a=(a=a.replace("{{struct}}",`
${r}
`)).replace("{{start}}",`
${n}
`)).replace("{{return}}",`
${o}
`)}function io(r,t){let e=r;for(const i in t){var s=t[i];e=s.join(`
`).length?e.replace(`{{${i}}}`,`//-----${i} START-----//
${s.join(`
`)}
//----${i} FINISH----//`):e.replace(`{{${i}}}`,"")}return e}const xe=Object.create(null),so=new Map;let b1=0;function gd({template:r,bits:t}){var s,e=bd(r,t);return xe[e]||({vertex:r,fragment:s}=function(r,t){var e=t.map(o=>o.vertex).filter(o=>!!o),t=t.map(o=>o.fragment).filter(o=>!!o);return{vertex:md(e,ro(e,r.vertex,!0)),fragment:ro(t,r.fragment,!0)}}(r,t),xe[e]=vd(r,s,t)),xe[e]}function _d({template:r,bits:t}){var e=bd(r,t);return xe[e]||(xe[e]=vd(r.vertex,r.fragment,t)),xe[e]}function bd(r,t){return t.map(e=>(so.has(e)||so.set(e,b1++),so.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function vd(r,t,e){const i=eo(r),s=eo(t);return e.forEach(n=>{to(n.vertex,i,n.name),to(n.fragment,s,n.name)}),{vertex:io(r,i),fragment:io(t,s)}}const yd=`
@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}}
};
`,xd=`
@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;
};
`,Td=`
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}}
}
`,Sd=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,Ed={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;
`}},y1={name:"global-uniforms-ubo-bit",vertex:{header:`
uniform globalUniforms {
mat3 uProjectionMatrix;
mat3 uWorldTransformMatrix;
vec4 uWorldColorAlpha;
vec2 uResolution;
};
`}},Ad={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};var x1=Object.defineProperty,Pd=Object.getOwnPropertySymbols,T1=Object.prototype.hasOwnProperty,S1=Object.prototype.propertyIsEnumerable,wd=(r,t,e)=>t in r?x1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;function He({bits:r,name:t}){return r=gd({template:{fragment:xd,vertex:yd},bits:[Ed,...r]}),gt.from({name:t,vertex:{source:r.vertex,entryPoint:"main"},fragment:{source:r.fragment,entryPoint:"main"}})}function Xe({bits:r,name:t}){return new Tt(((r,t)=>{for(var e in t=t||{})T1.call(t,e)&&wd(r,e,t[e]);if(Pd)for(var e of Pd(t))S1.call(t,e)&&wd(r,e,t[e]);return r})({name:t},_d({template:{vertex:Td,fragment:Sd},bits:[Ad,...r]})))}const Mi={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},Ci={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},no={};function Oi(r){return no[r]||(no[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;
${function(r){var t=[];if(1===r)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 i=0;i<r;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
`)}(r)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${function(r){var t=[];if(1===r)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(`
`)}(r)}
`}}),no[r]}const oo={};function Gi(r){return oo[r]||(oo[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:`
${function(r){var t=[];for(let e=0;e<r;e++)0<e&&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(`
`)}(r)}
`}}),oo[r]}const je={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;
}
`}},ze={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;
}
`}},ao=["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>"],Rd=ao.reduce((r,t)=>(r[t]=!0,r),{});function Md(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 R1=Object.defineProperty,Cd=Object.getOwnPropertySymbols,M1=Object.prototype.hasOwnProperty,C1=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?R1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gd=(r,t)=>{for(var e in t=t||{})M1.call(t,e)&&Od(r,e,t[e]);if(Cd)for(var e of Cd(t))C1.call(t,e)&&Od(r,e,t[e]);return r};(Bd=class $y{constructor(t,e){this._touched=0,this.uid=K("uniform"),this._resourceType="uniformGroup",this._resourceId=K("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e=Gd(Gd({},$y.defaultOptions),e);var i,n={};for(const o in this.uniformStructures=t){var a=t[o];if(a.name=o,a.size=null!=(i=a.size)?i:1,!Rd[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: `+ao.join(", "));null==a.value&&(a.value=Md(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Le(Object.keys(n).map(o=>o+"-"+t[o].type).join("-"),"uniform-group")}update(){this._dirtyId++}}).defaultOptions={ubo:!1,isStatic:!1};let st=Bd;const Id={};function Bi(r){var t=Id[r];if(!t){var e=new Int32Array(r);for(let i=0;i<r;i++)e[i]=i;t=Id[r]=new st({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0})}return t}var _t=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))({}),O1=Object.defineProperty,Ii=Object.getOwnPropertySymbols,Fd=Object.prototype.hasOwnProperty,Dd=Object.prototype.propertyIsEnumerable,Ud=(r,t,e)=>t in r?O1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class St extends ft{constructor(t){super(),this.uid=K("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,void 0===o&&(o=0,e&&(o|=_t.WEBGPU),i)&&(o|=_t.WEBGL),this.compatibleRenderers=o;const l={};if((n=n||s?n:{})&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const u in a)for(const c in a[u]){var d=a[u][c];l[d]={group:u,binding:c,name:d}}else if(e&&s&&!a)t=e.structsAndGroups.groups,a={},t.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c});else if(n){s={},a={},e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c});let u=0;for(const c in n)l[c]||(s[99]||(s[99]=new Ht,this._ownedBindGroups.push(s[99])),l[c]={group:99,binding:u,name:c},a[99]=a[99]||{},a[99][u]=c,u++);for(const c in n){const d=c;let p=n[c];p.source||p._resourceType||(p=new st(p));var f=l[d];f&&(s[f.group]||(s[f.group]=new Ht,this._ownedBindGroups.push(s[f.group])),s[f.group].setResource(p,f.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,l)}addResource(t,e,i){var s;(s=this._uniformBindMap)[e]||(s[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new Ht,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){var i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){this.emit("destroy",this),t&&(null!=(t=this.gpuProgram)&&t.destroy(),null!=(t=this.glProgram))&&t.destroy(),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){var{gpu:i,gl:s}=t,t=((r,t)=>{var e={};for(i in r)Fd.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ii)for(var i of Ii(r))t.indexOf(i)<0&&Dd.call(r,i)&&(e[i]=r[i]);return e})(t,["gpu","gl"]);let o,a;return i&&(o=gt.from(i)),s&&(a=Tt.from(s)),new St(((r,t)=>{for(var e in t=t||{})Fd.call(t,e)&&Ud(r,e,t[e]);if(Ii)for(var e of Ii(t))Dd.call(t,e)&&Ud(r,e,t[e]);return r})({gpuProgram:o,glProgram:a},t))}}class kd extends St{constructor(t){super({glProgram:Xe({name:"batch",bits:[Ci,Gi(t),ze]}),gpuProgram:He({name:"batch",bits:[Mi,Oi(t),je]}),resources:{batchSamplers:Bi(t)}})}}let $d=null,Fi=((Bd=class Ly extends Ei{constructor(){super(...arguments),this.geometry=new Kh,this.shader=$d=$d||new kd(this.maxTextures),this.name=Ly.extension.name,this.vertexSize=6}packAttributes(t,e,i,s,n){var o=n<<16|65535&t.roundPixels,l=(n=t.transform).a,u=n.b,c=n.c,d=n.d,p=n.tx,f=n.ty,{positions:m,uvs:_}=t,g=t.color,x=(n=t.attributeOffset)+t.attributeSize;for(let y=n;y<x;y++){var T=2*y,A=m[T],S=m[1+T];e[s++]=l*A+c*S+p,e[s++]=d*S+u*A+f,e[s++]=_[T],e[s++]=_[1+T],i[s++]=g,i[s++]=o}}packQuadAttributes(t,e,i,s,n){var o=t.texture,l=(a=t.transform).a,u=a.b,c=a.c,d=a.d,p=a.tx,a=a.ty,_=(m=t.bounds).maxX,g=m.minX,b=m.maxY,m=m.minY,o=o.uvs,T=t.color,n=n<<16|65535&t.roundPixels;e[s+0]=l*g+c*m+p,e[s+1]=d*m+u*g+a,e[s+2]=o.x0,e[s+3]=o.y0,i[s+4]=T,i[s+5]=n,e[s+6]=l*_+c*m+p,e[s+7]=d*m+u*_+a,e[s+8]=o.x1,e[s+9]=o.y1,i[s+10]=T,i[s+11]=n,e[s+12]=l*_+c*b+p,e[s+13]=d*b+u*_+a,e[s+14]=o.x2,e[s+15]=o.y2,i[s+16]=T,i[s+17]=n,e[s+18]=l*g+c*b+p,e[s+19]=d*b+u*g+a,e[s+20]=o.x3,e[s+21]=o.y3,i[s+22]=T,i[s+23]=n}}).extension={type:[r.Batcher],name:"default"},Bd);function lo(r,t,e,i,s,n,o,a=null){let l=0;e*=t,s*=n;for(var u=a.a,c=a.b,d=a.c,p=a.d,f=a.tx,m=a.ty;l<o;){var _=r[e],g=r[e+1];i[s]=u*_+d*g+f,i[s+1]=c*_+p*g+m,s+=n,e+=t,l++}}function uo(r,t,e,i){let s=0;for(t*=e;s<i;)r[t]=0,r[t+1]=0,t+=e,s++}function Di(r,t,e,i,s){var n=t.a,o=t.b,a=t.c,l=t.d,u=t.tx,c=t.ty;e=e||0,i=i||2,s=s||r.length/i-e;let d=e*i;for(let p=0;p<s;p++){var f=r[d],m=r[d+1];r[d]=n*f+a*m+u,r[d+1]=o*f+l*m+c,d+=i}}const I1=new M;class Ui{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.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){var t=(t=this.baseColor)>>16|65280&t|(255&t)<<16,i=this.renderable;return i?gn(t,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):t+(255*this.alpha<<24)}get transform(){var t;return(null==(t=this.renderable)?void 0:t.groupTransform)||I1}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"}}var F1=Object.defineProperty,D1=Object.defineProperties,U1=Object.getOwnPropertyDescriptors,Nd=Object.getOwnPropertySymbols,k1=Object.prototype.hasOwnProperty,$1=Object.prototype.propertyIsEnumerable,Hd=(r,t,e)=>t in r?F1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$i=(r,t)=>D1(r,U1(t));const Zt={extension:{type:r.ShapeBuilder,name:"circle"},build(r,t){let e,i,s,n,o,a;if("circle"===r.type)e=r.x,i=r.y,o=a=r.radius,s=n=0;else if("ellipse"===r.type){var T=r;e=T.x,i=T.y,o=T.halfWidth,a=T.halfHeight,s=n=0}else{const T=r,A=T.width/2,S=T.height/2;e=T.x+A,i=T.y+S,o=a=Math.max(0,Math.min(T.radius,Math.min(A,S))),s=A-o,n=S-a}if(0<=o&&0<=a&&0<=s&&0<=n){var l=Math.ceil(2.3*Math.sqrt(o+a));if(0!=(r=8*l+(s?4:0)+(n?4:0)))if(0===l)t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;else{let c=0,d=4*l+(s?2:0)+2,p=d,f=r,m=s+o,_=n,g=e+m,b=e-m,x=i+_;if(t[c++]=g,t[c++]=x,t[--d]=x,t[--d]=b,n){const T=i-_;t[p++]=b,t[p++]=T,t[--f]=T,t[--f]=g}for(let T=1;T<l;T++){var A=Math.PI/2*(T/l),S=s+Math.cos(A)*o,A=n+Math.sin(A)*a,U=e+S,S=e-S,R=i+A,A=i-A;t[c++]=U,t[c++]=R,t[--d]=R,t[--d]=S,t[p++]=S,t[p++]=A,t[--f]=A,t[--f]=U}m=s,_=n+a,g=e+m,b=e-m,x=i+_,r=i-_,t[c++]=g,t[c++]=x,t[--f]=r,t[--f]=g,s&&(t[c++]=b,t[c++]=x,t[--f]=r,t[--f]=b)}}return t},triangulate(r,t,e,i,s,n){if(0!==r.length){let o=0,a=0;for(let c=0;c<r.length;c+=2)o+=r[c],a+=r[c+1];o/=r.length/2,a/=r.length/2;let l=i;t[l*e]=o,t[l*e+1]=a;var u=l++;for(let c=0;c<r.length;c+=2)t[l*e]=r[c],t[l*e+1]=r[c+1],0<c&&(s[n++]=l,s[n++]=u,s[n++]=l-1),l++;s[n++]=1+u,s[n++]=u,s[n++]=l-1}}},Xd=$i((Bd=(r,t)=>{for(var e in t=t||{})k1.call(t,e)&&Hd(r,e,t[e]);if(Nd)for(var e of Nd(t))$1.call(t,e)&&Hd(r,e,t[e]);return r})({},Zt),{extension:$i(Bd({},Zt.extension),{name:"ellipse"})}),jd=$i(Bd({},Zt),{extension:$i(Bd({},Zt.extension),{name:"roundedRectangle"})}),co=1e-4,ho=1e-4;function zd(r){var t=r.length;if(t<6)return 1;let e=0;for(let i=0,s=r[t-2],n=r[t-1];i<t;i+=2){var o=r[i],a=r[i+1];e+=(o-s)*(a+n),s=o,n=a}return e<0?-1:1}function Vd(r,t,e,i,s,n,o,a){let p,f;return f=o?(p=i,-e):(p=-i,e),o=r-e*s+p,s=t-i*s+f,r=r+e*n+p,e=t+i*n+f,a.push(o,s),a.push(r,e),2}function Te(r,t,e,i,s,n,o,a){var l=e-r,u=i-t;let c=Math.atan2(l,u),d=Math.atan2(s-r,n-t);a&&c<d?c+=2*Math.PI:!a&&c>d&&(d+=2*Math.PI);var p=c,f=d-c,m=Math.abs(f),_=Math.sqrt(l*l+u*u),g=1+(15*m*Math.sqrt(_)/Math.PI>>0),b=f/g;if(p+=b,a){o.push(r,t),o.push(e,i);for(let x=1,y=p;x<g;x++,y+=b)o.push(r,t),o.push(r+Math.sin(y)*_,t+Math.cos(y)*_);o.push(r,t),o.push(s,n)}else{o.push(e,i),o.push(r,t);for(let x=1,y=p;x<g;x++,y+=b)o.push(r+Math.sin(y)*_,t+Math.cos(y)*_),o.push(r,t);o.push(s,n),o.push(r,t)}return 2*g}function Wd(r,t,e,i,s,n){var o=co;if(0!==r.length){var a=t;let l=a.alignment;if(.5!==t.alignment){let Y=zd(r);e&&(Y*=-1),l=(l-.5)*Y+.5}var t=new V(r[0],r[1]),e=new V(r[r.length-2],r[r.length-1]),o=Math.abs(t.x-e.x)<o&&Math.abs(t.y-e.y)<o,f=(i&&(r=r.slice(),o&&(r.pop(),r.pop(),e.set(r[r.length-2],r[r.length-1])),o=.5*(t.x+e.x),e=.5*(e.y+t.y),r.unshift(o,e),r.push(o,e)),s),m=r.length/2;let _=r.length;var g=f.length/2,b=a.width/2,x=b*b,y=a.miterLimit*a.miterLimit;let T=r[0],A=r[1],S=r[2],E=r[3],U=0,O=0,R=-(A-E),w=T-S,D,G,et=Math.sqrt(R*R+w*w);R/=et,w/=et,R*=b,w*=b;var Me,By,rn,Iy,I=2*(1-l),k=2*l;i||("round"===a.cap?_+=Te(T-R*(I-k)*.5,A-w*(I-k)*.5,T-R*I,A-w*I,T+R*k,A+w*k,f,!0)+2:"square"===a.cap&&(_+=Vd(T,A,R,w,I,k,!0,f))),f.push(T-R*I,A-w*I),f.push(T+R*k,A+w*k);for(let Y=1;Y<m-1;++Y){T=r[2*(Y-1)],A=r[2*(Y-1)+1],S=r[2*Y],E=r[2*Y+1],U=r[2*(Y+1)],O=r[2*(Y+1)+1],R=-(A-E),w=T-S,et=Math.sqrt(R*R+w*w),R/=et,w/=et,R*=b,w*=b,D=-(E-O),G=S-U,D=D/(et=Math.sqrt(D*D+G*G))*b,G=G/et*b;var he=S-T,Jr=A-E,ti=S-U,ei=O-E,Oy=he*ti+Jr*ei,tn=Jr*ti-ei*he,ri=tn<0;Math.abs(tn)<.001*Math.abs(Oy)?(f.push(S-R*I,E-w*I),f.push(S+R*k,E+w*k),0<=Oy&&("round"===a.join?_+=Te(S,E,S-R*I,E-w*I,S-D*I,E-G*I,f,!1)+4:_+=2,f.push(S-D*k,E-G*k),f.push(S+D*I,E+G*I))):(rn=(ei*(Oy=(-R+T)*(-w+E)-(-R+S)*(-w+A))-Jr*(By=(-D+U)*(-G+E)-(-D+S)*(-G+O)))/tn,Oy=((By=(he*By-ti*Oy)/tn)-S)*(By-S)+(rn-E)*(rn-E),tn=S+(By-S)*I,Me=E+(rn-E)*I,By=S-(By-S)*k,rn=E-(rn-E)*k,Iy=ri?I:k,Oy<=Math.min(he*he+Jr*Jr,ti*ti+ei*ei)+Iy*Iy*x?"bevel"===a.join||y<Oy/x?(ri?(f.push(tn,Me),f.push(S+R*k,E+w*k),f.push(tn,Me),f.push(S+D*k,E+G*k)):(f.push(S-R*I,E-w*I),f.push(By,rn),f.push(S-D*I,E-G*I),f.push(By,rn)),_+=2):"round"===a.join?ri?(f.push(tn,Me),f.push(S+R*k,E+w*k),_+=Te(S,E,S+R*k,E+w*k,S+D*k,E+G*k,f,!0)+4,f.push(tn,Me),f.push(S+D*k,E+G*k)):(f.push(S-R*I,E-w*I),f.push(By,rn),_+=Te(S,E,S-R*I,E-w*I,S-D*I,E-G*I,f,!1)+4,f.push(S-D*I,E-G*I),f.push(By,rn)):(f.push(tn,Me),f.push(By,rn)):(f.push(S-R*I,E-w*I),f.push(S+R*k,E+w*k),"round"===a.join?_+=ri?Te(S,E,S+R*k,E+w*k,S+D*k,E+G*k,f,!0)+2:Te(S,E,S-R*I,E-w*I,S-D*I,E-G*I,f,!1)+2:"miter"===a.join&&Oy/x<=y&&(ri?(f.push(By,rn),f.push(By,rn)):(f.push(tn,Me),f.push(tn,Me)),_+=2),f.push(S-D*I,E-G*I),f.push(S+D*k,E+G*k),_+=2))}T=r[2*(m-2)],A=r[2*(m-2)+1],S=r[2*(m-1)],E=r[2*(m-1)+1],R=-(A-E),w=T-S,et=Math.sqrt(R*R+w*w),R/=et,w/=et,R*=b,w*=b,f.push(S-R*I,E-w*I),f.push(S+R*k,E+w*k),i||("round"===a.cap?_+=Te(S-R*(I-k)*.5,E-w*(I-k)*.5,S-R*I,E-w*I,S+R*k,E+w*k,f,!1)+2:"square"===a.cap&&(_+=Vd(S,E,R,w,I,k,!1,f)));var xM=ho*ho;for(let Y=g;Y<_+g-2;++Y)T=f[2*Y],A=f[2*Y+1],S=f[2*(Y+1)],E=f[2*(Y+1)+1],U=f[2*(Y+2)],O=f[2*(Y+2)+1],Math.abs(T*(E-O)+S*(O-A)+U*(A-E))<xM||n.push(Y,Y+1,Y+2)}}function Yd(r,t,e,i){var s=co;if(0!==r.length){var n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],t=t||Math.abs(n-a)<s&&Math.abs(o-l)<s,c=e,d=r.length/2,p=c.length/2;for(let f=0;f<d;f++)c.push(r[2*f]),c.push(r[2*f+1]);for(let f=0;f<d-1;f++)i.push(p+f,p+f+1);t&&i.push(p+d-1,p)}}function Ni(r,t,e){e=e||2;var u,c,d,p,f,i=t&&t.length,s=i?t[0]*e:r.length,n=Kd(r,0,s,e,!0),o=[];if(n&&n.next!==n.prev){if(i&&(n=function(r,t,e,i){for(var a,s=[],n=0,o=t.length;n<o;n++)(a=Kd(r,a=t[n]*i,n<o-1?t[n+1]*i:r.length,i,!1))===a.next&&(a.steiner=!0),s.push(function(r){for(var t=r,e=r;(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),(t=t.next)!==r;);return e}(a));for(s.sort(z1),n=0;n<s.length;n++)e=function(r,t){var e=function(r,t){var o,e=t,i=r.x,s=r.y,n=-1/0;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&n<a&&(o=e.x<e.next.x?e:e.next,(n=a)===i))return o}}while((e=e.next)!==t);if(!o)return null;for(var p,l=o,u=o.x,c=o.y,d=1/0,e=o;i>=e.x&&e.x>=u&&i!==e.x&&Ve(s<c?i:n,s,u,c,s<c?n:i,s,e.x,e.y)&&(p=Math.abs(s-e.y)/(i-e.x),Sr(e,r))&&(p<d||p===d&&(e.x>o.x||e.x===o.x&&function(r,t){return q(r.prev,r,t.prev)<0&&q(t.next,r,r.next)<0}(o,e)))&&(o=e,d=p),(e=e.next)!==l;);return o}(r,t);return e?(Se(r=Zd(e,r),r.next),Se(e,e.next)):t}(s[n],e);return e}(r,t,n,e)),r.length>80*e){for(var a=u=r[0],l=c=r[1],m=e;m<s;m+=e)(d=r[m])<a&&(a=d),(p=r[m+1])<l&&(l=p),u<d&&(u=d),c<p&&(c=p);f=0!==(f=Math.max(u-a,c-l))?32767/f:0}!function Tr(r,t,e,i,s,n,o){if(r){!o&&n&&function(r,t,e,i){for(var s=r;0===s.z&&(s.z=po(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,(s=s.next)!==r;);s.prevZ.nextZ=null,s.prevZ=null,function(r){var t,e,i,s,n,o,a,l,u=1;do{for(e=r,n=r=null,o=0;e;){for(o++,i=e,t=a=0;t<u&&(a++,i=i.nextZ);t++);for(l=u;0<a||0<l&&i;)0!==a&&(0===l||!i||e.z<=i.z)?(e=(s=e).nextZ,a--):(i=(s=i).nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}}while(n.nextZ=null,u*=2,1<o)}(s)}(r,i,s,n);for(var l,u,a=r;r.prev!==r.next;)if(l=r.prev,u=r.next,n?function(r,t,e){var s=r.prev,o=r.next;if(!(0<=q(s,r,o))){for(var a=s.x,l=r.x,u=o.x,c=s.y,d=r.y,p=o.y,f=a<l?a<u?a:u:l<u?l:u,m=c<d?c<p?c:p:d<p?d:p,_=l<a?u<a?a:u:u<l?l:u,g=d<c?p<c?c:p:p<d?d:p,b=po(f,m,t,e,n),x=po(_,g,t,e,n),y=r.prevZ,T=r.nextZ;y&&y.z>=b&&T&&T.z<=x;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==s&&y!==o&&Ve(a,c,l,d,u,p,y.x,y.y)&&0<=q(y.prev,y,y.next)||(y=y.prevZ,T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ve(a,c,l,d,u,p,T.x,T.y)&&0<=q(T.prev,T,T.next)))return;T=T.nextZ}for(;y&&y.z>=b;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==s&&y!==o&&Ve(a,c,l,d,u,p,y.x,y.y)&&0<=q(y.prev,y,y.next))return;y=y.prevZ}for(;T&&T.z<=x;){if(T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ve(a,c,l,d,u,p,T.x,T.y)&&0<=q(T.prev,T,T.next))return;T=T.nextZ}return 1}}(r,i,s):function(r){var t=r.prev,e=r;if(!(0<=q(t,e,r=r.next))){for(var s=t.x,n=e.x,o=r.x,a=t.y,l=e.y,u=r.y,c=s<n?s<o?s:o:n<o?n:o,d=a<l?a<u?a:u:l<u?l:u,p=n<s?o<s?s:o:o<n?n:o,f=l<a?u<a?a:u:u<l?l:u,m=r.next;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=d&&m.y<=f&&Ve(s,a,n,l,o,u,m.x,m.y)&&0<=q(m.prev,m,m.next))return;m=m.next}return 1}}(r))t.push(l.i/e|0),t.push(r.i/e|0),t.push(u.i/e|0),Er(r),r=u.next,a=u.next;else if((r=u)===a){o?1===o?Tr(r=function(r,t,e){var i=r;do{var s=i.prev,n=i.next.next}while(!Hi(s,n)&&qd(s,i,i.next,n)&&Sr(s,n)&&Sr(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Er(i),Er(i.next),i=r=n),(i=i.next)!==r);return Se(i)}(Se(r),t,e),t,e,i,s,n,2):2===o&&function(r,t,e,i,s,n){var o=r;do{for(var l,a=o.next.next;a!==o.prev;){if(o.i!==a.i&&function(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&qd(e,e.next,r,t))return 1}while((e=e.next)!==r)}(r,t)&&(Sr(r,t)&&Sr(t,r)&&function(r,t){for(var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),(e=e.next)!==r;);return i}(r,t)&&(q(r.prev,r,t.prev)||q(r,t.prev,t))||Hi(r,t)&&0<q(r.prev,r,r.next)&&0<q(t.prev,t,t.next))}(o,a))return l=Zd(o,a),o=Se(o,o.next),l=Se(l,l.next),Tr(o,t,e,i,s,n,0),Tr(l,t,e,i,s,n,0);a=a.next}}while((o=o.next)!==r)}(r,t,e,i,s,n):Tr(Se(r),t,e,i,s,n,1);break}}}(n,o,e,a,l,f,0)}return o}function Kd(r,t,e,i,s){var n,o;if(s===0<mo(r,t,e,i))for(n=t;n<e;n+=i)o=Qd(n,r[n],r[n+1],o);else for(n=e-i;t<=n;n-=i)o=Qd(n,r[n],r[n+1],o);return o&&Hi(o,o.next)&&(Er(o),o=o.next),o}function Se(r,t){if(!r)return r;t=t||r;var i,e=r;do{if(i=!1,e.steiner||!Hi(e,e.next)&&0!==q(e.prev,e,e.next))e=e.next;else{if(Er(e),(e=t=e.prev)===e.next)break;i=!0}}while(i||e!==t);return t}function z1(r,t){return r.x-t.x}function po(r,t,e,i,s){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-e)*s|0)|r<<8))|r<<4))|r<<2))|r<<1))|(1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ve(r,t,e,i,s,n,o,a){return(r-o)*(n-a)<=(s-o)*(t-a)&&(e-o)*(t-a)<=(r-o)*(i-a)&&(s-o)*(i-a)<=(e-o)*(n-a)}function q(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Hi(r,t){return r.x===t.x&&r.y===t.y}function qd(r,t,e,i){var s=ji(q(r,t,e)),n=ji(q(r,t,i)),o=ji(q(e,i,r)),a=ji(q(e,i,t));return s!==n&&o!==a||0===s&&Xi(r,e,t)||0===n&&Xi(r,i,t)||0===o&&Xi(e,r,i)||0===a&&Xi(e,t,i)}function Xi(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ji(r){return 0<r?1:r<0?-1:0}function Sr(r,t){return q(r.prev,r,r.next)<0?0<=q(r,t,r.next)&&0<=q(r,r.prev,t):q(r,t,r.prev)<0||q(r,r.next,t)<0}function Zd(r,t){var e=new fo(r.i,r.x,r.y),i=new fo(t.i,t.x,t.y),s=r.next,n=t.prev;return(r.next=t).prev=r,(e.next=s).prev=e,(i.next=e).prev=i,(n.next=i).prev=n,i}function Qd(r,t,e,i){return r=new fo(r,t,e),i?(r.next=i.next,(r.prev=i).next.prev=r,i.next=r):(r.prev=r).next=r,r}function Er(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 fo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function mo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}($i={exports:{}}).exports=Ni,($i.exports.default=Ni).deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(mo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var u=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(mo(r,u,c,e))}for(var d=0,a=0;a<i.length;a+=3){var p=i[a]*e,f=i[a+1]*e,m=i[a+2]*e;d+=Math.abs((r[p]-r[m])*(r[1+f]-r[1+p])-(r[p]-r[f])*(r[1+m]-r[1+p]))}return 0===o&&0===d?0:Math.abs((d-o)/o)},Ni.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);0<s&&(i+=r[s-1].length,e.holes.push(i))}return e};var Jd=an($i.exports);function go(r,t,e,i,s,n,o){var a=Jd(r,t,2);if(a){for(let u=0;u<a.length;u+=3)n[o++]=a[u]+s,n[o++]=a[u+1]+s,n[o++]=a[u+2]+s;let l=s*i;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=i}}const rT=[],_o={extension:{type:r.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return t},triangulate(r,t,e,i,s,n){go(r,rT,t,e,i,s,n)}},bo={extension:{type:r.ShapeBuilder,name:"rectangle"},build(r,t){var i=r.x,s=r.y,n=r.width,r=r.height;return 0<=n&&0<=r&&(t[0]=i,t[1]=s,t[2]=i+n,t[3]=s,t[4]=i+n,t[5]=s+r,t[6]=i,t[7]=s+r),t},triangulate(r,t,e,i,s,n){var o=0,t=(t[0+(i*=e)]=r[0],t[i+0+1]=r[1],t[i+(o+=e)]=r[2],t[i+o+1]=r[3],t[i+(o+=e)]=r[6],t[i+o+1]=r[7],t[i+(o+=e)]=r[4],t[i+o+1]=r[5],i/e);s[n++]=t,s[n++]=1+t,s[n++]=2+t,s[n++]=1+t,s[n++]=3+t,s[n++]=2+t}},vo={extension:{type:r.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,t},triangulate(r,t,e,i,s,n){var o=0,t=(t[0+(i*=e)]=r[0],t[i+0+1]=r[1],t[i+(o+=e)]=r[2],t[i+o+1]=r[3],t[i+(o+=e)]=r[4],t[i+o+1]=r[5],i/e);s[n++]=t,s[n++]=1+t,s[n++]=2+t}},iT=new M,sT=new z;function tp(r,t,e,i){return r=t.matrix?r.copyFrom(t.matrix).invert():r.identity(),"local"===t.textureSpace?(e=e.getBounds(sT),r.translate(-e.x,-e.y),r.scale(1/e.width,1/e.height)):(r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height),"clamp-to-edge"===(e=t.texture.source.style).addressMode&&(e.addressMode="repeat",e.update())),i&&r.append(iT.copyFrom(i).invert()),r}const Ar={},nT=(B.handleByMap(r.ShapeBuilder,Ar),B.add(bo,_o,vo,Zt,Xd,jd),new z),oT=new M;function ep(r,t){var{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0;for(let s=e.uvs.length=0;s<r.instructions.length;s++){var o,a,l,n=r.instructions[s];"texture"===n.action?function(r,t,e){var{vertices:i,uvs:s,indices:n}=e,o=n.length,a=i.length/2,l=[],u=Ar.rectangle,c=nT,d=r.image,p=(c.x=r.dx,c.y=r.dy,c.width=r.dw,c.height=r.dh,r.transform),c=(u.build(c,l),p&&Di(l,p),u.triangulate(l,i,2,a,n,o),d.uvs);s.push(c.x0,c.y0,c.x1,c.y1,c.x3,c.y3,c.x2,c.y2),(p=N.get(Ui)).indexOffset=o,p.indexSize=n.length-o,p.attributeOffset=a,p.attributeSize=i.length/2-a,p.baseColor=r.style,p.alpha=r.alpha,p.texture=d,p.geometryData=e,t.push(p)}(n.data,i,e):"fill"!==n.action&&"stroke"!==n.action||(o="stroke"===n.action,a=n.data.path.shapePath,l=n.data.style,n=n.data.hole,o&&n&&rp(n.shapePath,l,!0,i,e),n&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=n.shapePath.shapePrimitives),rp(a,l,o,i,e))}}function rp(r,t,e,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:l,transform:u,holes:c})=>{var p=a.length,f=n.length/2,m=[],_=Ar[l.type];let g="triangle-list";if(_.build(l,m),u&&Di(m,u),e){var d=null==(d=l.closePath)||d,A=t;A.pixelLine?(Yd(m,d,n,a),g="line-list"):Wd(m,A,!1,d,n,a)}else if(c){const T=[],A=m.slice();(function(r){var t=[];for(let e=0;e<r.length;e++){var i=r[e].shape,s=[];Ar[i.type].build(i,s),t.push(s)}return t})(c).forEach(S=>{T.push(A.length/2),A.push(...S)}),go(A,T,n,2,f,a,p)}else _.triangulate(m,n,2,f,a,p);A=o.length/2,(d=t.texture)!==P.WHITE?(_=tp(oT,t,l,u),lo(n,2,f,o,A,2,n.length/2-f,_)):uo(o,A,2,n.length/2-f),(c=N.get(Ui)).indexOffset=p,c.indexSize=a.length-p,c.attributeOffset=f,c.attributeSize=n.length/2-f,c.baseColor=t.color,c.alpha=t.alpha,c.texture=d,c.geometryData=s,c.topology=g,i.push(c)})}class ip{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class sp{constructor(){this.batcher=new Fi,this.instructions=new bn}init(){this.instructions.reset()}get geometry(){return this.batcher.geometry}}(Bd=class Bu{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(t){Bu.defaultOptions.bezierSmoothness=null!=(t=null==t?void 0:t.bezierSmoothness)?t:Bu.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);var i;return t.dirty&&(e?this._cleanGraphicsContextData(t):e=this._initContext(t),ep(t,e),i=t.batchMode,t.customShader||"no-batch"===i?e.isBatchable=!1:"auto"===i&&(e.isBatchable=e.geometryData.vertices.length<400),t.dirty=!1),e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){var e=N.get(sp),{batches:i,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,s=s.indices.length;for(let c=0;c<i.length;c++)i[c].applyTransform=!1;var a=e.batcher;a.ensureAttributeBuffer(n),a.ensureIndexBuffer(s),a.begin();for(let c=0;c<i.length;c++){var d=i[c];a.add(d)}a.finish(e.instructions),(n=a.geometry).indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),n.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);var u=a.batches;for(let c=0;c<u.length;c++){const d=u[c];d.bindGroup=Ai(d.textures.textures,d.textures.count)}return this._graphicsDataContextHash[t.uid]=e}_initContext(t){var e=new ip;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){var e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(N.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{N.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}}).extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"graphicsContext"},Bd.defaultOptions={bezierSmoothness:.5};let zi=Bd;const uT={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},wo=class Ny{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"===t?this.culling=!1:(this.culling=!0,this.clockwiseFrontFace="front"===t)}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=uT[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){var t=new Ny;return t.depthTest=!1,t.blend=!0,t}};wo.default2d=wo.for2d();let Et=wo;function We(r,t,e){var i=(r>>24&255)/255;t[e++]=(255&r)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class Ro{constructor(t,e){this.state=Et.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=t,this._adaptor=e,this._adaptor.init(),this.renderer.renderableGC.addManagedHash(this,"_graphicsBatchesHash")}validateRenderable(t){var e=t.context,t=!!this._graphicsBatchesHash[t.uid];return!(!(e=this.renderer.graphicsContext.updateGpuContext(e)).isBatchable&&t===e.isBatchable)}addRenderable(t,e){var i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){var e=this._graphicsBatchesHash[t.uid];if(e)for(let i=0;i<e.length;i++){var s=e[i];s._batcher.updateElement(s)}}destroyRenderable(t){this._graphicsBatchesHash[t.uid]&&this._removeBatchForRenderable(t.uid),t.off("destroyed",this._destroyRenderableBound)}execute(t){var e,i;t.isRenderable&&(e=this.renderer,i=t.context,e.graphicsContext.getGpuContext(i).batches.length)&&(i=i.customShader||this._adaptor.shader,this.state.blendMode=t.groupBlendMode,(i=i.resources.localUniforms.uniforms).uTransformMatrix=t.groupTransform,i.uRound=e._roundPixels|t._roundPixels,We(t.groupColorAlpha,i.uColor,0),this._adaptor.execute(this,t))}_rebuild(t){var e=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(t.context);e&&this._removeBatchForRenderable(t.uid),i.isBatchable&&this._initBatchesForRenderable(t),t.batched=i.isBatchable}_addToBatcher(t,e){var i=this.renderer.renderPipes.batch,s=this._getBatchesForRenderable(t);for(let n=0;n<s.length;n++){var o=s[n];i.addToBatch(o,e)}}_getBatchesForRenderable(t){return this._graphicsBatchesHash[t.uid]||this._initBatchesForRenderable(t)}_initBatchesForRenderable(t){const e=t.context,i=this.renderer.graphicsContext.getGpuContext(e),s=this.renderer._roundPixels|t._roundPixels,n=i.batches.map(o=>{var a=N.get(Ui);return o.copyTo(a),a.renderable=t,a.roundPixels=s,a});return void 0===this._graphicsBatchesHash[t.uid]&&t.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[t.uid]=n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{N.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}Ro.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"graphics"},B.add(Ro),B.add(zi);class Vi{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(){var t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;var s=this.texture.textureMatrix;return s.isSimple||(i=this._transformedUvs,this._textureMatrixUpdateId===s._updateID&&this._uvUpdateId===t._updateID)||((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,i)),i}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 Mo{constructor(t,e){this.localUniforms=new st({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Ht({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=t,this._adaptor=e,this._adaptor.init(),t.renderableGC.addManagedHash(this,"_gpuBatchableMeshHash"),t.renderableGC.addManagedHash(this,"_meshDataHash")}validateRenderable(t){var e=this._getMeshData(t),i=e.batched,s=t.batched;return i!==(e.batched=s)||!!s&&((i=t._geometry).indices.length!==e.indexSize||i.positions.length!==e.vertexSize?(e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0):((s=this._getBatchableMesh(t)).texture.uid!==t._texture.uid&&(s._textureMatrixUpdateId=-1),!s._batcher.checkAndUpdateTexture(s,t._texture)))}addRenderable(t,e){var i=this.renderer.renderPipes.batch,s=this._getMeshData(t).batched;s?((s=this._getBatchableMesh(t)).setTexture(t._texture),s.geometry=t._geometry,i.addToBatch(s,e)):(i.break(e),e.add(t))}updateRenderable(t){var e;t.batched&&((e=this._gpuBatchableMeshHash[t.uid]).setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e))}destroyRenderable(t){this._meshDataHash[t.uid]=null;var e=this._gpuBatchableMeshHash[t.uid];e&&(N.return(e),this._gpuBatchableMeshHash[t.uid]=null),t.off("destroyed",this._destroyRenderableBound)}execute(t){var e;t.isRenderable&&(t.state.blendMode=$e(t.groupBlendMode,t.texture._source),(e=this.localUniforms).uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),We(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t))}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:null==(e=t._geometry.indices)?void 0:e.length,vertexSize:null==(e=t._geometry.positions)?void 0:e.length},t.on("destroyed",this._destroyRenderableBound),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){var e=N.get(Vi);return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&N.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Mo.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"mesh"},B.add(Mo);class np{execute(t,e){var i=t.state,s=t.renderer,n=e.shader||t.defaultShader,o=(n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms,s.gl),t=t.getBuffers(e),i=(s.shader.bind(n),s.state.set(i),s.geometry.bind(t.geometry,n.glProgram),2===t.geometry.indexBuffer.data.BYTES_PER_ELEMENT?o.UNSIGNED_SHORT:o.UNSIGNED_INT);o.drawElements(o.TRIANGLES,6*e.particleChildren.length,i,0)}}function Co(r,t=null){var e=6*r;if((t=65535<e?t||new Uint32Array(e):t||new Uint16Array(e)).length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected `+e);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function op(r){return{dynamicUpdate:ap(r,!0),staticUpdate:ap(r,!1)}}function ap(r,t){var e=[];e.push(`
var index = 0;
for (let i = 0; i < ps.length; ++i)
{
const p = ps[i];
`);let i=0;for(const n in r){var o=r[n];t===o.dynamic&&(e.push("offset = index + "+i),e.push(o.code),o=qt(o.format),i+=o.stride/4)}e.push(`
index += stride * 4;
}
`),e.unshift(`
var stride = ${i};
`);var s=e.join(`
`);return new Function("ps","f32v","u32v",s)}class lp{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e=this._size=null!=(e=t.size)?e:1e3,s=t.properties;let n=0,o=0;for(const d in s){var p=s[d],f=qt(p.format);p.dynamic?o+=f.stride:n+=f.stride}this._dynamicStride=o/4,this._staticStride=n/4,this.staticAttributeBuffer=new ve(4*e*n),this.dynamicAttributeBuffer=new ve(4*e*o),this.indexBuffer=Co(e);var a=new ye;let l=0,u=0;this._staticBuffer=new ht({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:L.VERTEX|L.COPY_DST}),this._dynamicBuffer=new ht({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:L.VERTEX|L.COPY_DST});for(const d in s){const p=s[d],f=qt(p.format);p.dynamic?(a.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*l,format:p.format}),l+=f.size):(a.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*u,format:p.format}),u+=f.size)}a.addIndex(this.indexBuffer),t=this.getParticleUpdate(s),this._dynamicUpload=t.dynamicUpdate,this._staticUpload=t.staticUpdate,this.geometry=a}getParticleUpdate(t){var e=function(r){var t=[];for(const e in r){var i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return op(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new ve(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new ve(this._size*this._dynamicStride*4*4),this.indexBuffer=Co(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));var i=this.dynamicAttributeBuffer;this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e&&(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()}}var up=`varying vec2 vUV;
varying vec4 vColor;
uniform sampler2D uTexture;
void main(void){
vec4 color = texture2D(uTexture, vUV) * vColor;
gl_FragColor = color;
}`,cp=`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;
}
`,Oo=`
struct ParticleUniforms {
uProjectionMatrix:mat3x3<f32>,
uColor:vec4<f32>,
uResolution:vec2<f32>,
uRoundPixels:f32,
};
@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;
let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
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 hp extends St{constructor(){super({glProgram:Tt.from({vertex:cp,fragment:up}),gpuProgram:gt.from({fragment:{source:Oo,entryPoint:"mainFragment"},vertex:{source:Oo,entryPoint:"mainVertex"}}),resources:{uTexture:P.WHITE.source,uSampler:new yn({}),uniforms:{uTranslationMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new X(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Go{constructor(t,e){this.state=Et.for2d(),this._gpuBufferHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.localUniforms=new st({uTranslationMatrix:{value:new M,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 hp,this.state=Et.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return this._gpuBufferHash[t.uid]||this._initBuffer(t)}_initBuffer(t){return this._gpuBufferHash[t.uid]=new lp({size:t.particleChildren.length,properties:t._properties}),t.on("destroyed",this._destroyRenderableBound),this._gpuBufferHash[t.uid]}updateRenderable(t){}destroyRenderable(t){this._gpuBufferHash[t.uid].destroy(),this._gpuBufferHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}execute(t){var i,n,s,e=t.particleChildren;0!==e.length&&(i=this.renderer,s=this.getBuffers(t),t.texture||(t.texture=e[0].texture),n=this.state,s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=$e(t.blendMode,t.texture._source),e=(s=this.localUniforms.uniforms).uTranslationMatrix,t.worldTransform.copyTo(e),e.prepend(i.globalUniforms.globalUniformData.projectionMatrix),s.uResolution=i.globalUniforms.globalUniformData.resolution,s.uRound=i._roundPixels|t._roundPixels,We(t.groupColorAlpha,s.uColor,0),this.adaptor.execute(this,t))}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class Bo extends Go{constructor(t){super(t,new np)}}Bo.extension={type:[r.WebGLPipes],name:"particle"};class dp{execute(t,e){var i=t.renderer,s=((s=e.shader||t.defaultShader).groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture),t.state),o=t.getBuffers(e);i.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:s,size:6*e.particleChildren.length})}}class Io extends Go{constructor(t){super(t,new dp)}}Io.extension={type:[r.WebGPUPipes],name:"particle"},B.add(Bo),B.add(Io);class Pr{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}}function Wi(r,t){var{texture:r,bounds:i}=r,r=(Dn(i,t._anchor,r),t._style.padding);i.minX-=r,i.minY-=r,i.maxX-=r,i.maxY-=r}class Fo{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this),this._renderer.renderableGC.addManagedHash(this,"_gpuText")}resolutionChange(){for(const t in this._gpuText){var e=this._gpuText[t];e&&(e=e.batchableSprite.renderable)._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){var e=this._getGpuText(t),t=t._getKey();return e.currentKey!==t}addRenderable(t,e){var i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){var e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e._batcher.updateElement(e)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(t.uid)}_destroyRenderableById(t){var e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),N.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){var e=t._getKey(),i=this._getGpuText(t),s=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1,Wi(s,t)}_updateGpuText(t){var e=this._getGpuText(t),i=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=i.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),i.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){var e={texture:null,currentKey:"--",batchableSprite:N.get(Pr)};return e.batchableSprite.renderable=t,e.batchableSprite.transform=t.groupTransform,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t._resolution=(t._autoResolution?this._renderer:t).resolution,this._updateText(t),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Fo.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"text"};class pp{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){var i=H.get().createCanvas(),t=(i.width=t,i.height=e,i.getContext("2d"));return{canvas:i,context:t}}getOptimalCanvasAndContext(t,e,i=1){return t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),i=((t=de(t))<<17)+((e=de(e))<<1),this._canvasPool[i]||(this._canvasPool[i]=[]),(i=this._canvasPool[i].pop())||this._createCanvasAndContext(t,e)}returnCanvasAndContext(t){var{width:i,height:s}=t.canvas,n=(i<<17)+(s<<1);t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Xt=new pp;function fp(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(0!==r[s+3])return;return 1}function mp(r,t,e,i,s){var n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(0!==r[a+3])return;return 1}function gp(r,t=1){var{width:e,height:i}=r;if(null===(r=r.getContext("2d",{willReadFrequently:!0})))throw new TypeError("Failed to get canvas 2D context");var n=r.getImageData(0,0,e,i).data;let o=0,a=0,l=e-1,u=i-1;for(;a<i&&fp(n,e,a);)++a;if(a===i)return z.EMPTY;for(;fp(n,e,u);)--u;for(;mp(n,e,o,a,u);)++o;for(;mp(n,e,l,a,u);)--l;return++l,++u,new z(o/t,a/t,(l-o)/t,(u-a)/t)}var dT=Object.defineProperty,_p=Object.getOwnPropertySymbols,pT=Object.prototype.hasOwnProperty,fT=Object.prototype.propertyIsEnumerable,bp=(r,t,e)=>t in r?dT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vp=(r,t)=>{for(var e in t=t||{})pT.call(t,e)&&bp(r,e,t[e]);if(_p)for(var e of _p(t))fT.call(t,e)&&bp(r,e,t[e]);return r};const yp=[{offset:0,color:"white"},{offset:1,color:"black"}],Do=class Iu{constructor(...t){this.uid=K("fillGradient"),this.type="linear",this.colorStops=[];var s="radial"===(t=function(r){var t,i=null!=(t=r[0])?t:{};return"number"==typeof i||r[1]?{type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:null!=(t=r[5])?t:Qt.defaultLinearOptions.textureSize}:i}(t)).type?Iu.defaultRadialOptions:Iu.defaultLinearOptions,t=vp(vp({},s),Bt(t));this._textureSize=t.textureSize,"radial"===t.type?(this.center=t.center,this.outerCenter=null!=(s=t.outerCenter)?s:this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:X.shared.setValue(e).toHexa()}),this}buildLinearGradient(){var e,t,n,c,s,f,i;this.texture||(t=this.colorStops.length?this.colorStops:yp,{canvas:i,context:s}=Tp(e=this._textureSize,1),{x:t,y:n}=(xp(n=s.createLinearGradient(0,0,this._textureSize,0),t),s.fillStyle=n,s.fillRect(0,0,e,1),this.texture=new P({source:new ie({resource:i})}),this.start),{x:s,y:i}=this.end,c=new M,s-=t,i-=n,f=Math.sqrt(s*s+i*i),i=Math.atan2(i,s),c.scale(f/e,1),c.rotate(i),c.translate(t,n),"local"===this.textureSpace&&c.scale(e,e),this.transform=c)}buildGradient(){"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){var t,e,i,s,l,c,n,o,f,m,_,u,a;this.texture||(t=this.colorStops.length?this.colorStops:yp,{canvas:i,context:s}=Tp(e=this._textureSize,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,xp(u=s.createRadialGradient(m=(n-(n=a-c))*(f=e/(2*c)),_=(o-(o=l-c))*f,u*f,(a-n)*f,(l-o)*f,c*f),t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=u,s.translate(m,_),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-m,-_),s.fillRect(0,0,e,e),this.texture=new P({source:new ie({resource:i,addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"})}),(a=new M).scale(1/f,1/f),a.translate(n,o),"local"===this.textureSpace&&a.scale(e,e),this.transform=a)}get styleKey(){return this.uid}destroy(){var t;null!=(t=this.texture)&&t.destroy(!0),this.texture=null}};Do.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256},Do.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256};let Qt=Do;function xp(r,t){for(let e=0;e<t.length;e++){var i=t[e];r.addColorStop(i.offset,i.color)}}function Tp(r,t){return t=(r=H.get().createCanvas(r,t)).getContext("2d"),{canvas:r,context:t}}const Sp={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 wr{constructor(t,e){this.uid=K("fillPattern"),this.transform=new M,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Sp[e].addressModeU,t.source.style.addressModeV=Sp[e].addressModeV)}setTransform(t){var e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-`+this.transform.toArray().join("-"),this._styleKey)}}var Uo={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},_T=/([astvzqmhlc])([^astvzqmhlc]*)/gi,vT=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,xT=an(function(r){var t=[];return r.replace(_T,function(e,i,s){var r,n=i.toLowerCase();for(s=(r=(r=s).match(vT))?r.map(Number):[],"m"==n&&2<s.length&&(t.push([i].concat(s.splice(0,2))),n="l",i="m"==i?"l":"L");;){if(s.length==Uo[n])return s.unshift(i),t.push(s);if(s.length<Uo[n])throw new Error("malformed path data");t.push([i].concat(s.splice(0,Uo[n])))}}),t});function Ep(r,t){var e=xT(r),i=[];let s=null,n=0,o=0;for(let a=0;a<e.length;a++){var l=e[a],u=l[0],c=l;switch(u){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),0<i.length&&(s=i.pop(),o=s?(n=s.startX,s.startY):n=0),s=null}"Z"!==u&&"z"!==u&&null===s&&(s={startX:n,startY:o},i.push(s))}return t}class Yi{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Yi(this.x,this.y,this.radius)}contains(t,e){var i;return!(this.radius<=0)&&(i=this.radius*this.radius,t=this.x-t,e=this.y-e,(t*=t)+(e*=e)<=i)}strokeContains(t,e,i,s=.5){var a;return 0!==this.radius&&(t=this.x-t,e=this.y-e,a=this.radius,s=(1-s)*i,(t=Math.sqrt(t*t+e*e))<=a+s)&&a-(i-s)<t}getBounds(t){return(t=t||new z).x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,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 Ki{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new Ki(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){return!(this.halfWidth<=0||this.halfHeight<=0)&&(t=(t-this.x)/this.halfWidth,(t*=t)+(e=(e-this.y)/this.halfHeight)*e<=1)}strokeContains(t,e,i,s=.5){var d,p,{halfWidth:n,halfHeight:o}=this;return!(n<=0||o<=0)&&(d=n+(s=i*(1-s)),p=o+s,1<(t-=this.x)*t/((i=n-(n=i-s))*i)+(s=e-this.y)*s/((i=o-n)*i))&&t*t/(d*d)+s*s/(p*p)<=1}getBounds(t){return(t=t||new z).x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,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}}function Rr(r,t,e,i,s,n){var l=s-e,u=n-i,d=l*l+u*u;let p,f,m;return m=(p=0!=d?((r-e)*l+(t-i)*u)/d:-1)<0?(f=e,i):1<p?(f=s,n):(f=e+p*l,i+p*u),(d=r-f)*d+(s=t-m)*s}class Ye{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){var i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;var e=this.points,i=e.length;for(let s=0;s<i;s+=2){var n=e[s],o=e[s+1],a=e[(s+2)%i],l=e[(s+3)%i];t+=(a-n)*(l+o)}return t<0}containsPolygon(t){var e=this.getBounds(void 0),i=t.getBounds(void 0);if(!e.containsRect(i))return!1;var s=t.points;for(let n=0;n<s.length;n+=2){var o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){var t=this.points.slice();return(t=new Ye(t)).closePath=this.closePath,t}contains(t,e){let i=!1;var s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){var a=this.points[2*n],l=this.points[2*n+1],u=this.points[2*o],c=this.points[2*o+1];e<l!=e<c&&t<(e-l)/(c-l)*(u-a)+a&&(i=!i)}return i}strokeContains(t,e,i,s=.5){var o=(i*=i)*(1-s),a=i-o,l=this.points,u=l.length-(this.closePath?0:2);for(let c=0;c<u;c+=2){var d=l[c],p=l[c+1],f=l[(c+2)%l.length],m=l[(c+3)%l.length];if(Rr(t,e,d,p,f,m)<=(Math.sign((f-d)*(e-p)-(m-p)*(t-d))<0?a:o))return!0}return!1}getBounds(t){t=t||new z;var e=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){var u=e[a],c=e[a+1];i=u<i?u:i,s=u>s?u:s,n=c<n?c:n,o=c>o?c:o}return t.x=i,t.width=s-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const qi=(r,t,e,i,s,n,o)=>(r-=e,e=t-i,s-n<=(t=Math.sqrt(r*r+e*e))&&t<=s+o);class Zi{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return(t=t||new z).x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Zi(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)&&t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){var i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);var o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i))*s+n*n<=o||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i))*s+n*n<=o)return!0}return!1}strokeContains(t,e,i,s=.5){var{x:n,y:o,width:a,height:l,radius:u}=this,i=i-(s=i*(1-s)),p=n+u,f=o+u,g=n+a,b=o+l;return(n-s<=t&&t<=n+i||g-i<=t&&t<=g+s)&&f<=e&&e<=f+(l-2*u)||(o-s<=e&&e<=o+i||b-i<=e&&e<=b+s)&&p<=t&&t<=p+(a-2*u)||t<p&&e<f&&qi(t,e,p,f,u,i,s)||g-u<t&&e<f&&qi(t,e,g-u,f,u,i,s)||g-u<t&&b-u<e&&qi(t,e,g-u,b-u,u,i,s)||t<p&&b-u<e&&qi(t,e,p,b-u,u,i,s)}}const ET=8,Qi=1.1920929e-7,AT=1,ko=.01,Ke=0,Ee=0;function $o(r,t,e,i,s,n,o,a,l,u){return u=Math.min(.99,Math.max(0,null!=u?u:zi.defaultOptions.bezierSmoothness)),u=AT-u,function(r,t,e,i,s,n,o,a,l,u){(function Lo(r,t,e,i,s,n,o,a,l,u,c){if(!(c>ET)){var d=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+s)/2,_=(i+n)/2,g=(s+o)/2,b=(n+a)/2,x=(p+m)/2,y=(f+_)/2,S=(x+(m=(m+g)/2))/2,E=(y+(_=(_+b)/2))/2;if(0<c){var U=o-r,O=a-t,R=Math.abs((e-o)*O-(i-a)*U),w=Math.abs((s-o)*O-(n-a)*U);let D,G;if(R>Qi&&w>Qi){if((R+w)*(R+w)<=u*(U*U+O*O)){if(Ke<ko)return l.push(S,E);var et=Math.atan2(n-i,s-e);if(D=Math.abs(et-Math.atan2(i-t,e-r)),G=Math.abs(Math.atan2(a-n,o-s)-et),D>=d&&(D=2*d-D),G>=d&&(G=2*d-G),D+G<Ke)return l.push(S,E);if(0!==Ee){if(D>Ee)return l.push(e,i);if(G>Ee)return l.push(s,n)}}}else if(R>Qi){if(R*R<=u*(U*U+O*O)){if(Ke<ko)return l.push(S,E);if((D=(D=Math.abs(Math.atan2(n-i,s-e)-Math.atan2(i-t,e-r)))>=d?2*d-D:D)<Ke)return l.push(e,i),l.push(s,n);if(0!==Ee&&D>Ee)return l.push(e,i)}}else if(w>Qi){if(w*w<=u*(U*U+O*O)){if(Ke<ko)return l.push(S,E);if((D=(D=Math.abs(Math.atan2(a-n,o-s)-Math.atan2(n-i,s-e)))>=d?2*d-D:D)<Ke)return l.push(e,i),l.push(s,n);if(0!==Ee&&D>Ee)return l.push(s,n)}}else if((U=S-(r+o)/2)*U+(O=E-(t+a)/2)*O<=u)return l.push(S,E)}Lo(r,t,p,f,x,y,S,E,l,u,c+1),Lo(S,E,m,_,g,b,o,a,l,u,c+1)}})(r,t,e,i,s,n,o,a,l,u,0),l.push(o,a)}(t,e,i,s,n,o,a,l,r,u*=u),r}function Pp(r,t,e,i,s,n,o,a){return a=1-Math.min(.99,Math.max(0,null!=a?a:zi.defaultOptions.bezierSmoothness)),function(r,t,e,i,s,n,o,a){(function No(r,t,e,i,s,n,o,a,l){if(!(8<l)){Math.PI;var c=(t+i)/2,d=(e+s)/2,p=(i+n)/2,f=(s+o)/2,m=(c+p)/2,_=(d+f)/2,g=n-t,b=o-e;if(1.1920929e-7<(i=Math.abs((i-n)*b-(s-o)*g))){if(i*i<=a*(g*g+b*b))return r.push(m,_)}else if((g=m-(t+n)/2)*g+(b=_-(e+o)/2)*b<=a)return r.push(m,_);No(r,t,e,c,d,m,_,a,l+1),No(r,m,_,p,f,n,o,a,l+1)}})(o,r,t,e,i,s,n,a,0),o.push(s,n)}(t,e,i,s,n,o,r,a*=a),r}function Ho(r,t,e,i,s,n,o,a){let l=Math.abs(s-n),u=((!o&&n<s||o&&s<n)&&(l=2*Math.PI-l),a=a||Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI))),a=Math.max(a,3),l/a),c=s;u*=o?-1:1;for(let d=0;d<a+1;d++){var p=Math.cos(c),f=Math.sin(c);r.push(t+p*i,e+f*i),c+=u}}function wp(r,t,e,i,s,n){var _,p,f,m,o=r[r.length-2],a=r[r.length-1]-e,o=o-t,s=s-e,i=i-t,d=Math.abs(a*i-o*s);d<1e-8||0===n?r[r.length-2]===t&&r[r.length-1]===e||r.push(t,e):(p=a*a+o*o,f=s*s+i*i,m=a*s+o*i,p=(_=n*Math.sqrt(p)/d)*m/p,f=i*(_+(m=(d=n*Math.sqrt(f)/d)*m/f)),m=s*(_+m),Ho(r,(r=_*i+d*o)+t,(t=_*s+d*a)+e,n,Math.atan2(a*(d+p)-t,o*(d+p)-r),Math.atan2(m-t,f-r),i*a<o*s))}const Mr=2*Math.PI,Xo={centerX:0,centerY:0,ang1:0,ang2:0},jo=({x:r,y:t},e,i,s,n,o,a,l)=>(e=n*(r*=e)+s*(t*=i),l.x=s*r-n*t+o,l.y=e+a,l),Rp=(r,t,e,i)=>{let n=r*e+t*i;return(n=1<n?1:n)<-1&&(n=-1),(r*i-t*e<0?-1:1)*Math.acos(n)};function Mp(r,t,e,i,s,n,o,a=0,l=0,u=0){if(0!==n&&0!==o){var c=Math.sin(a*Mr/360),d=Math.cos(a*Mr/360),f=-c*(t-i)/2+d*(e-s)/2;if(0!=(a=d*(t-i)/2+c*(e-s)/2)||0!=f){n=Math.abs(n),o=Math.abs(o);var m=Math.pow(a,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);1<m&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),((r,t,e,i,s,n,o,a,l,u,c,d,p)=>{var f=Math.pow(s,2),m=Math.pow(n,2),_=Math.pow(c,2),g=Math.pow(d,2);let b=f*m-f*g-m*_,w=(b<0&&(b=0),b/=f*g+m*_,m=u*(f=(b=Math.sqrt(b)*(o===a?-1:1))*s/n*d)-l*(g=b*-n/s*c)+(r+e)/2,_=l*f+u*g+(t+i)/2,o=(c-f)/s,r=(d-g)/n,e=(-c-f)/s,l=(-d-g)/n,u=Rp(1,0,o,r),Rp(o,r,e,l));0===a&&0<w&&(w-=Mr),1===a&&w<0&&(w+=Mr),p.centerX=m,p.centerY=_,p.ang1=u,p.ang2=w})(t,e,i,s,n,o,l,u,c,d,a,f,Xo);let{ang1:_,ang2:g}=Xo;var{centerX:b,centerY:x}=Xo;let y=Math.abs(g)/(Mr/4);Math.abs(1-y)<1e-7&&(y=1);var T=Math.max(Math.ceil(y),1);g/=T;let A=r[r.length-2],S=r[r.length-1];var E={x:0,y:0};for(let U=0;U<T;U++){var O=function(r,t){var e=-1.5707963267948966==t?-.551915024494:1.3333333333333333*Math.tan(t/4),e=1.5707963267948966==t?.551915024494:e,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t);return[{x:s-n*e,y:n+s*e},{x:o+(r=Math.sin(r+t))*e,y:r-o*e},{x:o,y:r}]}(_,g),{x:R,y:w}=jo(O[0],n,o,d,c,b,x,E),{x:D,y:G}=jo(O[1],n,o,d,c,b,x,E),{x:O,y:ee}=jo(O[2],n,o,d,c,b,x,E);$o(r,A,S,R,w,D,G,O,ee),A=O,S=ee,_+=g}}}}function Cp(r,t,e){var s=(a,l)=>{var u=l.x-a.x,l=l.y-a.y;return{len:a=Math.sqrt(u*u+l*l),nx:u/a,ny:l/a}},n=(a,l)=>{0===a?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++){var l=t[a%t.length],i=null!=(i=l.radius)?i:e;if(i<=0)n(a,l);else{var c=t[(a+1)%t.length],d=s(l,o),c=s(l,c);if(d.len<1e-4||c.len<1e-4)n(a,l);else{let f=Math.asin(d.nx*c.ny-d.ny*c.nx),m=1,_=!1;d.nx*c.nx-d.ny*-c.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,m=-1,_=!0):0<f&&(m=-1,_=!0);var g=f/2;let b,x=Math.abs(Math.cos(g)*i/Math.sin(g));b=x>Math.min(d.len/2,c.len/2)?(x=Math.min(d.len/2,c.len/2),Math.abs(x*Math.sin(g)/Math.cos(g))):i,g=l.x+c.nx*x+-c.ny*b*m,i=l.y+c.ny*x+c.nx*b*m,d=Math.atan2(d.ny,d.nx)+Math.PI/2*m,c=Math.atan2(c.ny,c.nx)-Math.PI/2*m,0===a&&r.moveTo(g+Math.cos(d)*b,i+Math.sin(d)*b),r.arc(g,i,b,d,c,_)}}o=l}}function Op(r,t,e,i){var n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c}),a=t.length;for(let l=0;l<a;l++){var f,d,p,u=t[(l+1)%a],s=null!=(s=u.radius)?s:e;s<=0?0===l?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y):(d=t[l],p=t[(l+2)%a],f=(f=n(d,u))<1e-4?u:o(u,d,Math.min(f/2,s)/f),p=(d=n(p,u))<1e-4?u:o(u,p,Math.min(d/2,s)/d),0===l?r.moveTo(f.x,f.y):r.lineTo(f.x,f.y),r.quadraticCurveTo(u.x,u.y,p.x,p.y,i))}}const IT=new z;class Gp{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new nt,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();var i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return s===t&&n===e||i.push(t,e),this}arc(t,e,i,s,n,o){return this._ensurePoly(!1),Ho(this._currentPoly.points,t,e,i,s,n,o),this}arcTo(t,e,i,s,n){return this._ensurePoly(),wp(this._currentPoly.points,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,o,a){return Mp(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o,a){this._ensurePoly();var l=this._currentPoly;return $o(this._currentPoly.points,l.lastX,l.lastY,t,e,i,s,n,o,a),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();var o=this._currentPoly;return Pp(this._currentPoly.points,o.lastX,o.lastY,t,e,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);var i=this.shapePrimitives,e=i.length;for(let n=0;n<t.instructions.length;n++){var o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&1<i.length-e){let n=null;for(let o=e;o<i.length;o++){var l,u,a=i[o];"polygon"===a.shape.type&&(l=a.shape,(u=null==n?void 0:n.shape)&&u.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a)}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,s,n){return this.drawShape(new z(t,e,i,s),n),this}circle(t,e,i,s){return this.drawShape(new Yi(t,e,i),s),this}poly(t,e,i){return(t=new Ye(t)).closePath=e,this.drawShape(t,i),this}regularPoly(t,e,i,s,n=0,o){s=Math.max(0|s,3);var a=-1*Math.PI/2+n,l=2*Math.PI/s,u=[];for(let c=0;c<s;c++){var d=a-c*l;u.push(t+i*Math.cos(d),e+i*Math.sin(d))}return this.poly(u,!0,o),this}roundPoly(t,e,i,s,n,o=0,a){if(s=Math.max(0|s,3),n<=0)return this.regularPoly(t,e,i,s,o);var l=i*Math.sin(Math.PI/s)-.001,u=(n=Math.min(n,l),-1*Math.PI/2+o),c=2*Math.PI/s,d=(s-2)*Math.PI/s/2;for(let p=0;p<s;p++){var f=p*c+u,m=t+i*Math.cos(f),_=e+i*Math.sin(f),g=f+Math.PI+d,f=f-Math.PI-d,x=m+n*Math.cos(g),g=_+n*Math.sin(g),T=m+n*Math.cos(f),f=_+n*Math.sin(f);0===p?this.moveTo(x,g):this.lineTo(x,g),this.quadraticCurveTo(m,_,T,f,a)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?Op(this,t,e,s):Cp(this,t,e),this.closePath())}filletRect(t,e,i,s,n){var l,o;return 0===n?this.rect(t,e,i,s):(o=Math.min(i,s)/2,l=t+i,s=e+s,n=(o=Math.min(o,Math.max(-o,n)))<0?-o:0,o=Math.abs(o),this.moveTo(t,e+o).arcTo(t+n,e+n,t+o,e,o).lineTo(l-o,e).arcTo(l-n,e+n,l,e+o,o).lineTo(l,s-o).arcTo(l-n,s-n,t+i-o,s,o).lineTo(t+o,s).arcTo(t+n,s-n,t,s-o,o).closePath())}chamferRect(t,e,i,s,n,o){if(n<=0)return this.rect(t,e,i,s);var c=[t+(n=Math.min(n,Math.min(i,s)/2)),e,(i=t+i)-n,e,i,e+n,i,(s=e+s)-n,i-n,s,t+n,s,t,s-n,t,e+n];for(let d=c.length-1;2<=d;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,s,n){return this.drawShape(new Ki(t,e,i,s),n),this}roundRect(t,e,i,s,n,o){return this.drawShape(new Zi(t,e,i,s,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){var i=this._currentPoly;return i&&this.endPoly(),(i=new Ye).points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){var e=this._currentPoly;return e&&2<e.points.length&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){var o;if(!this._currentPoly&&(this._currentPoly=new Ye,t))if(t=this.shapePrimitives[this.shapePrimitives.length-1]){let i=t.shape.x,s=t.shape.y;t.transform&&!t.transform.isIdentity()&&(t=t.transform,o=i,i=t.a*i+t.c*s+t.tx,s=t.b*o+t.d*s+t.ty),this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}buildPath(){var t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){var i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){var t=this._bounds,e=(t.clear(),this.shapePrimitives);for(let i=0;i<e.length;i++){var s=e[i],n=s.shape.getBounds(IT);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class se{constructor(t,e=!1){this.instructions=[],this.uid=K("graphicsPath"),this._dirty=!0,this.checkForHoles=e,"string"==typeof t?Ep(t,this):this.instructions=null!=(e=null==t?void 0:t.slice())?e:[]}get shapePath(){return this._shapePath||(this._shapePath=new Gp(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,i,s,n){var d,o=this.instructions[this.instructions.length-1],a=this.getLastPoint(V.shared);let l=0,u=0;return u=o&&"bezierCurveTo"===o.action?(l=o.data[2],u=o.data[3],o=a.x,d=a.y,l=o+(o-l),d+(d-u)):(l=a.x,a.y),this.instructions.push({action:"bezierCurveTo",data:[l,u,t,e,i,s,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,i){var u,s=this.instructions[this.instructions.length-1],n=this.getLastPoint(V.shared);let o=0,a=0;return a=s&&"quadraticCurveTo"===s.action?(o=s.data[0],a=s.data[1],s=n.x,u=n.y,o=s+(s-o),u+(u-a)):(o=n.x,n.y),this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,s,n){return this.instructions.push({action:"rect",data:[t,e,i,s,n]}),this._dirty=!0,this}circle(t,e,i,s){return this.instructions.push({action:"circle",data:[t,e,i,s]}),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,i,s,n,o,a){n=n||s/2;var l=-1*Math.PI/2+o,u=2*i,c=2*Math.PI/u,d=[];for(let p=0;p<u;p++){var f=p%2?n:s,m=p*c+l;d.push(t+f*Math.cos(m),e+f*Math.sin(m))}return this.poly(d,!0,a),this}clone(t=!1){var e=new se;if(e.checkForHoles=this.checkForHoles,t)for(let i=0;i<this.instructions.length;i++){var s=this.instructions[i];e.instructions.push({action:s.action,data:s.data.slice()})}else e.instructions=this.instructions.slice();return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(!t.isIdentity()){var e=t.a,i=t.b,s=t.c,n=t.d,o=t.tx,a=t.ty;let l=0,u=0,c=0,d=0,p,f,m,_;for(let g=0;g<this.instructions.length;g++){var b=this.instructions[g],x=b.data;switch(b.action){case"moveTo":case"lineTo":l=x[0],u=x[1],x[0]=e*l+s*u+o,x[1]=i*l+n*u+a;break;case"bezierCurveTo":c=x[0],d=x[1],p=x[2],f=x[3],l=x[4],u=x[5],x[0]=e*c+s*d+o,x[1]=i*c+n*d+a,x[2]=e*p+s*f+o,x[3]=i*p+n*f+a,x[4]=e*l+s*u+o,x[5]=i*l+n*u+a;break;case"quadraticCurveTo":c=x[0],d=x[1],l=x[2],u=x[3],x[0]=e*c+s*d+o,x[1]=i*c+n*d+a,x[2]=e*l+s*u+o,x[3]=i*l+n*u+a;break;case"arcToSvg":l=x[5],u=x[6],m=x[0],_=x[1],x[0]=e*m+s*_,x[1]=i*m+n*_,x[5]=e*l+s*u+o,x[6]=i*l+n*u+a;break;case"circle":x[4]=Cr(x[3],t);break;case"rect":x[4]=Cr(x[4],t);break;case"ellipse":x[8]=Cr(x[8],t);break;case"roundRect":x[5]=Cr(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=Cr(x[2],t)}}this._dirty=!0}return this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(i){for(;"closePath"===i.action;){if(--e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t)}}else t.x=0,t.y=0;return t}}function Cr(r,t){return r?r.prepend(t):t.clone()}let zo=0;const Bp=500;function Ot(...r){zo!==Bp&&(++zo===Bp?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function Z(r,t,e){return(r=r.getAttribute(t))?Number(r):e}function Ip(r,t){var e=r.querySelectorAll("defs");for(let i=0;i<e.length;i++){var s=e[i];for(let n=0;n<s.children.length;n++){var o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=function(r){var t=Z(r,"x1",0),e=Z(r,"y1",0),i=Z(r,"x2",1),s=Z(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new Qt(t,e,i,s,"objectBoundingBox"===n?"local":"global");for(let a=0;a<r.children.length;a++){var u=Z(l=r.children[a],"offset",0),l=X.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(u,l)}return o}(o);break;case"radialgradient":t.defs[o.id]=new Qt(0,0,1,0)}}}}function Vo(r){return(r=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i))?r[1]:""}const Wo={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 Yo(r,t){var e=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in Wo){var a=r.getAttribute(o);a&&Ko(t,n,o,a.trim())}if(e){var o=e.split(";");for(let a=0;a<o.length;a++){var[u,c]=o[a].trim().split(":");Wo[u]&&Ko(t,n,u,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function Ko(r,t,e,i){switch(e){case"stroke":var s;"none"!==i&&(i.startsWith("url(")?(s=Vo(i),t.strokeStyle.fill=r.defs[s]):t.strokeStyle.color=X.shared.setValue(i).toNumber(),t.useStroke=!0);break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if("none"!==i){if(i.startsWith("url(")){const s=Vo(i);t.fillStyle.fill=r.defs[s]}else t.fillStyle.color=X.shared.setValue(i).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(i);break;case"stroke-opacity":t.strokeStyle.alpha=Number(i);break;case"opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i)}}var UT=Object.defineProperty,Fp=Object.getOwnPropertySymbols,kT=Object.prototype.hasOwnProperty,$T=Object.prototype.propertyIsEnumerable,Dp=(r,t,e)=>t in r?UT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t=t||{})kT.call(t,e)&&Dp(r,e,t[e]);if(Fp)for(var e of Fp(t))$T.call(t,e)&&Dp(r,e,t[e]);return r};function Up(r,t){"string"==typeof r&&((o=document.createElement("div")).innerHTML=r.trim(),r=o.querySelector("svg"));var o,e={context:t,defs:{},path:new se},i=(Ip(r,e),r.children),{fillStyle:s,strokeStyle:n}=Yo(r,e);for(let o=0;o<i.length;o++){var a=i[o];"defs"!==a.nodeName.toLowerCase()&&function kp(r,t,e,i){var s=r.children,{fillStyle:n,strokeStyle:o}=Yo(r,t);n&&e?e=Ji(Ji({},e),n):n&&(e=n),o&&i?i=Ji(Ji({},i),o):o&&(i=o),(n=!e&&!i)&&(e={color:0});let l,u,c,d,p,f,m,_,g,b,x,y,T,A,S,E,U;switch(r.nodeName.toLowerCase()){case"path":A=r.getAttribute("d"),r.getAttribute("fill-rule"),S=new se(A,!0),t.context.path(S),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"circle":m=Z(r,"cx",0),_=Z(r,"cy",0),g=Z(r,"r",0),t.context.ellipse(m,_,g,g),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":l=Z(r,"x",0),u=Z(r,"y",0),E=Z(r,"width",0),U=Z(r,"height",0),b=Z(r,"rx",0),x=Z(r,"ry",0),b||x?t.context.roundRect(l,u,E,U,b||x):t.context.rect(l,u,E,U),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=Z(r,"cx",0),_=Z(r,"cy",0),b=Z(r,"rx",0),x=Z(r,"ry",0),t.context.beginPath(),t.context.ellipse(m,_,b,x),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=Z(r,"x1",0),d=Z(r,"y1",0),p=Z(r,"x2",0),f=Z(r,"y2",0),t.context.beginPath(),t.context.moveTo(c,d),t.context.lineTo(p,f),i&&t.context.stroke(i);break;case"polygon":T=r.getAttribute("points"),y=T.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(y,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":T=r.getAttribute("points"),y=T.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(y,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:Ot(`[SVG parser] <${r.nodeName}> elements unsupported`)}n&&(e=null);for(let O=0;O<s.length;O++)kp(s[O],t,e,i)}(a,e,s,n)}return t}var LT=Object.defineProperty,ts=Object.getOwnPropertySymbols,$p=Object.prototype.hasOwnProperty,Lp=Object.prototype.propertyIsEnumerable,Np=(r,t,e)=>t in r?LT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dt=(r,t)=>{for(var e in t=t||{})$p.call(t,e)&&Np(r,e,t[e]);if(ts)for(var e of ts(t))Lp.call(t,e)&&Np(r,e,t[e]);return r};function Hp(r){return r instanceof wr}function Xp(r){return r instanceof Qt}function jp(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Dt(Dt({},e),r)}function zp(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,Dt(Dt({},e),r)}function ne(r,t){var e,i;return null==r?null:(e={},function(r){return X.isColorLike(r)}(i=r)?function(r,t,e){return t=X.shared.setValue(null!=t?t:0),r.color=t.toNumber(),r.alpha=(1===t.alpha?e:t).alpha,r.texture=P.WHITE,Dt(Dt({},e),r)}(e,r,t):function(r){return r instanceof P}(r)?function(r,t,e){return r.texture=t,Dt(Dt({},e),r)}(e,r,t):Hp(r)?jp(e,r,t):Xp(r)?zp(e,r,t):i.fill&&Hp(i.fill)?jp(i,i.fill,t):i.fill&&Xp(i.fill)?zp(i,i.fill,t):function(r,t){return t=Dt(Dt({},t),r),r=X.shared.setValue(t.color),t.alpha*=r.alpha,t.color=r.toNumber(),t}(i,t))}function Or(r,t){var{width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l}=t;return(r=ne(r,((r,t)=>{var e={};for(i in r)$p.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&ts)for(var i of ts(r))t.indexOf(i)<0&&Lp.call(r,i)&&(e[i]=r[i]);return e})(t,["width","alignment","miterLimit","cap","join","pixelLine"])))?Dt({width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l},r):null}var WT=Object.defineProperty,Vp=Object.getOwnPropertySymbols,YT=Object.prototype.hasOwnProperty,KT=Object.prototype.propertyIsEnumerable,Wp=(r,t,e)=>t in r?WT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qe=(r,t)=>{for(var e in t=t||{})YT.call(t,e)&&Wp(r,e,t[e]);if(Vp)for(var e of Vp(t))KT.call(t,e)&&Wp(r,e,t[e]);return r};const qT=new V,Yp=new M,qo=class zt extends ft{constructor(){super(...arguments),this.uid=K("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new se,this._transform=new M,this._fillStyle=qe({},zt.defaultFillStyle),this._strokeStyle=qe({},zt.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new nt,this._boundsDirty=!0}clone(){var t=new zt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=qe({},this._fillStyle),t._strokeStyle=qe({},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=ne(t,zt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Or(t,zt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ne(t,zt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ne(t,zt.defaultStrokeStyle),this}texture(t,e,i,s,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?X.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new se,this}fill(t,e){var s=this.instructions[this.instructions.length-1];return(s=0===this._tick&&s&&"stroke"===s.action?s.data.path:this._activePath.clone())&&(null!=t&&(this._fillStyle=ne(t=void 0!==e&&"number"==typeof t?{color:t,alpha:e}:t,zt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0),this}_initNextPathLocation(){var{x:t,y:e}=this._activePath.getLastPoint(V.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){var i=this.instructions[this.instructions.length-1];return(i=0===this._tick&&i&&"fill"===i.action?i.data.path:this._activePath.clone())&&(null!=t&&(this._strokeStyle=Or(t,zt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0),this}cut(){for(let t=0;t<2;t++){var e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=i;break}e.data.hole.addPath(i)}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,o){this._tick++;var a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,s,n,o),this}arcTo(t,e,i,s,n){this._tick++;var o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(t,e,i,s,n,o,a){this._tick++;var l=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,i,s,n,o,a){this._tick++;var 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*i+l.c*s+l.tx,l.b*i+l.d*s+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++,null!=(t=this._activePath)&&t.closePath(),this}ellipse(t,e,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;var i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;var i=this._transform,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,t=i.b*t+i.d*e+i.ty;return 1===s.length&&"moveTo"===s[0].action?(s[0].data[0]=n,s[0].data[1]=t):this._activePath.moveTo(n,t),this}quadraticCurveTo(t,e,i,s,n){this._tick++;var o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,o),this}roundPoly(t,e,i,s,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,o),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,o),this}star(t,e,i,s,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,s,n,o,this._transform.clone()),this}svg(t){return this._tick++,Up(t,this),this}restore(){var 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:qe({},this._fillStyle),strokeStyle:qe({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,s,n,o){return t instanceof M?this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty):this._transform.set(t,e,i,s,n,o),this}transform(t,e,i,s,n,o){return t instanceof M?this._transform.append(t):(Yp.set(t,e,i,s,n,o),this._transform.append(Yp)),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.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;var t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){var i=this.instructions[e],s=i.action;if("fill"===s){var n=i.data;t.addBounds(n.path.bounds)}else if("texture"===s){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if("stroke"===s){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),l=n.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;var i=this.instructions;let s=!1;for(let n=0;n<i.length;n++){var o=i[n],a=o.data,l=a.path;if(o.action&&l){var u=a.style,c=l.shapePath.shapePrimitives;for(let d=0;d<c.length;d++){var p=c[d].shape;if(u&&p){var f=c[d].transform,m=f?f.applyInverse(t,qT):t;if(s="fill"===o.action?p.contains(m.x,m.y):p.strokeContains(m.x,m.y,u.width,u.alignment),f=a.hole){var g=null==(p=f.shapePath)?void 0:p.shapePrimitives;if(g)for(let b=0;b<g.length;b++)g[b].shape.contains(m.x,m.y)&&(s=!1)}if(s)return!0}}}}return s}destroy(t=!1){this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,this._fillStyle.texture&&this._fillStyle.texture.destroy(t),this._strokeStyle.texture)&&this._strokeStyle.texture.destroy(t),this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};qo.defaultFillStyle={color:16777215,alpha:1,texture:P.WHITE,matrix:null,fill:null,textureSpace:"local"},qo.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:P.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let dt=qo;const Kp=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Zo(r){var t=[];let e=0;for(let i=0;i<Kp.length;i++){var s="_"+Kp[i];t[e++]=r[s]}return e=qp(r._fill,t,e),e=function(r,t,e){return r&&(e=qp(r,t,e),t[e++]=r.width,t[e++]=r.alignment,t[e++]=r.cap,t[e++]=r.join,t[e++]=r.miterLimit),e}(r._stroke,t,e),e=function(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=X.shared.setValue(r.color).toNumber()),e}(r.dropShadow,t,e),t.join("-")}function qp(r,t,e){return r&&(t[e++]=r.color,t[e++]=r.alpha,t[e++]=null==(t=r.fill)?void 0:t.styleKey),e}var JT=Object.defineProperty,tS=Object.defineProperties,eS=Object.getOwnPropertyDescriptors,Zp=Object.getOwnPropertySymbols,rS=Object.prototype.hasOwnProperty,iS=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?JT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,At=(r,t)=>{for(var e in t=t||{})rS.call(t,e)&&Qp(r,e,t[e]);if(Zp)for(var e of Zp(t))iS.call(t,e)&&Qp(r,e,t[e]);return r};($i=class ar extends ft{constructor(t={}){super(),function(r){var a,o=r;if("boolean"==typeof o.dropShadow&&o.dropShadow&&(a=Pt.defaultDropShadow,r.dropShadow={alpha:null!=(t=o.dropShadowAlpha)?t:a.alpha,angle:null!=(t=o.dropShadowAngle)?t:a.angle,blur:null!=(t=o.dropShadowBlur)?t:a.blur,color:null!=(t=o.dropShadowColor)?t:a.color,distance:null!=(t=o.dropShadowDistance)?t:a.distance}),void 0!==o.strokeThickness){var t=o.stroke;let l={};if(X.isColorLike(t))l.color=t;else if(t instanceof Qt||t instanceof wr)l.fill=t;else{if(!Object.hasOwnProperty.call(t,"color")&&!Object.hasOwnProperty.call(t,"fill"))throw new Error("Invalid stroke value.");l=t}r.stroke=((r,t)=>tS(r,eS(t)))(At({},l),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){let a;null==r.fontSize?r.fontSize=Pt.defaultTextStyle.fontSize:a="string"==typeof r.fontSize?parseInt(r.fontSize,10):r.fontSize;const l=new Qt({start:{x:0,y:0},end:{x:0,y:1.7*(a||0)}}),u=o.fillGradientStops.map(c=>X.shared.setValue(c).toNumber());u.forEach((c,d)=>{d/=u.length-1,l.addColorStop(d,c)}),r.fill={fill:l}}}(t);var e=At(At({},ar.defaultTextStyle),t);for(const i in e)this[i]=e[i];this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow=null!==t&&"object"==typeof t?this._createProxy(At(At({},ar.defaultDropShadow),t)):t?this._createProxy(At({},ar.defaultDropShadow)):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize="string"==typeof t?parseInt(t,10):t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set 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(At(At({},dt.defaultFillStyle),t),()=>{this._fill=ne(At({},this._originalFill),dt.defaultFillStyle)})),this._fill=ne(0===t?"black":t,dt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(At(At({},dt.defaultStrokeStyle),t),()=>{this._stroke=Or(At({},this._originalStroke),dt.defaultStrokeStyle)})),this._stroke=Or(t,dt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Zo(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){var t=ar.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new ar({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?At({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var e;this.removeAllListeners(),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,null!=(e=this._fill)&&e.texture&&this._fill.texture.destroy(t),null!=(e=this._originalFill)&&e.texture&&this._originalFill.texture.destroy(t),null!=(e=this._stroke)&&e.texture&&this._stroke.texture.destroy(t),null!=(e=this._originalStroke))&&e.texture&&this._originalStroke.texture.destroy(t),this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]=n,null!=e&&e(s,n),this.update(),!0)})}_isFillStyle(t){return null!==(null!=t?t:null)&&!(X.isColorLike(t)||t instanceof Qt||t instanceof wr)}}).defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},$i.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 Pt=$i;const oS=new nt;function Jo(r,t,e,i){var s=oS;return s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0,(s=it.getOptimalTexture(s.width,s.height,i,!1)).source.uploadMethodId="image",s.source.resource=r,s.source.alphaMode="premultiply-alpha-on-upload",s.frame.width=t/i,s.frame.height=e/i,s.source.emit("update",s.source),s.updateUvs(),s}const aS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Gr(r){var t="number"==typeof r.fontSize?r.fontSize+"px":r.fontSize,e=r.fontFamily;for(let i=(e=Array.isArray(r.fontFamily)?e:r.fontFamily.split(",")).length-1;0<=i;i--){let s=e[i].trim();/([\"\'])[^\'\"]+\1/.test(s)||aS.includes(s)||(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} `+e.join(",")}const ta={willReadFrequently:!0},Ut=class C{static get experimentalLetterSpacingSupported(){let t=C._experimentalLetterSpacingSupported;var e;return void 0!==t&&(e=H.get().getCanvasRenderingContext2D().prototype,t=C._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e),t}constructor(t,e,i,s,n,o,a,l,u){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u}static measureText(t=" ",e,i=C._canvas,s=e.wordWrap){var o=t+":"+e.styleKey;if(C._measurementCache[o])return C._measurementCache[o];var o=Gr(e),l=C.measureFont(o),u=(0===l.fontSize&&(l.fontSize=e.fontSize,l.ascent=e.fontSize),C.__context),c=(u.font=o,(s?C._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/)),d=new Array(c.length);let p=0;for(let b=0;b<c.length;b++){var x=C._measureText(c[b],e.letterSpacing,u);d[b]=x,p=Math.max(p,x)}s=(null==(o=e._stroke)?void 0:o.width)||0;let m=p+s,g=(e.dropShadow&&(m+=e.dropShadow.distance),i=e.lineHeight||l.fontSize,Math.max(i,l.fontSize+s)+(c.length-1)*(i+e.leading));return e.dropShadow&&(g+=e.dropShadow.distance),new C(t,e,m,g,c,d,i+e.leading,p,l)}static _measureText(t,e,i){let s=!1,o=(C.experimentalLetterSpacingSupported&&(C.experimentalLetterSpacing?(i.letterSpacing=e+"px",i.textLetterSpacing=e+"px",s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px")),(i=i.measureText(t)).width);var a=-i.actualBoundingBoxLeft;let l=i.actualBoundingBoxRight-a;return 0<o&&(s?(o-=e,l-=e):(i=(C.graphemeSegmenter(t).length-1)*e,o+=i,l+=i)),Math.max(o,l)}static _wordWrap(t,e,i=C._canvas){var s=i.getContext("2d",ta);let n=0,o="",a="";var l=Object.create(null),{letterSpacing:u,whiteSpace:i}=e,d=C._collapseSpaces(i),p=C._collapseNewlines(i);let f=!d;var m=e.wordWrapWidth+u,_=C._tokenize(t);for(let g=0;g<_.length;g++){let b=_[g];if(C._isNewline(b)){if(!p){a+=C._addLine(o),f=!d,o="",n=0;continue}b=" "}if(d){var y=C.isBreakingSpace(b),T=C.isBreakingSpace(o[o.length-1]);if(y&&T)continue}if(m<(y=C._getFromCache(b,u,l,s)))if(""!==o&&(a+=C._addLine(o),o="",n=0),C.canBreakWords(b,e.breakWords)){const y=C.wordWrapSplit(b);for(let T=0;T<y.length;T++){let A=y[T],S=A,E=1;for(;y[T+E];){var O=y[T+E];if(C.canBreakChars(S,O,b,T,e.breakWords))break;A+=O,S=O,E++}T+=E-1;var U=C._getFromCache(A,u,l,s);U+n>m&&(a+=C._addLine(o),f=!1,o="",n=0),o+=A,n+=U}}else{0<o.length&&(a+=C._addLine(o),o="",n=0);const y=g===_.length-1;a+=C._addLine(b,!y),f=!1,o="",n=0}else y+n>m&&(f=!1,a+=C._addLine(o),o="",n=0),(0<o.length||!C.isBreakingSpace(b)||f)&&(o+=b,n+=y)}return a+=C._addLine(o,!1)}static _addLine(t,e=!0){return t=C._trimRight(t),e?t+`
`:t}static _getFromCache(t,e,i,s){let n=i[t];return"number"!=typeof n&&(n=C._measureText(t,e,s)+e,i[t]=n),n}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(t){if("string"!=typeof t)return"";for(let e=t.length-1;0<=e;e--){var i=t[e];if(!C.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return"string"==typeof t&&C._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return"string"==typeof t&&C._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){var e=[];let i="";if("string"==typeof t){for(let s=0;s<t.length;s++){var n=t[s],o=t[s+1];C.isBreakingSpace(n,o)||C._isNewline(n)?(""!==i&&(e.push(i),i=""),e.push(n)):i+=n}""!==i&&e.push(i)}return e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return C.graphemeSegmenter(t)}static measureFont(t){var e;return C._fonts[t]||((e=C._context).font=t,e={ascent:(e=e.measureText(C.METRICS_STRING+C.BASELINE_SYMBOL)).actualBoundingBoxAscent,descent:e.actualBoundingBoxDescent,fontSize:e.actualBoundingBoxAscent+e.actualBoundingBoxDescent},C._fonts[t]=e)}static clearMetrics(t=""){t?delete C._fonts[t]:C._fonts={}}static get _canvas(){if(!C.__canvas){let t;try{var e=new OffscreenCanvas(0,0),i=e.getContext("2d",ta);if(null!=i&&i.measureText)return C.__canvas=e;t=H.get().createCanvas()}catch(e){t=H.get().createCanvas()}t.width=t.height=10,C.__canvas=t}return C.__canvas}static get _context(){return C.__context||(C.__context=C._canvas.getContext("2d",ta)),C.__context}};Ut.METRICS_STRING="|ÉqÅ",Ut.BASELINE_SYMBOL="M",Ut.BASELINE_MULTIPLIER=1.4,Ut.HEIGHT_MULTIPLIER=2,Ut.graphemeSegmenter=(()=>{if("function"!=typeof(null==Intl?void 0:Intl.Segmenter))return r=>[...r];{const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}})(),Ut.experimentalLetterSpacing=!1,Ut._fonts={},Ut._newlines=[10,13],Ut._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ut._measurementCache={};let jt=Ut;function Br(r,t,e,i=0){var o,a,s,m,_;if(r.texture===P.WHITE&&!r.fill)return X.shared.setValue(r.color).setAlpha(null!=(s=r.alpha)?s:1).toHexa();if(!r.fill){const n=t.createPattern(r.texture.source.resource,"repeat"),o=r.matrix.copyTo(M.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}if(r.fill instanceof wr)return s=r.fill,o=t.createPattern(s.texture.source.resource,"repeat"),(a=s.transform.copyTo(M.shared)).scale(s.texture.frame.width,s.texture.frame.height),o.setTransform(a),o;if(r.fill instanceof Qt){const n=r.fill,o="linear"===n.type,a="local"===n.textureSpace;let l=1,u=1;a&&e&&(l=e.width+i,u=e.height+i);let c,d=!1;if(o?({start:s,end:r}=n,c=t.createLinearGradient(s.x*l,s.y*u,r.x*l,r.y*u),d=Math.abs(r.x-s.x)<Math.abs(.1*(r.y-s.y))):({center:r,innerRadius:s,outerCenter:m,outerRadius:_}=n,c=t.createRadialGradient(r.x*l,r.y*u,s*l,m.x*l,m.y*u,_*l)),d&&a&&e){const p=e.lineHeight/u;for(let f=0;f<e.lines.length;f++){const m=(f*e.lineHeight+i/2)/u;n.colorStops.forEach(_=>{var g=m+_.offset*p;c.addColorStop(Math.floor(1e5*g)/1e5,X.shared.setValue(_.color).toHex())})}}else n.colorStops.forEach(p=>{c.addColorStop(p.offset,X.shared.setValue(p.color).toHex())});return c}return"red"}class ea{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,i){var t=jt.measureText(t||" ",i),n=Math.ceil(Math.ceil(Math.max(1,t.width)+2*i.padding)*e),t=Math.ceil(Math.ceil(Math.max(1,t.height)+2*i.padding)*e),n=Math.ceil(n-1e-6),t=Math.ceil(t-1e-6);return{width:de(n),height:de(t)}}getTexture(t,e,i,s){(t="string"==typeof t?{text:t,style:i,resolution:e}:t).style instanceof Pt||(t.style=new Pt(t.style));var{texture:i,canvasAndContext:e}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(i._source),Xt.returnCanvasAndContext(e),i}createTextureAndCanvas(t){var{text:i,style:s}=t,t=null!=(t=t.resolution)?t:this._renderer.resolution,o=jt.measureText(i||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+2*s.padding)*t),o=Math.ceil(Math.ceil(Math.max(1,o.height)+2*s.padding)*t),u=Xt.getOptimalCanvasAndContext(a,o),c=u.canvas,i=(this.renderTextToCanvas(i,s,t,u),Jo(c,a,o,t));return s.trim&&(a=gp(c,t),i.frame.copyFrom(a),i.updateUvs()),{texture:i,canvasAndContext:u}}getManagedTexture(t){t._resolution=(t._autoResolution?this._renderer:t).resolution;var s,e=t._getKey();return this._activeTextures[e]?(this._increaseReferenceCount(e),this._activeTextures[e].texture):({texture:t,canvasAndContext:s}=this.createTextureAndCanvas(t),this._activeTextures[e]={canvasAndContext:s,texture:t,usageCount:1},t)}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}returnTexture(t){var e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",it.returnTexture(t)}decreaseReferenceCount(t){var e=this._activeTextures[t];e.usageCount--,0===e.usageCount&&(Xt.returnCanvasAndContext(e.canvasAndContext),this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,i,s){var u,{canvas:c,context:d}=s,p=Gr(e),f=jt.measureText(t||" ",e),m=f.lines,_=f.lineHeight,g=f.lineWidths,b=f.maxLineWidth,x=f.fontProperties,y=c.height;d.resetTransform(),d.scale(i,i),d.textBaseline=e.textBaseline,null!=(t=e._stroke)&&t.width&&(c=e._stroke,d.lineWidth=c.width,d.miterLimit=c.miterLimit,d.lineJoin=c.join,d.lineCap=c.cap),d.font=p;let T,A;var S=e.dropShadow?2:1;for(let E=0;E<S;++E){var et,ee,U=e.dropShadow&&0===E,O=U?Math.ceil(Math.max(1,y)+2*e.padding):0,R=O*i;U?(d.fillStyle="black",d.strokeStyle="black",et=(U=e.dropShadow).color,ee=U.alpha,d.shadowColor=X.shared.setValue(et).setAlpha(ee).toRgbaString(),et=U.blur*i,ee=U.distance*i,d.shadowBlur=et,d.shadowOffsetX=Math.cos(U.angle)*ee,d.shadowOffsetY=Math.sin(U.angle)*ee+R):(d.fillStyle=e._fill?Br(e._fill,d,f):null,null!=(et=e._stroke)&&et.width&&(R=e._stroke.width*e._stroke.alignment,d.strokeStyle=Br(e._stroke,d,f,R)),d.shadowColor="black");let w=(_-x.fontSize)/2;_-x.fontSize<0&&(w=0);var D=null!=(ee=null==(U=e._stroke)?void 0:U.width)?ee:0;for(let G=0;G<m.length;G++)A=(T=D/2)+G*_+x.ascent+w,"right"===e.align?T+=b-g[G]:"center"===e.align&&(T+=(b-g[G])/2),null!=(u=e._stroke)&&u.width&&this._drawLetterSpacing(m[G],e,s,T+e.padding,A+e.padding-O,!0),void 0!==e._fill&&this._drawLetterSpacing(m[G],e,s,T+e.padding,A+e.padding-O)}}_drawLetterSpacing(t,e,i,s,n,o=!1){var a=i.context,l=e.letterSpacing;let u=!1;if(jt.experimentalLetterSpacingSupported&&(jt.experimentalLetterSpacing?(a.letterSpacing=l+"px",a.textLetterSpacing=l+"px",u=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),0===l||u)o?a.strokeText(t,s,n):a.fillText(t,s,n);else{let c=s;var d=jt.graphemeSegmenter(t);let p=a.measureText(t).width,f;for(let m=0;m<d.length;++m){var _=d[m];o?a.strokeText(_,c,n):a.fillText(_,c,n);let g="";for(let b=m+1;b<d.length;++b)g+=d[b];f=a.measureText(g).width,c+=p-f+l,p=f}}}destroy(){this._activeTextures=null}}ea.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"canvasText"},B.add(ea),B.add(Fo);var lS=Object.defineProperty,es=Object.getOwnPropertySymbols,tf=Object.prototype.hasOwnProperty,ef=Object.prototype.propertyIsEnumerable,rf=(r,t,e)=>t in r?lS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Ze extends Lt{constructor(t){var{context:i,roundPixels:s}=t=(t instanceof dt?{context:t}:t)||{};super(((r,t)=>{for(var e in t=t||{})tf.call(t,e)&&rf(r,e,t[e]);if(es)for(var e of es(t))ef.call(t,e)&&rf(r,e,t[e]);return r})({label:"Graphics"},((r,t)=>{var e={};for(i in r)tf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&es)for(var i of es(r))t.indexOf(i)<0&&ef.call(r,i)&&(e[i]=r[i]);return e})(t,["context","roundPixels"]))),this.renderPipeId="graphics",this._context=i||(this._ownedContext=new dt),this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=null!=s&&s}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==(null==t?void 0:t.context)||this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Ze(this._context.clone()):(this._ownedContext=null,new Ze(this._context))}lineStyle(t,e,i){var s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){var i={};return void 0!==t&&(i.color=t),void 0!==e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();var t=this.context.strokeStyle;return t.width===dt.defaultStrokeStyle.width&&t.color===dt.defaultStrokeStyle.color&&t.alpha===dt.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)}}const sf={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, localUniforms.uColor, localUniforms.uDistance));
`}},nf={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));
`}},of={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;
}
`}},af={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 ra,ia;class lf extends St{constructor(){var t=new st({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=be();null==ra&&(ra=He({name:"sdf-shader",bits:[Mi,Oi(e),sf,of,je]})),super({glProgram:ia=null==ia?Xe({name:"sdf-shader",bits:[Ci,Gi(e),nf,af,ze]}):ia,gpuProgram:ra,resources:{localUniforms:t,batchSamplers:Bi(e)}})}}class sa extends ft{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 i in this.chars)null!=(e=this.chars[i].texture)&&e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}function na(r){if(""===r)return[];var t=[];for(let e=0,i=(r="string"==typeof r?[r]:r).length;e<i;e++){var s=r[e];if(Array.isArray(s)){if(2!==s.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(0===s[0].length||0===s[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");var n=s[0].charCodeAt(0),o=s[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(s))}if(0===t.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var hS=Object.defineProperty,uf=Object.getOwnPropertySymbols,dS=Object.prototype.hasOwnProperty,pS=Object.prototype.propertyIsEnumerable,cf=(r,t,e)=>t in r?hS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hf=(r,t)=>{for(var e in t=t||{})dS.call(t,e)&&cf(r,e,t[e]);if(uf)for(var e of uf(t))pS.call(t,e)&&cf(r,e,t[e]);return r};(Bd=class Hy extends sa{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;var t=hf(hf({},Hy.defaultOptions),t),o=(this._textureSize=t.textureSize,this._mipmap=t.mipmap,t.style.clone()),a=(t.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=P.WHITE,o._fill.fill=null),this.applyFillAsTint=t.overrideFill,o.fontSize),l=(o.fontSize=this.baseMeasurementFontSize,Gr(o));t.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=null!=(a=t.skipKerning)&&a,this.resolution=null!=(a=t.resolution)?a:1,this._padding=null!=(a=t.padding)?a:4,this.fontMetrics=jt.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var o=na(t).filter(T=>!this._currentChars.includes(T)).filter((T,A,S)=>S.indexOf(T)===A);if(o.length){this._currentChars=[...this._currentChars,...o];let a,{canvas:l,context:u}=(a=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex]).canvasAndContext,c=a.texture.source;var d=this._style;let p=this._currentX,f=this._currentY;var m=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=this._padding*m;let g=0,b=!1;var x=l.width/this.resolution,y=l.height/this.resolution;for(let T=0;T<o.length;T++){var G,A=o[T],S=jt.measureText(A,d,l,!1),E=(S.lineHeight=S.height,S.width*m),R=Math.ceil(("italic"===d.fontStyle?2:1)*E)+2*_,w=S.height*m+2*_,E=(b=!1,A!==`
`&&"\r"!==A&&"\t"!==A&&" "!==A&&(b=!0,g=Math.ceil(Math.max(w,g))),p+R>x&&(f+=g,g=w,p=0,f+g>y)&&(c.update(),G=this._nextPage(),l=G.canvasAndContext.canvas,u=G.canvasAndContext.context,c=G.texture.source,f=0),E/m-(null!=(E=null==(G=d.dropShadow)?void 0:G.distance)?E:0)-(null!=(E=null==(E=d._stroke)?void 0:E.width)?E:0));if(this.chars[A]={id:A.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:E,kerning:{}},b){this._drawGlyph(u,S,p+_,f+_,m,d);const G=c.width*m,et=c.height*m,ee=new z(p/G*c.width,f/et*c.height,R/G*c.width,w/et*c.height);this.chars[A].texture=new P({source:c,frame:ee}),p+=Math.ceil(R)}}c.update(),this._currentX=p,this._currentY=f,this._skipKerning&&this._applyKerning(o,u)}}get pageTextures(){return this.pages}_applyKerning(t,e){var i=this._measureCache;for(let s=0;s<t.length;s++){var n=t[s];for(let o=0;o<this._currentChars.length;o++){var a=this._currentChars[o],l=i[n]||(i[n]=e.measureText(n).width),u=i[a]||(i[a]=e.measureText(a).width),d=e.measureText(n+a).width-(l+u);d&&(this.chars[n].kerning[a]=d),(d=e.measureText(n+a).width-(l+u))&&(this.chars[a].kerning[n]=d)}}}_nextPage(){this._currentPageIndex++;var t=this.resolution,e=Xt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t),t=(this._setupContext(e.context,this._style,t),t*(this.baseRenderedFontSize/this.baseMeasurementFontSize)),e={canvasAndContext:e,texture:new P({source:new ie({resource:e.canvas,resolution:t,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})})};return this.pages[this._currentPageIndex]=e}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Gr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;var n=e._stroke,s=null!=(s=null==n?void 0:n.width)?s:0;n&&(t.lineWidth=s,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Br(n,t)),e._fill&&(t.fillStyle=Br(e._fill,t)),e.dropShadow?(s=e.dropShadow,n=X.shared.setValue(s.color).toArray(),e=s.blur*i,i=s.distance*i,t.shadowColor=`rgba(${255*n[0]},${255*n[1]},${255*n[2]},${s.alpha})`,t.shadowBlur=e,t.shadowOffsetX=Math.cos(s.angle)*i,t.shadowOffsetY=Math.sin(s.angle)*i):(t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0)}_drawGlyph(t,e,i,s,n,o){var l=e.text,u=e.fontProperties,c=o._stroke,i=i+(c=(null!=(c=null==c?void 0:c.width)?c:0)*n)/2,s=s-c/2,u=u.descent*n,e=e.lineHeight*n;o.stroke&&c&&t.strokeText(l,i,s+e-u),o._fill&&t.fillText(l,i,s+e-u)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){var{canvasAndContext:e,texture:i}=this.pages[t];Xt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}}).defaultOptions={textureSize:512,style:new Pt,mipmap:!0};let oa=Bd;function aa(r,t,e,i){const s={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=e.baseLineOffset;let n=s.lines[0],o=null,a=!0;const l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=()=>{let m=n.chars.length-1;if(i){let _=n.chars[m];for(;" "===_;)n.width-=e.chars[_].xAdvance,_=n.chars[--m]}s.width=Math.max(s.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(n),s.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,p=t.letterSpacing*d,f=t.wordWrapWidth*d;for(let m=0;m<r.length+1;m++){let _;var g=m===r.length,b=(g||(_=r[m]),e.chars[_]||e.chars[" "]);/(?:\s)/.test(_)||"\r"===_||_===`
`||g?(!a&&t.wordWrap&&n.width+l.width-p>f?c():l.start=n.width,(m=>{var _=n.width;for(let g=0;g<l.index;g++){var b=m.positions[g];n.chars.push(m.chars[g]),n.charPositions.push(b+_)}n.width+=m.width,a=!1,l.width=0,l.index=0,l.chars.length=0})(l),g||n.charPositions.push(0),"\r"===_||_===`
`?0!==n.width&&c():g||(g=b.xAdvance+(b.kerning[o]||0)+p,n.width+=g,n.spaceWidth=g,n.spacesIndex.push(n.charPositions.length),n.chars.push(_))):(g=b.kerning[o]||0,b=b.xAdvance+g+p,l.positions[l.index++]=l.width+g,l.chars.push(_),l.width+=b),o=_}return c(),"center"===t.align?function(r){for(let t=0;t<r.lines.length;t++){var e=r.lines[t],i=r.width/2-e.width/2;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}(s):"right"===t.align?function(r){for(let t=0;t<r.lines.length;t++){var e=r.lines[t],i=r.width-e.width;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}(s):"justify"===t.align&&function(r){var t=r.width;for(let e=0;e<r.lines.length;e++){var i=r.lines[e];let s=0,n=i.spacesIndex[s++],o=0;var a=i.spacesIndex.length,l=(t-i.width)/a;for(let u=0;u<i.charPositions.length;u++)u===n&&(n=i.spacesIndex[s++],o+=l),i.charPositions[u]+=o}}(s),s}var _S=Object.defineProperty,pf=Object.getOwnPropertySymbols,bS=Object.prototype.hasOwnProperty,vS=Object.prototype.propertyIsEnumerable,ff=(r,t,e)=>t in r?_S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,la=(r,t)=>{for(var e in t=t||{})bS.call(t,e)&&ff(r,e,t[e]);if(pf)for(var e of pf(t))vS.call(t,e)&&ff(r,e,t[e]);return r};let rs=0;const Ir=new 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}}getFont(t,e){var i;let s=e.fontFamily+"-bitmap",n=!0;if(e._fill.fill&&!e._stroke)s+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let a=e.styleKey;a=a.substring(0,a.lastIndexOf("-")),s=a+"-bitmap",n=!1}return W.has(s)||(e=new oa(la({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions)),50<++rs&&Ot("BitmapText",`You have dynamically created ${rs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),e.once("destroy",()=>{rs--,W.remove(s)}),W.set(s,e)),null!=(i=(e=W.get(s)).ensureCharacters)&&i.call(e,t),e}getLayout(t,e,i=!0){var s=this.getFont(t,e);return aa([...t],e,s,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,o=t[0];const a=null==(o="string"==typeof o?{name:o,style:t[1],chars:null==(e=t[2])?void 0:e.chars,resolution:null==(e=t[2])?void 0:e.resolution,padding:null==(e=t[2])?void 0:e.padding,skipKerning:null==(e=t[2])?void 0:e.skipKerning}:o)?void 0:o.name;if(a)return t=null!==(e=(t=(o=la(la({},this.defaultOptions),o)).style)instanceof Pt?t:new Pt(t))._fill.fill&&void 0!==e._fill.fill,e=new oa({style:e,overrideFill:t,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1}),t=na(o.chars),e.ensureCharacters(t.join("")),W.set(a+"-bitmap",e),e.once("destroy",()=>W.remove(a+"-bitmap")),e;throw new Error("[BitmapFontManager] Property `name` is required.")}uninstall(t){t+="-bitmap",(t=W.get(t))&&t.destroy()}};class ua{constructor(t){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){var e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){var i=this._getGpuBitmapText(t);mf(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){var e=this._gpuBitmapText[t].context;e.customShader&&(N.return(e.customShader),e.customShader=null),N.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){var e=this._getGpuBitmapText(t);mf(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){var i=e.context,s=Ir.getFont(t.text,t._style),n=(i.clear(),"none"===s.distanceField.type||i.customShader||(i.customShader=N.get(lf)),Array.from(t.text)),e=t._style;let a=s.baseLineOffset;var l=aa(n,e,s,!0);let u=0;var c=e.padding,d=l.scale;let p=l.width,f=l.height+l.offsetY;e._stroke&&(p+=e._stroke.width/d,f+=e._stroke.width/d),i.translate(-t._anchor._x*p-c,-t._anchor._y*f-c).scale(d,d);var m=s.applyFillAsTint?e._fill.color:16777215;for(let _=0;_<l.lines.length;_++){var g=l.lines[_];for(let b=0;b<g.charPositions.length;b++){var x=n[u++];null!=(x=s.chars[x])&&x.texture&&i.texture(x.texture,m||"black",Math.round(g.charPositions[b]+x.xOffset),Math.round(a+x.yOffset))}a+=s.lineHeight}}_getGpuBitmapText(t){return this._gpuBitmapText[t.uid]||this.initGpuText(t)}initGpuText(t){var e=N.get(Ze);return this._gpuBitmapText[t.uid]=e,this._updateContext(t,e),t.on("destroyed",this._destroyRenderableBound),this._gpuBitmapText[t.uid]}_updateDistanceField(t){var e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,i=W.get(i+"-bitmap"),{a:n,b:o,c:a,d:l}=t.groupTransform,n=Math.sqrt(n*n+o*o),o=Math.sqrt(a*a+l*l),a=(Math.abs(n)+Math.abs(o))/2,l=i.baseRenderedFontSize/t._style.fontSize,n=a*i.distanceField.range*(1/l);e.customShader.resources.localUniforms.uniforms.uDistance=n}destroy(){for(const t in this._gpuBitmapText)this._destroyRenderableByUid(t);this._gpuBitmapText=null,this._renderer=null}}function mf(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}ua.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"bitmapText"},B.add(ua);class ca{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this),this._renderer.renderableGC.addManagedHash(this,"_gpuText")}resolutionChange(){for(const t in this._gpuText){var e=this._gpuText[t];e&&(e=e.batchableSprite.renderable)._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){var e=this._getGpuText(t),t=t._getKey();return e.textureNeedsUploading?!(e.textureNeedsUploading=!1):e.currentKey!==t}addRenderable(t,e){var i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){var e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e._batcher.updateElement(e)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(t.uid)}_destroyRenderableById(t){var e=this._gpuText[t];this._renderer.htmlText.decreaseReferenceCount(e.currentKey),N.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){var e=t._getKey(),i=this._getGpuText(t),s=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t).catch(n=>{console.error(n)}),t._didTextUpdate=!1,Wi(s,t)}async _updateGpuText(t){t._didTextUpdate=!1;var s,a,i=this._getGpuText(t);i.generatingTexture||(s=t._getKey(),this._renderer.htmlText.decreaseReferenceCount(i.currentKey),i.generatingTexture=!0,i.currentKey=s,s=null!=(s=t.resolution)?s:this._renderer.resolution,s=await this._renderer.htmlText.getManagedTexture(t.text,s,t._style,t._getKey()),(a=i.batchableSprite).texture=i.texture=s,i.generatingTexture=!1,i.textureNeedsUploading=!0,t.onViewUpdate(),Wi(a,t))}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){var e={texture:P.EMPTY,currentKey:"--",batchableSprite:N.get(Pr),textureNeedsUploading:!1,generatingTexture:!1},i=e.batchableSprite;return i.renderable=t,i.transform=t.groupTransform,i.texture=P.EMPTY,i.bounds={minX:0,maxX:1,minY:0,maxY:0},i.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=(t._autoResolution?this._renderer:t).resolution,this._gpuText[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}function gf(){var r=H.get().getNavigator().userAgent;return/^((?!chrome|android).)*safari/i.test(r)}ca.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"htmlText"};const ha="http://www.w3.org/2000/svg",da="http://www.w3.org/1999/xhtml";class pa{constructor(){this.svgRoot=document.createElementNS(ha,"svg"),this.foreignObject=document.createElementNS(ha,"foreignObject"),this.domElement=document.createElementNS(da,"div"),this.styleElement=document.createElementNS(da,"style"),this.image=new Image;var{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s)}}function _f(r){var t=r._stroke,e=r._fill,e=[`div { ${["color: "+X.shared.setValue(e.color).toHex(),`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: "+("pre"===r.whiteSpace&&r.wordWrap?"pre-wrap":r.whiteSpace),...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?["word-wrap: "+(r.breakWords?"break-all":"break-word"),`max-width: ${r.wordWrapWidth}px`]:[],...t?[vf(t)]:[],...r.dropShadow?[bf(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return function(r,t){for(const e in r){var i=r[e],s=[];for(const n in i)xf[n]?s.push(xf[n](i[n])):yf[n]&&s.push(yf[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${s.join(";")} }`)}}(r.tagStyles,e),e.join(" ")}function bf(r){var t=X.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),s=Math.round(Math.cos(r.angle)*r.distance)+`px ${Math.round(Math.sin(r.angle)*r.distance)}px`;return 0<r.blur?`text-shadow: ${s} ${r.blur}px `+t:`text-shadow: ${s} `+t}function vf(r){return[`-webkit-text-stroke-width: ${r.width}px`,"-webkit-text-stroke-color: "+X.shared.setValue(r.color).toHex(),`text-stroke-width: ${r.width}px`,"text-stroke-color: "+X.shared.setValue(r.color).toHex(),"paint-order: stroke"].join(";")}const yf={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"},xf={fill:r=>"color: "+X.shared.setValue(r).toHex(),breakWords:r=>"word-wrap: "+(r?"break-all":"break-word"),stroke:vf,dropShadow:bf};var TS=Object.defineProperty,Tf=Object.getOwnPropertySymbols,SS=Object.prototype.hasOwnProperty,ES=Object.prototype.propertyIsEnumerable,Sf=(r,t,e)=>t in r?TS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Ae extends Pt{constructor(t={}){super(t),this._cssOverrides=[],null==this.cssOverrides&&(this.cssOverrides=t.cssOverrides),this.tagStyles=null!=(t=t.tagStyles)?t:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Zo(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Ae({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?((r,t)=>{for(var e in t=t||{})SS.call(t,e)&&Sf(r,e,t[e]);if(Tf)for(var e of Tf(t))ES.call(t,e)&&Sf(r,e,t[e]);return r})({},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})}get cssStyle(){return this._cssStyle||(this._cssStyle=_f(this)),this._cssStyle}addOverride(...t){0<(t=t.filter(i=>!this.cssOverrides.includes(i))).length&&(this.cssOverrides.push(...t),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));0<e.length&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}function Ef(r,t){const e=t.fontFamily,i=[],s={},o=r.match(/font-family:([^;"\s]+)/g);function a(l){s[l]||(i.push(l),s[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)a(e[l]);else a(e);o&&o.forEach(l=>{a(l.split(":")[1].trim())});for(const l in t.tagStyles)a(t.tagStyles[l].fontFamily);return i}async function Af(r){const t=await(await H.get().fetch(r)).blob(),e=new FileReader;return new Promise((i,s)=>{e.onloadend=()=>i(e.result),e.onerror=s,e.readAsDataURL(t)})}async function fa(r,t){return t=await Af(t),`@font-face {
font-family: "${r.fontFamily}";
src: url('${t}');
font-weight: ${r.fontWeight};
font-style: ${r.fontStyle};
}`}const Fr=new Map;async function Pf(r,t,e){return r=r.filter(s=>W.has(s+"-and-url")).map((s,n)=>{var o;return Fr.has(s)||(o=W.get(s+"-and-url").url,0===n?Fr.set(s,fa({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:s},o)):Fr.set(s,fa({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:s},o))),Fr.get(s)}),(await Promise.all(r)).join(`
`)}function wf(r,t,e,i,s){var{domElement:n,styleElement:o,svgRoot:a}=s,{width:t,height:r}=(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=i,s.image);return a.setAttribute("width",t.toString()),a.setAttribute("height",r.toString()),(new XMLSerializer).serializeToString(a)}function Rf(r,t){var i=(t=Xt.getOptimalCanvasAndContext(r.width,r.height,t)).context;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),t}function Mf(r,t,e){return new Promise(async i=>{e&&await new Promise(s=>setTimeout(s,100)),r.onload=()=>{i()},r.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(t),r.crossOrigin="anonymous"})}let Cf;function ma(r,t,e,i){var{domElement:i,styleElement:n,svgRoot:o}=i=i||(Cf=Cf||new pa),r=(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),i.getBoundingClientRect()),n=(o.remove(),2*t.padding);return{width:r.width-n,height:r.height-n}}class is{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===_t.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,i,s){return this._activeTextures[s]?(this._increaseReferenceCount(s),this._activeTextures[s].promise):(t=this._buildTexturePromise(t,e,i).then(o=>this._activeTextures[s].texture=o),this._activeTextures[s]={texture:null,promise:t,usageCount:1},t)}async _buildTexturePromise(t,e,i){var s=N.get(pa),n=Ef(t,i),o=await Pf(n,i,Ae.defaultTextStyle),a=ma(t,i,o,s),l=Math.ceil(Math.ceil(Math.max(1,a.width)+2*i.padding)*e),a=Math.ceil(Math.ceil(Math.max(1,a.height)+2*i.padding)*e),c=s.image,l=(c.width=2+(0|l),c.height=2+(0|a),wf(t,i,e,o,s)),a=(await Mf(c,l,gf()&&0<n.length),c);return t=Jo((i=this._createCanvas?Rf(c,e):void 0)?i.canvas:a,c.width-2,c.height-2,e),this._createCanvas&&(this._renderer.texture.initSource(t.source),Xt.returnCanvasAndContext(i)),N.return(s),t}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,0===e.usageCount)&&(e.texture?this._cleanUp(e):e.promise.then(i=>{e.texture=i,this._cleanUp(e)}).catch(()=>{}),this._activeTextures[t]=null)}_cleanUp(t){it.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}is.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"htmlText"},is.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"},B.add(is),B.add(ca);var PS=Object.defineProperty,Of=Object.getOwnPropertySymbols,wS=Object.prototype.hasOwnProperty,RS=Object.prototype.propertyIsEnumerable,Gf=(r,t,e)=>t in r?PS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bf=(r,t)=>{for(var e in t=t||{})wS.call(t,e)&&Gf(r,e,t[e]);if(Of)for(var e of Of(t))RS.call(t,e)&&Gf(r,e,t[e]);return r};($i=class Xy extends ye{constructor(...t){let i=null!=(e=t[0])?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]});var e=(i=Bf(Bf({},Xy.defaultOptions),i)).positions||new Float32Array([0,0,1,0,1,1,0,1]),n=i.uvs||(i.positions?new Float32Array(e.length):new Float32Array([0,0,1,0,1,1,0,1])),t=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new ht({data:e,label:"attribute-mesh-positions",shrinkToFit:a,usage:L.VERTEX|L.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new ht({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:L.VERTEX|L.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new ht({data:t,label:"index-mesh-buffer",shrinkToFit:a,usage:L.INDEX|L.COPY_DST}),topology:i.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}}).defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let oe=$i;var MS=Object.defineProperty,CS=Object.defineProperties,OS=Object.getOwnPropertyDescriptors,Ff=Object.getOwnPropertySymbols,GS=Object.prototype.hasOwnProperty,BS=Object.prototype.propertyIsEnumerable,Df=(r,t,e)=>t in r?MS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const Qe={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);
}
`}},$f=($i=(r,t)=>CS(r,OS(t)))((Bd=(r,t)=>{for(var e in t=t||{})GS.call(t,e)&&Df(r,e,t[e]);if(Ff)for(var e of Ff(t))BS.call(t,e)&&Df(r,e,t[e]);return r})({},Qe),{vertex:$i(Bd({},Qe.vertex),{header:Qe.vertex.header.replace("group(1)","group(2)")})}),ss={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);
}
`}},Lf={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);
`}},Nf={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 ga,_a;class Hf extends St{constructor(){null==ga&&(ga=He({name:"tiling-sprite-shader",bits:[Qe,Lf,je]})),null==_a&&(_a=Xe({name:"tiling-sprite-shader",bits:[ss,Nf,ze]}));var t=new st({uMapCoord:{value:new M,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 M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:_a,gpuProgram:ga,resources:{localUniforms:new st({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:P.EMPTY.source,uSampler:P.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,o){var a=this.resources.tilingUniforms,l=o.width,u=o.height,c=o.textureMatrix,d=a.uniforms.uTextureTransform;d.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.ty/e),d.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=d,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class Xf extends oe{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 jf(r,t){var e=r.anchor.x,i=r.anchor.y;t[0]=-e*r.width,t[1]=-i*r.height,t[2]=(1-e)*r.width,t[3]=-i*r.height,t[4]=(1-e)*r.width,t[5]=(1-i)*r.height,t[6]=-e*r.width,t[7]=(1-i)*r.height}function zf(r,t,e,i){let s=0;var n=r.length/(t||2),o=i.a,a=i.b,l=i.c,u=i.d,c=i.tx,d=i.ty;for(e*=t;s<n;){var p=r[e],f=r[e+1];r[e]=o*p+l*f+c,r[e+1]=a*p+u*f+d,e+=t,s++}}function Vf(r,t){var i=(e=r.texture).frame.width,e=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;var a=M.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/e),zf(t,2,0,a)}const ns=new Xf;class ba{constructor(t){this._state=Et.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash")}validateRenderable(t){var e=this._getTilingSpriteData(t),i=e.canBatch,s=(this._updateCanBatch(t),e.canBatch);return s&&s===i?!(e=e.batchableMesh)._batcher.checkAndUpdateTexture(e,t.texture):i!==s}addRenderable(t,e){var i=this._renderer.renderPipes.batch,s=(this._updateCanBatch(t),this._getTilingSpriteData(t)),{geometry:n,canBatch:o}=s;o?(s.batchableMesh||(s.batchableMesh=new Vi),o=s.batchableMesh,t.didViewUpdate&&(this._updateBatchableMesh(t),o.geometry=n,o.renderable=t,o.transform=t.groupTransform,o.setTexture(t._texture)),o.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(o,e)):(i.break(e),s.shader||(s.shader=new Hf),this.updateRenderable(t),e.add(t))}execute(t){var e=this._tilingSpriteDataHash[t.uid].shader,i=(e.groups[0]=this._renderer.globalUniforms.bindGroup,e.resources.localUniforms.uniforms);i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,We(t.groupColorAlpha,i.uColor,0),this._state.blendMode=$e(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:ns,shader:e,state:this._state})}updateRenderable(t){var e=this._getTilingSpriteData(t),i=e.canBatch;i?(i=e.batchableMesh,t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)):t.didViewUpdate&&e.shader.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}destroyRenderable(t){var i=this._getTilingSpriteData(t);(i.batchableMesh=null)!=(i=i.shader)&&i.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){var e=new oe({indices:ns.indices,positions:ns.positions.slice(),uvs:ns.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:!0,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){var i=this._getTilingSpriteData(t).geometry,s=t.texture.source.style;"repeat"!==s.addressMode&&(s.addressMode="repeat",s.update()),Vf(t,i.uvs),jf(t,i.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){var e=this._getTilingSpriteData(t),t=t.texture;let s=!0;return this._renderer.type===_t.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=t.textureMatrix.isSimple&&(s||t.source.isPowerOfTwo),e.canBatch}}ba.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"tilingSprite"},B.add(ba);var IS=Object.defineProperty,Wf=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,DS=Object.prototype.propertyIsEnumerable,Yf=(r,t,e)=>t in r?IS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Kf=(r,t)=>{for(var e in t=t||{})FS.call(t,e)&&Yf(r,e,t[e]);if(Wf)for(var e of Wf(t))DS.call(t,e)&&Yf(r,e,t[e]);return r};($i=class jy extends oe{constructor(...t){var e;super({});let i=null!=(e=t[0])?e:{};"number"==typeof i&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){t=Kf(Kf({},jy.defaultOptions),t),this.verticesX=null!=(e=this.verticesX)?e:t.verticesX,this.verticesY=null!=(e=this.verticesY)?e:t.verticesY,this.width=null!=(e=this.width)?e:t.width,this.height=null!=(e=this.height)?e:t.height;var e,o=this.verticesX*this.verticesY,a=[],l=[],u=[],c=this.verticesX-1,d=this.verticesY-1,p=this.width/c,f=this.height/d;for(let _=0;_<o;_++){var g=_%this.verticesX,b=_/this.verticesX|0;a.push(g*p,b*f),l.push(g/c,b/d)}var m=c*d;for(let _=0;_<m;_++){const g=_%c,b=_/c|0,x=b*this.verticesX+g,y=b*this.verticesX+g+1,T=(1+b)*this.verticesX+g,A=(1+b)*this.verticesX+g+1;u.push(x,y,T,y,A,T)}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()}}).defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let os=$i;var US=Object.defineProperty,Zf=Object.getOwnPropertySymbols,kS=Object.prototype.hasOwnProperty,$S=Object.prototype.propertyIsEnumerable,Qf=(r,t,e)=>t in r?US(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jf=(r,t)=>{for(var e in t=t||{})kS.call(t,e)&&Qf(r,e,t[e]);if(Zf)for(var e of Zf(t))$S.call(t,e)&&Qf(r,e,t[e]);return r};(Bd=class zy extends os{constructor(t={}){super({width:(t=Jf(Jf({},zy.defaultOptions),t)).width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e;this.width=null!=(e=t.width)?e:this.width,this.height=null!=(e=t.height)?e:this.height,this._originalWidth=null!=(e=t.originalWidth)?e:this._originalWidth,this._originalHeight=null!=(e=t.originalHeight)?e:this._originalHeight,this._leftWidth=null!=(e=t.leftWidth)?e:this._leftWidth,this._rightWidth=null!=(e=t.rightWidth)?e:this._rightWidth,this._topHeight=null!=(e=t.topHeight)?e:this._topHeight,this._bottomHeight=null!=(e=t.bottomHeight)?e:this._bottomHeight,this._anchorX=null==(e=t.anchor)?void 0:e.x,this._anchorY=null==(e=t.anchor)?void 0:e.y,this.updateUvs(),this.updatePositions()}updatePositions(){var t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,c=s+n,p=o+a,c=Math.min(c<e?1:e/c,p<i?1:i/p),p=l*e,l=u*i;t[0]=t[8]=t[16]=t[24]=-p,t[2]=t[10]=t[18]=t[26]=s*c-p,t[4]=t[12]=t[20]=t[28]=e-n*c-p,t[6]=t[14]=t[22]=t[30]=e-p,t[1]=t[3]=t[5]=t[7]=-l,t[9]=t[11]=t[13]=t[15]=o*c-l,t[17]=t[19]=t[21]=t[23]=i-a*c-l,t[25]=t[27]=t[29]=t[31]=i-l,this.getBuffer("aPosition").update()}updateUvs(){var t=this.uvs,e=(t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,(t[25]=t[27]=t[29]=t[31]=1)/this._originalWidth),i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}}).defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ae=Bd;class va{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash")}addRenderable(t,e){var i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){var e=this._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){var e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){var e=this._gpuSpriteHash[t.uid];N.return(e.geometry),N.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){var e=N.get(Vi);return e.geometry=N.get(ae),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.didViewUpdate||this._updateBatchableSprite(t,e),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}va.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"nineSliceSprite"},B.add(va);class ya{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}function em(r,t){t.clear();var e=t.matrix;for(let i=0;i<r.length;i++){var s=r[i];s.globalDisplayStatus<7||(t.matrix=s.worldTransform,t.addBounds(s.bounds))}return t.matrix=e,t}ya.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"filter"};const LS=new ye({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])});class xa{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new st({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 Ht({}),this.renderer=t}get activeBackTexture(){var t;return null==(t=this._activeFilterData)?void 0:t.backTexture}push(t){var e,s=this.renderer,n=t.filterEffect.filters,o=(this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData()),this._filterStack[this._filterStackIndex]);if(this._filterStackIndex++,0===n.length)o.skip=!0;else{var _,a=o.bounds,l=(t.renderables?em(t.renderables,a):t.filterEffect.filterArea?(a.clear(),a.addRect(t.filterEffect.filterArea),a.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,a),t.container&&(_=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform)&&a.applyMatrix(_),s.renderTarget.renderTarget.colorTexture.source);let u=1/0,c=0,d=!0,p=!1,f=!1,m=!0;for(let _=0;_<n.length;_++){var g=n[_];if(u=Math.min(u,"inherit"===g.resolution?l._resolution:g.resolution),c+=g.padding,"off"===g.antialias?d=!1:"inherit"===g.antialias&&(d=d&&l.antialias),g.clipToViewport||(m=!1),!(g.compatibleRenderers&s.type)){f=!1;break}if(g.blendRequired&&null!=(e=null==(e=s.backBuffer)?void 0:e.useBackBuffer)&&!e){f=!1;break}f=g.enabled||f,p=p||g.blendRequired}if(f){if(m){const _=s.renderTarget.rootViewPort,g=s.renderTarget.renderTarget.resolution;a.fitBounds(0,_.width/g,0,_.height/g)}a.scale(u).ceil().scale(1/u).pad(0|c),a.isPositive?(o.skip=!1,o.bounds=a,o.blendRequired=p,o.container=t.container,o.filterEffect=t.filterEffect,o.previousRenderSurface=s.renderTarget.renderSurface,o.inputTexture=it.getOptimalTexture(a.width,a.height,u,d),s.renderTarget.bind(o.inputTexture,!0),s.globalUniforms.push({offset:a})):o.skip=!0}else o.skip=!0}}pop(){var t=this.renderer,e=(this._filterStackIndex--,this._filterStack[this._filterStackIndex]);if(!e.skip){var a,l,i=(this._activeFilterData=e).inputTexture,s=e.bounds;let n=P.EMPTY;t.renderTarget.finishRenderPass(),e.blendRequired&&(a=0<this._filterStackIndex?this._filterStack[this._filterStackIndex-1].bounds:null,l=t.renderTarget.getRenderTarget(e.previousRenderSurface),n=this.getBackTexture(l,s,a)),e.backTexture=n;var o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),1===o.length)o[0].apply(this,i,e.previousRenderSurface,!1),it.returnTexture(i);else{let a=e.inputTexture,l=it.getOptimalTexture(s.width,s.height,a.source._resolution,!1),u=0;for(u=0;u<o.length-1;++u){o[u].apply(this,a,l,!0);var c=a;a=l,l=c}o[u].apply(this,a,e.previousRenderSurface,!1),it.returnTexture(a),it.returnTexture(l)}e.blendRequired&&it.returnTexture(n)}}getBackTexture(t,e,i){var s=t.colorTexture.source._resolution,n=it.getOptimalTexture(e.width,e.height,s,!1);let o=e.minX,a=e.minY;return i&&(o-=i.minX,a-=i.minY),o=Math.floor(o*s),a=Math.floor(a*s),i=Math.ceil(e.width*s),e=Math.ceil(e.height*s),this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:i,height:e},{x:0,y:0}),n}applyFilter(t,e,i,s){var n=this.renderer,a=(o=this._filterStack[this._filterStackIndex]).bounds,l=V.shared,o=o.previousRenderSurface===i;let c=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,d=this._filterStackIndex-1;for(;0<d&&this._filterStack[d].skip;)--d;0<d&&(c=this._filterStack[d].inputTexture.source._resolution);var p=this._filterGlobalUniforms,m=(f=p.uniforms).uOutputFrame,_=f.uInputSize,g=f.uInputPixel,b=f.uInputClamp,x=f.uGlobalFrame,f=f.uOutputTexture;if(o){let S=this._filterStackIndex;for(;0<S;){S--;var E=this._filterStack[this._filterStackIndex-1];if(!E.skip){l.x=E.bounds.minX,l.y=E.bounds.minY;break}}m[0]=a.minX-l.x,m[1]=a.minY-l.y}else m[0]=0,m[1]=0;m[2]=e.frame.width,m[3]=e.frame.height,_[0]=e.source.width,_[1]=e.source.height,_[2]=1/_[0],_[3]=1/_[1],g[0]=e.source.pixelWidth,g[1]=e.source.pixelHeight,g[2]=1/g[0],g[3]=1/g[1],b[0]=.5*g[2],b[1]=.5*g[3],b[2]=e.frame.width*_[2]-.5*g[2],b[3]=e.frame.height*_[3]-.5*g[3],o=this.renderer.renderTarget.rootRenderTarget.colorTexture,x[0]=l.x*c,x[1]=l.y*c,x[2]=o.source.width*c,x[3]=o.source.height*c,a=this.renderer.renderTarget.getRenderTarget(i),n.renderTarget.bind(i,!!s),i instanceof P?(f[0]=i.frame.width,f[1]=i.frame.height):(f[0]=a.width,f[1]=a.height),f[2]=a.isRoot?-1:1,p.update(),n.renderPipes.uniformBatch?(m=n.renderPipes.uniformBatch.getUboResource(p),this._globalFilterBindGroup.setResource(m,0)):this._globalFilterBindGroup.setResource(p,0),this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:LS,shader:t,state:t._state,topology:"triangle-list"}),n.type===_t.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new nt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(t,e){var i=this._activeFilterData,t=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),i=e.worldTransform.copyTo(M.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),t.prepend(i),t.scale(1/e.texture.frame.width,1/e.texture.frame.height),t.translate(e.anchor.x,e.anchor.y),t}}xa.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"filter"},B.add(xa),B.add(ya);var NS={__proto__:null};const Ta=[];async function Sa(r){if(!r)for(let t=0;t<Ta.length;t++){var e=Ta[t];if(e.value.test())return void await e.value.load()}}B.handleByNamedList(r.Environment,Ta);let Dr;function Ea(){if("boolean"!=typeof Dr)try{Dr=!0===new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")}catch(r){Dr=!1}return Dr}var bt=(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))({});class Aa{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,l){var{name:u,items:c}=this;for(let d=0,p=c.length;d<p;d++)c[d][u](t,e,i,s,n,o,a,l);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){return-1!==(t=this.items.indexOf(t))&&this.items.splice(t,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}var XS=Object.defineProperty,rm=Object.getOwnPropertySymbols,jS=Object.prototype.hasOwnProperty,zS=Object.prototype.propertyIsEnumerable,im=(r,t,e)=>t in r?XS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,as=(r,t)=>{for(var e in t=t||{})jS.call(t,e)&&im(r,e,t[e]);if(rm)for(var e of rm(t))zS.call(t,e)&&im(r,e,t[e]);return r};const VS=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],sm=class Vy extends ft{constructor(t){super(),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,t=[...VS,...null!=(t=this.config.runners)?t:[]],this._addRunners(...t),this._unsafeEvalCheck()}async init(t={}){await Sa(!0===t.skipExtensionImports||!1===t.manageImports),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){var s=this._systemsHash[i].constructor.defaultOptions;t=as(as({},s),t)}t=as(as({},Vy.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){let n=t;n instanceof lt&&(n={container:n},e)&&(n.target=e.renderTexture),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,null==n.clearColor&&(n.clearColor=this.background.colorRgba),null==n.clear)&&(n.clear=this.background.clearBeforeRender),n.clearColor&&(t=Array.isArray(n.clearColor)&&4===n.clearColor.length,n.clearColor=t?n.clearColor:X.shared.setValue(n.clearColor).toArray()),n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),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,i){var s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==i&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),null==t.clear&&(t.clear=bt.ALL);var{clear:t,clearColor:n,target:o}=t;X.shared.setValue(null!=n?n:this.background.colorRgba),this.renderTarget.clear(o,t,X.shared.toArray())}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){var i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){var i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{var n=s.value,s=s.name,a=i[s];this.renderPipes[s]=new n(this,a?new a:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ea())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()}};sm.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Ur=sm,Pa;function kr(r){return Pa=void 0===Pa?(()=>{var t,e={stencil:!0,failIfMajorPerformanceCaveat:null!=r?r:Ur.defaultOptions.failIfMajorPerformanceCaveat};try{if(!H.get().getWebGLRenderingContext())return!1;let i=H.get().createCanvas().getContext("webgl",e);var n,s=!(null==(t=null==i?void 0:i.getContextAttributes())||!t.stencil);return i&&(n=i.getExtension("WEBGL_lose_context"))&&n.loseContext(),i=null,s}catch(i){return!1}})():Pa}let wa;async function $r(r={}){return wa=void 0===wa?await(async()=>{var t=H.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})():wa}var WS=Object.defineProperty,nm=Object.getOwnPropertySymbols,YS=Object.prototype.hasOwnProperty,KS=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?WS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lr=(r,t)=>{for(var e in t=t||{})YS.call(t,e)&&om(r,e,t[e]);if(nm)for(var e of nm(t))KS.call(t,e)&&om(r,e,t[e]);return r};const am=["webgl","webgpu","canvas"];async function lm(r){var n;let e=[];r.preference?(e.push(r.preference),am.forEach(o=>{o!==r.preference&&e.push(o)})):e=am.slice();let i,s={};for(let o=0;o<e.length;o++){var a=e[o];if("webgpu"===a&&await $r()){var l=(await Promise.resolve().then(function(){return Nw})).WebGPURenderer;i=l,s=Lr(Lr({},r),r.webgpu);break}if("webgl"===a&&kr(null!=(l=r.failIfMajorPerformanceCaveat)?l:Ur.defaultOptions.failIfMajorPerformanceCaveat)){const l=(await Promise.resolve().then(function(){return Tw})).WebGLRenderer;i=l,s=Lr(Lr({},r),r.webgl);break}if("canvas"===a)throw s=Lr({},r),new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,i)return await(n=new i).init(s),n;throw new Error("No available renderer for the current environment")}const Nr="8.9.1";class Ra{static init(){var t;null!=(t=globalThis.__PIXI_APP_INIT__)&&t.call(globalThis,this,Nr)}static destroy(){}}Ra.extension=r.Application;class Ma{constructor(t){this._renderer=t}init(){var t;null!=(t=globalThis.__PIXI_RENDERER_INIT__)&&t.call(globalThis,this._renderer,Nr)}destroy(){this._renderer=null}}Ma.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"initHook",priority:-10};var ZS=Object.defineProperty,um=Object.getOwnPropertySymbols,QS=Object.prototype.hasOwnProperty,JS=Object.prototype.propertyIsEnumerable,cm=(r,t,e)=>t in r?ZS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bd=(($i=class Fu{constructor(){this.stage=new lt}async init(t){t=((r,t)=>{for(var e in t=t||{})QS.call(t,e)&&cm(r,e,t[e]);if(um)for(var e of um(t))JS.call(t,e)&&cm(r,e,t[e]);return r})({},t),this.renderer=await lm(t),Fu._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){var i=Fu._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}})._plugins=[],$i);B.handleByList(r.Application,Bd._plugins),B.add(Ra);class Ca extends sa{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(o=>{o=n.pages[parseInt(o,10)],o=s[o.id],this.pages.push({texture:o})}),Object.keys(n.chars).forEach(o=>{var l=n.chars[o],{frame:u,source:c}=s[l.page],u=new z(l.x+u.x,l.y+u.y,l.width,l.height),c=new P({source:c,frame:u});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:null!=(u=l.kerning)?u:{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=null!=(t=n.distanceField)?t:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++)this.pages[t].texture.destroy(!0);this.pages=null}static install(t){Ir.install(t)}static uninstall(t){Ir.uninstall(t)}}const ls={test(r){return"string"==typeof r&&r.startsWith("info face=")},parse(r){var e,s=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in s){var _=s[m].match(/^[a-z]+/gm)[0],g=s[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),b={};for(const x in g){var T=(y=g[x].split("="))[0],y=y[1].replace(/"/gm,""),S=parseFloat(y),y=isNaN(S)?y:S;b[T]=y}n[_].push(b)}var o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=n.info,[l]=n.common,[t]=null!=(t=n.distanceField)?t:[],c=(t&&(o.distanceField={range:parseInt(t.distanceRange,10),type:t.fieldType}),o.fontSize=parseInt(r.size,10),o.fontFamily=r.face,o.lineHeight=parseInt(l.lineHeight,10),n.page);for(let m=0;m<c.length;m++)o.pages.push({id:parseInt(c[m].id,10)||0,file:c[m].file});var d={},p=(o.baseLineOffset=o.lineHeight-parseInt(l.base,10),n.char);for(let m=0;m<p.length;m++){const _=p[m],g=parseInt(_.id,10);let b=null!=(e=null!=(e=_.letter)?e:_.char)?e:String.fromCharCode(g);"space"===b&&(b=" "),d[g]=b,o.chars[b]={id:g,page:parseInt(_.page,10)||0,x:parseInt(_.x,10),y:parseInt(_.y,10),width:parseInt(_.width,10),height:parseInt(_.height,10),xOffset:parseInt(_.xoffset,10),yOffset:parseInt(_.yoffset,10),xAdvance:parseInt(_.xadvance,10),kerning:{}}}var f=n.kerning||[];for(let m=0;m<f.length;m++){const _=parseInt(f[m].first,10),g=parseInt(f[m].second,10),b=parseInt(f[m].amount,10);o.chars[d[g]].kerning[d[_]]=b}return o}},Oa={test(r){return"string"!=typeof r&&"getElementsByTagName"in r&&r.getElementsByTagName("page").length&&null!==r.getElementsByTagName("info")[0].getAttribute("face")},parse(r){var t,i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},s=r.getElementsByTagName("info")[0],n=r.getElementsByTagName("common")[0],o=r.getElementsByTagName("distanceField")[0],a=(o&&(i.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)}),r.getElementsByTagName("page")),l=r.getElementsByTagName("char"),u=r.getElementsByTagName("kerning");i.fontSize=parseInt(s.getAttribute("size"),10),i.fontFamily=s.getAttribute("face"),i.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let d=0;d<a.length;d++)i.pages.push({id:parseInt(a[d].getAttribute("id"),10)||0,file:a[d].getAttribute("file")});var c={};i.baseLineOffset=i.lineHeight-parseInt(n.getAttribute("base"),10);for(let d=0;d<l.length;d++){var p=l[d],f=parseInt(p.getAttribute("id"),10);let m=null!=(t=null!=(t=p.getAttribute("letter"))?t:p.getAttribute("char"))?t:String.fromCharCode(f);"space"===m&&(m=" "),c[f]=m,i.chars[m]={id:f,page:parseInt(p.getAttribute("page"),10)||0,x:parseInt(p.getAttribute("x"),10),y:parseInt(p.getAttribute("y"),10),width:parseInt(p.getAttribute("width"),10),height:parseInt(p.getAttribute("height"),10),xOffset:parseInt(p.getAttribute("xoffset"),10),yOffset:parseInt(p.getAttribute("yoffset"),10),xAdvance:parseInt(p.getAttribute("xadvance"),10),kerning:{}}}for(let d=0;d<u.length;d++){const p=parseInt(u[d].getAttribute("first"),10),f=parseInt(u[d].getAttribute("second"),10),m=parseInt(u[d].getAttribute("amount"),10);i.chars[c[f]].kerning[c[p]]=m}return i}},Ga={test(r){return!("string"!=typeof r||!r.includes("<font>"))&&Oa.test(H.get().parseXML(r))},parse(r){return Oa.parse(H.get().parseXML(r))}},e2=[".xml",".fnt"],pm={extension:{type:r.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof Ca,getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[i+"-bitmap"]=t}),e[t.fontFamily+"-bitmap"]=t,e}},fm={extension:{type:r.LoadParser,priority:xt.Normal},name:"loadBitmapFont",test(r){return e2.includes(mt.extname(r).toLowerCase())},async testParse(r){return ls.test(r)||Ga.test(r)},async parse(r,t,e){var r=(ls.test(r)?ls:Ga).parse(r),s=t.src,n=r.pages,o=[],a=r.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;c<n.length;++c){var d=n[c].file,d=mt.join(mt.dirname(s),d),d=yi(d,s);o.push({src:d,data:a})}const l=await e.load(o),u=o.map(c=>l[c.src]);return new Ca({data:r,textures:u},s)},async load(r,t){return(await H.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class mm{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;var t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)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)&&!this._isLoading&&this._next()}}async function Ba(r){if("Image"in globalThis)return new Promise(t=>{var e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{var t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}$i={extension:{type:r.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof P),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(0===n?"":n+1)]=s})}),e}};const _m={extension:{type:r.DetectionParser,priority:1},test:async()=>Ba("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>"avif"!==t)},bm=["png","jpg","jpeg"],vm={extension:{type:r.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...bm],remove:async r=>r.filter(t=>!bm.includes(t))},r2="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function us(r){return!r2&&""!==document.createElement("video").canPlayType(r)}var ym={extension:{type:r.DetectionParser,priority:0},test:async()=>us("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>"mp4"!==t&&"m4v"!==t)},xm={extension:{type:r.DetectionParser,priority:0},test:async()=>us("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>"ogv"!==t)},Tm={extension:{type:r.DetectionParser,priority:0},test:async()=>us("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>"webm"!==t)},Sm={extension:{type:r.DetectionParser,priority:0},test:async()=>Ba("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>"webp"!==t)},i2=Object.defineProperty,s2=Object.defineProperties,n2=Object.getOwnPropertyDescriptors,Em=Object.getOwnPropertySymbols,o2=Object.prototype.hasOwnProperty,a2=Object.prototype.propertyIsEnumerable,Am=(r,t,e)=>t in r?i2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Pm{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var s,n;let o=null,a=null;if(!(a=e.loadParser?this._parserHash[e.loadParser]:a)){for(let l=0;l<this.parsers.length;l++){var u=this.parsers[l];if(u.load&&null!=(s=u.test)&&s.call(u,t,e,this)){a=u;break}}if(!a)return null}o=await a.load(t,e,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];u.parse&&u.parse&&await(null==(n=u.testParse)?void 0:n.call(u,o,e,this))&&(o=await u.parse(o,e,this)||o,i.parser=u)}return o})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=br(t),o=Ct(t,u=>({alias:[u],src:u,data:{}})),a=o.length,l=o.map(async u=>{var c=mt.toAbsolute(u.src);if(!s[u.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,u)),s[u.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(d){throw delete this.promiseCache[c],delete s[u.src],new Error(`[Loader.load] Failed to load ${c}.
`+d)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){t=Ct(t,i=>({alias:[i],src:i})).map(async i=>{var l,o=mt.toAbsolute(i.src),a=this.promiseCache[o];a&&(l=await a.promise,delete this.promiseCache[o],await(null==(a=null==(o=a.parser)?void 0:o.unload)?void 0:a.call(o,l,i,this)))}),await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name&&t[e.name],((r,t)=>s2(r,n2(t)))(((r,t)=>{for(var e in t=t||{})o2.call(t,e)&&Am(r,e,t[e]);if(Em)for(var e of Em(t))a2.call(t,e)&&Am(r,e,t[e]);return r})({},t),{[e.name]:e})),{})}}function Pe(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 Gt(r,t){return r=r.split("?")[0],r=mt.extname(r).toLowerCase(),Array.isArray(t)?t.includes(r):r===t}var wm={extension:{type:r.LoadParser,priority:xt.Low},name:"loadJson",test(r){return Pe(r,"application/json")||Gt(r,".json")},async load(r){return(await H.get().fetch(r)).json()}},Rm={name:"loadTxt",extension:{type:r.LoadParser,priority:xt.Low,name:"loadTxt"},test(r){return Pe(r,"text/plain")||Gt(r,".txt")},async load(r){return(await H.get().fetch(r)).text()}},f2=Object.defineProperty,m2=Object.defineProperties,g2=Object.getOwnPropertyDescriptors,Mm=Object.getOwnPropertySymbols,_2=Object.prototype.hasOwnProperty,b2=Object.prototype.propertyIsEnumerable,Cm=(r,t,e)=>t in r?f2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const x2=["normal","bold","100","200","300","400","500","600","700","800","900"],T2=[".ttf",".otf",".woff",".woff2"],S2=["font/ttf","font/otf","font/woff","font/woff2"],E2=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Om(r){var t=mt.extname(r);let i=0<(r=mt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1))).length;for(const n of r)if(!n.match(E2)){i=!1;break}let s=r.join(" ");return s=i?s:`"${s.replace(/[\\"]/g,"\\$&")}"`}const A2=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;var Gm={extension:{type:r.LoadParser,priority:xt.Low},name:"loadWebFont",test(r){return Pe(r,S2)||Gt(r,T2)},async load(r,t){var e,l=H.get().getFontFaceSet();if(l){var u=[],c=null!=(e=null==(e=t.data)?void 0:e.family)?e:Om(r),d=null!=(e=null==(e=null==(e=t.data)?void 0:e.weights)?void 0:e.filter(f=>x2.includes(f)))?e:["normal"],p=null!=(e=t.data)?e:{};for(let f=0;f<d.length;f++){var m=d[f];await(m=new FontFace(c,`url(${function(r){return A2.test(r)?r:encodeURI(r)}(r)})`,(r=>m2(r,g2({weight:m})))(((r,t)=>{for(var e in t=p||{})_2.call(t,e)&&Cm(r,e,t[e]);if(Mm)for(var e of Mm(t))b2.call(t,e)&&Cm(r,e,t[e]);return r})({})))).load(),l.add(m),u.push(m)}return W.set(c+"-and-url",{url:r,fontFaces:u}),1===u.length?u[0]:u}return null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>{W.remove(t.family+"-and-url"),H.get().getFontFaceSet().delete(t)})}};function cs(r,t=1){var e=null==(e=re.RETINA_PREFIX)?void 0:e.exec(r);return e?parseFloat(e[1]):t}function le(r,t,e){r.label=e,r._sourceOrigin=e;const i=new P({source:r,label:e}),s=()=>{delete t.promiseCache[e],W.has(e)&&W.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&s()}),i.once("destroy",()=>{r.destroyed||s()}),i}var w2=Object.defineProperty,hs=Object.getOwnPropertySymbols,Bm=Object.prototype.hasOwnProperty,Im=Object.prototype.propertyIsEnumerable,Fm=(r,t,e)=>t in r?w2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dm={extension:{type:r.LoadParser,priority:xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Pe(r,"image/svg+xml")||Gt(r,".svg")},async load(r,t,e){var i;return(null!=(i=null==(i=t.data)?void 0:i.parseAsGraphicsContext)?i:this.config.parseAsGraphicsContext)?async function(r){var r=await(await H.get().fetch(r)).text(),e=new dt;return e.svg(r),e}(r):async function(r,t,e,i){var c=await(await H.get().fetch(r)).blob(),c=URL.createObjectURL(c),p=new Image,c=(p.src=c,p.crossOrigin=i,await p.decode(),URL.revokeObjectURL(c),(i=document.createElement("canvas")).getContext("2d")),s=(null==(s=t.data)?void 0:s.resolution)||cs(r),n=null!=(n=null==(n=t.data)?void 0:n.width)?n:p.width,a=null!=(a=null==(a=t.data)?void 0:a.height)?a:p.height,{}=(i.width=n*s,i.height=a*s,c.drawImage(p,0,0,n*s,a*s),p=null!=(c=t.data)?c:{}),n=((r,t)=>{var e={};for(i in r)Bm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&hs)for(var i of hs(r))t.indexOf(i)<0&&Im.call(r,i)&&(e[i]=r[i]);return e})(p,["parseAsGraphicsContext"]);return le(new ie(((r,t)=>{for(var e in t=n||{})Bm.call(t,e)&&Fm(r,e,t[e]);if(hs)for(var e of hs(t))Im.call(t,e)&&Fm(r,e,t[e]);return r})({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:s})),e,r)}(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};let Je=null,Ia=class{constructor(){Je=Je||URL.createObjectURL(new Blob([`(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)})})();
`],{type:"application/javascript"})),this.worker=new Worker(Je)}},tr=(Ia.revokeObjectURL=function(){Je&&(URL.revokeObjectURL(Je),Je=null)},null),Um=class{constructor(){tr=tr||URL.createObjectURL(new Blob(['(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'],{type:"application/javascript"})),this.worker=new Worker(tr)}},km=(Um.revokeObjectURL=function(){tr&&(URL.revokeObjectURL(tr),tr=null)},0),Fa;const Da=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0===this._isImageBitmapSupported&&(this._isImageBitmapSupported=new Promise(t=>{const e=(new Ia).worker;e.addEventListener("message",i=>{e.terminate(),Ia.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,null==(t=null==e?void 0:e.data)?void 0:t.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===Fa&&(Fa=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Fa&&(this._createdWorkers++,(t=(new Um).worker).addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();var i=new Promise((s,n)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:n})});return this._next(),i}_next(){var t,e,i;this._queue.length&&(t=this._getWorker())&&(i=(e=this._queue.pop()).id,this._resolveHash[km]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:km++,id:i}))}};var U2=Object.defineProperty,$m=Object.getOwnPropertySymbols,k2=Object.prototype.hasOwnProperty,$2=Object.prototype.propertyIsEnumerable,Lm=(r,t,e)=>t in r?U2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const N2=[".jpeg",".jpg",".png",".webp",".avif"],H2=["image/jpeg","image/png","image/webp","image/avif"];async function Nm(r,t){var s,i=await H.get().fetch(r);if(i.ok)return s=await i.blob(),"premultiplied-alpha"===(null==(t=null==t?void 0:t.data)?void 0:t.alphaMode)?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s);throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} `+i.statusText)}var Ua={name:"loadTextures",extension:{type:r.LoadParser,priority:xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Pe(r,H2)||Gt(r,N2)},async load(r,t,e){var i;let s=null;return s=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Da.isImageBitmapSupported()?await Da.loadImageBitmap(r,t):await Nm(r,t):await new Promise((o,a)=>{(s=new Image).crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)}),le(new ie(((r,t)=>{for(var e in t=t||{})k2.call(t,e)&&Lm(r,e,t[e]);if($m)for(var e of $m(t))$2.call(t,e)&&Lm(r,e,t[e]);return r})({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:(null==(i=t.data)?void 0:i.resolution)||cs(r)},t.data)),e,r)},unload(r){r.destroy(!0)}},X2=Object.defineProperty,j2=Object.defineProperties,z2=Object.getOwnPropertyDescriptors,Hm=Object.getOwnPropertySymbols,V2=Object.prototype.hasOwnProperty,W2=Object.prototype.propertyIsEnumerable,Xm=(r,t,e)=>t in r?X2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ka=(r,t)=>{for(var e in t=t||{})V2.call(t,e)&&Xm(r,e,t[e]);if(Hm)for(var e of Hm(t))W2.call(t,e)&&Xm(r,e,t[e]);return r},jm=(r,t)=>j2(r,z2(t));const zm=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Y2=zm.map(r=>"video/"+r.substring(1));function Vm(r,t,e){void 0!==e||t.startsWith("data:")?!1!==e&&(r.crossOrigin="string"==typeof e?e:"anonymous"):r.crossOrigin=Ym(t)}function Wm(r){return new Promise((t,e)=>{function i(){n(),t()}function s(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load()})}function Ym(r,t=globalThis.location){return r.startsWith("data:")||(t=t||globalThis.location,(r=new URL(r,document.baseURI)).hostname===t.hostname&&r.port===t.port&&r.protocol===t.protocol)?"":"anonymous"}var Km={name:"loadVideo",extension:{type:r.LoadParser,name:"loadVideo"},test(r){var t=Pe(r,Y2),r=Gt(r,zm);return t||r},async load(r,t,e){var i;const n=ka(jm(ka({},vr.defaultOptions),{resolution:(null==(i=t.data)?void 0:i.resolution)||cs(r),alphaMode:(null==(i=t.data)?void 0:i.alphaMode)||await Hn()}),t.data),o=document.createElement("video"),a={preload:!1!==n.autoLoad?"auto":void 0,"webkit-playsinline":!1!==n.playsinline?"":void 0,playsinline:!1!==n.playsinline?"":void 0,muted:!0===n.muted?"":void 0,loop:!0===n.loop?"":void 0,autoplay:!1!==n.autoPlay?"":void 0},l=(Object.keys(a).forEach(c=>{var d=a[c];void 0!==d&&o.setAttribute(c,d)}),!0===n.muted&&(o.muted=!0),Vm(o,r,n.crossorigin),document.createElement("source"));let u;return r.startsWith("data:")?u=r.slice(5,r.indexOf(";")):r.startsWith("blob:")||(i=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase(),u=vr.MIME_TYPES[i]||"video/"+i),l.src=r,u&&(l.type=u),new Promise(c=>{const d=async()=>{var p=new vr(jm(ka({},n),{resource:o}));o.removeEventListener("canplay",d),t.data.preload&&await Wm(o),c(le(p,e,r))};o.addEventListener("canplay",d),o.appendChild(l)})},unload(r){r.destroy(!0)}},$a={extension:{type:r.ResolveParser,name:"resolveTexture"},test:Ua.test,parse:r=>{var t;return{resolution:parseFloat(null!=(t=null==(t=re.RETINA_PREFIX.exec(r))?void 0:t[1])?t:"1"),format:r.split(".").pop(),src:r}}},qm={extension:{type:r.ResolveParser,priority:-2,name:"resolveJson"},test:r=>re.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:$a.parse};class Zm{constructor(){this._detections=[],this._initialized=!1,this.resolver=new re,this.loader=new Pm,this.cache=W,this._backgroundLoader=new mm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(!this._initialized){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;"string"==typeof l&&(l=await this.load(l)),this.resolver.addManifest(l)}var e="number"==typeof(e=null!=(e=null==(e=t.texturePreference)?void 0:e.resolution)?e:1)?[e]:e,s=await this._detectFormats({preferredFormats:null==(s=t.texturePreference)?void 0:s.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:e}}),t.preferences&&this.setPreferences(t.preferences)}}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();var i=br(t),t=Ct(t).map(a=>{var l;return"string"!=typeof a?((l=this.resolver.getAlias(a)).some(u=>!this.resolver.hasKey(u))&&this.add(a),Array.isArray(l)?l[0]:l):(this.resolver.hasKey(a)||this.add({alias:a,src:a}),a)}),n=this.resolver.resolve(t),n=await this._mapLoadToResolve(n,e);return i?n[t[0]]:n}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;"string"==typeof t&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const u=()=>{null!=e&&e(++a/l)},c=o.map(d=>{var p=s[d];return l+=Object.keys(p).length,this._mapLoadToResolve(p,u).then(f=>{n[d]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),t=this.resolver.resolve(t="string"==typeof t?[t]:t),this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(t){this._initialized||await this.init(),t=this.resolver.resolveBundle(t="string"==typeof t?[t]:t),Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return W.get(t);var e={};for(let i=0;i<t.length;i++)e[i]=W.get(t[i]);return e}async _mapLoadToResolve(t,e){t=[...new Set(Object.values(t))],this._backgroundLoader.active=!1;const s=await this.loader.load(t,e),n=(this._backgroundLoader.active=!0,{});return t.forEach(o=>{const a=s[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),W.set(l,a)}),n}async unload(t){this._initialized||await this.init(),t=Ct(t).map(s=>"string"!=typeof s?s.src:s),t=this.resolver.resolve(t),await this._unloadFromResolved(t)}async unloadBundle(t){this._initialized||await this.init(),t=Ct(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){(t=Object.values(t)).forEach(i=>{W.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s)}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}var Hr=new Zm;B.handleByList(r.LoadParser,Hr.loader.parsers).handleByList(r.ResolveParser,Hr.resolver.parsers).handleByList(r.CacheParser,Hr.cache.parsers).handleByList(r.DetectionParser,Hr.detections),B.add($i,vm,_m,Sm,ym,xm,Tm,wm,Rm,Gm,Dm,Ua,Km,fm,pm,$a,qm);const Qm={loader:r.LoadParser,resolver:r.ResolveParser,cache:r.CacheParser,detection:r.DetectionParser};B.handle(r.Asset,r=>{const t=r.ref;Object.entries(Qm).filter(([e])=>!!t[e]).forEach(([e,i])=>B.add(Object.assign(t[e],{extension:null!=(e=t[e].extension)?e:i})))},r=>{const t=r.ref;Object.keys(Qm).filter(e=>!!t[e]).forEach(e=>B.remove(t[e]))});var K2={extension:{type:r.DetectionParser,priority:3},test:async()=>!(!await $r()&&!kr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>"basis"!==t)};class Xr extends Q{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let ds;function La(){var r;return ds||((r=document.createElement("canvas").getContext("webgl"))?ds=[...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"]:[]]:[])}let ps;async function Na(){var r;return ps||(r=await H.get().getNavigator().gpu.requestAdapter(),ps=[...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"]:[]]),ps}let Ha;async function Xa(){return Ha=void 0===Ha?await(async()=>{var r=await $r(),t=kr();if(r&&t){const e=await Na(),i=La();return e.filter(s=>i.includes(s))}return r?Na():t?La():[]})():Ha}const Jm=["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 fs;async function jr(){var r;return void 0===fs&&(r=await Xa(),fs=[...Jm,...r]),fs}let er=null,tg=class{constructor(){er=er||URL.createObjectURL(new Blob(['(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'],{type:"application/javascript"})),this.worker=new Worker(er)}};tg.revokeObjectURL=function(){er&&(URL.revokeObjectURL(er),er=null)};const ms={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};let zr;const eg={};function rg(r,t){const e=function(r){return zr||((zr=(new tg).worker).onmessage=t=>{var{success:t,url:i,textureOptions:s}=t.data;t||console.warn("Failed to load Basis texture",i),eg[i](s)},zr.postMessage({type:"init",jsUrl:ms.jsUrl,wasmUrl:ms.wasmUrl,supportedTextures:r})),zr}(t);return new Promise(i=>{eg[r]=i,e.postMessage({type:"load",url:r})})}var J2={extension:{type:r.LoadParser,priority:xt.High,name:"loadBasis"},name:"loadBasis",test(r){return Gt(r,[".basis"])},async load(r,t,e){var s=await rg(r,await jr());return le(new Xr(s),e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};const eE={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};var ja=(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))({}),za=(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))({});function at(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=at("UYVY")]="UYVY",r[r.R8G8_B8G8=at("RGBG")]="R8G8_B8G8",r[r.YUY2=at("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=at("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=at("DXT1")]="DXT1",r[r.DXT2=at("DXT2")]="DXT2",r[r.DXT3=at("DXT3")]="DXT3",r[r.DXT4=at("DXT4")]="DXT4",r[r.DXT5=at("DXT5")]="DXT5",r[r.ATI1=at("ATI1")]="ATI1",r[r.AT1N=at("AT1N")]="AT1N",r[r.ATI2=at("ATI2")]="ATI2",r[r.AT2N=at("AT2N")]="AT2N",r[r.BC4U=at("BC4U")]="BC4U",r[r.BC4S=at("BC4S")]="BC4S",r[r.BC5U=at("BC5U")]="BC5U",r[r.BC5S=at("BC5S")]="BC5S",r[r.DX10=at("DX10")]="DX10",r))({});const Va={[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"},F={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:{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},HEADER_DX10_FIELDS:{DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},DXGI_FORMAT:ja,D3D10_RESOURCE_DIMENSION:za,D3DFMT:vt},ig={"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 sg(r,t){var{format:e,fourCC:i,width:s,height:n,dataOffset:o,mipmapCount:a}=function(r){var t=new Uint32Array(r,0,F.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[F.HEADER_FIELDS.MAGIC]!==F.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");var e=t[F.HEADER_FIELDS.HEIGHT],i=t[F.HEADER_FIELDS.WIDTH],s=Math.max(1,t[F.HEADER_FIELDS.MIPMAP_COUNT]),n=t[F.HEADER_FIELDS.PF_FLAGS],o=t[F.HEADER_FIELDS.FOURCC];return{format:function(r,t,e,i){if(t&F.PIXEL_FORMAT_FLAGS.FOURCC){if(e===F.D3DFMT.DX10){if((i=new Uint32Array(i,F.MAGIC_SIZE+F.HEADER_SIZE,F.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT))[F.HEADER_DX10_FIELDS.MISC_FLAG]===F.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[F.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===F.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");if((i=i[F.HEADER_DX10_FIELDS.DXGI_FORMAT])in yt)return yt[i];throw new Error("DDSParser cannot parse texture data with DXGI format "+i)}if(e in Va)return Va[e];throw new Error("DDSParser cannot parse texture data with fourCC format "+e)}if(t&F.PIXEL_FORMAT_FLAGS.RGB||t&F.PIXEL_FORMAT_FLAGS.RGBA)return function(r){var t=r[F.HEADER_FIELDS.RGB_BITCOUNT],e=r[F.HEADER_FIELDS.R_BIT_MASK],i=r[F.HEADER_FIELDS.G_BIT_MASK],s=r[F.HEADER_FIELDS.B_BIT_MASK],n=r[F.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(255===e&&65280===i&&16711680===s&&4278190080===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(16711680===e&&65280===i&&255===s&&4278190080===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(1072693248===e&&1047552===i&&1023===s&&3221225472===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(65535===e&&4294901760===i&&0===s&&0===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(4294967295===e&&0===i&&0===s&&0===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(31744===e&&992===i&&31===s&&32768===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(63488===e&&2016===i&&31===s&&0===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(3840===e&&240===i&&15===s&&61440===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(255===e&&0===i&&0===s&&65280===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(65535===e&&0===i&&0===s&&0===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(255===e&&0===i&&0===s&&0===n)return yt[F.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM]}throw new Error(`DDSParser does not support uncompressed texture with configuration:
bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = `+n)}(r);throw t&F.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&F.PIXEL_FORMAT_FLAGS.LUMINANCE||t&F.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&F.PIXEL_FORMAT_FLAGS.ALPHA||t&F.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!")}(t,n,o,r),fourCC:o,width:i,height:e,dataOffset:F.MAGIC_SIZE+F.HEADER_SIZE+(o===F.D3DFMT.DX10?F.HEADER_DX10_SIZE:0),mipmapCount:s}}(r);if(t.includes(e))return a<=1?{format:e,width:s,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"}:{format:e,width:s,height:n,resource:function(r,t,e,i,s,n){var o=[],a=ig[r];let l=t,u=e,c=i;for(let d=0;d<s;++d){var p=4*Math.ceil(Math.max(4,l)/4),f=4*Math.ceil(Math.max(4,u)/4),p=a?p/4*f/4*a:l*u*4,f=new Uint8Array(n,c,p);o.push(f),c+=p,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return o}(e,s,n,o,a,r),alphaMode:"no-premultiply-alpha"};throw new Error(`Unsupported texture format: ${i} ${e}, supported: `+t)}var uE={extension:{type:r.LoadParser,priority:xt.High,name:"loadDDS"},name:"loadDDS",test(r){return Gt(r,[".dds"])},async load(r,t,e){var i=await jr(),i=sg(await(await fetch(r)).arrayBuffer(),i);return le(new Xr(i),e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},ng=(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))({});const tt={FILE_HEADER_SIZE:64,FILE_IDENTIFIER:[171,75,84,88,32,49,49,187,13,10,26,10],FORMATS_TO_COMPONENTS:{6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:{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},INTERNAL_FORMAT_TO_TEXTURE_FORMATS:{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"},FIELDS:{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},TYPES_TO_BYTES_PER_COMPONENT:{5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},TYPES_TO_BYTES_PER_PIXEL:{32819:2,32820:2,33635:2},ENDIANNESS:67305985};function og(r,t){if(!function(r){for(let t=0;t<tt.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==tt.FILE_IDENTIFIER[t])return;return 1}(r=new DataView(r)))throw new Error("Invalid KTX identifier in header");var{littleEndian:i,glType:s,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=function(r){var t=r.getUint32(tt.FIELDS.ENDIANNESS,!0)===tt.ENDIANNESS,e=r.getUint32(tt.FIELDS.GL_TYPE,t),i=r.getUint32(tt.FIELDS.GL_FORMAT,t),s=r.getUint32(tt.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(tt.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(tt.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(tt.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(tt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(tt.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(tt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),r=r.getUint32(tt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(0===o||1!==a)throw new Error("Only 2D textures are supported");if(1!==u)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(1!==l)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:s,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:c,offset:tt.FILE_HEADER_SIZE+r}}(r),d=tt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!d)throw new Error("Unknown texture format "+o);if(t.includes(d))return r=function(r,t,e,i,n,o,a){let c=i*l,d=(0===t?(i+3&-4)*(l+3&-4):c)*e,p=i,f=l,m,_,g=n;var b=new Array(o);for(let x=0;x<o;x++){var y=r.getUint32(g,a),T=g+4;b[x]=new Uint8Array(r.buffer,T,d),d,g=(g+=y+4)%4!=0?g+4-g%4:g,p=p>>1||1,f=f>>1||1,m=p+4-1&-4,_=f+4-1&-4,d=m*_*e}return b}(r,s,function(r,t,e){if(e=tt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e],void 0===(e=0!==r?tt.TYPES_TO_BYTES_PER_COMPONENT[r]?tt.TYPES_TO_BYTES_PER_COMPONENT[r]*tt.FORMATS_TO_COMPONENTS[t]:tt.TYPES_TO_BYTES_PER_PIXEL[r]:e))throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return e}(s,n,o),a,c,u,i),{format:d,width:a,height:l,resource:r,alphaMode:"no-premultiply-alpha"};throw new Error(`Unsupported texture format: ${d}, supportedFormats: `+t)}var gE={extension:{type:r.LoadParser,priority:xt.High,name:"loadKTX"},name:"loadKTX",test(r){return Gt(r,".ktx")},async load(r,t,e){var i=await jr(),i=og(await(await fetch(r)).arrayBuffer(),i);return le(new Xr(i),e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};let rr=null;class ag{constructor(){rr=rr||URL.createObjectURL(new Blob(['(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 T={"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 y(r){const t=T[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=y(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,o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}})();\n'],{type:"application/javascript"})),this.worker=new Worker(rr)}}ag.revokeObjectURL=function(){rr&&(URL.revokeObjectURL(rr),rr=null)};const gs={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};let Vr;const lg={};function ug(r,t){const e=function(r){return Vr||((Vr=(new ag).worker).onmessage=t=>{var{success:t,url:i,textureOptions:s}=t.data;t||console.warn("Failed to load KTX texture",i),lg[i](s)},Vr.postMessage({type:"init",jsUrl:gs.jsUrl,wasmUrl:gs.wasmUrl,supportedTextures:r})),Vr}(t);return new Promise(i=>{lg[r]=i,e.postMessage({type:"load",url:r})})}const yE={extension:{type:r.LoadParser,priority:xt.High,name:"loadKTX2"},name:"loadKTX2",test(r){return Gt(r,".ktx2")},async load(r,t,e){var s=await ug(r,await jr());return le(new Xr(s),e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Wa={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:cg},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:cg}};function cg(r){var t=r.byteLength/3,e=new Uint32Array(t);for(let i=0;i<t;++i)e[i]=r[3*i]+(r[3*i+1]<<8)+(r[3*i+2]<<16)+4278190080;return new Uint8Array(e.buffer)}const SE={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 hg(r){var t=SE[r];if(t)return t;throw new Error("Unsupported glInternalFormat: "+r)}const EE={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function dg(r){var t=EE[r];if(t)return t;throw new Error("Unsupported VkFormat: "+r)}const PE={"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"},_s=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],RE={extension:r.ResolveParser,test:r=>Gt(r,[".ktx",".ktx2",".dds"]),parse:r=>{let i;var n,s=r.split(".");return 2<s.length?(n=s[s.length-2],_s.includes(n)&&(i=n)):i=s[s.length-1],{resolution:parseFloat(null!=(s=null==(n=re.RETINA_PREFIX.exec(r))?void 0:n[1])?s:"1"),format:i,src:r}}};let bs;var ME={extension:{type:r.DetectionParser,priority:2},test:async()=>!(!await $r()&&!kr()),add:async r=>{var t=await Xa();return[...bs=function(r){const t=["basis"],e={};return r.forEach(i=>{(i=i.split("-")[0])&&!e[i]&&(e[i]=!0,t.push(i))}),t.sort((i,s)=>(i=_s.indexOf(i),s=_s.indexOf(s),-1===i?1:-1===s?-1:i-s)),t}(t),...r]},remove:async r=>bs?r.filter(t=>!(t in bs)):r};const OE=new nt,Ya=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){var s;if(t.cullable&&t.measurable&&t.includeInBuild?(s=null!=(s=t.cullArea)?s:dr(t,i,OE),t.culled=s.x>=e.x+e.width||s.y>=e.y+e.height||s.x+s.width<=e.x||s.y+s.height<=e.y):t.culled=!1,t.cullableChildren&&!t.culled&&t.renderable&&t.measurable&&t.includeInBuild)for(let n=0;n<t.children.length;n++)this._cullRecursive(t.children[n],e,i)}};Ya.shared=new Ya;let pg=Ya;class fg{static init(){this._renderRef=this.render.bind(this),this.render=()=>{pg.shared.cull(this.stage,this.renderer.screen),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}fg.extension={priority:10,type:r.Application,name:"culler"};var GE={extension:{type:r.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return NS})}},BE=Object.defineProperty,vs=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,gg=Object.prototype.propertyIsEnumerable,_g=(r,t,e)=>t in r?BE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ka=(r,t)=>{for(var e in t=t||{})mg.call(t,e)&&_g(r,e,t[e]);if(vs)for(var e of vs(t))gg.call(t,e)&&_g(r,e,t[e]);return r},bg=class Du extends St{constructor(t){super(t=Ka(Ka({},Du.defaultOptions),t)),this.enabled=!0,this._state=Et.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,"boolean"==typeof t.antialias?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)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){var{gpu:i,gl:s}=t,t=((r,t)=>{var e={};for(i in r)mg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&vs)for(var i of vs(r))t.indexOf(i)<0&&gg.call(r,i)&&(e[i]=r[i]);return e})(t,["gpu","gl"]);let o,a;return i&&(o=gt.from(i)),s&&(a=Tt.from(s)),new Du(Ka({gpuProgram:o,glProgram:a},t))}},vg=(bg.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0},`
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}
}
`),yg=`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();
}
`,xg=`
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;
}`,FE=Object.defineProperty,Tg=Object.getOwnPropertySymbols,DE=Object.prototype.hasOwnProperty,UE=Object.prototype.propertyIsEnumerable,Sg=(r,t,e)=>t in r?FE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Eg=(r,t)=>{for(var e in t=t||{})DE.call(t,e)&&Sg(r,e,t[e]);if(Tg)for(var e of Tg(t))UE.call(t,e)&&Sg(r,e,t[e]);return r};function Ag(r){var{source:r,functions:e,main:i}=r;return r.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}var ys=`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();
}
`,Pg=`
in vec2 vTextureCoord;
out vec4 finalColor;
uniform float uAlpha;
uniform sampler2D uTexture;
void main()
{
finalColor = texture(uTexture, vTextureCoord) * uAlpha;
}
`,qa=`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;
}`,NE=Object.defineProperty,HE=Object.defineProperties,XE=Object.getOwnPropertyDescriptors,xs=Object.getOwnPropertySymbols,wg=Object.prototype.hasOwnProperty,Rg=Object.prototype.propertyIsEnumerable,Mg=(r,t,e)=>t in r?NE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Za=(r,t)=>{for(var e in t=t||{})wg.call(t,e)&&Mg(r,e,t[e]);if(xs)for(var e of xs(t))Rg.call(t,e)&&Mg(r,e,t[e]);return r},Cg=class Wy extends bg{constructor(t){t=Za(Za({},Wy.defaultOptions),t);var e=gt.from({vertex:{source:qa,entryPoint:"mainVertex"},fragment:{source:qa,entryPoint:"mainFragment"}}),i=Tt.from({vertex:ys,fragment:Pg,name:"alpha-filter"}),n=t.alpha,t=((r,t)=>{var e={};for(i in r)wg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&xs)for(var i of xs(r))t.indexOf(i)<0&&Rg.call(r,i)&&(e[i]=r[i]);return e})(t,["alpha"]),n=new st({uAlpha:{value:n,type:"f32"}});super((t=Za({},t),HE(t,XE({gpuProgram:e,glProgram:i,resources:{alphaUniforms:n}}))))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};Cg.defaultOptions={alpha:1};const Qa={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]},WE=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(`
`);function Og(r){var t=Qa[r],e=t.length;let i=WE,s="",o;for(let a=0;a<r;a++){let l="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;".replace("%index%",a.toString());(o=a)>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s=s+l+`
`}return i=(i=i.replace("%blur%",s)).replace("%size%",r.toString())}const YE=`
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 Gg(r,t){var e=Math.ceil(r/2);let i=YE,s="",n;n=t?"vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":"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"),s=s+a+`
`}return i=(i=(i=i.replace("%blur%",s)).replace("%size%",r.toString())).replace("%dimension%",t?"z":"w")}function Bg(r,t){var e=Gg(t,r),t=Og(t);return Tt.from({vertex:e,fragment:t,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var Ig=`
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 Fg(r,t){var e=Qa[t],i=e.length,s=[],n=[],o=[];for(let d=0;d<t;d++){s[d]=`@location(${d}) offset${d}: vec2<f32>,`,n[d]=r?`filteredCord + vec2(${d-i+1} * pixelStrength, 0.0),`:`filteredCord + vec2(0.0, ${d-i+1} * pixelStrength),`;var f=e[d<i?d:t-d-1].toString();o[d]=`finalColor += textureSample(uTexture, uSampler, offset${d}) * ${f};`}var a=s.join(`
`),l=n.join(`
`),u=o.join(`
`),l=Ig.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return gt.from({vertex:{source:l,entryPoint:"mainVertex"},fragment:{source:l,entryPoint:"mainFragment"}})}var KE=Object.defineProperty,Dg=Object.getOwnPropertySymbols,qE=Object.prototype.hasOwnProperty,ZE=Object.prototype.propertyIsEnumerable,Ug=(r,t,e)=>t in r?KE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ja=(r,t)=>{for(var e in t=t||{})qE.call(t,e)&&Ug(r,e,t[e]);if(Dg)for(var e of Dg(t))ZE.call(t,e)&&Ug(r,e,t[e]);return r},kg=class Yy extends bg{constructor(t){var e=Bg((t=Ja(Ja({},Yy.defaultOptions),t)).horizontal,t.kernelSize),i=Fg(t.horizontal,t.kernelSize);super(Ja({glProgram:e,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,i,s){if(this._uniforms.uStrength=this.strength/this.passes,1===this.passes)t.applyFilter(this,e,i,s);else{var n=it.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;var l=t.renderer.type===_t.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,o,a,0===u||l);var c=a;a=o,o=c}this._state.blend=!0,t.applyFilter(this,o,i,s),it.returnTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+2*Math.abs(t),this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};kg.defaultOptions={strength:8,quality:4,kernelSize:5};let Ts=kg;var QE=Object.defineProperty,JE=Object.defineProperties,tA=Object.getOwnPropertyDescriptors,Ss=Object.getOwnPropertySymbols,$g=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,Ng=(r,t,e)=>t in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wr=(r,t)=>{for(var e in t=t||{})$g.call(t,e)&&Ng(r,e,t[e]);if(Ss)for(var e of Ss(t))Lg.call(t,e)&&Ng(r,e,t[e]);return r};class Hg extends bg{constructor(...t){let i=null!=(e=t[0])?e:{};"number"==typeof i&&(i={strength:i},void 0!==t[1]&&(i.quality=t[1]),void 0!==t[2]&&(i.resolution=t[2]||"inherit"),void 0!==t[3])&&(i.kernelSize=t[3]);var{strength:e,strengthX:t,strengthY:a,quality:l}=i=Wr(Wr({},Ts.defaultOptions),i),u=((r,t)=>{var e={};for(i in r)$g.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ss)for(var i of Ss(r))t.indexOf(i)<0&&Lg.call(r,i)&&(e[i]=r[i]);return e})(i,["strength","strengthX","strengthY","quality"]);super(((r,t)=>JE(r,tA(t)))(Wr({},u),{compatibleRenderers:_t.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new Ts(Wr({horizontal:!0},i)),this.blurYFilter=new Ts(Wr({horizontal:!1},i)),this.quality=l,this.strengthX=null!=t?t:e,this.strengthY=null!=a?a:e,this.repeatEdgePixels=!1}apply(t,e,i,s){var n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);n&&o?(n=it.getSameSizeTexture(e),this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,n,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,n,i,s),it.returnTexture(n)):(o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter)).apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=2*Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))}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()}}Hg.defaultOptions={strength:8,quality:4,kernelSize:5};var Xg=`
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);
}
`,tl=`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);
}`,iA=Object.defineProperty,sA=Object.defineProperties,nA=Object.getOwnPropertyDescriptors,jg=Object.getOwnPropertySymbols,oA=Object.prototype.hasOwnProperty,aA=Object.prototype.propertyIsEnumerable,zg=(r,t,e)=>t in r?iA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vg=`
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));
}
`,Wg=`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();
}
`,el=`
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));
}`,hA=Object.defineProperty,dA=Object.defineProperties,pA=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,Yg=Object.prototype.hasOwnProperty,Kg=Object.prototype.propertyIsEnumerable,qg=(r,t,e)=>t in r?hA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zg=`
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;
}
`,rl=`
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;
}`,bA=Object.defineProperty,vA=Object.defineProperties,yA=Object.getOwnPropertyDescriptors,As=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,Jg=Object.prototype.propertyIsEnumerable,t_=(r,t,e)=>t in r?bA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,il=(r,t)=>{for(var e in t=t||{})Qg.call(t,e)&&t_(r,e,t[e]);if(As)for(var e of As(t))Jg.call(t,e)&&t_(r,e,t[e]);return r},r_=((kg=class Ky extends bg{constructor(t={}){t=il(il({},Ky.defaultOptions),t);var e=gt.from({vertex:{source:rl,entryPoint:"mainVertex"},fragment:{source:rl,entryPoint:"mainFragment"}}),i=Tt.from({vertex:ys,fragment:Zg,name:"noise-filter"}),{noise:n,seed:o}=t,t=((r,t)=>{var e={};for(i in r)Qg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&As)for(var i of As(r))t.indexOf(i)<0&&Jg.call(r,i)&&(e[i]=r[i]);return e})(t,["noise","seed"]);super(((r,t)=>vA(r,yA(t)))(il({},t),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new st({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=null!=o?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}}).defaultOptions={noise:.5},`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;
}
`),i_=`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);
}
`,sl=`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;
}
`,EA=Object.defineProperty,AA=Object.defineProperties,PA=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,s_=Object.prototype.hasOwnProperty,n_=Object.prototype.propertyIsEnumerable,o_=(r,t,e)=>t in r?EA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class a_ extends bg{constructor(t){var i=t.sprite,s=((r,t)=>{var e={};for(i in r)s_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ps)for(var i of Ps(r))t.indexOf(i)<0&&n_.call(r,i)&&(e[i]=r[i]);return e})(t,["sprite"]),n=new Sn(i.texture),t=new st({uFilterMatrix:{value:new M,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),a=gt.from({vertex:{source:sl,entryPoint:"mainVertex"},fragment:{source:sl,entryPoint:"mainFragment"}}),l=Tt.from({vertex:i_,fragment:r_,name:"mask-filter"});super(((r,t)=>AA(r,PA(t)))(((r,t)=>{for(var e in t=s||{})s_.call(t,e)&&o_(r,e,t[e]);if(Ps)for(var e of Ps(t))n_.call(t,e)&&o_(r,e,t[e]);return r})({}),{gpuProgram:a,glProgram:l,resources:{filterUniforms:t,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,i,s){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,i,s)}}function nl(r,t,e,i,s,n,o,a){return o-=e,s-=e,r-=e,e=t-i,t=o*o+(a-=i)*a,i=o*s+a*(n-=i),o=o*r+a*e,a=s*s+n*n,e=(t*(s=s*r+n*e)-i*o)*(r=1/(t*a-i*i)),0<=(n=(a*o-i*s)*r)&&0<=e&&n+e<1}var l_=class qy{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{var e=this.queue;let i=0;for(;e.length&&i<qy.uploadsPerFrame;){var s=e.shift();this.uploadQueueItem(s),i++}e.length?ut.system.addOnce(this._tick,this,Yt.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){for(const i of Array.isArray(t)?t:[t])i instanceof lt?this._addContainer(i):this.resolveQueueItem(i,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(),ut.system.addOnce(this._tick,this,Yt.UTILITY)):e()})}dedupeQueue(){var t=Object.create(null);let e=0;for(let i=0;i<this.queue.length;i++){var s=this.queue[i];t[s.uid]||(t[s.uid]=!0,this.queue[e++]=s)}this.queue.length=e}_resolve(){var t=this.resolves,e=t.slice(0);t.length=0;for(const i of e)i()}},OA=(l_.uploadsPerFrame=4,Object.defineProperty),ws=Object.getOwnPropertySymbols,c_=Object.prototype.hasOwnProperty,h_=Object.prototype.propertyIsEnumerable,d_=(r,t,e)=>t in r?OA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class ir extends Lt{constructor(...t){let i=t[0];i instanceof ye&&(i={geometry:i,shader:t[1]},t[3])&&(i.geometry.topology=t[3]);var{geometry:t,shader:o,texture:a,roundPixels:l,state:u}=i;super(((r,t)=>{for(var e in t=t||{})c_.call(t,e)&&d_(r,e,t[e]);if(ws)for(var e of ws(t))h_.call(t,e)&&d_(r,e,t[e]);return r})({label:"Mesh"},((r,t)=>{var e={};for(i in r)c_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&ws)for(var i of ws(r))t.indexOf(i)<0&&h_.call(r,i)&&(e[i]=r[i]);return e})(i,["geometry","shader","texture","roundPixels","state"]))),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=null!=o?o:null,this.texture=null!=(a=null!=a?a:null==o?void 0:o.texture)?a:P.WHITE,this.state=null!=u?u:Et.for2d(),this._geometry=t,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=null!=l&&l}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&&(null!=(e=this._geometry)&&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||P.EMPTY;var 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||12&this.state.data)&&this._geometry instanceof oe&&("auto"===this._geometry.batchMode?this._geometry.positions.length/2<=100:"batch"===this._geometry.batchMode)}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){var{x:e,y:i}=t;if(this.bounds.containsPoint(e,i)){var s=this.geometry.getBuffer("aPosition").data,n="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){var o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){var u=2*o[l],c=2*o[l+1],d=2*o[l+2];if(nl(e,i,s[u],s[1+u],s[c],s[1+c],s[d],s[1+d]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const l=2*a,u=2*(a+1),c=2*(a+2);if(nl(e,i,s[l],s[1+l],s[u],s[1+u],s[c],s[1+c]))return!0}}}return!1}destroy(t){super.destroy(t),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,this._texture.destroy(t)),null!=(t=this._geometry)&&t.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}var IA=Object.defineProperty,FA=Object.defineProperties,DA=Object.getOwnPropertyDescriptors,Rs=Object.getOwnPropertySymbols,p_=Object.prototype.hasOwnProperty,f_=Object.prototype.propertyIsEnumerable,m_=(r,t,e)=>t in r?IA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Yr extends Ft{constructor(...t){var e=t[0],{animationSpeed:t=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:d,updateAnchor:p=!1}=e=Array.isArray(t[0])?{textures:t[0],autoUpdate:t[1]}:e,[m]=d;super(((r,t)=>FA(r,DA(t)))(((r,t)=>{for(var e in t=t||{})p_.call(t,e)&&m_(r,e,t[e]);if(Rs)for(var e of Rs(t))f_.call(t,e)&&m_(r,e,t[e]);return r})({},((r,t)=>{var e={};for(i in r)p_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Rs)for(var i of Rs(r))t.indexOf(i)<0&&f_.call(r,i)&&(e[i]=r[i]);return e})(e,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"])),{texture:m instanceof P?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=t,this.loop=a,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=d,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate)&&this._isConnectedToTicker&&(ut.shared.remove(this.update,this),this._isConnectedToTicker=!1)}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ut.shared.add(this.update,this,Yt.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(this._playing){var t=t.deltaTime,i=this.animationSpeed*t,s=this.currentFrame;if(null!==this._durations){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];var o=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(0<this.animationSpeed&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}}_updateTexture(){var 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(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){var e=[];for(let i=0;i<t.length;++i)e.push(P.from(t[i]));return new Yr(e)}static fromImages(t){var e=[];for(let i=0;i<t.length;++i)e.push(P.from(t[i]));return new Yr(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof P)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}.`);var 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?(ut.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ut.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class g_{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=null!=t?t:new M,this.observer=e,this.position=new rt(this,0,0),this.scale=new rt(this,1,1),this.pivot=new rt(this,0,0),this.skew=new rt(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){var 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){this.dirty=!0,t===this.skew&&this.updateSkew(),null!=(t=this.observer)&&t._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))}}var LA=Object.defineProperty,Ms=Object.getOwnPropertySymbols,__=Object.prototype.hasOwnProperty,b_=Object.prototype.propertyIsEnumerable,v_=(r,t,e)=>t in r?LA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Kr=(r,t)=>{for(var e in t=t||{})__.call(t,e)&&v_(r,e,t[e]);if(Ms)for(var e of Ms(t))b_.call(t,e)&&v_(r,e,t[e]);return r},y_=class nn extends Lt{constructor(...t){let e=t[0]||{};e instanceof P&&(e={texture:e}),1<t.length&&(e.width=t[1],e.height=t[2]);var{texture:s,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:c,applyAnchorToTexture:d,roundPixels:p}=t=null!=(e=Kr(Kr({},nn.defaultOptions),e))?e:{},t=((r,t)=>{var e={};for(i in r)__.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ms)for(var i of Ms(r))t.indexOf(i)<0&&b_.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Kr({label:"TilingSprite"},t)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=d,this.texture=s,this._width=null!=u?u:s.width,this._height=null!=c?c:s.height,this._tileTransform=new g_({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=null!=p&&p}static from(t,e={}){return"string"==typeof t?new nn(Kr({texture:W.get(t)},e)):new nn(Kr({texture:t},e))}get uvRespectAnchor(){return Ot("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Ot("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){"number"==typeof t?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){"number"==typeof t?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||P.EMPTY;var 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 i;"object"==typeof t&&(e=null!=(i=t.height)?i:t.width,t=t.width),this._width=t,this._height=null!=e?e:t,this.onViewUpdate()}getSize(t){return(t=t||{}).width=this._width,t.height=this._height,t}updateBounds(){var t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}containsPoint(t){var e=this._width,i=this._height,s=-e*this._anchor._x;return t.x>=s&&t.x<=s+e&&(s=-i*this._anchor._y,t.y>=s)&&t.y<=s+i}destroy(t=!1){super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,this._texture.destroy(t)),this._texture=null}};y_.defaultOptions={texture:P.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let x_=y_;var HA=Object.defineProperty,Cs=Object.getOwnPropertySymbols,T_=Object.prototype.hasOwnProperty,S_=Object.prototype.propertyIsEnumerable,E_=(r,t,e)=>t in r?HA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class Os extends Lt{constructor(t,e){var{text:s,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:c}=t;super(((r,t)=>{for(var e in t=t||{})T_.call(t,e)&&E_(r,e,t[e]);if(Cs)for(var e of Cs(t))S_.call(t,e)&&E_(r,e,t[e]);return r})({},((r,t)=>{var e={};for(i in r)T_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Cs)for(var i of Cs(r))t.indexOf(i)<0&&S_.call(r,i)&&(e[i]=r[i]);return e})(t,["text","resolution","style","anchor","width","height","roundPixels"]))),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=null!=s?s:"",this.style=o,this.resolution=null!=n?n:null,this.allowChildren=!1,this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=null!=c&&c,void 0!==l&&(this.width=l),void 0!==u&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?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=null===t,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},null!=(e=this._style)&&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||{}).width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;"object"==typeof t?(e=null!=(i=t.height)?i:t.width,t=t.width):null==e&&(e=t),void 0!==t&&this._setWidth(t,this.bounds.width),void 0!==e&&this._setHeight(e,this.bounds.height)}containsPoint(t){var e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;return t.x>=s&&t.x<=s+e&&(s=-i*this.anchor.y,t.y>=s)&&t.y<=s+i}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}_getKey(){return`${this.text}:${this._style.styleKey}:`+this._resolution}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,("boolean"==typeof t?t:null!=t&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function Gs(r,t){var e=null!=(e=r[0])?e:{};return"string"==typeof e||r[1]?{text:e,style:r[1]}:e}class al extends Os{constructor(...t){super(Gs(t),Pt),this.renderPipeId="text"}updateBounds(){var t=this._bounds,e=this._anchor,{width:s,height:n}=jt.measureText(this._text,this._style);t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}class A_ extends l_{resolveQueueItem(t,e){return t instanceof lt?this.resolveContainerQueueItem(t,e):t instanceof Q||t instanceof P?e.push(t.source):t instanceof dt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Ft||t instanceof x_||t instanceof ir?e.push(t.texture.source):t instanceof al?e.push(t):t instanceof Ze?e.push(t.context):t instanceof Yr&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){var s;this.renderer.graphicsContext.getGpuContext(t);for(const i of t=t.instructions){if("texture"===i.action)return(s=i.data.image).source;if("fill"===i.action){const s=i.data.style.texture;return s.source}}return null}}class P_ extends Os{constructor(...t){var i;null==(t=Gs(t)).style&&(t.style=t.style||{}),null==(i=t.style).fill&&(i.fill=16777215),super(t,Pt),this.renderPipeId="bitmapText"}updateBounds(){var t=this._bounds,e=this._anchor,i=Ir.measureText(this.text,this._style),s=i.scale,n=i.offsetY*s;let o=i.width*s,a=i.height*s;(i=this._style._stroke)&&(o+=i.width,a+=i.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}}class w_ extends Os{constructor(...t){super(Gs(t),Ae),this.renderPipeId="htmlText"}updateBounds(){var t=this._bounds,e=this._anchor,{width:s,height:n}=ma(this.text,this._style);t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}class R_ extends A_{uploadQueueItem(t){t instanceof Q?this.uploadTextureSource(t):t instanceof al?this.uploadText(t):t instanceof w_?this.uploadHTMLText(t):t instanceof P_?this.uploadBitmapText(t):t instanceof dt&&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);for(const i of t=t.instructions)if("texture"===i.action){var s=i.data.image;this.uploadTextureSource(s.source)}else if("fill"===i.action){const s=i.data.style.texture;this.uploadTextureSource(s.source)}return null}}class M_ extends R_{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}M_.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"prepare"};class ll{constructor(){this._tempState=Et.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){var t=t.renderer,n=this._didUploadHash[i.uid];t.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),t.shader.updateUniformGroup(t.globalUniforms.uniformGroup),t.geometry.bind(e,i.glProgram)}execute(t,e){var i=t.renderer,s=(this._tempState.blendMode=e.blendMode,i.state.set(this._tempState),e.textures.textures);for(let n=0;n<e.textures.count;n++)i.texture.bind(s[n],n);i.geometry.draw(e.topology,e.size,e.start)}}ll.extension={type:[r.WebGLPipesAdaptor],name:"batch"};const Bs=Et.for2d();class ul{start(t,e,i){var n=(t=t.renderer).encoder,o=i.gpuProgram,i=(this._shader=i,this._geometry=e,n.setGeometry(e,o),Bs.blendMode="normal",t.pipeline.getPipeline(e,o,Bs),t.globalUniforms.bindGroup);n.resetBindGroup(1),n.setBindGroup(0,i,o)}execute(t,e){var i=this._shader.gpuProgram,n=(t=t.renderer).encoder,l=(e.bindGroup||(l=e.textures,e.bindGroup=Ai(l.textures,l.count)),Bs.blendMode=e.blendMode,t.bindGroup.getBindGroup(e.bindGroup,i,1)),i=t.pipeline.getPipeline(this._geometry,i,Bs,e.topology);e.bindGroup._touch(t.textureGC.count),n.setPipeline(i),n.renderPassEncoder.setBindGroup(1,l),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}ul.extension={type:[r.WebGPUPipesAdaptor],name:"batch"},(y_=class Zy{constructor(t,e){this.state=Et.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,null!=(e=(t=this._adaptor).init)&&e.call(t,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)).default||(e.default=new Fi),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const i in this._activeBatches)this._activeBatches[i].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let i=this._activeBatches[t.batcherName];i||(i=this._activeBatches[t.batcherName]=Zy.getBatcher(t.batcherName)).begin(),this._activeBatch=i}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);var e=this._activeBatches;for(const i in e){var s=e[i],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(t){var e=this._batchersByInstructionSet[t.uid];for(const i in e){var s=e[i],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(4*s.attributeSize))}}execute(t){var i,e;"startBatch"===t.action&&(i=(e=t.batcher).geometry,e=e.shader,this._adaptor.start(this,i,e)),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}}).extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"batch"},y_._availableBatchers=Object.create(null),B.handleByMap(r.Batcher,y_._availableBatchers),B.add(Fi);const C_={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);
`}},O_={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);
`}},YA=new nt;let KA=class extends hr{constructor(){super(),this.filters=[new a_({sprite:new Ft(P.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 dl{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){var n,s=this._renderer;s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture&&((n=t.mask).includeInBuild=!0,n.collectRenderables(i,s,null),n.includeInBuild=!1),s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){var e=this._renderer,i=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){var n,o,l,s=N.get(KA);s.inverse=t.inverse,i?(t.mask.mask.measurable=!0,n=dr(t.mask.mask,!0,YA),t.mask.mask.measurable=!1,n.ceil(),o=e.renderTarget.renderTarget.colorTexture.source,o=it.getOptimalTexture(n.width,n.height,o._resolution,o.antialias),e.renderTarget.push(o,!0),e.globalUniforms.push({offset:n,worldColor:4294967295}),(l=s.sprite).texture=o,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:o})):(s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer}))}else if("pushMaskEnd"===t.action){const s=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===_t.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const s=this._activeMaskStage.pop();i&&it.returnTexture(s.filterTexture),N.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}dl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"alphaMask"};class pl{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,i){this._renderer.renderPipes.batch.break(i);var s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask,(s=this._colorStack[this._colorStackIndex])!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);var s=this._colorStack;this._colorStackIndex--,(s=s[this._colorStackIndex-1])!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}pl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"colorMask"};class fl{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var o=t,a=this._renderer,l=(a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(o.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1}),(l=o.mask).includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0}),(o=this._maskHash.get(o)).instructionsStart=i.instructionSize,l.collectRenderables(i,a,null),l.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1}),i.instructionSize-o.instructionsStart-1),t=(o.instructionsLength=l,a.renderTarget.renderTarget.uid);null==(e=this._maskStackHash)[t]&&(e[t]=0)}pop(t,e,i){var s=t,n=this._renderer,o=(n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1}),this._maskHash.get(t));for(let a=0;a<o.instructionsLength;a++)i.instructions[i.instructionSize++]=i.instructions[o.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i,s=this._renderer,n=s.renderTarget.renderTarget.uid;let o=null!=(i=(e=this._maskStackHash)[n])?i:e[n]=0;"pushMaskBegin"===t.action?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(J.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?s.stencil.setStencilMode(J.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(J.MASK_ACTIVE,o),s.colorMask.setMask(15)):"popMaskBegin"===t.action?(s.colorMask.setMask(0),0!==o?s.stencil.setStencilMode(J.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,bt.STENCIL),s.stencil.setStencilMode(J.DISABLED,o)),o--):"popMaskEnd"===t.action&&(t.inverse?s.stencil.setStencilMode(J.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(J.MASK_ACTIVE,o),s.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}fl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"stencilMask"};var qr=(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))({});class G_{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class ml{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){var t=this._gl=this._renderer.gl;this._gpuBuffers=Object.create(null),this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){var e=this._gl,t=this.getGlBuffer(t);e.bindBuffer(t.type,t.buffer)}bindBufferBase(t,e){var i=this._gl;this._boundBufferBases[e]!==t&&((this._boundBufferBases[e]=t)._lastBindBaseLocation=e,i.bindBufferBase(i.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){var e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,s=this._nextBindBaseIndex;for(;i<2;){s>=this._maxBindings&&(s=this._minBaseLocation,i++);var n=this._boundBufferBases[s];if(!n||n._lastBindCallId!==this._bindCallId)break;s++}return e=s,this._nextBindBaseIndex=s+1,2<=i?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){var e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){var n=this._gl;i=i||0,this._boundBufferBases[e=e||0]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,256*i,s||256)}updateBuffer(t){var s,n,e=this._gl,i=this.getGlBuffer(t);return t._updateID!==i.updateID&&(i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer),s=t.data,n=t.descriptor.usage&L.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW,s?i.byteLength>=s.byteLength?e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(i.byteLength=s.byteLength,e.bufferData(i.type,s,n)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,n))),i}destroyAll(){var t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){var i=this._gpuBuffers[t.uid],s=this._gl;e||s.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){var e=this._gl;let i=qr.ARRAY_BUFFER;return t.descriptor.usage&L.INDEX?i=qr.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&L.UNIFORM&&(i=qr.UNIFORM_BUFFER),e=new G_(e.createBuffer(),i),this._gpuBuffers[t.uid]=e,t.on("destroy",this.onBufferDestroy,this),e}resetState(){this._boundBufferBases=Object.create(null)}}ml.extension={type:[r.WebGLSystem],name:"buffer"};var ZA=Object.defineProperty,QA=Object.defineProperties,JA=Object.getOwnPropertyDescriptors,B_=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,eP=Object.prototype.propertyIsEnumerable,I_=(r,t,e)=>t in r?ZA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Is=(r,t)=>{for(var e in t=t||{})tP.call(t,e)&&I_(r,e,t[e]);if(B_)for(var e of B_(t))eP.call(t,e)&&I_(r,e,t[e]);return r},F_=(r,t)=>QA(r,JA(t)),gl=class Qy{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 n,e,a;t=Is(Is({},Qy.defaultOptions),t);let s=this.multiView=t.multiView;t.context&&s&&(Ot("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),s=!1),s?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):(n=this._renderer.background.alpha<1,e=null==(e=t.premultipliedAlpha)||e,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer,this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:e,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:null!=(n=t.powerPreference)?n:"default"}))}ensureCanvasSize(t){var e;this.multiView?((e=this.canvas).width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height)):t!==this.canvas&&Ot("multiView is disabled, but targetCanvas is not the main canvas")}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),(t=this._renderer.view.canvas).addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;var s=this.canvas;if(!(i=2===t?s.getContext("webgl2",e):i)&&!(i=s.getContext("webgl",e)))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){var t=this.gl,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")};1===this.webGLVersion?this.extensions=F_(Is({},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")}):(this.extensions=F_(Is({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")}),(e=t.getExtension("WEBGL_provoking_vertex"))&&e.provokingVertexWEBGL(e.FIRST_VERTEX_CONVENTION_WEBGL))}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&null!=(e=this.extensions.loseContext)&&e.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),null!=(e=this.extensions.loseContext)&&e.loseContext()}forceContextLoss(){var t;null!=(t=this.extensions.loseContext)&&t.loseContext(),this._contextLossForced=!0}validateContext(t){(t=t.getContextAttributes())&&t.stencil;var t=this.supports,s=2===this.webGLVersion,n=this.extensions;t.uint32Indices=s||!!n.uint32ElementIndex,t.uniformBufferObject=s,t.vertexArrayObject=s||!!n.vertexArrayObject,t.srgbTextures=s||!!n.srgb,t.nonPowOf2wrapping=s,t.nonPowOf2mipmaps=s,t.msaa=s,t.uint32Indices}};function _l(r,t){for(const n in r.attributes){var o=r.attributes[n],a=t[n];a?(null==o.format&&(o.format=a.format),null==o.offset&&(o.offset=a.offset),null==o.instance&&(o.instance=a.instance)):Ot(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(r){var l,{buffers:i,attributes:s}=r,n={},o={};for(const a in i)n[(l=i[a]).uid]=0,o[l.uid]=0;for(const a in s)n[(l=s[a]).buffer.uid]+=qt(l.format).stride;for(const a in s)null==(l=s[a]).stride&&(l.stride=n[l.buffer.uid]),null==l.start&&(l.start=o[l.buffer.uid]),o[l.buffer.uid]+=qt(l.format).stride}(r)}gl.extension={type:[r.WebGLSystem],name:"context"},gl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};var Fs=(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))({}),bl=(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))({}),U_=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))({}),j=(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))({});const k_={uint8x2:j.UNSIGNED_BYTE,uint8x4:j.UNSIGNED_BYTE,sint8x2:j.BYTE,sint8x4:j.BYTE,unorm8x2:j.UNSIGNED_BYTE,unorm8x4:j.UNSIGNED_BYTE,snorm8x2:j.BYTE,snorm8x4:j.BYTE,uint16x2:j.UNSIGNED_SHORT,uint16x4:j.UNSIGNED_SHORT,sint16x2:j.SHORT,sint16x4:j.SHORT,unorm16x2:j.UNSIGNED_SHORT,unorm16x4:j.UNSIGNED_SHORT,snorm16x2:j.SHORT,snorm16x4:j.SHORT,float16x2:j.HALF_FLOAT,float16x4:j.HALF_FLOAT,float32:j.FLOAT,float32x2:j.FLOAT,float32x3:j.FLOAT,float32x4:j.FLOAT,uint32:j.UNSIGNED_INT,uint32x2:j.UNSIGNED_INT,uint32x3:j.UNSIGNED_INT,uint32x4:j.UNSIGNED_INT,sint32:j.INT,sint32x2:j.INT,sint32x3:j.INT,sint32x4:j.INT};function $_(r){return null!=(r=k_[r])?r:k_.float32}const iP={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class vl{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){var 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");const e=this._renderer.context.extensions.vertexArrayObject,i=(e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=s=>e.bindVertexArrayOES(s),t.deleteVertexArray=s=>e.deleteVertexArrayOES(s)),this._renderer.context.extensions.vertexAttribDivisorANGLE);i&&(t.drawArraysInstanced=(s,n,o,a)=>{i.drawArraysInstancedANGLE(s,n,o,a)},t.drawElementsInstanced=(s,n,o,a,l)=>{i.drawElementsInstancedANGLE(s,n,o,a,l)},t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){var i=this.gl,t=(this._activeGeometry=t,this.getVao(t,e));this._activeVao!==t&&(this._activeVao=t,i.bindVertexArray(t)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){var t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){var s=t.buffers[i];e.updateBuffer(s)}}checkCompatibility(t,e){var i=t.attributes;for(const n in e._attributeData)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){var i=t.attributes,s=e._attributeData,n=["g",t.uid];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}getVao(t,e){var i;return(null==(i=this._geometryVaoHash[t.uid])?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=0){var s=this._renderer.gl,n=this._renderer.buffer,o=(this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e),this.getSignature(t,e)),a=(this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this)),this._geometryVaoHash[t.uid]);if(l=a[o])a[e._key]=l;else{_l(t,e._attributeData);var u=t.buffers,l=s.createVertexArray();s.bindVertexArray(l);for(let c=0;c<u.length;c++){var d=u[c];n.bind(d)}this.activateVao(t,e),a[e._key]=l,a[o]=l,s.bindVertexArray(null)}return l}onGeometryDestroy(t,e){var i=this._geometryVaoHash[t.uid],s=this.gl;if(i){if(e)for(const n in i)this._activeVao!==i[n]&&this.unbind(),s.deleteVertexArray(i[n]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){var e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const s in this._geometryVaoHash[i]){var n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[s])}this._geometryVaoHash[i]=null}}activateVao(t,e){var 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){var c=a[u],d=c.buffer,p=o.getGlBuffer(d),f=e._attributeData[u];if(f){l!==p&&(o.bind(d),l=p);var d=f.location,p=(n.enableVertexAttribArray(d),qt(c.format)),g=$_(c.format);if("int"===(null==(f=f.format)?void 0:f.substring(1,4))?n.vertexAttribIPointer(d,p.size,g,c.stride,c.offset):n.vertexAttribPointer(d,p.size,g,p.normalised,c.stride,c.offset),c.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");g=null!=(f=c.divisor)?f:1,n.vertexAttribDivisor(d,g)}}}}draw(t,e,i,s){var l,u,n=this._renderer.gl,o=this._activeGeometry,t=iP[t||o.topology];return null==s&&(s=o.instanceCount),o.indexBuffer?(u=2===(l=o.indexBuffer.data.BYTES_PER_ELEMENT)?n.UNSIGNED_SHORT:n.UNSIGNED_INT,1<s?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,u,(i||0)*l,s):n.drawElements(t,e||o.indexBuffer.data.length,u,(i||0)*l)):1<s?n.drawArraysInstanced(t,i||0,e||o.getSize(),s):n.drawArrays(t,i||0,e||o.getSize()),this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}vl.extension={type:[r.WebGLSystem],name:"geometry"};var sP=Object.defineProperty,L_=Object.getOwnPropertySymbols,nP=Object.prototype.hasOwnProperty,oP=Object.prototype.propertyIsEnumerable,N_=(r,t,e)=>t in r?sP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H_=(r,t)=>{for(var e in t=t||{})nP.call(t,e)&&N_(r,e,t[e]);if(L_)for(var e of L_(t))oP.call(t,e)&&N_(r,e,t[e]);return r};const aP=new ye({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),yl=class Jy{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){var{useBackBuffer:t,antialias:i}=H_(H_({},Jy.defaultOptions),t),t=(this.useBackBuffer=t,this._antialias=i,this._renderer.context.supports.msaa||(Ot("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Et.for2d(),new Tt({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 St({glProgram:t,resources:{uTexture:P.WHITE.source}})}renderStart(t){var e=this._renderer.renderTarget.getRenderTarget(t.target);this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender&&(e=this._renderer.renderTarget.getRenderTarget(t.target),this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.colorTexture))}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){var 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:aP,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new P({source:new Q({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)}};yl.extension={type:[r.WebGLSystem],name:"backBuffer",priority:1},yl.defaultOptions={useBackBuffer:!1};var X_=yl;class xl{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}xl.extension={type:[r.WebGLSystem],name:"colorMask"};class Tl{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){var e=this._renderer,{geometry:t,shader:s,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:c}=t;e.shader.bind(s,o),e.geometry.bind(t,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,null!=c?c:t.instanceCount)}destroy(){this._renderer=null}}Tl.extension={type:[r.WebGLSystem],name:"encoder"};class j_{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const te=[];te[J.NONE]=void 0,te[J.DISABLED]={stencilWriteMask:0,stencilReadMask:0},te[J.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},te[J.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},te[J.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},te[J.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"replace"},stencilBack:{compare:"not-equal",passOp:"replace"}};class Sl{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:J.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){this._activeRenderTarget!==t&&(this._activeRenderTarget=t,t=this._renderTargetStencilState[t.uid]||(this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference))}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=J.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){var i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=te[t],o=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t===J.DISABLED?this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST)):(this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),t===o.stencilMode&&o.stencilReference===e||(o.stencilMode=t,o.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp])))}}Sl.extension={type:[r.WebGLSystem],name:"stencil"};class El{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ea())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){var e=this.getUniformGroupData(t);t.buffer||(t.buffer=new ht({data:new Float32Array(e.layout.size/4),usage:L.UNIFORM|L.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){var s,o,e=t._signature;return this._syncFunctionHash[e]||(s=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),s=this._adaptor.createUboElements(s),o=this._generateUboSync(s.uboElements),this._syncFunctionHash[e]={layout:s,syncFunction:o}),this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){var s=this.getUniformGroupData(t);t.buffer||(t.buffer=new ht({data:new Float32Array(s.layout.size/4),usage:L.UNIFORM|L.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),i=i||0,s.syncFunction(t.uniforms,e,n,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;var e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const Al={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 z_(r){var t=r.map(n=>({data:n,offset:0,size:0}));let i,s=0;for(let n=0;n<t.length;n++){var o=t[n];if(!(i=Al[o.data.type]))throw new Error("Unknown type "+o.data.type);var a=12===(i=1<o.data.size?Math.max(i,16)*o.data.size:i)?16:i,l=(o.size=i,s%16);s+=0<l&&16-l<a?(16-l)%16:(i-l%i)%i,o.offset=s,s+=i}return{uboElements:t,size:s=16*Math.ceil(s/16)}}const ue=[{type:"mat3x3<f32>",test:r=>void 0!==r.value.a,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=>"vec4<f32>"===r.type&&1===r.size&&void 0!==r.value.width,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=>"vec2<f32>"===r.type&&1===r.size&&void 0!==r.value.x,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=>"vec4<f32>"===r.type&&1===r.size&&void 0!==r.value.red,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=>"vec3<f32>"===r.type&&1===r.size&&void 0!==r.value.red,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 Pl(r,t,e,i){var s=[`
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++){var p,l=r[a],u=l.data.name;let c=!1,d=0;for(let p=0;p<ue.length;p++)if(ue[p].test(l.data)){d=l.offset/4,s.push(`name = "${u}";`,`offset += ${d-n};`,ue[p][t]||ue[p].ubo),c=!0;break}c||(1<l.data.size?(d=l.offset/4,s.push(e(l,d-n))):(p=i[l.data.type],d=l.offset/4,s.push(`
v = uv.${u};
offset += ${d-n};
${p};
`))),n=d}var o=s.join(`
`);return new Function("uv","data","dataInt32","offset",o)}var lP=Object.defineProperty,uP=Object.defineProperties,cP=Object.getOwnPropertyDescriptors,V_=Object.getOwnPropertySymbols,hP=Object.prototype.hasOwnProperty,dP=Object.prototype.propertyIsEnumerable,W_=(r,t,e)=>t in r?lP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;function sr(r,t){return`
for (let i = 0; i < ${r*t}; i++) {
data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
}
`}const wl={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>":sr(3,2),"mat4x2<f32>":sr(4,2),"mat2x3<f32>":sr(2,3),"mat4x3<f32>":sr(4,3),"mat2x4<f32>":sr(2,4),"mat3x4<f32>":sr(3,4)},Y_=(r=>uP(r,cP({"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];
`})))(((r,t)=>{for(var e in wl)hP.call(t,e)&&W_(r,e,t[e]);if(V_)for(var e of V_(t))dP.call(t,e)&&W_(r,e,t[e]);return r})({},wl));function K_(r,t){var e=Math.max(Al[r.data.type]/16,1),i=r.data.value.length/r.data.size,s=(4-i%4)%4,n=0<=r.data.type.indexOf("i32")?"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 < ${i}; j++)
{
${n}[arrayOffset++] = v[t++];
}
${0!=s?`arrayOffset += ${s};`:""}
}
`}function q_(r){return Pl(r,"uboStd40",K_,wl)}class Rl extends El{constructor(){super({createUboElements:z_,generateUboSync:q_})}}Rl.extension={type:[r.WebGLSystem],name:"ubo"};class Z_{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z}copyToTexture(t,e,i,s,n){var o=this._renderTargetSystem,a=this._renderer,o=o.getGpuRenderTarget(t),u=a.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,o.resolveTargetFramebuffer),a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){var n=this._renderTargetSystem,o=t.colorTexture,n=n.getGpuRenderTarget(t);let l=s.y;t.isRoot&&(l=o.pixelHeight-s.height),t.colorTextures.forEach(d=>{this._renderer.texture.unbind(d)}),(o=this._renderer.gl).bindFramebuffer(o.FRAMEBUFFER,n.framebuffer);var c=this._viewPortCache;c.x===s.x&&c.y===l&&c.width===s.width&&c.height===s.height||(c.x=s.x,c.y=l,c.width=s.width,c.height=s.height,o.viewport(s.x,l,s.width,s.height)),n.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(n),this.clear(t,e,i)}finishRenderPass(t){var i;(t=this._renderTargetSystem.getGpuRenderTarget(t)).msaa&&((i=this._renderer.gl).bindFramebuffer(i.FRAMEBUFFER,t.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,t.framebuffer))}initGpuRenderTarget(t){var e=this._renderer.gl,i=new j_,s=t.colorTexture;return Nt.test(s.resource)?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null)),i}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(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){var n,s;e&&(s=this._renderTargetSystem,"boolean"==typeof e&&(e=e?bt.ALL:bt.NONE),n=this._renderer.gl,e&bt.COLOR&&(s=i=null==i?s.defaultClearColor:i,(i=this._clearColorCache)[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]&&i[3]===s[3]||(i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],n.clearColor(s[0],s[1],s[2],s[3]))),n.clear(e))}resizeGpuRenderTarget(t){var e;!t.isRoot&&(e=this._renderTargetSystem.getGpuRenderTarget(t),this._resizeColor(t,e),t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();var o;e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{(o=o.source).antialias&&(i.context.supports.msaa?e.msaa=!0:Ot("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(o,0),o=i.texture.getGlSource(o).texture,s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,3553,o,0)}),e.msaa?(o=s.createFramebuffer(),e.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{var u=s.createRenderbuffer();e.msaaRenderBuffer[l]=u})):e.framebuffer=n,this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((s,n)=>{0!==n&&s.source.resize(i.width,i.height,i._resolution)}),e.msaa){const s=this._renderer,n=s.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{var a=a.source,c=(s.texture.bindSource(a,0),s.texture.getGlSource(a).internalFormat),d=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,a.pixelWidth,a.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,d)})}}_initStencil(t){var e,i;null!==t.framebuffer&&(i=(e=this._renderer.gl).createRenderbuffer(),t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t))}_resizeStencil(t){var 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,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){t=t.colorTexture.resource,this._renderer.context.multiView&&Nt.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(t){var e;this._renderer.context.multiView&&Nt.test(t.colorTexture.resource)&&(e=this._renderer.context.canvas,(t=t.colorTexture).context2D.drawImage(e,0,t.pixelHeight-e.height))}}function Q_(r,t,e,i,s,n){return n=n?1:-1,r.identity(),r.a=1/i*2,r.d=1/s*2*n,r.tx=-1-t*r.a,r.ty=-n-e*r.d,r}var mP=Object.defineProperty,J_=Object.getOwnPropertySymbols,gP=Object.prototype.hasOwnProperty,_P=Object.prototype.propertyIsEnumerable,tb=(r,t,e)=>t in r?mP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const nr=new Map;function Ml(r,t){if(!nr.has(r)){const e=new P({source:new Nt(((r,t)=>{for(var e in t=t||{})gP.call(t,e)&&tb(r,e,t[e]);if(J_)for(var e of J_(t))_P.call(t,e)&&tb(r,e,t[e]);return r})({resource:r},t))}),i=()=>{nr.get(r)===e&&nr.delete(r)};e.once("destroy",i),e.source.once("destroy",i),nr.set(r,e)}return nr.get(r)}function eb(r){return r=r.colorTexture.source.resource,globalThis.HTMLCanvasElement&&r instanceof HTMLCanvasElement&&document.body.contains(r)}var yP=Object.defineProperty,rb=Object.getOwnPropertySymbols,xP=Object.prototype.hasOwnProperty,TP=Object.prototype.propertyIsEnumerable,ib=(r,t,e)=>t in r?yP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sb=(r,t)=>{for(var e in t=t||{})xP.call(t,e)&&ib(r,e,t[e]);if(rb)for(var e of rb(t))TP.call(t,e)&&ib(r,e,t[e]);return r},nb=class tx{constructor(t={}){if(this.uid=K("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=sb(sb({},tx.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,"number"==typeof t.colorTextures){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new Q({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];var 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 P||t.depthStencilTexture instanceof Q?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){var 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 Q({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{s&&0===o||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}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)}};nb.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Ds=nb;class Cl{constructor(t){this.rootViewPort=new z,this.viewport=new z,this.onRenderTargetChange=new Aa("onRenderTargetChange"),this.projectionMatrix=new M,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],(this._renderer=t).renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=eb(this.rootRenderTarget),null!=(e=(t=this.adaptor).prerender)&&e.call(t,this.rootRenderTarget)}postrender(){var t,e;null!=(e=(t=this.adaptor).postrender)&&e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,s){var n=this.getRenderTarget(t),o=this.renderTarget!==n,a=(this.renderTarget=n,this.renderSurface=t,this.getGpuRenderTarget(n)),a=(n.pixelWidth===a.width&&n.pixelHeight===a.height||(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight),n.colorTexture),u=this.viewport,c=a.pixelWidth,d=a.pixelHeight;return(s=!s&&t instanceof P?t.frame:s)?(t=a._resolution,u.x=s.x*t+.5|0,u.y=s.y*t+.5|0,u.width=s.width*t+.5|0,u.height=s.height*t+.5|0):(u.x=0,u.y=0,u.width=c,u.height=d),Q_(this.projectionMatrix,0,0,u.width/a.resolution,u.height/a.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,u),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=bt.ALL,i){e&&(t=t&&this.getRenderTarget(t),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=bt.ALL,i,s){return t=this.bind(t,e,i,s),this._renderTargetStack.push({renderTarget:t,frame:s}),t}pop(){this._renderTargetStack.pop();var t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),null!=(e=this._renderSurfaceToRenderTargetHash.get(t))?e:this._initRenderTarget(t)}copyToTexture(t,e,i,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);var{pixelWidth:o,pixelHeight:a}=t;return s.width=Math.min(s.width,o-i.x),s.height=Math.min(s.height,a-i.y),this.adaptor.copyToTexture(t,e,i,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}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(t=Nt.test(t)?Ml(t).source:t)instanceof Ds?e=t:t instanceof Q&&(e=new Ds({colorTextures:[t]}),Nt.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);var i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),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 Ol extends Cl{constructor(t){super(t),this.adaptor=new Z_,this.adaptor.init(t,this)}}Ol.extension={type:[r.WebGLSystem],name:"renderTarget"};class Us extends ft{constructor({buffer:t,offset:e,size:i}){super(),this.uid=K("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=K("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|e,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=K("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function ob(r,t){var e=[],i=[`
var g = s.groups;
var sS = r.shader;
var p = s.glProgram;
var ugS = r.uniformGroup;
var resources;
`];let s=!1,n=0;var o=t._getProgramData(r.glProgram);for(const l in r.groups){var u=r.groups[l];e.push(`
resources = g[${l}].resources;
`);for(const c in u.resources){var p,d=u.resources[c];if(d instanceof st)d.ubo?(p=r._uniformBindMap[l][Number(c)],e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)):e.push(`
ugS.updateUniformGroup(resources[${c}], p, sD);
`);else if(d instanceof Us){const p=r._uniformBindMap[l][Number(c)];e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)}else if(d instanceof Q){const p=r._uniformBindMap[l][c],f=o.uniformData[p];f&&(s||(s=!0,i.push(`
var tS = r.texture;
`)),t._gl.uniform1i(f.location,n),e.push(`
tS.bind(resources[${c}], ${n});
`),n++)}}}var a=[...i,...e].join(`
`);return new Function("r","s","sD",a)}class ab{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 Gl(r,t,e){return t=r.createShader(t),r.shaderSource(t,e),r.compileShader(t),t}function Bl(r){var t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Il(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 Bl(2*t);case"bvec3":return Bl(3*t);case"bvec4":return Bl(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 ks=null;const lb={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"},EP={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 Fl(r,t){if(!ks){var e=Object.keys(lb);ks={};for(let i=0;i<e.length;++i){var s=e[i];ks[r[s]]=lb[s]}}return ks[t]}function ub(r,t){return r=Fl(r,t),EP[r]||"float32"}function cb(r,t,e=!1){var i={},s=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){var l,a=t.getActiveAttrib(r,o);a.name.startsWith("gl_")||(l=ub(t,a.type),i[a.name]={location:0,format:l,stride:qt(l).stride,offset:0,instance:!1,start:0})}var n=Object.keys(i);if(e){n.sort((o,a)=>a<o?1:-1);for(let o=0;o<n.length;o++)i[n[o]].location=o,t.bindAttribLocation(r,o,n[o]);t.linkProgram(r)}else for(let o=0;o<n.length;o++)i[n[o]].location=t.getAttribLocation(r,n[o]);return i}function hb(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};var e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){var n=t.getActiveUniformBlockName(r,s),o=t.getUniformBlockIndex(r,n),a=t.getActiveUniformBlockParameter(r,s,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function db(r,t){var e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){var n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Fl(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Il(l,n.size)}}return e}function pb(r,t){const e=r.getShaderSource(t).split(`
`).map((u,c)=>c+": "+u),i=r.getShaderInfoLog(t),s=i.split(`
`),n={},o=s.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>!(!u||n[u]||(n[u]=!0,0))),a=[""];o.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")}),r=e.join(`
`),a[0]=r,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function fb(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||pb(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||pb(r,i),console.error("PixiJS Error: Could not initialize shader."),""!==r.getProgramInfoLog(t)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function mb(r,t){var e=Gl(r,r.VERTEX_SHADER,t.vertex),i=Gl(r,r.FRAGMENT_SHADER,t.fragment),s=r.createProgram(),n=(r.attachShader(s,e),r.attachShader(s,i),t.transformFeedbackVaryings),o=(n&&"function"==typeof r.transformFeedbackVaryings&&r.transformFeedbackVaryings(s,n.names,"separate"===n.bufferMode?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||fb(r,s,e,i),t._attributeData=cb(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=db(s,r),t._uniformBlockData=hb(s,r),r.deleteShader(e),r.deleteShader(i),{});for(const a in t._uniformData){var l=t._uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:Il(l.type,l.size)}}return new ab(s,o)}const $s={textureCount:0,blockIndex:0};class Dl{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=be()}bind(t,e){this._setProgram(t.glProgram),e||($s.textureCount=0,$s.blockIndex=0,e=(e=this._shaderSyncFunctions[t.glProgram._key])||(this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),e(this._renderer,t,$s))}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,$s)}bindUniformBlock(t,e,i=0){var s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource,a=(o||this._renderer.ubo.updateUniformGroup(t),t.buffer),l=s.updateBuffer(a),u=s.freeLocationForBufferBase(l),t=(o?({offset:o,size:t}=t,0===o&&t===a.data.byteLength?s.bindBufferBase(l,u):s.bindBufferRange(l,u,o)):s.getLastBindBaseLocation(l)!==u&&s.bindBufferBase(l,u),this._activeProgram._uniformBlockData[e].index);n.uniformBlockBindings[i]!==u&&(n.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(n.program,t,u))}_setProgram(t){this._activeProgram!==t&&(this._activeProgram=t,t=this._getProgramData(t),this._gl.useProgram(t.program))}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){var e=t._key;return this._programDataHash[e]=mb(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null}_generateShaderSync(t,e){return ob(t,e)}resetState(){this._activeProgram=null}}Dl.extension={type:[r.WebGLSystem],name:"shader"};const gb={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);"},_b={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 bb(r,t){var e=[`
var v = null;
var cv = null;
var cu = null;
var t = 0;
var gl = renderer.gl;
var name = null;
`];for(const i in r.uniforms)if(t[i]){var o,s=r.uniformStructures[i];let n=!1;for(let o=0;o<ue.length;o++){var a=ue[o];if(s.type===a.type&&a.test(s)){e.push(`name = "${i}";`,ue[o].uniform),n=!0;break}}n||(o=(1===s.size?gb:_b)[s.type].replace("location",`ud["${i}"].location`),e.push(`
cu = ud["${i}"];
cv = cu.value;
v = uv["${i}"];
${o};`))}else r.uniforms[i]instanceof st?r.uniforms[i].ubo?e.push(`
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
`):e.push(`
renderer.shader.updateUniformGroup(uv.${i});
`):r.uniforms[i]instanceof Us&&e.push(`
renderer.shader.bindBufferResource(uv.${i}, "${i}");
`);return new Function("ud","uv","renderer","syncData",e.join(`
`))}class Ul{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){var s=this._renderer.shader._getProgramData(e);t.isStatic&&t._dirtyId===s.uniformDirtyGroups[t.uid]||(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){var i;return(null==(i=this._uniformGroupSyncHash[t._signature])?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){var i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[s],i[e._key]}_generateUniformsSync(t,e){return bb(t,e)}_getSignature(t,e,i){var n=[i+"-"];for(const o in t.uniforms)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Ul.extension={type:[r.WebGLSystem],name:"uniformGroup"};const PP={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 vb(r){var e,t={};return 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()?(e=r.getExtension("EXT_blend_minmax"))&&(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]):(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]),t}var yb=class Uu{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=Et.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=vb(t),this.resetState()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;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(Uu._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Uu._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,t=this._invertFrontFace?!t:t,this._glFrontFace!==t&&(this._glFrontFace=t,this.gl.frontFace(this.gl[t?"CW":"CCW"]))}setBlendMode(t){var i;(t=this.blendModesMap[t]?t:"normal")!==this.blendMode&&(this.blendMode=t,t=this.blendModesMap[t],i=this.gl,2===t.length?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),6===t.length?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.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){var i=this.checks.indexOf(t);e&&-1===i?this.checks.push(t):e||-1===i||this.checks.splice(i,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}};yb.extension={type:[r.WebGLSystem],name:"state"},nb=yb;class Tb{constructor(t){this.target=bl.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=j.UNSIGNED_BYTE,this.internalFormat=Fs.RGBA,this.format=Fs.RGBA,this.samplerType=0}}const Sb={id:"buffer",upload(r,t,e){t.width===r.width||t.height===r.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},IP={"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},Eb={id:"compressed",upload(r,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=r.pixelWidth,s=r.pixelHeight;var n=!!IP[r.format];for(let o=0;o<r.resource.length;o++){var a=r.resource[o];n?e.compressedTexImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,a):e.texImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,t.format,t.type,a),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},kl={id:"image",upload(r,t,e,i){var s=t.width,n=t.height,o=r.pixelWidth,a=r.pixelHeight,l=r.resourceWidth,u=r.resourceHeight;l<o||u<a?(s===o&&n===a||e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,null),2===i?e.texSubImage2D(e.TEXTURE_2D,0,0,0,l,u,t.format,t.type,r.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource)):s===o&&n===a?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource):2===i?e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,r.resource),t.width=o,t.height=a}},Ab={id:"video",upload(r,t,e,i){r.isValid?kl.upload(r,t,e,i):e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null)}},$l={linear:9729,nearest:9728},Pb={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Ls={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},wb={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Ll(r,t,e,i,s,n,o,a){var u,c;if(a&&"repeat"===r.addressModeU&&"repeat"===r.addressModeV&&"repeat"===r.addressModeW||(u=Ls[o?"clamp-to-edge":r.addressModeU],c=Ls[o?"clamp-to-edge":r.addressModeV],o=Ls[o?"clamp-to-edge":r.addressModeW],t[s](n,t.TEXTURE_WRAP_S,u),t[s](n,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[s](n,t.TEXTURE_WRAP_R,o)),a&&"linear"===r.magFilter||t[s](n,t.TEXTURE_MAG_FILTER,$l[r.magFilter]),e){if(!a||"linear"!==r.mipmapFilter){const u=Pb[r.minFilter][r.mipmapFilter];t[s](n,t.TEXTURE_MIN_FILTER,u)}}else t[s](n,t.TEXTURE_MIN_FILTER,$l[r.minFilter]);if(i&&1<r.maxAnisotropy){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](n,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[s](n,t.TEXTURE_COMPARE_FUNC,wb[r.compare])}function Rb(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 FP=Object.defineProperty,DP=Object.defineProperties,UP=Object.getOwnPropertyDescriptors,Mb=Object.getOwnPropertySymbols,kP=Object.prototype.hasOwnProperty,$P=Object.prototype.propertyIsEnumerable,Cb=(r,t,e)=>t in r?FP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,we=(r,t)=>{for(var e in t=t||{})kP.call(t,e)&&Cb(r,e,t[e]);if(Mb)for(var e of Mb(t))$P.call(t,e)&&Cb(r,e,t[e]);return r};function Ob(r,t){let e={},i=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},i=r.RGBA8),we(we(we(we(we(we(((r,t)=>DP(r,UP(t)))(we({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:i,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 Gb(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}}class Nl{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:kl,buffer:Sb,video:Ab,compressed:Eb},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Ob(t,this._renderer.context.extensions),this._mapFormatToType=Gb(t),this._mapFormatToFormat=Rb(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(P.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){var i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){var i=this._gl;t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t&&(this._boundTextures[e]=t,this._activateLocation(e),t=t||P.EMPTY.source,e=this.getGlSource(t),i.bindTexture(e.target,e.texture))}_bindSampler(t,e=0){var i=this._gl;t?(t=this._getGlSampler(t),this._boundSamplers[e]!==t&&(this._boundSamplers[e]=t,i.bindSampler(e,t))):(this._boundSamplers[e]=null,i.bindSampler(e,null))}unbind(t){var o,e=t.source,i=this._boundTextures,s=this._gl;for(let n=0;n<i.length;n++)i[n]===e&&(this._activateLocation(n),o=this.getGlSource(e),s.bindTexture(o.target,null),i[n]=null)}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){var s,e=this._gl;return(e=new Tb(e.createTexture())).type=this._mapFormatToType[t.format],e.internalFormat=this._mapFormatToInternalFormat[t.format],e.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)&&(s=Math.max(t.width,t.height),t.mipLevelCount=Math.floor(Math.log2(s))+1),this._glTextures[t.uid]=e,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),e}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){var i=this._gl,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),Ll((this._boundTextures[this._activeTextureLocation]=t).style,i,1<t.mipLevelCount,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){var e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){var e=this._gl,i=this.getGlSource(t),s=(e.bindTexture(e.TEXTURE_2D,i.texture),"premultiply-alpha-on-upload"===(this._boundTextures[this._activeTextureLocation]=t).alphaMode);this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&1<t.mipLevelCount&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0),e=this.getGlSource(t),this._gl.generateMipmap(e.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){var e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Ll(t,e,1<this._boundTextures[this._activeTextureLocation].mipLevelCount,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){var{pixels:t,width:i,height:s}=this.getPixels(t),n=H.get().createCanvas(),o=(n.width=i,n.height=s,n.getContext("2d"));return o&&((i=o.createImageData(i,s)).data.set(t),o.putImageData(i,0,0)),n}getPixels(t){var e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),o=new Uint8Array(4*s*n),a=this._renderer,t=a.renderTarget.getRenderTarget(t),t=a.renderTarget.getGpuRenderTarget(t);return(a=a.gl).bindFramebuffer(a.FRAMEBUFFER,t.resolveTargetFramebuffer),a.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,a.RGBA,a.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(P.EMPTY.source),this._boundSamplers=Object.create(null);var t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Nl.extension={type:[r.WebGLSystem],name:"texture"};class Hl{init(){var t=new st({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),e=be(),i=Xe({name:"graphics",bits:[Ci,Gi(e),ss,ze]});this.shader=new St({glProgram:i,resources:{localUniforms:t,batchSamplers:Bi(e)}})}execute(t,e){var s=(e=e.context).customShader||this.shader,n=t.renderer,{batcher:e,instructions:l}=n.graphicsContext.getContextRenderData(e),u=(s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(e.geometry,s.glProgram),l.instructions);for(let c=0;c<l.instructionSize;c++){var d=u[c];if(d.size){for(let p=0;p<d.textures.count;p++)n.texture.bind(d.textures.textures[p],p);n.geometry.draw(d.topology,d.size,d.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Hl.extension={type:[r.WebGLPipesAdaptor],name:"graphics"};class Xl{init(){var t=Xe({name:"mesh",bits:[ss,O_,ze]});this._shader=new St({glProgram:t,resources:{uTexture:P.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new M}}}})}execute(t,e){var i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return}else{s=this._shader;var n=e.texture,o=n.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Xl.extension={type:[r.WebGLPipesAdaptor],name:"mesh"};class jl{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}}function Ns(r,t){var e=r.instructionSet,i=e.instructions;for(let s=0;s<e.instructionSize;s++){var n=i[s];t[n.renderPipeId].execute(n)}}jl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"customRender"};const XP=new M;class zl{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&&(N.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i=null!=(i=t._batchableRenderGroup)?i:t._batchableRenderGroup=N.get(Pr);i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(i,e)}_executeCacheAsTexture(t){var e;t.textureNeedsUpdate&&(t.textureNeedsUpdate=!1,e=XP.identity().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}),Ns(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}),Ns(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}function Hs(r,t){for(let e=t=t||0;e<r.length&&r[e];e++)r[e]=null}zl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"renderGroup"};const jP=new lt,Bb=Ie|fr|mi;function Vl(r,t=!1){Ib(r);var e=r.childrenToUpdate,i=r.updateTick++;for(const s in e){var n=Number(s),o=e[s],a=o.list,l=o.index;for(let u=0;u<l;u++){var c=a[u];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===n&&Wl(c,i,0)}Hs(a,l),o.index=0}if(t)for(let s=0;s<r.renderGroupChildren.length;s++)Vl(r.renderGroupChildren[s],t)}function Ib(r){var t=r.root,i=(i=r.renderGroupParent?(i=r.renderGroupParent,r.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),r.worldColor=pr(t.groupColor,i.worldColor),t.groupAlpha*i.worldAlpha):(r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,t.localAlpha))<0?0:1<i?1:i;r.worldAlpha=i,r.worldColorAlpha=r.worldColor+((255*i|0)<<24)}function Wl(r,t,e){if(t!==r.updateTick){r.updateTick=t,r.didChange=!1;var i=r.localTransform,s=(r.updateLocalTransform(),r.parent);if(s&&!s.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,s.relativeGroupTransform),e&Bb&&Fb(r,s,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&Bb&&Fb(r,jP,e)),!r.renderGroup){var n=r.children,o=n.length;for(let u=0;u<o;u++)Wl(n[u],t,e);s=r.parentRenderGroup,r.renderPipeId&&!s.structureDidChange&&s.updateRenderable(r)}}}function Fb(r,t,e){var i;e&fr&&(r.groupColor=pr(r.localColor,t.groupColor),i=r.localAlpha*t.groupAlpha,r.groupAlpha=i=i<0?0:1<i?1:i,r.groupColorAlpha=r.groupColor+((255*i|0)<<24)),e&mi&&(r.groupBlendMode="inherit"===r.localBlendMode?t.groupBlendMode:r.localBlendMode),e&Ie&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function Db(r,t){var{list:e,index:i}=r.childrenRenderablesToUpdate;let s=!1;for(let n=0;n<i;n++){var o=e[n];if(s=t[o.renderPipeId].validateRenderable(o))break}return r.structureDidChange=s}const zP=new M;class Yl{constructor(t){this._renderer=t}render({container:t,transform:e}){var i=t.parent,s=t.renderGroup.renderGroupParent,n=(t.parent=null,t.renderGroup.renderGroupParent=null,this._renderer);let o=zP;e&&(o=o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));var 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}),Ns(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=i,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var s,n,o,a,i;if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let s=t.renderGroupChildren.length-1;0<=s;s--)this._updateCachedRenderGroups(t.renderGroupChildren[s],e);t.invalidateMatrices(),t.isCachedAsTexture?t.textureNeedsUpdate&&((s=t.root.getLocalBounds()).ceil(),n=t.texture,t.texture&&it.returnTexture(t.texture),o=this._renderer,a=t.textureOptions.resolution||o.view.resolution,i=null!=(i=t.textureOptions.antialias)?i:o.view.antialias,t.texture=it.getOptimalTexture(s.width,s.height,a,i),t._textureBounds||(t._textureBounds=new nt),t._textureBounds.copyFrom(s),n!==t.texture)&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0):t.texture&&(it.returnTexture(t.texture),t.texture=null)}_updateRenderGroups(t){var e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?Hs(t.childrenRenderablesToUpdate.list,0):Db(t,i),Vl(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 s=0;s<t.renderGroupChildren.length;s++)this._updateRenderGroups(t.renderGroupChildren[s])}_updateRenderables(t){var{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){var n=e[s];n.didViewUpdate&&t.updateRenderable(n)}Hs(e,i)}_buildInstructions(t,e){var i=t.root,o=((t=t.instructionSet).reset(),(e=e.renderPipes?e:e.batch.renderer).renderPipes);o.batch.buildStart(t),o.blendMode.buildStart(),o.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(t,e,null),o.batch.buildEnd(t),o.blendMode.buildEnd(t)}}Yl.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"renderGroup"};class Kl{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash")}addRenderable(t,e){var i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){var e=this._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){var e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){var e=this._gpuSpriteHash[t.uid];N.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){var e=N.get(Pr);return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuSpriteHash)N.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}Kl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"sprite"};var VP=Object.defineProperty,Ub=Object.getOwnPropertySymbols,WP=Object.prototype.hasOwnProperty,YP=Object.prototype.propertyIsEnumerable,kb=(r,t,e)=>t in r?VP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$b=(r,t)=>{for(var e in t=t||{})WP.call(t,e)&&kb(r,e,t[e]);if(Ub)for(var e of Ub(t))YP.call(t,e)&&kb(r,e,t[e]);return r};(yb=class ex{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new X(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=$b($b({},ex.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(){}}).extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"background",priority:0},yb.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};const Zr={};B.handle(r.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Zr[r.name]=r.ref},r=>{delete Zr[r.name]});class Zl{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}setBlendMode(t,e,i){this._activeBlendMode===e?this._isAdvanced&&this._renderableList.push(t):(this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!Zr[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t)))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);var e=this._activeBlendMode;if(Zr[e]){let i=this._filterHash[e];i||((i=this._filterHash[e]=new hr).filters=[new Zr[e]]),e={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1},this._renderableList=e.renderables,t.add(e)}}_endAdvancedBlendMode(t){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}}Zl.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:"blendMode"};var KP=Object.defineProperty,Nb=Object.getOwnPropertySymbols,qP=Object.prototype.hasOwnProperty,ZP=Object.prototype.propertyIsEnumerable,Hb=(r,t,e)=>t in r?KP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ql=(r,t)=>{for(var e in t=t||{})qP.call(t,e)&&Hb(r,e,t[e]);if(Nb)for(var e of Nb(t))ZP.call(t,e)&&Hb(r,e,t[e]);return r};const Jl={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},tu=class rx{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof lt||t instanceof P?Ql({target:t},e):Ql(Ql({},e),t)}async image(t){var e=new Image;return e.src=await this.base64(t),e}async base64(t){const{format:e,quality:i}=t=this._normalizeOptions(t,rx.defaultImageOptions),s=this.canvas(t);if(void 0!==s.toBlob)return new Promise((n,o)=>{s.toBlob(a=>{if(a){const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)}else o(new Error("ICanvas.toBlob failed!"))},Jl[e],i)});if(void 0!==s.toDataURL)return s.toDataURL(Jl[e],i);if(void 0===s.convertToBlob)throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented");{const n=await s.convertToBlob({type:Jl[e],quality:i});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}}canvas(t){var e=(t=this._normalizeOptions(t)).target,i=this._renderer;return e instanceof P?i.texture.generateCanvas(e):(e=i.textureGenerator.generateTexture(t),t=i.texture.generateCanvas(e),e.destroy(!0),t)}pixels(t){var e=(t=this._normalizeOptions(t)).target,i=this._renderer,t=e instanceof P?e:i.textureGenerator.generateTexture(t),i=i.texture.getPixels(t);return e instanceof lt&&t.destroy(!0),i}texture(t){return(t=this._normalizeOptions(t)).target instanceof P?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);var i=this.canvas(t),s=document.createElement("a");s.download=null!=(t=t.filename)?t:"image.png",s.href=i.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var e=null!=(e=t.width)?e:200,n=(t=this._normalizeOptions(t),(t=this.canvas(t)).toDataURL()),t=(console.log(`[Pixi Texture] ${t.width}px ${t.height}px`),["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" "));console.log("%c ",t)}destroy(){this._renderer=null}};tu.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"extract"},tu.defaultImageOptions={format:"png",quality:1};var Xb=tu;class Xs extends P{static create(t){return new Xs({source:new Q(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}var QP=Object.defineProperty,JP=Object.defineProperties,tw=Object.getOwnPropertyDescriptors,jb=Object.getOwnPropertySymbols,ew=Object.prototype.hasOwnProperty,rw=Object.prototype.propertyIsEnumerable,zb=(r,t,e)=>t in r?QP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const nw=new z,ow=new nt,aw=[0,0,0,0];class eu{constructor(t){this._renderer=t}generateTexture(t){var i=(t=t instanceof lt?{target:t,frame:void 0,textureSourceOptions:{},resolution:void 0}:t).resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,n=t.target,o=(o=t.clearColor)?Array.isArray(o)&&4===o.length?o:X.shared.setValue(o).toArray():aw,e=(null==(e=t.frame)?void 0:e.copyTo(nw))||hi(n,ow).rectangle,t=(e.width=0|Math.max(e.width,1/i),e.height=0|Math.max(e.height,1/i),Xs.create(((r,t)=>JP(r,tw(t)))(((r,t)=>{for(var e in t=t||{})ew.call(t,e)&&zb(r,e,t[e]);if(jb)for(var e of jb(t))rw.call(t,e)&&zb(r,e,t[e]);return r})({},t.textureSourceOptions),{width:e.width,height:e.height,resolution:i,antialias:s}))),i=M.shared.translate(-e.x,-e.y);return this._renderer.render({container:n,transform:i,target:t,clearColor:o}),t.source.updateMipmaps(),t}destroy(){this._renderer=null}}eu.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"textureGenerator"};class ru{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){for(let t=this._stackIndex=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:i,worldColor:s,offset:n}){var o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new M,worldColor:4294967295,offset:new V},e={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:i||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:n||a.offset,bindGroup:null},t=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(t),(o=t.uniforms).uProjectionMatrix=e.projectionMatrix,o.uResolution=e.resolution,o.uWorldTransformMatrix.copyFrom(e.worldTransformMatrix),o.uWorldTransformMatrix.tx-=e.offset.x,o.uWorldTransformMatrix.ty-=e.offset.y,We(e.worldColor,o.uWorldColorAlpha,0),t.update();let d;this._renderer.renderPipes.uniformBatch?d=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(t,!1):(d=this._bindGroupPool.pop()||new Ht,this._activeBindGroups.push(d),d.setResource(t,0)),e.bindGroup=d,this._currentGlobalUniformData=e}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===_t.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 st({uProjectionMatrix:{value:new M,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new M,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}ru.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"globalUniforms"};let lw=1;class iu{constructor(){this._tasks=[],this._offset=0}init(){ut.system.add(this._update,this)}repeat(t,e,i=!0){var s=lw++;let n=0;return i&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){var t=performance.now();for(let e=0;e<this._tasks.length;e++){var s,i=this._tasks[e];t-i.offset-i.last>=i.duration&&(s=t-i.start,i.func(s),i.last=t)}}destroy(){ut.system.remove(this._update,this),this._tasks.length=0}}let Vb=!(iu.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"scheduler",priority:0});function Wb(r){Vb||(-1<H.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")?globalThis.console.log(`%c %c %c %c %c PixiJS %c v8.9.1 (${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&&globalThis.console.log(`PixiJS 8.9.1 - ${r} - http://www.pixijs.com/`),Vb=!0)}class js{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===_t.WEBGL&&(e+=" "+this._renderer.context.webGLVersion),Wb(e)}}}function Yb(r){let t=!1;for(const i in r)if(null==r[i]){t=!0;break}if(!t)return r;var e=Object.create(null);for(const i in r){var s=r[i];s&&(e[i]=s)}return e}function Kb(r){let t=0;for(let e=0;e<r.length;e++)null==r[e]?t++:r[e-t]=r[e];return r.length-=t,r}js.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"hello",priority:-2},js.defaultOptions={hello:!1};var uw=Object.defineProperty,qb=Object.getOwnPropertySymbols,cw=Object.prototype.hasOwnProperty,hw=Object.prototype.propertyIsEnumerable,Zb=(r,t,e)=>t in r?uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qb=(r,t)=>{for(var e in t=t||{})cw.call(t,e)&&Zb(r,e,t[e]);if(qb)for(var e of qb(t))hw.call(t,e)&&Zb(r,e,t[e]);return r};let dw=0;var su=class ix{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(t){t=Qb(Qb({},ix.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedHashes)e.context[e.hash]=Yb(e.context[e.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedArrays)Kb(e.context[e.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=dw++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var n=this._now,o=this._managedRenderables,a=this._renderer.renderPipes;let l=0;for(let u=0;u<o.length;u++){var t,e,s,c=o[u];null===c?l++:(e=null!=(e=null==(e=null==(t=null!=(t=c.renderGroup)?t:c.parentRenderGroup)?void 0:t.instructionSet)?void 0:e.gcTick)?e:-1,(null!=(s=null==t?void 0:t.gcTick)?s:0)===e&&(c._lastUsed=n),n-c._lastUsed>this.maxUnusedTime?(c.destroyed||(s=a,t&&(t.structureDidChange=!0),s[c.renderPipeId].destroyRenderable(c)),c._lastUsed=-1,l++,c.off("destroyed",this._removeRenderable,this)):o[u-l]=c)}o.length-=l}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){var e=this._managedRenderables.indexOf(t);0<=e&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}},pw=(su.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"renderableGC",priority:0},su.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4},Object.defineProperty),tv=Object.getOwnPropertySymbols,fw=Object.prototype.hasOwnProperty,mw=Object.prototype.propertyIsEnumerable,ev=(r,t,e)=>t in r?pw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rv=(r,t)=>{for(var e in t=t||{})fw.call(t,e)&&ev(r,e,t[e]);if(tv)for(var e of tv(t))mw.call(t,e)&&ev(r,e,t[e]);return r},nu=class sx{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t=rv(rv({},sx.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=null!=(e=t.textureGCAMaxIdle)?e:t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active)&&(this.checkCount++,this.checkCount>this.checkCountMax)&&(this.checkCount=0,this.run())}run(){var t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){var i=t[e];i.autoGarbageCollect&&i.resource&&-1<i._touched&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}},gw=(nu.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:"textureGC"},nu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600},Object.defineProperty),sv=Object.getOwnPropertySymbols,_w=Object.prototype.hasOwnProperty,bw=Object.prototype.propertyIsEnumerable,nv=(r,t,e)=>t in r?gw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ov=(r,t)=>{for(var e in t=t||{})_w.call(t,e)&&nv(r,e,t[e]);if(sv)for(var e of sv(t))bw.call(t,e)&&nv(r,e,t[e]);return r},ou=class nx{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=ov(ov({},nx.defaultOptions),t)).view&&(t.canvas=t.view),this.screen=new z(0,0,t.width,t.height),this.canvas=t.canvas||H.get().createCanvas(),this.antialias=!!t.antialias,this.texture=Ml(this.canvas,t),this.renderTarget=new Ds({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){("boolean"==typeof t?t:null!=t&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};ou.extension={type:[r.WebGLSystem,r.WebGPUSystem,r.CanvasSystem],name:"view",priority:0},ou.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const au=[yb,ru,js,ou,Yl,nu,eu,Xb,Ma,su,iu],lu=[Zl,y_,Kl,zl,dl,fl,pl,jl],vw=[...au,Rl,X_,gl,ml,Nl,Ol,vl,Ul,Dl,Tl,nb,Sl,xl],yw=[...lu],xw=[ll,Xl,Hl],lv=[],uv=[],cv=[];B.handleByNamedList(r.WebGLSystem,lv),B.handleByNamedList(r.WebGLPipes,uv),B.handleByNamedList(r.WebGLPipesAdaptor,cv),B.add(...vw,...yw,...xw);class hv extends Ur{constructor(){super({name:"webgl",type:_t.WEBGL,systems:lv,renderPipes:uv,renderPipeAdaptors:cv})}}var Tw={__proto__:null,WebGLRenderer:hv};class uu{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n=this._gpu.device,o=e.layout[i],a=[],l=this._renderer;for(const d in o){var s=null!=(s=t.resources[d])?s:t.resources[o[d]];let f;if("uniformGroup"===s._resourceType){var m=s,m=(l.ubo.updateUniformGroup(m),m.buffer);f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if("buffer"===s._resourceType){const m=s;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if("bufferResource"===s._resourceType){const m=s;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if("textureSampler"===s._resourceType){const m=s;f=l.texture.getGpuSampler(m)}else if("textureSource"===s._resourceType){const m=s;f=l.texture.getGpuSource(m).createView({})}a.push({binding:o[d],resource:f})}return e=l.shader.getProgramData(e).bindGroups[i],i=n.createBindGroup({layout:e,entries:a}),this._hash[t._key]=i}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}uu.extension={type:[r.WebGPUSystem],name:"bindGroup"};class cu{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){var e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));var e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Pi(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}cu.extension={type:[r.WebGPUSystem],name:"buffer"};class dv{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: "+4*t);var e=this.byteIndex,t=e+4*t;if((t=Math.ceil(t/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment)>4*this.data.length)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=t,e}addGroup(t){var e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this.data=null}}class hu{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}}hu.extension={type:[r.WebGPUSystem],name:"colorMask"};class zs{constructor(t){this._renderer=t}async init(t){return this._initPromise||(this._initPromise=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}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}zs.extension={type:[r.WebGPUSystem],name:"device"},zs.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var Ew=Object.defineProperty,pv=Object.getOwnPropertySymbols,Aw=Object.prototype.hasOwnProperty,Pw=Object.prototype.propertyIsEnumerable,fv=(r,t,e)=>t in r?Ew(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mv=(r,t)=>{for(var e in t=t||{})Aw.call(t,e)&&fv(r,e,t[e]);if(pv)for(var e of pv(t))Pw.call(t,e)&&fv(r,e,t[e]);return r};class du{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,i,s){t=this._renderer.pipeline.getPipeline(t,e,i,s),this.setPipeline(t)}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){var e;this._boundIndexBuffer!==t&&(e=2===(this._boundIndexBuffer=t).data.BYTES_PER_ELEMENT?"uint16":"uint32",this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e))}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){this._boundBindGroup[t]!==e&&((this._boundBindGroup[t]=e)._touch(this._renderer.textureGC.count),e=this._renderer.bindGroup.getBindGroup(e,i,t),this.renderPassEncoder.setBindGroup(t,e))}setGeometry(t,e){var i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const s in i)this._setVertexBuffer(s,t.attributes[i[s]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){var s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){var i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){var{geometry:t,shader:i,state:s,topology:n,size:o,start:a,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(t,i.gpuProgram,s,n),this.setGeometry(t,i.gpuProgram),this._setShaderBindGroups(i,u),t.indexBuffer?this.renderPassEncoder.drawIndexed(o||t.indexBuffer.data.length,null!=l?l:t.instanceCount,a||0):this.renderPassEncoder.draw(o||t.getSize(),null!=l?l:t.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(){var t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]),t=(this.renderPassEncoder=this.commandEncoder.beginRenderPass(t),this._boundPipeline),i=mv({},this._boundVertexBuffer),s=this._boundIndexBuffer,n=mv({},this._boundBindGroup),o=(this._clearCache(),this._renderer.renderTarget.viewport);this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(t);for(const a in i)this._setVertexBuffer(a,i[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(s)}_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}}du.extension={type:[r.WebGPUSystem],name:"encoder",priority:1};class pu{constructor(t){this._renderTargetStencilState=Object.create(null),(this._renderer=t).renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){var e=this._renderTargetStencilState[t.uid]||(this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0});this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){var i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e,(i=this._renderer).pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}pu.extension={type:[r.WebGPUSystem],name:"stencil"};const Qr={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 gv(r){var t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){var s=t[i];let n=Qr[s.data.type].size;var o=Qr[s.data.type].align;if(!Qr[s.data.type])throw new Error("[Pixi.js] WebGPU UniformBuffer: Unknown type "+s.data.type);1<s.data.size&&(n=Math.max(n,o)*s.data.size),e=Math.ceil(e/o)*o,s.size=n,s.offset=e,e+=n}return{uboElements:t,size:e=16*Math.ceil(e/16)}}function _v(r,t){var{size:e,align:i}=Qr[r.data.type],i=(i-e)/4,n=0<=r.data.type.indexOf("i32")?"dataInt32":"data";return`
v = uv.${r.data.name};
${0!==t?`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++];
}
${0!=i?`arrayOffset += ${i};`:""}
}
`}function bv(r){return Pl(r,"uboWgsl",_v,Y_)}class fu extends El{constructor(){super({createUboElements:gv,generateUboSync:bv})}}fu.extension={type:[r.WebGPUSystem],name:"ubo"};class mu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new dv({minUniformOffsetAlignment:128});for(let i=0;i<2;i++){let s=L.UNIFORM|L.COPY_DST;0===i&&(s|=L.COPY_SRC),this._buffers.push(new ht({data:this._batchBuffer.data,usage:s}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){return!e&&this._bindGroupHash[t.uid]||(this._renderer.ubo.ensureUniformGroup(t),e=t.buffer.data,e=this._batchBuffer.addEmptyGroup(e.length),this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,e/4),this._bindGroupHash[t.uid]=this._getBindGroup(e/128)),this._bindGroupHash[t.uid]}getUboResource(t){return this._renderer.ubo.updateUniformGroup(t),t=t.buffer.data,t=this._batchBuffer.addGroup(t),this._getBufferResource(t/128)}getArrayBindGroup(t){return t=this._batchBuffer.addGroup(t),this._getBindGroup(t/128)}getArrayBufferResource(t){return t=this._batchBuffer.addGroup(t)/128,this._getBufferResource(t)}_getBufferResource(t){var e;return this._bufferResources[t]||(e=this._buffers[t%2],this._bufferResources[t]=new Us({buffer:e,offset:256*(t/2|0),size:128})),this._bufferResources[t]}_getBindGroup(t){var e;return this._bindGroups[t]||(e=new Ht({0:this._getBufferResource(t)}),this._bindGroups[t]=e),this._bindGroups[t]}_uploadBindGroups(){var t=this._renderer.buffer,e=this._buffers[0],i=(e.update(this._batchBuffer.byteIndex),t.updateBuffer(e),this._renderer.gpu.device.createCommandEncoder());for(let s=1;s<this._buffers.length;s++){var n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),128,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}mu.extension={type:[r.WebGPUPipes],name:"uniformBatch"};var ww=Object.defineProperty,Rw=Object.defineProperties,Mw=Object.getOwnPropertyDescriptors,vv=Object.getOwnPropertySymbols,Cw=Object.prototype.hasOwnProperty,Ow=Object.prototype.propertyIsEnumerable,yv=(r,t,e)=>t in r?ww(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;const Iw={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class gu{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._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(J.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._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=te[t],this._updatePipeHash())}setPipeline(t,e,i,s){t=this.getPipeline(t,e,i),s.setPipeline(t)}getPipeline(t,e,i,s){t._layoutKey||(_l(t,e.attributeData),this._generateBufferKey(t)),s=s||t.topology;var n=t._layoutKey<<24|e._layoutKey<<16|i.data<<10|i._blendModeId<<5|Iw[s];return this._pipeCache[n]||(this._pipeCache[n]=this._createPipeline(t,e,i,s),this._pipeCache[n])}_createPipeline(t,e,i,s){var n=this._gpu.device,t=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(i),l=(a[0].writeMask=this._stencilMode===J.RENDERING_MASK_ADD?0:this._colorMask,this._renderer.shader.getProgramData(e).pipeline),t={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:t},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:i.cullMode},layout:l,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(t.depthStencil=((r,t)=>Rw(r,Mw(t)))(((r,t)=>{for(var e in t=t||{})Cw.call(t,e)&&yv(r,e,t[e]);if(vv)for(var e of vv(t))Ow.call(t,e)&&yv(r,e,t[e]);return r})({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),n.createRenderPipeline(t)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){var e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){var e=[];let i=0;var s=Object.keys(t.attributes).sort();for(let o=0;o<s.length;o++){var a=t.attributes[s[o]];e[i++]=a.offset,e[i++]=a.format,e[i++]=a.stride,e[i++]=a.instance}var n=e.join("|");return t._layoutKey=Le(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){var e=[];let i=0;var s=Object.keys(t.attributeData).sort();for(let o=0;o<s.length;o++){var a=t.attributeData[s[o]];e[i++]=a.location}var n=e.join("|");return t._attributeLocationsKey=Le(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){var i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];var s=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<s.length;a++){var l=Object.values(s[a].attributes)[0].shaderLocation;for(const u in o)if(o[u].location===l){n[a]=u;break}}return this._bindingNamesCache[i]=n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);var i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(n=>{var o,a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){var c=t.attributes[u];1!==(null!=(o=c.divisor)?o:1)&&Ot(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===n&&(a.arrayStride=c.stride,a.stepMode=c.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:c.offset,format:c.format}))}l.length&&s.push(a)}),this._bufferLayoutsCache[i]=s}_updatePipeHash(){var t=function(r,t,e,i){return e<<6|r<<3|i<<1|t}(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}gu.extension={type:[r.WebGPUSystem],name:"pipeline"};class xv{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Tv{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){var o=this._renderer,t=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:t,origin:i},{texture:l,origin:n},s),e}startRenderPass(t,e=!0,i,s){var n=this._renderTargetSystem.getGpuRenderTarget(t),t=this.getDescriptor(t,e,i);n.descriptor=t,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){var e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){"boolean"==typeof e&&(e=e?bt.ALL:bt.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),o=t.colorTextures.map((l,u)=>{var c=n.contexts[u];let d,p;return d=c?c.getCurrentTexture().createView():this._renderer.texture.getGpuSource(l).createView({mipLevelCount:1}),n.msaaTextures[u]&&(p=d,d=this._renderer.texture.getTextureView(n.msaaTextures[u])),c=e&bt.COLOR?"clear":"load",null==i&&(i=s.defaultClearColor),{view:d,resolveTarget:p,clearValue:i,storeOp:"store",loadOp:c}});let a;var l,u;return!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture&&(l=e&bt.STENCIL?"clear":"load",u=e&bt.DEPTH?"clear":"load",a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:l,depthClearValue:1,depthLoadOp:u,depthStoreOp:"store"}),{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,i,s){var n,o,u;e&&({gpu:n,encoder:o}=this._renderer,n=n.device,null===o.commandEncoder?(o=n.createCommandEncoder(),u=this.getDescriptor(t,e,i),(u=o.beginRenderPass(u)).setViewport(s.x,s.y,s.width,s.height,0,1),u.end(),u=o.finish(),n.queue.submit([u])):this.startRenderPass(t,e,i,s))}initGpuRenderTarget(t){t.isRoot=!0;const e=new xv;return t.colorTextures.forEach((i,s)=>{if(Nt.test(i.resource)){var n=i.resource.getContext("webgpu"),o=i.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[s]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new Q({width:0,height:0,sampleCount:4});e.msaaTextures[s]=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){var 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((i,s)=>{null!=(s=e.msaaTextures[s])&&s.resize(i.source.width,i.source.height,i.source._resolution)})}}class _u extends Cl{constructor(t){super(t),this.adaptor=new Tv,this.adaptor.init(t,this)}}_u.extension={type:[r.WebGPUSystem],name:"renderTarget"};class bu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t,this.maxTextures=t.device.limits.maxSampledTexturesPerShaderStage}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}bu.extension={type:[r.WebGPUSystem],name:"shader"};const pt={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class vu{constructor(){this.defaultState=new Et,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:pt[t.blendMode]||pt.normal}]}destroy(){this.gpu=null}}vu.extension={type:[r.WebGPUSystem],name:"state"};const Sv={type:"image",upload(r,t,e){var i=r.resource,s=(0|r.pixelWidth)*(0|r.pixelHeight),s=i.byteLength/s;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*s},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},yu={"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}},Uw={blockBytes:4,blockWidth:1,blockHeight:1},Ev={type:"compressed",upload(r,t,e){let i=r.pixelWidth,s=r.pixelHeight;var n=yu[r.format]||Uw;for(let o=0;o<r.resource.length;o++){var a=r.resource[o],l=Math.ceil(i/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(i/n.blockWidth)*n.blockWidth,height:Math.ceil(s/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},xu={type:"image",upload(r,t,e){var s,n,i=r.resource;i&&(s=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),r="premultiply-alpha-on-upload"===r.alphaMode,e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:r},{width:s,height:n}))}},Av={type:"video",upload(r,t,e){xu.upload(r,t,e)}};class Pv{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){var e=this._getMipmapPipeline(t.format);if("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;var l,s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT,o=(n||(l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1},i=this.device.createTexture(l)),this.device.createCommandEncoder({})),a=e.getBindGroupLayout(0);for(let l=0;l<s;++l){let u=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),c=n?1:0;for(let d=1;d<t.mipLevelCount;++d){var p=i.createView({baseMipLevel:c++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),f=o.beginRenderPass({colorAttachments:[{view:p,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),m=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:u}]});f.setPipeline(e),f.setBindGroup(0,m),f.draw(3,1,0,0),f.end(),u=p}}if(!n){const l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let u=1;u<t.mipLevelCount;++u)o.copyTextureToTexture({texture:i,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||i.destroy(),t}}class Tu{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:xu,buffer:Sv,video:Av,compressed:Ev},(this._renderer=t).renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){t.autoGenerateMipmaps&&(l=Math.max(t.pixelWidth,t.pixelHeight),t.mipLevelCount=Math.floor(Math.log2(l))+1);let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e=(e|=GPUTextureUsage.RENDER_ATTACHMENT)|GPUTextureUsage.COPY_SRC);var l=yu[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/l.blockWidth)*l.blockWidth,l=Math.ceil(t.pixelHeight/l.blockHeight)*l.blockHeight,s={label:t.label,size:{width:s,height:l},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},l=this._gpu.device.createTexture(s);return this._gpuSources[t.uid]=l,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),l}onSourceUpdate(t){var e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps)&&1<t.mipLevelCount&&this.onUpdateMipmaps(t)}onSourceUnload(t){var e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new Pv(this._gpu.device)),t=this.getGpuSource(t),this._mipmapGenerator.generateMipmap(t)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){var e=this._gpuSources[t.uid];e?e.width===t.pixelWidth&&e.height===t.pixelHeight||(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),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){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return null!=(e=this._bindGroupHash[t.uid])?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){var e=t.source;return this._bindGroupHash[t.uid]=new Ht({0:e,1:e.style,2:new st({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e,t=t.source;return null!=(e=this._textureViewHash[t.uid])?e:this._createTextureView(t)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){var e=this._renderer,i=e.gpu.device.createCommandEncoder(),s=H.get().createCanvas(),n=(s.width=t.source.pixelWidth,s.height=t.source.pixelHeight,s.getContext("webgpu"));return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:H.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){var t=this.generateCanvas(t),i=Xt.getOptimalCanvasAndContext(t.width,t.height),{width:t,height:o}=((s=i.context).drawImage(t,0,0),t),s=s.getImageData(0,0,t,o),s=new Uint8ClampedArray(s.data.buffer);return Xt.returnCanvasAndContext(i),{pixels:s,width:t,height:o}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){var e=Number(t),i=this._bindGroupHash[e];null!=i&&i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Tu.extension={type:[r.WebGPUSystem],name:"texture"};class Su{init(){var t=new st({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),e=He({name:"graphics",bits:[Mi,Oi(be()),$f,je]});this.shader=new St({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){var s=(e=e.context).customShader||this.shader,n=t.renderer,{batcher:a,instructions:l}=n.graphicsContext.getContextRenderData(e),u=n.encoder,e=(u.setGeometry(a.geometry,s.gpuProgram),n.globalUniforms.bindGroup),e=(u.setBindGroup(0,e,s.gpuProgram),n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0)),p=(u.setBindGroup(2,e,s.gpuProgram),l.instructions);let f=null;for(let m=0;m<l.instructionSize;m++){var g,_=p[m];_.topology!==f&&(f=_.topology,u.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,t.state,_.topology)),s.groups[1]=_.bindGroup,_.gpuBindGroup||(g=_.textures,_.bindGroup=Ai(g.textures,g.count),_.gpuBindGroup=n.bindGroup.getBindGroup(_.bindGroup,s.gpuProgram,1)),u.setBindGroup(1,_.bindGroup,s.gpuProgram),u.renderPassEncoder.drawIndexed(_.size,1,_.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Su.extension={type:[r.WebGPUPipesAdaptor],name:"graphics"};class Eu{init(){var t=He({name:"mesh",bits:[Qe,C_,je]});this._shader=new St({gpuProgram:t,resources:{uTexture:P.EMPTY._source,uSampler:P.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new M}}}})}execute(t,e){var i=t.renderer;let s=e._shader;if(s){if(!s.gpuProgram)return}else(s=this._shader).groups[2]=i.texture.getTextureBindGroup(e.texture);var n=s.gpuProgram;n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms&&(n=t.localUniforms,s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(n,!0)),i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Eu.extension={type:[r.WebGPUPipesAdaptor],name:"mesh"};const kw=[...au,fu,du,zs,cu,Tu,_u,bu,vu,gu,hu,pu,uu],$w=[...lu,mu],Lw=[ul,Eu,Su],wv=[],Rv=[],Mv=[];B.handleByNamedList(r.WebGPUSystem,wv),B.handleByNamedList(r.WebGPUPipes,Rv),B.handleByNamedList(r.WebGPUPipesAdaptor,Mv),B.add(...kw,...$w,...Lw);class Cv extends Ur{constructor(){super({name:"webgpu",type:_t.WEBGPU,systems:wv,renderPipes:Rv,renderPipeAdaptors:Mv})}}var Nw={__proto__:null,WebGPURenderer:Cv};const Xw=new Proxy({POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},{get(r,t){return r[t]}}),jw=new z(0,0,1,1);var Ov=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))({}),Au=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))({}),Vw=new Proxy(Au,{get(r,t){return r[t]}}),Pu=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))({}),Ww=new Proxy(Pu,{get(r,t){return r[t]}});let Kw=0;var Jw=Object.defineProperty,Vs=Object.getOwnPropertySymbols,Gv=Object.prototype.hasOwnProperty,Bv=Object.prototype.propertyIsEnumerable,Iv=(r,t,e)=>t in r?Jw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class rR extends Lt{constructor(t){var s=t="function"==typeof t?{render:t}:t,n=s.render;super(((r,t)=>{for(var e in t=t||{})Gv.call(t,e)&&Iv(r,e,t[e]);if(Vs)for(var e of Vs(t))Bv.call(t,e)&&Iv(r,e,t[e]);return r})({label:"RenderContainer"},((r,t)=>{var e={};for(i in r)Gv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Vs)for(var i of Vs(r))t.indexOf(i)<0&&Bv.call(r,i)&&(e[i]=r[i]);return e})(s,["render"]))),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=null!=(s=t.containsPoint)?s:()=>!1,this.addBounds=null!=(n=t.addBounds)?n:()=>!1}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}const aR={rectangle:bo,polygon:_o,triangle:vo,circle:Zt,ellipse:Zt,roundedRectangle:Zt};var uR=Object.defineProperty,Fv=Object.getOwnPropertySymbols,cR=Object.prototype.hasOwnProperty,hR=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?uR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uv=(r,t)=>{for(var e in t=t||{})cR.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))hR.call(t,e)&&Dv(r,e,t[e]);return r},kv=class ox extends lt{constructor(t={}){t=Uv(Uv({},ox.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;e<t.length;e++){var i=t[e];if(i.parentRenderLayer){if(i.parentRenderLayer===this)continue;i.parentRenderLayer.detach(i)}this.renderLayerChildren.push(i),(i=(i.parentRenderLayer=this).renderGroup||this.parentRenderGroup)&&(i.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){var i=t[e],s=this.renderLayerChildren.indexOf(i);-1!==s&&this.renderLayerChildren.splice(s,1),i.parentRenderLayer=null,(s=this.renderGroup||this.parentRenderGroup)&&(s.structureDidChange=!0)}return t[0]}detachAll(){var t=this.renderLayerChildren;for(let e=0;e<t.length;e++)t[e].parentRenderLayer=null;this.renderLayerChildren.length=0}collectRenderables(t,e,i){var s=this.renderLayerChildren,n=s.length;this.sortableChildren&&this.sortRenderLayerChildren();for(let o=0;o<n;o++)s[o].parent||Ot("Container must be added to both layer and scene graph. Layers only handle render order - the scene graph is required for transforms (addChild)",s[o]),s[o].collectRenderables(t,e,this)}sortRenderLayerChildren(){this.renderLayerChildren.sort(this.sortFunction)}_getGlobalBoundsRecursive(t,e,i){if(t){var s=this.renderLayerChildren;for(let n=0;n<s.length;n++)s[n]._getGlobalBoundsRecursive(!0,e,this)}}},dR=(kv.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex},kv);function Lv(r,t,e,i){var s=e.buffers[0],n=s.data,{verticesX:o,verticesY:e}=e,l=r/(o-1),u=t/(e-1);let c=0;var d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],b=i[6],x=i[7],y=i[8];for(let T=0;T<n.length;T+=2){var A=c%o*l,S=(c/o|0)*u,U=m*A+_*S+g,O=b*A+x*S+y;n[T]=(d*A+p*S+f)/O,n[T+1]=U/O,c++}s.update()}function Nv(r,t){var e=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],l=t[6],u=t[7],t=t[8];return r[0]=o*t-a*u,r[1]=s*u-i*t,r[2]=i*a-s*o,r[3]=a*l-n*t,r[4]=e*t-s*l,r[5]=s*n-e*a,r[6]=n*u-o*l,r[7]=i*l-e*u,r[8]=e*o-i*n,r}function Hv(r,t,e){var i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],t=t[8],p=e[0],f=e[1],m=e[2],_=e[3],g=e[4],b=e[5],x=e[6],y=e[7],e=e[8];return r[0]=p*i+f*o+m*u,r[1]=p*s+f*a+m*c,r[2]=p*n+f*l+m*t,r[3]=_*i+g*o+b*u,r[4]=_*s+g*a+b*c,r[5]=_*n+g*l+b*t,r[6]=x*i+y*o+e*u,r[7]=x*s+y*a+e*c,r[8]=x*n+y*l+e*t,r}const fR=[0,0,0,0,0,0,0,0,0],mR=[0,0,0],Ws=[0,0,0];function Xv(r,t,e,i,s,n,o,a,l){var u=fR,t=(u[0]=t,u[1]=i,u[2]=n,u[3]=e,u[4]=s,u[5]=o,u[6]=1,u[7]=1,u[8]=1,Nv(r,u)),i=(Ws[0]=a,Ws[1]=l,Ws[2]=1,function(r,t,e){var i=e[0],s=e[1],e=e[2];return r[0]=t[0]*i+t[1]*s+t[2]*e,r[1]=t[3]*i+t[4]*s+t[5]*e,r[2]=t[6]*i+t[7]*s+t[8]*e,r}(mR,t,Ws)),n=r;return r[0]=i[0],r[1]=0,r[2]=0,r[3]=0,r[4]=i[1],r[5]=0,r[6]=0,r[7]=0,r[8]=i[2],Hv(r,n,u)}const gR=[0,0,0,0,0,0,0,0,0],_R=[0,0,0,0,0,0,0,0,0];function jv(r,t,e,i,s,n,o,a,l,u,c,d,p,f,m,_,g){return t=Xv(gR,t,e,n,o,u,c,f,m),e=Xv(_R,i,s,a,l,d,p,_,g),Hv(r,Nv(t,t),e)}class zv extends os{constructor(t){super(t),this._projectionMatrix=[0,0,0,0,0,0,0,0,0];var{width:t,height:i}=t;this.corners=[0,0,t,0,t,i,0,i]}setCorners(t,e,i,s,n,o,a,l){var u=this.corners;u[0]=t,u[1]=e,u[2]=i,u[3]=s,u[4]=n,u[5]=o,u[6]=a,u[7]=l,this.updateProjection()}updateProjection(){var{width:t,height:e}=this,i=this.corners;Lv(t,e,this,jv(this._projectionMatrix,0,0,i[0],i[1],t,0,i[2],i[3],t,e,i[4],i[5],0,e,i[6],i[7]))}}var bR=Object.defineProperty,vR=Object.defineProperties,yR=Object.getOwnPropertyDescriptors,Ys=Object.getOwnPropertySymbols,Vv=Object.prototype.hasOwnProperty,Wv=Object.prototype.propertyIsEnumerable,Yv=(r,t,e)=>t in r?bR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wu=(r,t)=>{for(var e in t=t||{})Vv.call(t,e)&&Yv(r,e,t[e]);if(Ys)for(var e of Ys(t))Wv.call(t,e)&&Yv(r,e,t[e]);return r},Kv=class ax extends ir{constructor(t){var{texture:i,verticesX:s,verticesY:n}=t=wu(wu({},ax.defaultOptions),t),o=((r,t)=>{var e={};for(i in r)Vv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ys)for(var i of Ys(r))t.indexOf(i)<0&&Wv.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","verticesX","verticesY"]),s=new zv(Bt({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(Bt((n=wu({},o),vR(n,yR({geometry:s}))))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){var e,i,t=this.geometry;t&&({width:e,height:i}=this.texture,t.width===e&&t.height===i||(t.width=e,t.height=i,t.updateProjection()))}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,i,s,n,o,a,l){this.geometry.setCorners(t,e,i,s,n,o,a,l)}},ER=(Kv.defaultOptions={texture:P.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100},Object.defineProperty),AR=Object.defineProperties,PR=Object.getOwnPropertyDescriptors,Ks=Object.getOwnPropertySymbols,qv=Object.prototype.hasOwnProperty,Zv=Object.prototype.propertyIsEnumerable,Qv=(r,t,e)=>t in r?ER(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class CR extends ir{constructor(t){var{texture:i,verticesX:s,verticesY:n}=t,t=((r,t)=>{var e={};for(i in r)qv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Ks)for(var i of Ks(r))t.indexOf(i)<0&&Zv.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","verticesX","verticesY"]),s=new os(Bt({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(Bt((n=((r,t)=>{for(var e in t=t||{})qv.call(t,e)&&Qv(r,e,t[e]);if(Ks)for(var e of Ks(t))Zv.call(t,e)&&Qv(r,e,t[e]);return r})({},t),AR(n,PR({geometry:s,texture:i}))))),this.texture=i,this.autoResize=!0}textureUpdated(){var t=this.geometry,{width:e,height:i}=this.texture;!this.autoResize||t.width===e&&t.height===i||(t.width=e,t.height=i,t.build({}))}set texture(t){var e;null!=(e=this._texture)&&e.off("update",this.textureUpdated,this),(super.texture=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 OR=Object.defineProperty,Jv=Object.getOwnPropertySymbols,GR=Object.prototype.hasOwnProperty,BR=Object.prototype.propertyIsEnumerable,ty=(r,t,e)=>t in r?OR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ey=(r,t)=>{for(var e in t=t||{})GR.call(t,e)&&ty(r,e,t[e]);if(Jv)for(var e of Jv(t))BR.call(t,e)&&ty(r,e,t[e]);return r},ry=class lx extends oe{constructor(t){var{width:t,points:i,textureScale:s}=ey(ey({},lx.defaultOptions),t);super({positions:new Float32Array(4*i.length),uvs:new Float32Array(4*i.length),indices:new Uint32Array(6*(i.length-1))}),this.points=i,this._width=t,this.textureScale=s,this._build()}get width(){return this._width}_build(){var t=this.points;if(t){var e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),s=this.getIndex();if(!(t.length<1)){e.data.length/4!==t.length&&(e.data=new Float32Array(4*t.length),i.data=new Float32Array(4*t.length),s.data=new Uint16Array(6*(t.length-1)));var n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];var u=this._width*this.textureScale,c=t.length;for(let p=0;p<c;p++){var _,m,f=4*p;0<this.textureScale?(m=l.x-t[p].x,_=l.y-t[p].y,m=Math.sqrt(m*m+_*_),l=t[p],a+=m/u):a=p/(c-1),n[f]=a,n[1+f]=0,n[2+f]=a,n[3+f]=1}let d=0;for(let p=0;p<c-1;p++){const f=2*p;o[d++]=f,o[d++]=1+f,o[d++]=2+f,o[d++]=2+f,o[d++]=1+f,o[d++]=3+f}i.update(),s.update(),this.updateVertices()}}}updateVertices(){var t=this.points;if(!(t.length<1)){let e=t[0],i,s=0,n=0;var o=this.buffers[0].data,a=t.length,l=0<this.textureScale?this.textureScale*this._width/2:this._width/2;for(let u=0;u<a;u++){var c=t[u],d=4*u,f=(i=u<t.length-1?t[u+1]:c,n=-(i.x-e.x),s=i.y-e.y,u,Math.sqrt(s*s+n*n));f<1e-6?(s=0,n=0):(s/=f,n/=f,s*=l,n*=l),o[d]=c.x+s,o[1+d]=c.y+n,o[2+d]=c.x-s,o[3+d]=c.y-n,e=c}this.buffers[0].update()}}update(){0<this.textureScale?this._build():this.updateVertices()}};ry.defaultOptions={width:200,points:[],textureScale:0};let iy=ry;var IR=Object.defineProperty,FR=Object.defineProperties,DR=Object.getOwnPropertyDescriptors,qs=Object.getOwnPropertySymbols,sy=Object.prototype.hasOwnProperty,ny=Object.prototype.propertyIsEnumerable,oy=(r,t,e)=>t in r?IR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ru=(r,t)=>{for(var e in t=t||{})sy.call(t,e)&&oy(r,e,t[e]);if(qs)for(var e of qs(t))ny.call(t,e)&&oy(r,e,t[e]);return r},LR=((ry=class ux extends ir{constructor(t){var{texture:i,points:s,textureScale:n}=t=Ru(Ru({},ux.defaultOptions),t),t=((r,t)=>{var e={};for(i in r)sy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&qs)for(var i of qs(r))t.indexOf(i)<0&&ny.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","points","textureScale"]),s=new iy(Bt({width:i.height,points:s,textureScale:n}));0<n&&(i.source.style.addressMode="repeat"),super(Bt((n=Ru({},t),FR(n,DR({texture:i,geometry:s}))))),this.autoUpdate=!0,this.onRender=this._render}_render(){var t=this.geometry;!this.autoUpdate&&t._width===this.texture.height||(t._width=this.texture.height,t.update())}}).defaultOptions={textureScale:0},Object.defineProperty),NR=Object.defineProperties,HR=Object.getOwnPropertyDescriptors,Zs=Object.getOwnPropertySymbols,ly=Object.prototype.hasOwnProperty,uy=Object.prototype.propertyIsEnumerable,cy=(r,t,e)=>t in r?LR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;class VR extends ir{constructor(t){var{texture:i,vertices:s,uvs:n,indices:o,topology:a}=t,t=((r,t)=>{var e={};for(i in r)ly.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Zs)for(var i of Zs(r))t.indexOf(i)<0&&uy.call(r,i)&&(e[i]=r[i]);return e})(t,["texture","vertices","uvs","indices","topology"]),s=new oe(Bt({positions:s,uvs:n,indices:o,topology:a}));super(Bt((n=((r,t)=>{for(var e in t=t||{})ly.call(t,e)&&cy(r,e,t[e]);if(Zs)for(var e of Zs(t))uy.call(t,e)&&cy(r,e,t[e]);return r})({},t),NR(n,HR({texture:i,geometry:s}))))),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()}}var YR=Object.defineProperty,hy=Object.getOwnPropertySymbols,KR=Object.prototype.hasOwnProperty,qR=Object.prototype.propertyIsEnumerable,dy=(r,t,e)=>t in r?YR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,py=(r,t)=>{for(var e in t=t||{})KR.call(t,e)&&dy(r,e,t[e]);if(hy)for(var e of hy(t))qR.call(t,e)&&dy(r,e,t[e]);return r},fy=class ku{constructor(t){t instanceof P?(this.texture=t,fi(this,ku.defaultOptions,{})):fi(this,py(py({},ku.defaultOptions),t),{})}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return Be(this._tint)}set tint(t){this._tint="number"==typeof t?t:X.shared.setValue(null!=t?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((255*this._alpha|0)<<24)}};const Mu={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:!(fy.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha: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}};var QR=Object.defineProperty,JR=Object.defineProperties,tM=Object.getOwnPropertyDescriptors,Qs=Object.getOwnPropertySymbols,my=Object.prototype.hasOwnProperty,gy=Object.prototype.propertyIsEnumerable,_y=(r,t,e)=>t in r?QR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,or=(r,t)=>{for(var e in t=t||{})my.call(t,e)&&_y(r,e,t[e]);if(Qs)for(var e of Qs(t))gy.call(t,e)&&_y(r,e,t[e]);return r},by=(r,t)=>JR(r,tM(t));const rM=new nt(0,0,0,0),vy=class $u extends Lt{constructor(t={}){var{dynamicProperties:i,shader:s,roundPixels:n,texture:o,particles:a}=t=by(or(or({},$u.defaultOptions),t),{dynamicProperties:or(or({},$u.defaultOptions.dynamicProperties),null==t?void 0:t.dynamicProperties)}),t=((r,t)=>{var e={};for(i in r)my.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Qs)for(var i of Qs(r))t.indexOf(i)<0&&gy.call(r,i)&&(e[i]=r[i]);return e})(t,["dynamicProperties","shader","roundPixels","texture","particles"]);super(or({label:"ParticleContainer"},t)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=s,this._properties={};for(const u in Mu){var c=Mu[u],d=i[u];this._properties[u]=by(or({},c),{dynamic:d})}this.allowChildren=!0,this.roundPixels=null!=n&&n,this.particleChildren=null!=a?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 i=0;i<t.length;i++){var s=this.particleChildren.indexOf(t[i]);-1<s&&(this.particleChildren.splice(s,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return rM}updateBounds(){}destroy(t=!1){var i;super.destroy(t),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,i=null!=(i=this.texture)?i:null==(i=this.particleChildren[0])?void 0:i.texture)&&i.destroy(t),(this.texture=null)!=(i=this.shader)&&i.destroy()}removeParticles(t,e){return t=this.particleChildren.splice(t,e),this.onViewUpdate(),t}removeParticleAt(t){return t=this.particleChildren.splice(t,1),this.onViewUpdate(),t[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(){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(){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")}};vy.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};var iM=vy,sM=Object.defineProperty,Js=Object.getOwnPropertySymbols,yy=Object.prototype.hasOwnProperty,xy=Object.prototype.propertyIsEnumerable,Ty=(r,t,e)=>t in r?sM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sy=class cx extends Lt{constructor(t){var{width:f,height:m,anchor:_,leftWidth:g,rightWidth:b,topHeight:x,bottomHeight:y,texture:T,roundPixels:A}=t=t instanceof P?{texture:t}:t;super(((r,t)=>{for(var e in t=t||{})yy.call(t,e)&&Ty(r,e,t[e]);if(Js)for(var e of Js(t))xy.call(t,e)&&Ty(r,e,t[e]);return r})({label:"NineSliceSprite"},((r,t)=>{var e={};for(i in r)yy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Js)for(var i of Js(r))t.indexOf(i)<0&&xy.call(r,i)&&(e[i]=r[i]);return e})(t,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]))),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=null!=(g=null!=g?g:null==(t=null==T?void 0:T.defaultBorders)?void 0:t.left)?g:ae.defaultOptions.leftWidth,this._topHeight=null!=(g=null!=x?x:null==(t=null==T?void 0:T.defaultBorders)?void 0:t.top)?g:ae.defaultOptions.topHeight,this._rightWidth=null!=(t=null!=b?b:null==(x=null==T?void 0:T.defaultBorders)?void 0:x.right)?t:ae.defaultOptions.rightWidth,this._bottomHeight=null!=(b=null!=y?y:null==(g=null==T?void 0:T.defaultBorders)?void 0:g.bottom)?b:ae.defaultOptions.bottomHeight,this._width=null!=(x=null!=f?f:T.width)?x:ae.defaultOptions.width,this._height=null!=(t=null!=m?m:T.height)?t:ae.defaultOptions.height,this.allowChildren=!1,this.texture=null!=T?T:cx.defaultOptions.texture,this.roundPixels=null!=A&&A,this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),_?this.anchor=_:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?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 i;"object"==typeof t&&(e=null!=(i=t.height)?i:t.width,t=t.width),this._width=t,this._height=null!=e?e:t,this.onViewUpdate()}getSize(t){return(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||P.EMPTY;var 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}destroy(t){super.destroy(t),("boolean"==typeof t?t:null!=t&&t.texture)&&(t="boolean"==typeof t?t:null==t?void 0:t.textureSource,this._texture.destroy(t)),this._texture=null}updateBounds(){var t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}};Sy.defaultOptions={texture:P.EMPTY};const Ay={};var pM=Object.defineProperty,fM=Object.defineProperties,mM=Object.getOwnPropertyDescriptors,Py=Object.getOwnPropertySymbols,gM=Object.prototype.hasOwnProperty,_M=Object.prototype.propertyIsEnumerable,wy=(r,t,e)=>t in r?pM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ry=(r,t)=>{for(var e in t=t||{})gM.call(t,e)&&wy(r,e,t[e]);if(Py)for(var e of Py(t))_M.call(t,e)&&wy(r,e,t[e]);return r};const vM=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let yM=0;return h.AbstractBitmapFont=sa,h.AbstractRenderer=Ur,h.AbstractText=Os,h.AccessibilitySystem=Cc,h.AlphaFilter=Cg,h.AlphaMask=kn,h.AlphaMaskPipe=dl,h.AnimatedSprite=Yr,h.Application=Bd,h.ApplicationInitHook=Ra,h.Assets=Hr,h.AssetsClass=Zm,h.BLEND_TO_NPM=Uh,h.BUFFER_TYPE=qr,h.BackgroundLoader=mm,h.BackgroundSystem=yb,h.Batch=Hh,h.BatchGeometry=Kh,h.BatchTextureArray=kh,h.BatchableGraphics=Ui,h.BatchableMesh=Vi,h.BatchableSprite=Pr,h.Batcher=Ei,h.BatcherPipe=y_,h.BigPool=N,h.BindGroup=Ht,h.BindGroupSystem=uu,h.BitmapFont=Ca,h.BitmapFontManager=Ir,h.BitmapText=P_,h.BitmapTextPipe=ua,h.BlendModeFilter=class extends bg{constructor(t){var e=t.gpu,e=Ag(Eg({source:xg},e)),e=gt.from({vertex:{source:e,entryPoint:"mainVertex"},fragment:{source:e,entryPoint:"mainFragment"}}),t=t.gl,t=Ag(Eg({source:vg},t));super({gpuProgram:e,glProgram:Tt.from({vertex:yg,fragment:t}),blendRequired:!0,resources:{blendUniforms:new st({uBlend:{value:1,type:"f32"}}),uBackTexture:P.EMPTY}})}},h.BlendModePipe=Zl,h.BlurFilter=Hg,h.BlurFilterPass=Ts,h.Bounds=nt,h.BrowserAdapter=bh,h.Buffer=ht,h.BufferImageSource=pi,h.BufferResource=Us,h.BufferUsage=L,h.CLEAR=bt,h.Cache=W,h.CanvasPool=Xt,h.CanvasPoolClass=pp,h.CanvasSource=Nt,h.CanvasTextMetrics=jt,h.CanvasTextPipe=Fo,h.CanvasTextSystem=ea,h.Circle=Yi,h.Color=X,h.ColorMask=$n,h.ColorMaskPipe=pl,h.ColorMatrixFilter=class extends bg{constructor(t={}){var e=new st({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"}}),i=gt.from({vertex:{source:tl,entryPoint:"mainVertex"},fragment:{source:tl,entryPoint:"mainFragment"}}),s=Tt.from({vertex:ys,fragment:Xg,name:"color-matrix-filter"});super((t=((r,t)=>{for(var e in t=t||{})oA.call(t,e)&&zg(r,e,t[e]);if(jg)for(var e of jg(t))aA.call(t,e)&&zg(r,e,t[e]);return r})({},t),sA(t,nA({gpuProgram:i,glProgram:s,resources:{colorMatrixUniforms:e}})))),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.matrix,t),i=this._colorMatrix(i)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i,this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){return(t=new Float32Array(t))[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,t}brightness(t,e){this._loadMatrix([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0],e)}tint(t,e){var[t,s,n]=X.shared.setValue(t).toArray();this._loadMatrix([t,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0],e)}greyscale(t,e){this._loadMatrix([t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0],e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)}hue(t,e){t=(t||0)/180*Math.PI;var i=Math.cos(t),t=Math.sin(t),o=1/3,a=(0,Math.sqrt)(o);this._loadMatrix([i+(1-i)*o,o*(1-i)-a*t,o*(1-i)+a*t,0,0,o*(1-i)+a*t,i+o*(1-i),o*(1-i)-a*t,0,0,o*(1-i)-a*t,o*(1-i)+a*t,i+o*(1-i),0,0,0,0,0,1,0],e)}contrast(t,e){var s=-.5*((t=(t||0)+1)-1);this._loadMatrix([t,0,0,0,s,0,t,0,0,s,0,0,t,0,s,0,0,0,1,0],e)}saturate(t=0,e){var s=-.5*((t=2*t/3+1)-1);this._loadMatrix([t,s,s,0,0,s,t,s,0,0,s,s,t,0,0,0,0,0,1,0],e)}desaturate(){this.saturate(-1)}negative(t){this._loadMatrix([-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0],t)}sepia(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)}technicolor(t){this._loadMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0],t)}polaroid(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)}toBGR(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)}kodachrome(t){this._loadMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0],t)}browni(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)}vintage(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;var[i,l,u]=(o=X.shared).setValue(i).toArray(),[o,s,p]=o.setValue(s).toArray();this._loadMatrix([.3,.59,.11,0,0,i,l,u,t,0,o,s,p,e,0,i-o,l-s,u-p,0,0],n)}night(t,e){this._loadMatrix([-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0],e)}predator(t,e){this._loadMatrix([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],e)}lsd(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)}reset(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!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}},h.CompressedSource=Xr,h.Container=lt,h.Culler=pg,h.CullerPlugin=fg,h.CustomRenderPipe=jl,h.D3D10_RESOURCE_DIMENSION=za,h.D3DFMT=vt,h.DATA_URI=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,h.DDS=F,h.DEG_TO_RAD=nc,h.DEPRECATED_SCALE_MODES=Pu,h.DEPRECATED_WRAP_MODES=Au,h.DOMAdapter=H,h.DOMContainer=G0,h.DOMPipe=In,h.DRAW_MODES=Xw,h.DXGI_FORMAT=ja,h.DXGI_TO_TEXTURE_FORMAT=yt,h.DefaultBatcher=Fi,h.DefaultShader=kd,h.DisplacementFilter=class extends bg{constructor(...t){var e=t[0],{sprite:t,scale:n}=e=e instanceof Ft?{sprite:e,scale:t[1]}:e,o=((r,t)=>{var e={};for(i in r)Yg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(null!=r&&Es)for(var i of Es(r))t.indexOf(i)<0&&Kg.call(r,i)&&(e[i]=r[i]);return e})(e,["sprite","scale"]);let a=null!=n?n:20;"number"==typeof a&&(a=new V(a,a));var n=new st({uFilterMatrix:{value:new M,type:"mat3x3<f32>"},uScale:{value:a,type:"vec2<f32>"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2<f32>"}}),u=Tt.from({vertex:Wg,fragment:Vg,name:"displacement-filter"}),c=gt.from({vertex:{source:el,entryPoint:"mainVertex"},fragment:{source:el,entryPoint:"mainFragment"}}),t=t.texture.source;super(((r,t)=>dA(r,pA(t)))(((r,t)=>{for(var e in t=o||{})Yg.call(t,e)&&qg(r,e,t[e]);if(Es)for(var e of Es(t))Kg.call(t,e)&&qg(r,e,t[e]);return r})({}),{gpuProgram:c,glProgram:u,resources:{filterUniforms:n,uMapTexture:t,uMapSampler:t.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,s){var n=this.resources.filterUniforms.uniforms,o=(t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite),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);0!==a&&0!==l&&(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,i,s)}get scale(){return this.resources.filterUniforms.uniforms.uScale}},h.DynamicBitmapFont=oa,h.Ellipse=Ki,h.EventBoundary=hh,h.EventEmitter=ft,h.EventSystem=Bn,h.EventsTicker=Kt,h.ExtensionType=r,h.ExtractSystem=Xb,h.FOURCC_TO_TEXTURE_FORMAT=Va,h.FederatedContainer=ch,h.FederatedEvent=Fe,h.FederatedMouseEvent=mr,h.FederatedPointerEvent=Mt,h.FederatedWheelEvent=_e,h.FillGradient=Qt,h.FillPattern=wr,h.Filter=bg,h.FilterEffect=hr,h.FilterPipe=ya,h.FilterSystem=xa,h.FontStylePromiseCache=Fr,h.GAUSSIAN_VALUES=Qa,h.GL_FORMATS=Fs,h.GL_INTERNAL_FORMAT=ng,h.GL_TARGETS=bl,h.GL_TYPES=j,h.GL_WRAP_MODES=U_,h.GenerateTextureSystem=eu,h.Geometry=ye,h.GlBackBufferSystem=X_,h.GlBatchAdaptor=ll,h.GlBuffer=G_,h.GlBufferSystem=ml,h.GlColorMaskSystem=xl,h.GlContextSystem=gl,h.GlEncoderSystem=Tl,h.GlGeometrySystem=vl,h.GlGraphicsAdaptor=Hl,h.GlMeshAdaptor=Xl,h.GlParticleContainerAdaptor=np,h.GlParticleContainerPipe=Bo,h.GlProgram=Tt,h.GlProgramData=ab,h.GlRenderTarget=j_,h.GlRenderTargetAdaptor=Z_,h.GlRenderTargetSystem=Ol,h.GlShaderSystem=Dl,h.GlStateSystem=nb,h.GlStencilSystem=Sl,h.GlTexture=Tb,h.GlTextureSystem=Nl,h.GlUboSystem=Rl,h.GlUniformGroupSystem=Ul,h.GlobalUniformSystem=ru,h.GpuBatchAdaptor=ul,h.GpuBlendModesToPixi=pt,h.GpuBufferSystem=cu,h.GpuColorMaskSystem=hu,h.GpuDeviceSystem=zs,h.GpuEncoderSystem=du,h.GpuGraphicsAdaptor=Su,h.GpuGraphicsContext=ip,h.GpuMeshAdapter=Eu,h.GpuMipmapGenerator=Pv,h.GpuParticleContainerAdaptor=dp,h.GpuParticleContainerPipe=Io,h.GpuProgram=gt,h.GpuReadBuffer=function(r,t){const e=r.descriptor.size,i=t.gpu.device,s=new ht({data:new Float32Array(24e5),usage:L.MAP_READ|L.COPY_DST}),n=t.buffer.createGPUBuffer(s),o=i.createCommandEncoder();o.copyBufferToBuffer(t.buffer.getGPUBuffer(r),0,n,0,e),i.queue.submit([o.finish()]),n.mapAsync(GPUMapMode.READ,0,e).then(()=>{n.getMappedRange(0,e),n.unmap()})},h.GpuRenderTarget=xv,h.GpuRenderTargetAdaptor=Tv,h.GpuRenderTargetSystem=_u,h.GpuShaderSystem=bu,h.GpuStateSystem=vu,h.GpuStencilModesToPixi=te,h.GpuStencilSystem=pu,h.GpuTextureSystem=Tu,h.GpuUboSystem=fu,h.GpuUniformBatchPipe=mu,h.Graphics=Ze,h.GraphicsContext=dt,h.GraphicsContextRenderData=sp,h.GraphicsContextSystem=zi,h.GraphicsPath=se,h.GraphicsPipe=Ro,h.HTMLText=w_,h.HTMLTextPipe=ca,h.HTMLTextRenderData=pa,h.HTMLTextStyle=Ae,h.HTMLTextSystem=is,h.HelloSystem=js,h.IGLUniformData=class{},h.ImageSource=ie,h.InstructionSet=bn,h.KTX=tt,h.Loader=Pm,h.LoaderParserPriority=xt,h.MSAA_QUALITY=Ov,h.MaskEffectManager=li,h.MaskEffectManagerClass=cc,h.MaskFilter=a_,h.Matrix=M,h.Mesh=ir,h.MeshGeometry=oe,h.MeshPipe=Mo,h.MeshPlane=CR,h.MeshRope=ry,h.MeshSimple=VR,h.NOOP=Tn,h.NineSliceGeometry=ae,h.NineSlicePlane=class extends Sy{constructor(...t){var e=t[0];super(e instanceof P?{texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}:e)}},h.NineSliceSprite=Sy,h.NineSliceSpritePipe=va,h.NoiseFilter=kg,h.ObservablePoint=rt,h.PI_2=ic,h.Particle=fy,h.ParticleBuffer=lp,h.ParticleContainer=iM,h.ParticleContainerPipe=Go,h.ParticleShader=hp,h.PerspectiveMesh=Kv,h.PerspectivePlaneGeometry=zv,h.PipelineSystem=gu,h.PlaneGeometry=os,h.Point=V,h.Polygon=Ye,h.Pool=ai,h.PoolGroupClass=oc,h.PrepareBase=l_,h.PrepareQueue=A_,h.PrepareSystem=M_,h.PrepareUpload=R_,h.QuadGeometry=Xf,h.RAD_TO_DEG=sc,h.Rectangle=z,h.RenderContainer=rR,h.RenderGroup=Hc,h.RenderGroupPipe=zl,h.RenderGroupSystem=Yl,h.RenderLayer=dR,h.RenderLayerClass=kv,h.RenderTarget=Ds,h.RenderTargetSystem=Cl,h.RenderTexture=Xs,h.RenderableGCSystem=su,h.RendererInitHook=Ma,h.RendererType=_t,h.ResizePlugin=Cn,h.Resolver=re,h.RopeGeometry=iy,h.RoundedRectangle=Zi,h.SCALE_MODES=Ww,h.STENCIL_MODES=J,h.SVGParser=Up,h.SchedulerSystem=iu,h.ScissorMask=class{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Ti(this.mask,t,e)}addLocalBounds(t,e){Si(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}},h.SdfShader=lf,h.Shader=St,h.ShaderStage=Ne,h.ShapePath=Gp,h.SharedRenderPipes=lu,h.SharedSystems=au,h.Sprite=Ft,h.SpritePipe=Kl,h.Spritesheet=Fn,h.State=Et,h.StencilMask=Ln,h.StencilMaskPipe=fl,h.SystemRunner=Aa,h.TEXTURE_FORMAT_BLOCK_SIZE=ig,h.Text=al,h.TextStyle=Pt,h.Texture=P,h.TextureGCSystem=nu,h.TextureMatrix=Sn,h.TexturePool=it,h.TexturePoolClass=Nc,h.TextureSource=Q,h.TextureStyle=yn,h.TextureUvs=class{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,i){var o,a,l,u,s=e.width,e=e.height;i?(o=t.width/2/s,a=t.height/2/e,l=t.x/s+o,u=t.y/e+a,i=$.add(i,$.NW),this.x0=l+o*$.uX(i),this.y0=u+a*$.uY(i),i=$.add(i,2),this.x1=l+o*$.uX(i),this.y1=u+a*$.uY(i),i=$.add(i,2),this.x2=l+o*$.uX(i),this.y2=u+a*$.uY(i),i=$.add(i,2),this.x3=l+o*$.uX(i),this.y3=u+a*$.uY(i)):(this.x0=t.x/s,this.y0=t.y/e,this.x1=(t.x+t.width)/s,this.y1=t.y/e,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/e,this.x3=t.x/s,this.y3=(t.y+t.height)/e),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}},h.Ticker=ut,h.TickerListener=bi,h.TickerPlugin=On,h.TilingSprite=x_,h.TilingSpritePipe=ba,h.TilingSpriteShader=Hf,h.Transform=g_,h.Triangle=class ol{constructor(t=0,e=0,i=0,s=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=s,this.x3=n,this.y3=o}contains(t,e){var i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),s=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);return!(i<0!=s<0&&0!=i&&0!=s||0!=(e=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2))&&e<0!=i+s<=0)}strokeContains(t,e,i,s=0){var i=(i/=2)*i,{x:a,x2:l,x3:u,y:c,y2:d,y3:p}=this;return Rr(t,e,a,c,l,p)<=i||Rr(t,e,l,d,u,p)<=i||Rr(t,e,u,p,a,c)<=i}clone(){return new ol(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 z;var e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),s=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=s,t.width=i-e,t.height=n-s,t}},h.UNIFORM_TO_ARRAY_SETTERS=_b,h.UNIFORM_TO_SINGLE_SETTERS=gb,h.UNIFORM_TYPES_MAP=Rd,h.UNIFORM_TYPES_VALUES=ao,h.UPDATE_BLEND=mi,h.UPDATE_COLOR=fr,h.UPDATE_PRIORITY=Yt,h.UPDATE_TRANSFORM=8,h.UPDATE_VISIBLE=Ie,h.UboBatch=dv,h.UboSystem=El,h.UniformGroup=st,h.VERSION=Nr,h.VideoSource=vr,h.ViewContainer=Lt,h.ViewSystem=ou,h.ViewableBuffer=ve,h.WGSL_ALIGN_SIZE_DATA=Qr,h.WGSL_TO_STD40_SIZE=Al,h.WRAP_MODES=Vw,h.WebGLRenderer=hv,h.WebGPURenderer=Cv,h.WorkerManager=Da,h._getGlobalBounds=mn,h.accessibilityTarget=Mn,h.addBits=to,h.addMaskBounds=Ti,h.addMaskLocalBounds=Si,h.addProgramDefines=Qh,h.alphaFrag=Pg,h.alphaWgsl=qa,h.applyMatrix=zf,h.applyProjectiveTransformationToPlane=Lv,h.applyStyleParams=Ll,h.assignWithIgnore=fi,h.autoDetectEnvironment=async function(r){return Sa(!r)},h.autoDetectRenderer=lm,h.autoDetectSource=function(r={}){return zn(r)},h.basisTranscoderUrls=ms,h.bgr2rgb=Be,h.bitmapFontCachePlugin=pm,h.bitmapFontTextParser=ls,h.bitmapFontXMLParser=Oa,h.bitmapFontXMLStringParser=Ga,h.blendTemplateFrag=vg,h.blendTemplateVert=yg,h.blendTemplateWgsl=xg,h.blockDataMap=yu,h.blurTemplateWgsl=Ig,h.boundsPool=$t,h.browserExt=GE,h.buildAdaptiveBezier=$o,h.buildAdaptiveQuadratic=Pp,h.buildArc=Ho,h.buildArcTo=wp,h.buildArcToSvg=Mp,h.buildCircle=Zt,h.buildContextBatches=ep,h.buildEllipse=Xd,h.buildGeometryFromPath=function(r){r instanceof se&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],s=r.path.shapePath,n=r.textureMatrix;return s.shapePrimitives.forEach(({shape:a,transform:l})=>{var u=i.length,c=t.length/2,d=[],p=aR[a.type],a=(p.build(a,d),l&&Di(d,l),p.triangulate(d,t,2,c,i,u),e.length/2);n?(l&&n.append(l.clone().invert()),lo(t,2,c,e,a,2,t.length/2-c,n)):uo(e,a,2,t.length/2-c)}),(r=r.out)?(r.positions=new Float32Array(t),r.uvs=new Float32Array(e),r.indices=new Uint32Array(i),r):new oe({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})},h.buildLine=Wd,h.buildPixelLine=Yd,h.buildPolygon=_o,h.buildRectangle=bo,h.buildRoundedRectangle=jd,h.buildSimpleUvs=uo,h.buildTriangle=vo,h.buildUvs=lo,h.cacheAsTextureMixin=ac,h.cacheTextureArray=$i,h.calculateProjection=Q_,h.checkChildrenDidChange=_n,h.checkDataUrl=Pe,h.checkExtension=Gt,h.checkMaxIfStatementsInShader=Fh,h.childrenHelperMixin=ln,h.cleanArray=Kb,h.cleanHash=Yb,h.clearList=Hs,h.closePointEps=co,h.collectAllRenderables=function(r,t,e){return e=e.renderPipes?e:e.batch.renderer,r.collectRenderables(t,e,null)},h.collectRenderablesMixin=uc,h.color32BitToUniform=We,h.colorBit=Mi,h.colorBitGl=Ci,h.colorMatrixFilterFrag=Xg,h.colorMatrixFilterWgsl=tl,h.colorToUniform=function(r,t,e,i){e[i++]=(r>>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(255&r)/255,e[i++]=t},h.compareModeToGlCompare=wb,h.compileHighShader=gd,h.compileHighShaderGl=_d,h.compileHighShaderGlProgram=Xe,h.compileHighShaderGpuProgram=He,h.compileHooks=eo,h.compileInputs=ro,h.compileOutputs=md,h.compileShader=Gl,h.compute2DProjection=jv,h.convertFormatIfRequired=function(r){var t=r.format;if(Wa[t]){var e=Wa[t].convertFunction,i=r.resource;for(let s=0;s<i.length;s++)i[s]=e(i[s]);r.format=Wa[t].convertedFormat}},h.convertToList=Ct,h.copySearchParams=yi,h.createIdFromString=Le,h.createIndicesForQuads=Co,h.createLevelBuffers=function(r,t){var e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");var s=[];for(let n=0;n<i;++n)for(let o=0;o<e;++o){var a=r.getImageTranscodedSizeInBytes(o,n,t),a=new Uint8Array(a);if(!r.transcodeImage(a,o,n,t,1,0))throw new Error("transcodeImage failed");s.push(a)}return s},h.createLevelBuffersFromKTX=function(r){var t=[];for(let e=0;e<r.numLevels;e++){var i=r.getImageData(e,0,0),s=new Uint8Array(i.byteLength);s.set(i),t.push(s)}return t},h.createStringVariations=xh,h.createTexture=le,h.createUboElementsSTD40=z_,h.createUboElementsWGSL=gv,h.createUboSyncFunction=Pl,h.createUboSyncFunctionSTD40=q_,h.createUboSyncFunctionWGSL=bv,h.crossOrigin=Vm,h.cullingMixin=rc,h.curveEps=ho,h.defaultFilterVert=ys,h.defaultValue=Il,h.definedProps=Bt,h.deprecation=function(r,t,e=3){if(!Ay[t]){let i=(new Error).stack;void 0===i?console.warn("PixiJS Deprecation Warning: ",t+`
Deprecated since v`+r):(i=i.split(`
`).splice(e).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",t+`
Deprecated since v`+r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",t+`
Deprecated since v`+r),console.warn(i))),Ay[t]=!0}},h.detectAvif=_m,h.detectBasis=K2,h.detectCompressed=ME,h.detectDefaults=vm,h.detectMp4=ym,h.detectOgv=xm,h.detectVideoAlphaMode=Hn,h.detectWebm=Tm,h.detectWebp=Sm,h.determineCrossOrigin=Ym,h.displacementFrag=Vg,h.displacementVert=Wg,h.displacementWgsl=el,h.earcut=Jd,h.effectsMixin=fc,h.ensureAttributes=_l,h.ensureIsBuffer=Kn,h.ensurePrecision=Jh,h.ensureTextOptions=Gs,h.ensureTextStyle=function(r,t){return t instanceof Pt||t instanceof Ae?t:new("html"===r?Ae:Pt)(t)},h.executeInstructions=Ns,h.extensions=B,h.extractAttributesFromGlProgram=cb,h.extractAttributesFromGpuProgram=ld,h.extractFontFamilies=Ef,h.extractStructAndGroups=Ri,h.extractSvgUrlId=Vo,h.fastCopy=Pi,h.findHooksRx=dd,h.findMixin=mc,h.fontStringFromTextStyle=Gr,h.formatShader=function(r){r=r.split(/([\n{}])/g).map(i=>i.trim()).filter(i=>i.length);let e="";return r.map(i=>{let s=e+i;return"{"===i?e+=" ":"}"===i&&(e=e.substr(0,e.length-4),s=e+i),s}).join(`
`)},h.fragmentGPUTemplate=xd,h.fragmentGlTemplate=Sd,h.generateArraySyncSTD40=K_,h.generateArraySyncWGSL=_v,h.generateBlurFragSource=Og,h.generateBlurGlProgram=Bg,h.generateBlurProgram=Fg,h.generateBlurVertSource=Gg,h.generateGPULayout=function(r){var t=[];let e=0;for(let i=0;i<r;i++)t[e]={texture:{sampleType:"float",viewDimension:"2d",multisampled:!1},binding:e,visibility:GPUShaderStage.FRAGMENT},t[++e]={sampler:{type:"filtering"},binding:e,visibility:GPUShaderStage.FRAGMENT},e++;return t},h.generateGpuLayoutGroups=ud,h.generateLayout=function(r){var t={};let e=0;for(let i=0;i<r;i++)t["textureSource"+(i+1)]=e++,t["textureSampler"+(i+1)]=e++;return t},h.generateLayoutHash=cd,h.generateParticleUpdateFunction=op,h.generateProgram=mb,h.generateShaderSyncCode=ob,h.generateTextStyleKey=Zo,h.generateTextureBatchBit=Oi,h.generateTextureBatchBitGl=Gi,h.generateTextureMatrix=tp,h.generateUID=function(){return Kw++},h.generateUniformsSync=bb,h.getAdjustedBlendModeBlend=$e,h.getAttributeInfoFromFormat=qt,h.getBatchSamplersUniformGroup=Bi,h.getBitmapTextLayout=aa,h.getCanvasBoundingBox=gp,h.getCanvasFillStyle=Br,h.getCanvasTexture=Ml,h.getDefaultUniformValue=Md,h.getFastGlobalBounds=function(r,t){return r.getFastGlobalBounds(!0,t)},h.getFastGlobalBoundsMixin=_c,h.getFontCss=Pf,h.getFontFamilyName=Om,h.getGeometryBounds=Yh,h.getGlTypeFromFormat=$_,h.getGlobalBounds=dr,h.getGlobalMixin=vc,h.getGlobalRenderableBounds=em,h.getLocalBounds=hi,h.getMatrixRelativeToParent=Un,h.getMaxFragmentPrecision=Zh,h.getMaxTexturesPerBatch=be,h.getOrientationOfPoints=zd,h.getParent=function xc(r,t,e){(r=r.parent)&&r!==t&&(xc(r,t,e),r.updateLocalTransform(),e.append(r.localTransform))},h.getPo2TextureFromSource=Jo,h.getResolutionOfUrl=cs,h.getSVGUrl=wf,h.getSupportedCompressedTextureFormats=Xa,h.getSupportedGPUCompressedTextureFormats=Na,h.getSupportedGlCompressedTextureFormats=La,h.getSupportedTextureFormats=jr,h.getTemporaryCanvasFromImage=Rf,h.getTestContext=Vn,h.getTextureBatchBindGroup=Ai,h.getTextureDefaultMatrix=function(r,t){var{width:r,height:i}=r.frame;return t.scale(1/r,1/i),t},h.getTextureFormatFromKTXTexture=function(r){return 2===r.classId?dg(r.vkFormat):hg(r.glInternalformat)},h.getUboData=hb,h.getUniformData=db,h.getUrlExtension=Eh,h.glFormatToGPUFormat=hg,h.glUploadBufferImageResource=Sb,h.glUploadCompressedTextureResource=Eb,h.glUploadImageResource=kl,h.glUploadVideoResource=Ab,h.globalUniformsBit=Ed,h.globalUniformsBitGl=Ad,h.globalUniformsUBOBitGl=y1,h.gpuFormatToBasisTranscoderFormat=function(r){var t=eE[r];if(t)return t;throw new Error("Unsupported transcoderFormat: "+r)},h.gpuFormatToKTXBasisTranscoderFormat=function(r){var t=PE[r];if(t)return t;throw new Error("Unsupported transcoderFormat: "+r)},h.gpuUploadBufferImageResource=Sv,h.gpuUploadCompressedTextureResource=Ev,h.gpuUploadImageResource=xu,h.gpuUploadVideoResource=Av,h.groupD8=$,h.hasCachedCanvasTexture=function(r){return nr.has(r)},h.hslWgsl=`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;
}`,h.hslgl=`
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;
}
`,h.hslgpu=`
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;
}
`,h.injectBits=io,h.insertVersion=td,h.isMobile=rh,h.isPow2=vn,h.isRenderingToScreen=eb,h.isSafari=gf,h.isSingleItem=br,h.isWebGLSupported=kr,h.isWebGPUSupported=$r,h.ktxTranscoderUrls=gs,h.loadBasis=J2,h.loadBasisOnWorker=rg,h.loadBitmapFont=fm,h.loadDDS=uE,h.loadEnvironmentExtensions=Sa,h.loadFontAsBase64=Af,h.loadFontCSS=fa,h.loadImageBitmap=Nm,h.loadJson=wm,h.loadKTX=gE,h.loadKTX2=yE,h.loadKTX2onWorker=ug,h.loadSVGImage=Mf,h.loadSvg=Dm,h.loadTextures=Ua,h.loadTxt=Rm,h.loadVideoTextures=Km,h.loadWebFont=Gm,h.localUniformBit=Qe,h.localUniformBitGl=ss,h.localUniformBitGroup2=$f,h.localUniformMSDFBit=sf,h.localUniformMSDFBitGl=nf,h.log2=function(r){var t=(65535<r?1:0)<<4,e=(255<(r>>>=t)?1:0)<<3;return(t|=e)|(e=(15<(r>>>=e)?1:0)<<2)|(e=(3<(r>>>=e)?1:0)<<1)|r>>>e>>1},h.logDebugTexture=async function(r,t,e=200){var i=await t.extract.base64(r),t=(await t.encoder.commandFinished,e),e=(console.log(`logging texture ${r.source.width}px ${r.source.height}px`),["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" "));console.log("%c ",e)},h.logProgramError=fb,h.logRenderGroupScene=function Cy(r,t=0,e={index:0,color:"#000000"}){let i="";for(let n=0;n<t;n++)i+=" ";var s=`%c ${i}- ${e.index}: ${r.root.label} worldX:`+r.worldTransform.tx;console.log(s,`color:${e.color}; font-weight:bold;`),t++;for(let n=0;n<r.renderGroupChildren.length;n++)Cy(r.renderGroupChildren[n],t,((r,t)=>fM(r,mM(t)))(Ry({},e),{index:n}))},h.logScene=function My(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=vM[yM++]);let i="";for(let o=0;o<t;o++)i+=" ";let s=r.label,n=(!s&&r instanceof Ft&&(s="sprite:"+r.texture.label),`%c ${i}|- ${s} (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++)My(r.children[o],t,Ry({},e))},h.mSDFBit=of,h.mSDFBitGl=af,h.mapFormatToGlFormat=Rb,h.mapFormatToGlInternalFormat=Ob,h.mapFormatToGlType=Gb,h.mapGlToVertexFormat=ub,h.mapSize=function(r){return PP[r]},h.mapType=Fl,h.mapWebGLBlendModesToPixi=vb,h.maskFrag=r_,h.maskVert=i_,h.maskWgsl=sl,h.matrixPool=ct,h.measureHtmlText=ma,h.measureMixin=Tc,h.migrateFragmentFromV7toV8=function(r){return`
out vec4 finalColor;
${r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in")}
`},h.mipmapScaleModeToGlFilter=Pb,h.mixHexColors=function(r,t,e){var i=r>>16&255,s=r>>8&255;return(i+((t>>16&255)-i)*e<<16)+(s+((t>>8&255)-s)*e<<8)+((r&=255)+((255&t)-r)*e)},h.multiplyColors=pr,h.multiplyHexColors=gn,h.nextPow2=de,h.noiseFrag=Zg,h.noiseWgsl=rl,h.nonCompressedFormats=Jm,h.normalizeExtensionPriority=lr,h.nssvg=ha,h.nsxhtml=da,h.onRenderMixin=Sc,h.parseAttribute=Ko,h.parseDDS=sg,h.parseFunctionBody=function(r){var e=(r=r.toString()).indexOf("{"),i=r.lastIndexOf("}");if(-1===e||-1===i)throw new Error("getFunctionBody: No body found in function definition");return r.slice(e+1,i).trim()},h.parseKTX=og,h.parseSVGDefinitions=Ip,h.parseSVGFloatAttribute=Z,h.parseSVGPath=Ep,h.parseSVGStyle=Yo,h.particleData=Mu,h.particlesFrag=up,h.particlesVert=cp,h.particlesWgsl=Oo,h.path=mt,h.pointInTriangle=nl,h.preloadVideo=Wm,h.removeItems=fn,h.removeStructAndGroupDuplicates=hd,h.resetUids=function(){for(const r in cr)delete cr[r]},h.resolveCharacters=na,h.resolveCompressedTextureUrl=RE,h.resolveJsonUrl=qm,h.resolveTextureUrl=$a,h.resourceToTexture=Bh,h.roundPixelsBit=je,h.roundPixelsBitGl=ze,h.roundedShapeArc=Cp,h.roundedShapeQuadraticCurve=Op,h.sayHello=Wb,h.scaleModeToGlFilter=$l,h.setBasisTranscoderPath=function(r){Object.assign(ms,r)},h.setKTXTranscoderPath=function(r){Object.assign(gs,r)},h.setPositions=jf,h.setProgramName=ed,h.setUvs=Vf,h.shapeBuilders=Ar,h.sortMixin=Ec,h.spritesheetAsset=wh,h.squaredDistanceToLineSegment=Rr,h.stripVersion=rd,h.styleAttributes=Wo,h.testImageFormat=Ba,h.testVideoFormat=us,h.textStyleToCSS=_f,h.textureBit=C_,h.textureBitGl=O_,h.textureFrom=Ih,h.tilingBit=Lf,h.tilingBitGl=Nf,h.toFillStyle=ne,h.toLocalGlobalMixin=Ac,h.toStrokeStyle=Or,h.transformVertices=Di,h.triangulateWithHoles=go,h.uboSyncFunctionsSTD40=wl,h.uboSyncFunctionsWGSL=Y_,h.uid=K,h.uniformParsers=ue,h.unpremultiplyAlpha=function(r){var t=(r=r instanceof Uint8ClampedArray?new Uint8Array(r.buffer):r).length;for(let e=0;e<t;e+=4){var i=r[e+3];0!==i&&(i=255.001/i,r[e]=r[e]*i+.5,r[e+1]=r[e+1]*i+.5,r[e+2]=r[e+2]*i+.5)}},h.unsafeEvalSupported=Ea,h.updateLocalTransform=function(r,t){var e=t._scale,i=t._pivot,s=t._position,n=e._x,e=e._y,a=i._x,i=i._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*e,r.d=t._sy*e,r.tx=s._x-(a*r.a+i*r.c),r.ty=s._y-(a*r.b+i*r.d)},h.updateQuadBounds=Dn,h.updateRenderGroupTransform=Ib,h.updateRenderGroupTransforms=Vl,h.updateTextBounds=Wi,h.updateTransformAndChildren=Wl,h.updateTransformBackwards=ci,h.updateWorldTransform=function(r,t,e){var i=r.a,s=r.b,n=r.c,o=r.d,a=r.tx,r=r.ty,u=t.a,c=t.b,d=t.c,p=t.d;e.a=i*u+s*d,e.b=i*c+s*p,e.c=n*u+o*d,e.d=n*c+o*p,e.tx=a*u+r*d+t.tx,e.ty=a*c+r*p+t.ty},h.v8_0_0="8.0.0",h.v8_3_4="8.3.4",h.validFormats=_s,h.validateRenderables=Db,h.vertexGPUTemplate=yd,h.vertexGlTemplate=Td,h.viewportFromFrame=function(r,t,e){e=e||jw;var i=t.pixelWidth,t=t.pixelHeight;return r.x=e.x*i|0,r.y=e.y*t|0,r.width=e.width*i|0,r.height=e.height*t|0,r},h.vkFormatToGPUFormat=dg,h.warn=Ot,h.wrapModeToGlAddress=Ls,h}({});