pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
2,240 lines • 679 kB
JavaScript
/*!
* PixiJS - v8.10.1
* Compiled Thu, 05 Jun 2025 17:35:59 UTC
*
* PixiJS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/var PIXI=function(d){"use strict";"use strict";var Tx=Object.defineProperty,Sx=Object.defineProperties,Ex=Object.getOwnPropertyDescriptors,Ou=Object.getOwnPropertySymbols,Ax=Object.prototype.hasOwnProperty,Px=Object.prototype.propertyIsEnumerable,Gu=(r,t,e)=>t in r?Tx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bu=(r,t)=>{for(var e in t||(t={}))Ax.call(t,e)&&Gu(r,e,t[e]);if(Ou)for(var e of Ou(t))Px.call(t,e)&&Gu(r,e,t[e]);return r},wx=(r,t)=>Sx(r,Ex(t)),y=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(y||{});const nn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=wx(Bu({},t),{ref:r})}if(typeof r=="object")r=Bu({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},cr=(r,t)=>{var e;return(e=nn(r).priority)!=null?e:t},B={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(nn).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(nn).forEach(t=>{t.type.forEach(e=>{var i,s;const n=this._addHandlers,o=this._queue;n[e]?(s=n[e])==null||s.call(n,t):(o[e]=o[e]||[],(i=o[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const s=this._addHandlers,n=this._removeHandlers;s[r]=t,n[r]=e;const o=this._queue;return o[r]&&((i=o[r])==null||i.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,n)=>cr(n.value,e)-cr(s.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&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)=>cr(n,e)-cr(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var wM=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Iu(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function RM(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function MM(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function CM(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var on={exports:{}},OM=on.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function n(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,h||l,p),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=e?e+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,m=new Array(f);p<f;p++)m[p]=h[p].fn;return m},a.prototype.listenerCount=function(u){var c=e?e+u:u,h=this._events[c];return h?h.fn?1:h.length:0},a.prototype.emit=function(u,c,h,p,f,m){var _=e?e+u:u;if(!this._events[_])return!1;var g=this._events[_],b=arguments.length,v,x;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,h),!0;case 4:return g.fn.call(g.context,c,h,p),!0;case 5:return g.fn.call(g.context,c,h,p,f),!0;case 6:return g.fn.call(g.context,c,h,p,f,m),!0}for(x=1,v=new Array(b-1);x<b;x++)v[x-1]=arguments[x];g.fn.apply(g.context,v)}else{var T=g.length,E;for(x=0;x<T;x++)switch(g[x].once&&this.removeListener(u,g[x].fn,void 0,!0),b){case 1:g[x].fn.call(g[x].context);break;case 2:g[x].fn.call(g[x].context,c);break;case 3:g[x].fn.call(g[x].context,c,h);break;case 4:g[x].fn.call(g[x].context,c,h,p);break;default:if(!v)for(E=1,v=new Array(b-1);E<b;E++)v[E-1]=arguments[E];g[x].fn.apply(g[x].context,v)}}return!0},a.prototype.on=function(u,c,h){return n(this,u,c,h,!1)},a.prototype.once=function(u,c,h){return n(this,u,c,h,!0)},a.prototype.removeListener=function(u,c,h,p){var f=e?e+u:u;if(!this._events[f])return this;if(!c)return o(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!p||m.once)&&(!h||m.context===h)&&o(this,f);else{for(var _=0,g=[],b=m.length;_<b;_++)(m[_].fn!==c||p&&!m[_].once||h&&m[_].context!==h)&&g.push(m[_]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(u){var c;return u?(c=e?e+u:u,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(on);var Rx=on.exports,pt=Iu(Rx),Mx={grad:.9,turn:360,rad:360/(2*Math.PI)},Wt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},nt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},wt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Fu=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Du=function(r){return{r:wt(r.r,0,255),g:wt(r.g,0,255),b:wt(r.b,0,255),a:wt(r.a)}},an=function(r){return{r:nt(r.r),g:nt(r.g),b:nt(r.b),a:nt(r.a,3)}},Cx=/^#([0-9a-f]{3,8})$/i,ui=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Uu=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},ku=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),u=n%6;return{r:255*[i,a,o,o,l,i][u],g:255*[l,i,i,a,o,o][u],b:255*[o,o,l,i,i,a][u],a:s}},$u=function(r){return{h:Fu(r.h),s:wt(r.s,0,100),l:wt(r.l,0,100),a:wt(r.a)}},Lu=function(r){return{h:nt(r.h),s:nt(r.s),l:nt(r.l),a:nt(r.a,3)}},Nu=function(r){return ku((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},hr=function(r){return{h:(t=Uu(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},Ox=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gx=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bx=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ix=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ln={string:[[function(r){var t=Cx.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?nt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?nt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Bx.exec(r)||Ix.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Du({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=Ox.exec(r)||Gx.exec(r);if(!t)return null;var e,i,s=$u({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Mx[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Nu(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Wt(t)&&Wt(e)&&Wt(i)?Du({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Wt(t)||!Wt(e)||!Wt(i))return null;var o=$u({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Nu(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Wt(t)||!Wt(e)||!Wt(i))return null;var o=function(a){return{h:Fu(a.h),s:wt(a.s,0,100),v:wt(a.v,0,100),a:wt(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return ku(o)},"hsv"]]},Xu=function(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]},Hu=function(r){return typeof r=="string"?Xu(r.trim(),ln.string):typeof r=="object"&&r!==null?Xu(r,ln.object):[null,void 0]},GM=function(r){return Hu(r)[1]},un=function(r,t){var e=hr(r);return{h:e.h,s:wt(e.s+100*t,0,100),l:e.l,a:e.a}},cn=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},ju=function(r,t){var e=hr(r);return{h:e.h,s:e.s,l:wt(e.l+100*t,0,100),a:e.a}},ci=function(){function r(t){this.parsed=Hu(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return nt(cn(this.rgba),2)},r.prototype.isDark=function(){return cn(this.rgba)<.5},r.prototype.isLight=function(){return cn(this.rgba)>=.5},r.prototype.toHex=function(){return t=an(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?ui(nt(255*n)):"","#"+ui(e)+ui(i)+ui(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return an(this.rgba)},r.prototype.toRgbString=function(){return t=an(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return Lu(hr(this.rgba))},r.prototype.toHslString=function(){return t=Lu(hr(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Uu(this.rgba),{h:nt(t.h),s:nt(t.s),v:nt(t.v),a:nt(t.a,3)};var t},r.prototype.invert=function(){return $t({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),$t(un(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),$t(un(this.rgba,-t))},r.prototype.grayscale=function(){return $t(un(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),$t(ju(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),$t(ju(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?$t({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):nt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=hr(this.rgba);return typeof t=="number"?$t({h:t,s:e.s,l:e.l,a:e.a}):nt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===$t(t).toHex()},r}(),$t=function(r){return r instanceof ci?r:new ci(r)},zu=[],Fx=function(r){r.forEach(function(t){zu.indexOf(t)<0&&(t(ci,ln),zu.push(t))})},BM=function(){return new ci({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function Dx(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var 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 a,l,u=i[this.toHex()];if(u)return u;if(o!=null&&o.closest){var c=this.toRgb(),h=1/0,p="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var m in e){var _=(a=c,l=n[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<h&&(h=_,p=m)}return p}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}var Ux=Object.defineProperty,Vu=Object.getOwnPropertySymbols,kx=Object.prototype.hasOwnProperty,$x=Object.prototype.propertyIsEnumerable,Wu=(r,t,e)=>t in r?Ux(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lx=(r,t)=>{for(var e in t||(t={}))kx.call(t,e)&&Wu(r,e,t[e]);if(Vu)for(var e of Vu(t))$x.call(t,e)&&Wu(r,e,t[e]);return r};Fx([Dx]);const Ge=class ai{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 ai)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?Lx({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[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);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=ai._temp.setValue(t)._components;return this._components[0]*=e,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(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ai.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=$t(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ai||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};Ge.shared=new Ge,Ge._temp=new Ge,Ge.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let H=Ge;const Yu={cullArea:null,cullable:!1,cullableChildren:!0},Ku=Math.PI*2,qu=180/Math.PI,Zu=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 hn.x=0,hn.y=0,hn}}const hn=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){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new V;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new V;const 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,h=t.y;return e.x=o*u*c+-n*u*h+(l*n-a*o)*u,e.y=i*u*h+-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){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const 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){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*u+s*h,this.b=i*c+s*p,this.c=n*u+o*h,this.d=n*c+o*p,this.tx=a*u+l*h+e.tx,this.ty=a*c+l*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){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const 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}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,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(Ku-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(){const 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 this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new 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 Xx.identity()}static get shared(){return Nx.identity()}}const Nx=new M,Xx=new M;class et{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new et(t!=null?t:this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}const dr={default:-1};function Y(r="default"){return dr[r]===void 0&&(dr[r]=-1),++dr[r]}function Hx(){for(const r in dr)delete dr[r]}class hi{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let i;return this._index>0?i=this._pool[--this._index]:i=new this._classType,(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class Qu{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 hi(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const ot=new Qu,Ju={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function dn(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}const tc={allowChildren:!0,removeChildren(r=0,t){var e;const i=t!=null?t:this.children.length,s=i-r,n=[];if(s>0&&s<=i){for(let a=i-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}dn(this.children,r,i);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a<n.length;++a){const l=n[a];(e=l.parentRenderLayer)==null||e.detach(l),this.emit("childRemoved",l,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r}},ec={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:i}=t;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class pr{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 rc{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return ot.get(i.maskClass,t)}return t}returnMaskEffect(t){ot.return(t)}}const di=new rc;B.handleByList(y.MaskEffect,di._effectClasses);var jx=Object.defineProperty,ic=Object.getOwnPropertySymbols,zx=Object.prototype.hasOwnProperty,Vx=Object.prototype.propertyIsEnumerable,sc=(r,t,e)=>t in r?jx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nc=(r,t)=>{for(var e in t||(t={}))zx.call(t,e)&&sc(r,e,t[e]);if(ic)for(var e of ic(t))Vx.call(t,e)&&sc(r,e,t[e]);return r};const oc={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),di.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=di.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=nc(nc({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new pr);r=r;const i=(r==null?void 0:r.length)>0,s=((t=e.filters)==null?void 0:t.length)>0,n=i!==s;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new pr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},ac={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const 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=[]){const i=this.children;for(let s=0;s<i.length;s++){const 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}},pi=[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?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,u=i*(1-s),c=i-u,h=a-u,p=a+n+u,f=l-u,m=l+o+u,_=a+c,g=a+n-c,b=l+c,v=l+o-c;return t>=h&&t<=p&&e>=f&&e<=m&&!(t>_&&t<g&&e>b&&e<v)}intersects(t,e){if(!e){const G=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=G)return!1;const O=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>O}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=pi[0].set(t.left,t.top),l=pi[1].set(t.left,t.bottom),u=pi[2].set(t.right,t.top),c=pi[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(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))return!1;const p=h*(l.y-a.y),f=h*(a.x-l.x),m=p*i+f*n,_=p*s+f*n,g=p*i+f*o,b=p*s+f*o;if(Math.max(m,_,g,b)<=p*a.x+f*a.y||Math.min(m,_,g,b)>=p*c.x+f*c.y)return!1;const v=h*(a.y-u.y),x=h*(u.x-a.x),T=v*i+x*n,E=v*s+x*n,S=v*i+x*o,A=v*s+x*o;return!(Math.max(T,E,S,A)<=v*a.x+x*a.y||Math.min(T,E,S,A)>=v*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const 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){const 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),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new z),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}}const lc=new M;class st{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=lc,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);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=lc,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,c=n.tx,h=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+h;g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*e+c,b=a*i+u*e+h,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*t+l*s+c,b=a*t+u*s+h,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*s+c,b=a*i+u*s+h,g<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.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:u,tx:c,ty:h}=t;let p=o*e+l*i+c,f=a*e+u*i+h;this.minX=p,this.minY=f,this.maxX=p,this.maxY=f,p=o*s+l*i+c,f=a*s+u*i+h,this.minX=p<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,p=o*e+l*n+c,f=a*e+u*n+h,this.minX=p<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,p=o*s+l*n+c,f=a*s+u*n+h,this.minX=p<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 st(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,s){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;s||(s=this.matrix);const u=s.a,c=s.b,h=s.c,p=s.d,f=s.tx,m=s.ty;for(let _=e;_<i;_+=2){const g=t[_],b=t[_+1],v=u*g+h*b+f,x=c*g+p*b+m;n=v<n?v:n,o=x<o?x:o,a=v>a?v:a,l=x>l?x: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 hi(M),Lt=new hi(st),Wx=new M,uc={getFastGlobalBounds(r,t){t||(t=new st),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=Lt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,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(Wx).invert()),t.addBounds(i,this.relativeGroupTransform)),t.addBounds(i),Lt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Lt.return(i))}};function fr(r,t,e){e.clear();let i,s;return r.parent?t?i=r.parent.worldTransform:(s=ct.get().identity(),i=fi(r,s)):i=M.IDENTITY,cc(r,e,i,t),s&&ct.return(s),e.isValid||e.set(0,0,0,0),e}function cc(r,t,e,i){var s,n;if(!r.visible||!r.measurable)return;let o;i?o=r.worldTransform:(r.updateLocalTransform(),o=ct.get(),o.appendFrom(r.localTransform,e));const a=t,l=!!r.effects.length;if(l&&(t=Lt.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++)cc(r.children[u],t,o,i)}if(l){for(let u=0;u<r.effects.length;u++)(n=(s=r.effects[u]).addBounds)==null||n.call(s,t);a.addBounds(t,M.IDENTITY),Lt.return(t)}i||ct.return(o)}function fi(r,t){const e=r.parent;return e&&(fi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function pn(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,i=r>>8&255,s=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=i*o/255|0,c=s*a/255|0;return(l<<16)+(u<<8)+c}const hc=16777215;function mr(r,t){return r===hc?t:t===hc?r:pn(r,t)}function Be(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const dc={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){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=fi(this,ct.get().identity());return r.appendFrom(this.localTransform,e),ct.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?Be(this.renderGroup.worldColor):this.parentRenderGroup?Be(mr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=mr(t,e.localColor),e=e.parent;return Be(t)}};function mi(r,t,e){return t.clear(),e||(e=M.IDENTITY),pc(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function pc(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();const c=r.localTransform;a=ct.get(),a.appendFrom(c,e)}const l=t,u=!!r.effects.length;if(u&&(t=Lt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const c=r.children;for(let h=0;h<c.length;h++)pc(c[h],t,a,i,!1)}if(u){for(let c=0;c<r.effects.length;c++)(o=(n=r.effects[c]).addLocalBounds)==null||o.call(n,t,i);l.addBounds(t,M.IDENTITY),Lt.return(t)}ct.return(a)}function fn(r,t){const e=r.children;for(let i=0;i<e.length;i++){const s=e[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,s.children.length&&fn(s,t)}return t.didChange}const Yx=new M,fc={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new st});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),fn(this,r),r.didChange&&mi(this,r.localBounds,Yx),r.localBounds},getBounds(r,t){return fr(this,r,t||new st)}},mc={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},gc={_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}const _c={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){const i=this.getGlobalTransform(ct.get(),e);return t=i.apply(r,t),ct.return(i),t},toLocal(r,t,e,i){t&&(r=t.toGlobal(r,e,i));const s=this.getGlobalTransform(ct.get(),i);return e=s.applyInverse(r,e),ct.return(s),e}};class mn{constructor(){this.uid=Y("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 he(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function gn(r){return!(r&r-1)&&!!r}function qx(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function It(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var Zx=Object.defineProperty,bc=Object.getOwnPropertySymbols,Qx=Object.prototype.hasOwnProperty,Jx=Object.prototype.propertyIsEnumerable,yc=(r,t,e)=>t in r?Zx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vc=(r,t)=>{for(var e in t||(t={}))Qx.call(t,e)&&yc(r,e,t[e]);if(bc)for(var e of bc(t))Jx.call(t,e)&&yc(r,e,t[e]);return r};const xc=Object.create(null);function t0(r){const t=xc[r];return t===void 0&&(xc[r]=Y("resource")),t}const Tc=class zv extends pt{constructor(t={}){var e,i,s,n,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=vc(vc({},zv.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(s=t.addressModeW)!=null?s:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=t0(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Tc.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Rt=Tc;var e0=Object.defineProperty,Sc=Object.getOwnPropertySymbols,r0=Object.prototype.hasOwnProperty,i0=Object.prototype.propertyIsEnumerable,Ec=(r,t,e)=>t in r?e0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ac=(r,t)=>{for(var e in t||(t={}))r0.call(t,e)&&Ec(r,e,t[e]);if(Sc)for(var e of Sc(t))i0.call(t,e)&&Ec(r,e,t[e]);return r};const Pc=class Vv extends pt{constructor(t={}){var e,i,s;super(),this.options=t,this.uid=Y("textureSource"),this._resourceType="textureSource",this._resourceId=Y("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=Ac(Ac({},Vv.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(s=this.resourceHeight)!=null?s: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 Rt(It(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Y("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const s=Math.round(t*i),n=Math.round(e*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Y("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=gn(this.pixelWidth)&&gn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Pc.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let q=Pc;const de=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pe=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],fe=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],me=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],_n=[],wc=[],gi=Math.sign;function s0(){for(let r=0;r<16;r++){const t=[];_n.push(t);for(let e=0;e<16;e++){const i=gi(de[r]*de[e]+fe[r]*pe[e]),s=gi(pe[r]*de[e]+me[r]*pe[e]),n=gi(de[r]*fe[e]+fe[r]*me[e]),o=gi(pe[r]*fe[e]+me[r]*me[e]);for(let a=0;a<16;a++)if(de[a]===i&&pe[a]===s&&fe[a]===n&&me[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new M;t.set(de[r],pe[r],fe[r],me[r],0,0),wc.push(t)}}s0();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=>de[r],uY:r=>pe[r],vX:r=>fe[r],vY:r=>me[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>_n[r][t],sub:(r,t)=>_n[r][$.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?$.S:$.N:Math.abs(t)*2<=Math.abs(r)?r>0?$.E:$.W:t>0?r>0?$.SE:$.SW:r>0?$.NE:$.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=wc[$.inv(t)];s.tx=e,s.ty=i,r.append(s)}},bn=()=>{};var n0=Object.defineProperty,o0=Object.defineProperties,a0=Object.getOwnPropertyDescriptors,Rc=Object.getOwnPropertySymbols,l0=Object.prototype.hasOwnProperty,u0=Object.prototype.propertyIsEnumerable,Mc=(r,t,e)=>t in r?n0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,c0=(r,t)=>{for(var e in t||(t={}))l0.call(t,e)&&Mc(r,e,t[e]);if(Rc)for(var e of Rc(t))u0.call(t,e)&&Mc(r,e,t[e]);return r},h0=(r,t)=>o0(r,a0(t));class _i extends q{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super(h0(c0({},t),{resource:e,format:i})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}_i.extension=y.TextureSource;const Cc=new M;class yn{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,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const 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(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,s=t.trim;s&&(Cc.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Cc));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+l)/n.width,o[1]=(t.frame.y+a+l)/n.height,o[2]=(t.frame.x+t.frame.width-a+l)/n.width,o[3]=(t.frame.y+t.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class P extends pt{constructor({source:t,label:e,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:u}={}){var c;if(super(),this.uid=Y("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=(c=t==null?void 0:t.source)!=null?c:new q,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:h,height:p}=this._source;this.frame.width=h,this.frame.height=p}this.orig=s||this.frame,this.trim=n,this.rotate=l!=null?l:0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new yn(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:s}=this._source,n=e.x/i,o=e.y/s,a=e.width/i,l=e.height/s;let u=this.rotate;if(u){const c=a/2,h=l/2,p=n+c,f=o+h;u=$.add(u,$.NW),t.x0=p+c*$.uX(u),t.y0=f+h*$.uY(u),u=$.add(u,2),t.x1=p+c*$.uX(u),t.y1=f+h*$.uY(u),u=$.add(u,2),t.x2=p+c*$.uX(u),t.y2=f+h*$.uY(u),u=$.add(u,2),t.x3=p+c*$.uX(u),t.y3=f+h*$.uY(u)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+l,t.x3=n,t.y3=o+l}destroy(t=!1){this._source&&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=bn,P.WHITE=new P({source:new _i({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),P.WHITE.destroy=bn;var d0=Object.defineProperty,p0=Object.defineProperties,f0=Object.getOwnPropertyDescriptors,Oc=Object.getOwnPropertySymbols,m0=Object.prototype.hasOwnProperty,g0=Object.prototype.propertyIsEnumerable,Gc=(r,t,e)=>t in r?d0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_0=(r,t)=>{for(var e in t||(t={}))m0.call(t,e)&&Gc(r,e,t[e]);if(Oc)for(var e of Oc(t))g0.call(t,e)&&Gc(r,e,t[e]);return r},b0=(r,t)=>p0(r,f0(t));let y0=0;class Bc{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Rt(this.textureOptions)}createTexture(t,e,i){const s=new q(b0(_0({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1}));return new P({source:s,label:`texturePool_${y0++}`})}getOptimalTexture(t,e,i=1,s){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=he(n),o=he(o);const a=(n<<17)+(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)),l.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){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const rt=new Bc;class Ic{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 mn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const 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&&(rt.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let 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);return}const 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:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const 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 this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new M),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(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(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const 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 bi(r,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(r[i]=t[i])}const vn=new et(null),xn=new et(null),Tn=new et(null,1,1),gr=1,yi=2,Ie=4,v0=8;class lt extends pt{constructor(t={}){var e,i;super(),this.uid=Y("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 et(this,0,0),this._scale=Tn,this._pivot=xn,this._skew=vn,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=[],bi(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(s=>this.addChild(s)),(i=t.parent)==null||i.addChild(this)}static mixin(t){B.mixin(lt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.addChild(t[s]);return t[0]}const 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):(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++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.removeChild(t[s]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=ot.get(Ic,this),this.groupTransform=M.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),ot.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new 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*qu}set angle(t){this.rotation=t*Zu}get pivot(){return this._pivot===xn&&(this._pivot=new et(this,0,0)),this._pivot}set pivot(t){this._pivot===xn&&(this._pivot=new et(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===vn&&(this._skew=new et(this,0,0)),this._skew}set skew(t){this._skew===vn&&(this._skew=new et(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Tn&&(this._scale=new et(this,1,1)),this._scale}set scale(t){this._scale===Tn&&(this._scale=new et(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const s=this.getLocalBounds();typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,s=this._pivot,n=this._position,o=i._x,a=i._y,l=s._x,u=s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=n._x-(l*e.a+u*e.c),e.ty=n._y-(l*e.b+u*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=gr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=H.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=gr,this._onUpdate())}get tint(){return Be(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=yi,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ie,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ie,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Ie,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let 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(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let s=0;s<i.length;++s)i[s].destroy(t);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}}B.mixin(lt,tc,uc,_c,mc,fc,oc,ac,gc,Yu,Ju,dc,ec);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}}var Sn=/iPhone/i,Fc=/iPod/i,Dc=/iPad/i,Uc=/\biOS-universal(?:.+)Mac\b/i,En=/\bAndroid(?:.+)Mobile\b/i,kc=/Android/i,De=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,vi=/Silk/i,Yt=/Windows Phone/i,$c=/\bWindows(?:.+)ARM\b/i,Lc=/BlackBerry/i,Nc=/BB10/i,Xc=/Opera Mini/i,Hc=/\b(CriOS|Chrome)(?:.+)Mobile/i,jc=/Mobile(?:.+)Firefox\b/i,zc=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function x0(r){return function(t){return t.test(r)}}function Vc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var s=x0(e),n={apple:{phone:s(Sn)&&!s(Yt),ipod:s(Fc),tablet:!s(Sn)&&(s(Dc)||zc(t))&&!s(Yt),universal:s(Uc),device:(s(Sn)||s(Fc)||s(Dc)||s(Uc)||zc(t))&&!s(Yt)},amazon:{phone:s(De),tablet:!s(De)&&s(vi),device:s(De)||s(vi)},android:{phone:!s(Yt)&&s(De)||!s(Yt)&&s(En),tablet:!s(Yt)&&!s(De)&&!s(En)&&(s(vi)||s(kc)),device:!s(Yt)&&(s(De)||s(vi)||s(En)||s(kc))||s(/\bokhttp\b/i)},windows:{phone:s(Yt),tablet:s($c),device:s(Yt)||s($c)},other:{blackberry:s(Lc),blackberry10:s(Nc),opera:s(Xc),firefox:s(jc),chrome:s(Hc),device:s(Lc)||s(Nc)||s(Xc)||s(jc)||s(Hc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var Wc;const Yc=((Wc=Vc.default)!=null?Wc:Vc)(globalThis.navigator);var T0=Object.defineProperty,Kc=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,E0=Object.prototype.propertyIsEnumerable,qc=(r,t,e)=>t in r?T0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zc=(r,t)=>{for(var e in t||(t={}))S0.call(t,e)&&qc(r,e,t[e]);if(Kc)for(var e of Kc(t))E0.call(t,e)&&qc(r,e,t[e]);return r};const A0=9,xi=100,P0=0,w0=0,Qc=2,Jc=1,R0=-1e3,M0=-1e3,C0=2,An=class Wv{constructor(t,e=Yc){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(){const t=document.createElement("button");t.style.width=`${Jc}px`,t.style.height=`${Jc}px`,t.style.position="absolute",t.style.top=`${R0}px`,t.style.left=`${M0}px`,t.style.zIndex=C0.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.width=`${xi}px`,this._div.style.height=`${xi}px`,this._div.style.position="absolute",this._div.style.top=`${P0}px`,this._div.style.left=`${w0}px`,this._div.style.zIndex=Qc.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)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){const e=Wv.defaultOptions,i={accessibilityOptions:Zc(Zc({},e),(t==null?void 0:t.accessibilityOptions)||{})};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.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(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas))return;const 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;i>=0;i--){const 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,dn(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)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const 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);const{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||(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=`
color: transparent;
pointer-events: none;
padding: 0;
margin: 0;
border: 0;
outline: 0;
background: transparent;
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
`,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${xi}px`,e.style.height=`${xi}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Qc.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t.interactive&&(t._accessibleDiv.tabIndex=t.tabIndex)}_dispatchEvent(t,e){const{container:i}=t.target,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){t.keyCode!==A0||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||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()}};An.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"accessibility"},An.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let th=An;const eh={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};B.add(th),B.mixin(lt,eh);class Pn{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Pn.extension=y.Application;var Kt=(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))(Kt||{});class Ti{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){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const rh=class Pt{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 Ti(null,null,1/0),this.deltaMS=1/Pt.targetFPMS,this.elapsedMS=1/Pt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Kt.NORMAL){return this._addListener(new Ti(t,e,i))}addOnce(t,e,i=Kt.NORMAL){return this._addListener(new Ti(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Pt.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Pt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Pt._shared){const t=Pt._shared=new Pt;t.autoStart=!0,t._protected=!0}return Pt._shared}static get system(){if(!Pt._system){const t=Pt._system=new Pt;t.autoStart=!0,t._protected=!0}return Pt._system}};rh.targetFPMS=.06;let ut=rh;class wn{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&&e.add(this.render,this,Kt.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(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}wn.extension=y.Application,B.add(Pn),B.add(wn);let O0=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,Kt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ut.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}};const qt=new O0;class _r 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,h,p,f,m,_){throw new Error("Method not implemented.")}}class Mt extends _r{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ge extends _r{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}ge.DOM_DELTA_PIXEL=0,ge.DOM_DELTA_LINE=1,ge.DOM_DELTA_PAGE=2;const G0=2048,B0=new V,br=new V;class ih{constructor(t){this.dispatch=new pt,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)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t)}hitTest(t,e){qt.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,B0.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const 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;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<G0&&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((t.eventMode==="dynamic"||e==="dynamic")&&(qt.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let h=c.length-1;h>=0;h--){const p=c[h],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(qt.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=i;for(let c=l.length-1;c>=0;c--){const h=l[c],p=this.hitTestRecursive(h,this._isInteractive(e)?e:h.eventMode,u,s,n);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,br),!t.hitArea.contains(br.x,br.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,br),t.containsPoint(br)):!1}notifyTarget(t,e){var i,s;if(!t.currentTarget.isInteractive())return;e!=null||(e=t.type);const n=`on${e}`;(s=(i=t.currentTarget)[n])==null||s.call(i,t);const o=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,o),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Mt))return;const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,s;if(!(t instanceof Mt))return;this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=n.pointerType==="mouse"||n.pointerType==="pen",a=this.trackingData(t.pointerId),l=this.findMountedTarget(a.overTargets);if(((e=a.overTargets)==null?void 0:e.length)>0&&l!==n.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,l);if(this.dispatchEvent(p,"pointerout"),o&&this.dispatchEvent(p,"mouseout"),!n.composedPath().includes(l)){const 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(p)}if(l!==n.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(n,h);this.dispatchEvent(p,"pointerover"),o&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const 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(p)}const u=[],c=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),c&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),c&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),c&&u.push("globalmousemove"),this.cursor=(s=n.target)==null?void 0:s.cursor),u.length>0&&this.all(n,u),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof Mt))return;const i=this.trackingData(t.pointerId),s=this.createPointerEvent(t),n=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(e=s.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(s,"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=s.composedPath(),this.freeEvent(s),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Mt))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=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))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=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);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const u=a.button===2;this.dispatchEvent(a,u?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof Mt))return;const 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"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof ge))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}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 s;const 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=(s=i!=null?i:this.hitTest(n.global.x,n.global.y))!=null?s:this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(ge);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const 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=e!=null?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 _r&&e instanceof _r&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const 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 I0=Object.defineProperty,sh=Object.getOwnPropertySymbols,F0=Object.prototype.hasOwnProperty,D0=Object.prototype.propertyIsEnumerable,nh=(r,t,e)=>t in r?I0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,U0=(r,t)=>{for(var e in t||(t={}))F0.call(t,e)&&nh(r,e,t[e]);if(sh)for(var e of sh(t))D0.call(t,e)&&nh(r,e,t[e]);return r};const k0=1,$0={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Rn=class Tu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ih(null),qt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Mt(null),this._rootWheelEvent=new ge(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(U0({},Tu.defaultEventFeatures),{set:(e,i,s)=>(i==="globalMove"&&(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 e,i;const{canvas:s,resolution:n}=this.renderer;this.setTargetElement(s),this.resolution=n,Tu._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),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)return;this._currentCursor=t;const 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);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,qt.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const 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)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,qt.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;qt.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;qt.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const 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){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button=="undefined"&&(n.button=0),typeof n.buttons=="undefined"&&(n.buttons=1),typeof n.isPrimary=="undefined"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width=="undefined"&&(n.width=n.radiusX||1),typeof n.height=="undefined"&&(n.height=n.radiusY||1),typeof n.tiltX=="undefined"&&(n.tiltX=0),typeof n.tiltY=="undefined"&&(n.tiltY=0),typeof n.pointerType=="undefined"&&(n.pointerType="touch"),typeof n.pointerId=="undefined"&&(n.pointerId=n.identifier||0),typeof n.pressure=="undefined"&&(n.pressure=n.force||.5),typeof n.twist=="undefined"&&(n.twist=0),typeof n.tangentialPressure=="undefined"&&(n.tangentialPressure=0),typeof n.layerX=="undefined"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY=="undefined"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary=="undefined"&&(i.isPrimary=!0),typeof i.width=="undefined"&&(i.width=1),typeof i.height=="undefined"&&(i.height=1),typeof i.tiltX=="undefined"&&(i.tiltX=0),typeof i.tiltY=="undefined"&&(i.tiltY=0),typeof i.pointerType=="undefined"&&(i.pointerType="mouse"),typeof i.pointerId=="undefined"&&(i.pointerId=k0),typeof i.pressure=="undefined"&&(i.pressure=.5),typeof i.twist=="undefined"&&(i.twist=0),typeof i.tangentialPressure=="undefined"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=$0[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}};Rn.extension={name:"events",type:[y.WebGLSystem,y.CanvasSystem,y.WebGPUSystem],priority:-1},Rn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Mn=Rn;const oh={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){var r;return(r=this._internalEventMode)!=null?r:Mn.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?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){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Fe))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};B.add(Mn),B.mixin(lt,oh);class Cn{constructor(t){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)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){var t;const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}const i=this._renderer.view.canvas;this._domElement.parentNode!==i.parentNode&&((t=i.parentNode)==null||t.appendChild(this._domElement));const s=parseFloat(i.style.width)/i.width*this._renderer.resolution,n=parseFloat(i.style.height)/i.height*this._renderer.resolution;this._domElement.style.transform=`translate(${i.offsetLeft}px, ${i.offsetTop}px) scale(${s}, ${n})`;for(let o=0;o<e.length;o++){const a=e[o],l=a.element;if(!a.parent||a.globalDisplayStatus<7)l==null||l.remove(),e.splice(o,1),o--;else{this._domElement.contains(l)||(l.style.position="absolute",l.style.pointerEvents="auto",this._domElement.appendChild(l));const u=a.worldTransform,c=a._anchor,h=a.width*c.x,p=a.height*c.y;l.style.transformOrigin=`${h}px ${p}px`,l.style.transform=`matrix(${u.a}, ${u.b}, ${u.c}, ${u.d}, ${u.tx-h}, ${u.ty-p})`,l.style.opacity=a.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._renderer=null}}Cn.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"dom"};class Nt extends lt{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new st(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const s in this._gpuData)(i=(e=this._gpuData[s]).destroy)==null||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.setBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,o=n.length;for(let a=0;a<o;a++)n[a].collectRenderables(t,e,i)}}var L0=Object.defineProperty,Si=Object.getOwnPropertySymbols,ah=Object.prototype.hasOwnProperty,lh=Object.prototype.propertyIsEnumerable,uh=(r,t,e)=>t in r?L0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,N0=(r,t)=>{for(var e in t||(t={}))ah.call(t,e)&&uh(r,e,t[e]);if(Si)for(var e of Si(t))lh.call(t,e)&&uh(r,e,t[e]);return r},X0=(r,t)=>{var e={};for(var i in r)ah.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Si)for(var i of Si(r))t.indexOf(i)<0&&lh.call(r,i)&&(e[i]=r[i]);return e};class H0 extends Nt{constructor(t={}){const e=t,{element:i,anchor:s}=e,n=X0(e,["element","anchor"]);super(N0({label:"DOMContainer"},n)),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){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:i,offsetHeight:s}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=s}destroy(t=!1){var e,i;super.destroy(t),(i=(e=this._element)==null?void 0:e.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}B.add(Cn);var xt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(xt||{});const ch={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let hh=ch;const L={get(){return hh},set(r){hh=r}};function Ft(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function yr(r){return r.split("?")[0].split("#")[0]}function j0(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z0(r,t,e){return r.replace(new RegExp(j0(t),"g"),e)}function V0(r,t){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(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const ft={toPosix(r){return z0(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Ft(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Ft(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=yr(this.toPosix(t!=null?t:L.get().getBaseUrl())),s=yr(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ft.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Ft(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=V0(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Ft(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let i=0;i<r.length;++i){const s=r[i];if(Ft(s),s.length>0)if(e===void 0)e=s;else{const n=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Ft(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){Ft(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Ft(r),t&&Ft(t),r=yr(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){Ft(r),r=yr(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Ft(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=yr(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;const n="";t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let o=-1,a=0,l=-1,u=!0,c=r.length-1,h=0;for(;c>=s;--c){if(e=r.charCodeAt(c),e===47){if(!u){a=c+1;break}continue}l===-1&&(u=!1,l=c+1),e===46?o===-1?o=c:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||l===-1||h===0||h===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&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),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Ct=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function dh(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?dh(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function ph(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),dh(r,s,0,e,i)}else i.push(r);return i}const vr=r=>!Array.isArray(r);var W0=Object.defineProperty,Y0=Object.defineProperties,K0=Object.getOwnPropertyDescriptors,fh=Object.getOwnPropertySymbols,q0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,mh=(r,t,e)=>t in r?W0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ue=(r,t)=>{for(var e in t||(t={}))q0.call(t,e)&&mh(r,e,t[e]);if(fh)for(var e of fh(t))Z0.call(t,e)&&mh(r,e,t[e]);return r},Q0=(r,t)=>Y0(r,K0(t));class ie{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,i,s;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(s=t.extractAssetIdFromBundle)!=null?s:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Ct(e||i,s=>typeof s=="string"?s:Array.isArray(s)?s.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):s!=null&&s.src?s.src:s,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Ue({alias:n},o))),s.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const 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(Q0(Ue({},n),{alias:l,src:o}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;Ct(e).forEach(s=>{const{src:n}=s;let{data:o,format:a,loadParser:l}=s;const u=Ct(n).map(p=>typeof p=="string"?ph(p):Array.isArray(p)?p:[p]),c=this.getAlias(s),h=[];u.forEach(p=>{p.forEach(f=>{var m,_,g;let b={};if(typeof f!="object"){b.src=f;for(let v=0;v<this._parsers.length;v++){const x=this._parsers[v];if(x.test(f)){b=x.parse(f);break}}}else o=(m=f.data)!=null?m:o,a=(_=f.format)!=null?_:a,l=(g=f.loadParser)!=null?g: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}),h.push(b)})}),c.forEach(p=>{this._assetMap[p]=h})})}resolveBundle(t){const e=vr(t);t=Ct(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(s,l)]=u}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=vr(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);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(c=>c[a]?c[a]===l:!1);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){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,s;const{aliases:n,data:o,loadParser:a,format:l}=e;return(this._basePath||this._rootPath)&&(t.src=ft.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=n!=null?n:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Ue(Ue({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=(s=l!=null?l:t.format)!=null?s:gh(t.src),t}}ie.RETINA_PREFIX=/@([0-9\.]+)x/;function gh(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ei=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},_h=class li{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof q&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof P?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.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<=li.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=li.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const u=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new z(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);n.rotated?a=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):a=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),n.trimmed!==!1&&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:c,trim:l,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:s.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*li.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*li.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};_h.BATCH_SIZE=1e3;let On=_h;const J0=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function bh(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=ft.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=bh([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const yh={extension:y.Asset,cache:{test:r=>r instanceof On,getCacheableAssets:(r,t)=>bh(r,t,!1)},resolver:{extension:{type:y.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&J0.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=ie.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:y.LoadParser,priority:xt.Normal,name:"spritesheetLoader"},async testParse(r,t){return ft.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,s,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let c=ft.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(o instanceof P)h=o;else{const m=Ei(c+(a!=null?a:r.meta.image),t.src);h=(await e.load([{src:m,data:l}]))[m]}const p=new On({texture:h.source,data:r,cachePrefix:u});await p.parse();const f=(s=r==null?void 0:r.meta)==null?void 0:s.related_multi_packs;if(Array.isArray(f)){const m=[];for(const g of f){if(typeof g!="string")continue;let b=c+g;(n=t.data)!=null&&n.ignoreMultiPack||(b=Ei(b,t.src),m.push(e.load({src:b,data:{textureOptions:l,ignoreMultiPack:!0}})))}const _=await Promise.all(m);p.linkedSheets=_,_.forEach(g=>{g.linkedSheets=[p].concat(p.linkedSheets.filter(b=>b!==g))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};B.add(yh);function Gn(r,t,e){const{width:i,height:s}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*i,r.maxX=r.minX+o,r.minY=n.y-t._y*s,r.maxY=r.minY+a}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*s,r.maxY=r.minY+s}var t1=Object.defineProperty,Ai=Object.getOwnPropertySymbols,vh=Object.prototype.hasOwnProperty,xh=Object.prototype.propertyIsEnumerable,Th=(r,t,e)=>t in r?t1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e1=(r,t)=>{for(var e in t||(t={}))vh.call(t,e)&&Th(r,e,t[e]);if(Ai)for(var e of Ai(t))xh.call(t,e)&&Th(r,e,t[e]);return r},r1=(r,t)=>{var e={};for(var i in r)vh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ai)for(var i of Ai(r))t.indexOf(i)<0&&xh.call(r,i)&&(e[i]=r[i]);return e};class Dt extends Nt{constructor(t=P.EMPTY){t instanceof P&&(t={texture:t});const e=t,{texture:i=P.EMPTY,anchor:s,roundPixels:n,width:o,height:a}=e,l=r1(e,["texture","anchor","roundPixels","width","height"]);super(e1({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new et({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof P?new Dt(t):new Dt(P.from(t,e))}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Gn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const i1=new st;function Pi(r,t,e){const i=i1;r.measurable=!0,fr(r,e,i),t.addBoundsMask(i),r.measurable=!1}function wi(r,t,e){const i=Lt.get();r.measurable=!0;const s=ct.get().identity(),n=Sh(r,e,s);mi(r,i,n),r.measurable=!1,t.addBoundsMask(i),ct.return(s),Lt.return(i)}function Sh(r,t,e){return r&&r!==t&&(Sh(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Bn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Dt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Pi(this.mask,t,e)}addLocalBounds(t,e){wi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Dt}}Bn.extension=y.MaskEffect;class In{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}In.extension=y.MaskEffect;class Fn{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Pi(this.mask,t,e)}addLocalBounds(t,e){wi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof lt}}Fn.extension=y.MaskEffect;class Xt extends q{constructor(t){t.resource||(t.resource=L.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}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"))}}Xt.extension=y.TextureSource;class se extends q{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}se.extension=y.TextureSource;let Dn;async function Un(){return Dn!=null||(Dn=(async()=>{var r;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const 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);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(s),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Dn}var s1=Object.defineProperty,n1=Object.defineProperties,o1=Object.getOwnPropertyDescriptors,Eh=Object.getOwnPropertySymbols,a1=Object.prototype.hasOwnProperty,l1=Object.prototype.propertyIsEnumerable,Ah=(r,t,e)=>t in r?s1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kn=(r,t)=>{for(var e in t||(t={}))a1.call(t,e)&&Ah(r,e,t[e]);if(Eh)for(var e of Eh(t))l1.call(t,e)&&Ah(r,e,t[e]);return r},u1=(r,t)=>n1(r,o1(t));const Ri=class Yv extends q{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=kn(kn({},Yv.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=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)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Un(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ut.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ut.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(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}};Ri.extension=y.TextureSource,Ri.defaultOptions=u1(kn({},q.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Ri.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let xr=Ri,c1=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const i=Ct(t);let s;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.test(e)){s=u.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(l=>{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=s?s[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}};const W=new c1,$n=[];B.handleByList(y.TextureSource,$n);function h1(r={}){return Ln(r)}function Ln(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s<$n.length;s++){const n=$n[s];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Ph(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,s=e?r:{resource:r};if(!t&&W.has(i))return W.get(i);const n=new P({source:Ln(s)});return n.on("destroy",()=>{W.has(i)&&W.remove(i)}),t||W.set(i,n),n}function wh(r,t=!1){return typeof r=="string"?W.get(r):r instanceof q?new P({source:r}):Ph(r,t)}P.from=wh,q.from=Ln,B.add(Bn,In,Fn,xr,se,Xt,_i);class Ht{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,s;const n=this.resources[e];t!==n&&(n&&((i=t.off)==null||i.call(t,"change",this.onResourceChange,this)),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}const Rh={};function Mi(r,t,e){let i=2166136261;for(let s=0;s<t;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return Rh[i]||d1(r,t,i,e)}function d1(r,t,e,i){const s={};let n=0;for(let a=0;a<i;a++){const l=a<t?r[a]:P.EMPTY.source;s[n++]=l.source,s[n++]=l.style}const o=new Ht(s);return Rh[e]=o,o}class _e{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._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`)}}}const Mh={},p1="8.0.0",f1="8.3.4";function Ch(r,t,e=3){if(Mh[t])return;let i=new Error().stack;typeof i=="undefined"?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))),Mh[t]=!0}function Ci(r,t){const e=r.byteLength/8|0,i=new Float64Array(r,0,e);new Float64Array(t,0,e).set(i);const s=r.byteLength-e*8;if(s>0){const n=new Uint8Array(r,e*8,s);new Uint8Array(t,e*8,s).set(n)}}const Oh={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))(J||{});function ke(r,t){return t.alphaMode==="no-premultiply-alpha"&&Oh[r]||r}let Tr;function Nn(){return(!Tr||Tr!=null&&Tr.isContextLost())&&(Tr=L.get().createCanvas().getContext("webgl",{})),Tr}const m1=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`);function g1(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Xn(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=m1.replace(/%forloop%/gi,g1(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let $e=null;function Gh(){var r;if($e)return $e;const t=Nn();return $e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),$e=Xn($e,t),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),$e}class Bh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}var _1=Object.defineProperty,Ih=Object.getOwnPropertySymbols,b1=Object.prototype.hasOwnProperty,y1=Object.prototype.propertyIsEnumerable,Fh=(r,t,e)=>t in r?_1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dh=(r,t)=>{for(var e in t||(t={}))b1.call(t,e)&&Fh(r,e,t[e]);if(Ih)for(var e of Ih(t))y1.call(t,e)&&Fh(r,e,t[e]);return r};class Uh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Bh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const kh=[];let Hn=0;function $h(){return Hn>0?kh[--Hn]:new Uh}function Lh(r){kh[Hn++]=r}let Sr=0;const Nh=class Kv{constructor(t){this.uid=Y("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=Dh(Dh({},Kv.defaultOptions),t),t.maxTextures||(Ch("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Gh());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:s}=t;this.attributeBuffer=new _e(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Lh(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=$h(),s=i.textures;s.clear();const n=e[this.elementStart];let o=ke(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer;let h=this._batchIndexSize,p=this._batchIndexStart,f="startBatch";const m=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const g=e[_];e[_]=null;const b=g.texture._source,v=ke(g.blendMode,b),x=o!==v||a!==g.topology;if(b._batchTick===Sr&&!x){g._textureId=b._textureBindLocation,h+=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;continue}b._batchTick=Sr,(s.count>=m||x)&&(this._finishBatch(i,p,h-p,s,o,a,t,f),f="renderBatch",p=h,o=v,a=g.topology,i=$h(),s=i.textures,s.clear(),++Sr),g._textureId=b._textureBindLocation=s.count,s.ids[b.uid]=s.count,s.textures[s.count++]=b,g._batch=i,h+=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))}s.count>0&&(this._finishBatch(i,p,h-p,s,o,a,t,f),p=h,++Sr),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=h}_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,++Sr,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new _e(e);Ci(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)s[n]=e[n];else Ci(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){const 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++)Lh(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}};Nh.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Xh=Nh;var X=(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))(X||{});class mt extends pt{constructor(t){let{data:e,size:i}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this.uid=Y("buffer"),this._resourceType="buffer",this._resourceId=Y("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i!=null||(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&X.STATIC)}set static(t){t?this.descriptor.usage|=X.STATIC:this.descriptor.usage&=~X.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const s=this._data;if(this._data=t,this._dataInt32=null,!s||s.length!==t.length){!this.shrinkToFit&&s&&t.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=Y("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t!=null?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 jn(r,t){if(!(r instanceof mt)){let e=t?X.INDEX:X.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=X.INDEX|X.COPY_DST):(r=new Float32Array(r),e=X.VERTEX|X.COPY_DST)),r=new mt({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function Hh(r,t,e){const i=r.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const u=s.BYTES_PER_ELEMENT,c=(i.offset||0)/u,h=(i.stride||2*4)/u;for(let p=c;p<s.length;p+=h){const f=s[p],m=s[p+1];f>a&&(a=f),m>l&&(l=m),f<n&&(n=f),m<o&&(o=m)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=l,e}function v1(r){return(r instanceof mt||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=jn(r.buffer,!1),r}class be extends pt{constructor(t={}){var e;super(),this.uid=Y("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new st,this._boundsDirty=!0;const{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=(e=t.instanceCount)!=null?e: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){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=v1(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=jn(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Hh(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 x1=new Float32Array(1),T1=new Uint32Array(1);class jh extends be{constructor(){const t=new mt({data:x1,label:"attribute-batch-buffer",usage:X.VERTEX|X.COPY_DST,shrinkToFit:!1}),e=new mt({data:T1,label:"index-batch-buffer",usage:X.INDEX|X.COPY_DST,shrinkToFit:!1}),i=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:i,offset:0},aUV:{buffer:t,format:"float32x2",stride:i,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:i,offset:20}},indexBuffer:e})}}const zn=Object.create(null),zh=Object.create(null);function Le(r,t){let e=zh[r];return e===void 0&&(zn[t]===void 0&&(zn[t]=1),zh[r]=e=zn[t]++),e}let Oi;function Vh(){if(!Oi){Oi="mediump";const r=Nn();r&&r.getShaderPrecisionFormat&&(Oi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Oi}function Wh(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),`
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${r}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${r}
`}function Yh(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float;
${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Kh(r,t){return t?`#version 300 es
${r}`:r}const S1={},E1={};function qh(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?S1:E1;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
${r}`}function Zh(r,t){return t?r.replace("#version 300 es",""):r}var A1=Object.defineProperty,Qh=Object.getOwnPropertySymbols,P1=Object.prototype.hasOwnProperty,w1=Object.prototype.propertyIsEnumerable,Jh=(r,t,e)=>t in r?A1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,td=(r,t)=>{for(var e in t||(t={}))P1.call(t,e)&&Jh(r,e,t[e]);if(Qh)for(var e of Qh(t))w1.call(t,e)&&Jh(r,e,t[e]);return r};const Vn={stripVersion:Zh,ensurePrecision:Yh,addProgramDefines:Wh,setProgramName:qh,insertVersion:Kh},Wn=Object.create(null),ed=class Su{constructor(t){t=td(td({},Su.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Vh()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(Vn).forEach(o=>{const a=i[o];s=Vn[o](s,a,!0),n=Vn[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){const e=`${t.vertex}:${t.fragment}`;return Wn[e]||(Wn[e]=new Su(t)),Wn[e]}};ed.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Tt=ed;const rd={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 Zt(r){var t;return(t=rd[r])!=null?t:rd.float32}const R1={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 id({source:r,entryPoint:t}){var e;const i={},s=r.indexOf(`fn ${t}`);if(s!==-1){const n=r.indexOf("->",s);if(n!==-1){const o=r.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let l;for(;(l=a.exec(o))!==null;){const u=(e=R1[l[3]])!=null?e:"float32";i[l[2]]={location:parseInt(l[1],10),format:u,stride:Zt(u).stride,offset:0,instance:!1,start:0}}}}return i}function Gi(r){var t,e,i;const s=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*(\w+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,p=(t=r.match(s))==null?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:m.match(a)[1]==="<uniform>",type:m.match(l)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(u))==null?void 0:e.map(m=>{const _=m.match(h)[1],g=m.match(c).reduce((b,v)=>{const[x,T]=v.split(":");return b[x.trim()]=T.trim(),b},{});return g?{name:_,members:g}:null}).filter(({name:m})=>p.some(_=>_.type===m)))!=null?i:[];return{groups:p,structs:f}}var Ne=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ne||{});function sd({groups:r}){const t=[];for(let e=0;e<r.length;e++){const 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"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ne.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Ne.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function nd({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function od(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const Yn=Object.create(null);class gt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:s,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=s,this.vertex=n,s.source===n.source){const u=Gi(s.source);this.structsAndGroups=u}else{const u=Gi(n.source),c=Gi(s.source);this.structsAndGroups=od(u,c)}this.layout=o!=null?o:nd(this.structsAndGroups),this.gpuLayout=a!=null?a:sd(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((i=this.layout[1])==null?void 0:i.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Le(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=id(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Yn[e]||(Yn[e]=new gt(t)),Yn[e]}}function Kn(r,t,e){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=t[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const M1=/\{\{(.*?)\}\}/g;function qn(r){var t,e;const i={};return((e=(t=r.match(M1))==null?void 0:t.map(s=>s.replace(/[{()}]/g,"")))!=null?e:[]).forEach(s=>{i[s]=[]}),i}function ad(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function Zn(r,t,e=!1){const i=[];ad(t,i),r.forEach(a=>{a.header&&ad(a.header,i)});const s=i;e&&s.sort();const n=s.map((a,l)=>` @location(${l}) ${a},`).join(`
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}function ld(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function C1(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function O1(r){const t=/@.*?\s+/g;return r.replace(t,"")}function ud(r,t){const e=[];ld(t,e),r.forEach(l=>{l.header&&ld(l.header,e)});let i=0;const s=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
`),n=e.sort().map(l=>` var ${O1(l)};`).join(`
`),o=`return VSOutput(
${e.sort().map(l=>` ${C1(l)}`).join(`,
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${s}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}function Qn(r,t){let e=r;for(const i in t){const s=t[i];s.join(`
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
${s.join(`
`)}
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const ye=Object.create(null),Jn=new Map;let G1=0;function cd({template:r,bits:t}){const e=dd(r,t);if(ye[e])return ye[e];const{vertex:i,fragment:s}=B1(r,t);return ye[e]=pd(i,s,t),ye[e]}function hd({template:r,bits:t}){const e=dd(r,t);return ye[e]||(ye[e]=pd(r.vertex,r.fragment,t)),ye[e]}function B1(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let s=Zn(e,r.vertex,!0);s=ud(e,s);const n=Zn(i,r.fragment,!0);return{vertex:s,fragment:n}}function dd(r,t){return t.map(e=>(Jn.has(e)||Jn.set(e,G1++),Jn.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function pd(r,t,e){const i=qn(r),s=qn(t);return e.forEach(n=>{Kn(n.vertex,i,n.name),Kn(n.fragment,s,n.name)}),{vertex:Qn(r,i),fragment:Qn(t,s)}}const fd=`
@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}}
};
`,md=`
@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;
};
`,gd=`
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}}
}
`,_d=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
{{end}}
}
`,bd={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;
`}},I1={name:"global-uniforms-ubo-bit",vertex:{header:`
uniform globalUniforms {
mat3 uProjectionMatrix;
mat3 uWorldTransformMatrix;
vec4 uWorldColorAlpha;
vec2 uResolution;
};
`}},yd={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}};var F1=Object.defineProperty,vd=Object.getOwnPropertySymbols,D1=Object.prototype.hasOwnProperty,U1=Object.prototype.propertyIsEnumerable,xd=(r,t,e)=>t in r?F1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k1=(r,t)=>{for(var e in t||(t={}))D1.call(t,e)&&xd(r,e,t[e]);if(vd)for(var e of vd(t))U1.call(t,e)&&xd(r,e,t[e]);return r};function Xe({bits:r,name:t}){const e=cd({template:{fragment:md,vertex:fd},bits:[bd,...r]});return gt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function He({bits:r,name:t}){return new Tt(k1({name:t},hd({template:{vertex:gd,fragment:_d},bits:[yd,...r]})))}const Bi={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},Ii={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}},to={};function $1(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let 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(`
`)}function L1(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<r;e++)e===r-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
`)}function Fi(r){return to[r]||(to[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;
${$1(r)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${L1(r)}
`}}),to[r]}const eo={};function N1(r){const t=[];for(let e=0;e<r;e++)e>0&&t.push("else"),e<r-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
`)}function Di(r){return eo[r]||(eo[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:`
${N1(r)}
`}}),eo[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;
}
`}},ro=["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>"],Td=ro.reduce((r,t)=>(r[t]=!0,r),{});function Sd(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 X1=Object.defineProperty,Ed=Object.getOwnPropertySymbols,H1=Object.prototype.hasOwnProperty,j1=Object.prototype.propertyIsEnumerable,Ad=(r,t,e)=>t in r?X1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pd=(r,t)=>{for(var e in t||(t={}))H1.call(t,e)&&Ad(r,e,t[e]);if(Ed)for(var e of Ed(t))j1.call(t,e)&&Ad(r,e,t[e]);return r};const wd=class qv{constructor(t,e){this._touched=0,this.uid=Y("uniform"),this._resourceType="uniformGroup",this._resourceId=Y("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,s;e=Pd(Pd({},qv.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(i=a.size)!=null?i:1,!Td[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${ro.join(", ")}`);(s=a.value)!=null||(a.value=Sd(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++}};wd.defaultOptions={ubo:!1,isStatic:!1};let it=wd;const Rd={};function Ui(r){let t=Rd[r];if(t)return t;const e=new Int32Array(r);for(let i=0;i<r;i++)e[i]=i;return t=Rd[r]=new it({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}var _t=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(_t||{}),z1=Object.defineProperty,ki=Object.getOwnPropertySymbols,Md=Object.prototype.hasOwnProperty,Cd=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?z1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V1=(r,t)=>{for(var e in t||(t={}))Md.call(t,e)&&Od(r,e,t[e]);if(ki)for(var e of ki(t))Cd.call(t,e)&&Od(r,e,t[e]);return r},W1=(r,t)=>{var e={};for(var i in r)Md.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ki)for(var i of ki(r))t.indexOf(i)<0&&Cd.call(r,i)&&(e[i]=r[i]);return e};class St extends pt{constructor(t){super(),this.uid=Y("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,o===void 0&&(o=0,e&&(o|=_t.WEBGPU),i&&(o|=_t.WEBGL)),this.compatibleRenderers=o;const l={};if(!n&&!s&&(n={}),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]){const h=a[u][c];l[h]={group:u,binding:c,name:h}}else if(e&&s&&!a){const u=e.structsAndGroups.groups;a={},u.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 h=c;let p=n[c];!p.source&&!p._resourceType&&(p=new it(p));const f=l[h];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,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Ht,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const 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){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:i,gl:s}=e,n=W1(e,["gpu","gl"]);let o,a;return i&&(o=gt.from(i)),s&&(a=Tt.from(s)),new St(V1({gpuProgram:o,glProgram:a},n))}}class Gd extends St{constructor(t){const e=He({name:"batch",bits:[Ii,Di(t),ze]}),i=Xe({name:"batch",bits:[Bi,Fi(t),je]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Ui(t)}})}}let io=null;const Bd=class Zv extends Xh{constructor(t){super(t),this.geometry=new jh,this.name=Zv.extension.name,this.vertexSize=6,io!=null||(io=new Gd(t.maxTextures)),this.shader=io}packAttributes(t,e,i,s,n){const o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,u=a.b,c=a.c,h=a.d,p=a.tx,f=a.ty,{positions:m,uvs:_}=t,g=t.color,b=t.attributeOffset,v=b+t.attributeSize;for(let x=b;x<v;x++){const T=x*2,E=m[T],S=m[T+1];e[s++]=l*E+c*S+p,e[s++]=h*S+u*E+f,e[s++]=_[T],e[s++]=_[T+1],i[s++]=g,i[s++]=o}}packQuadAttributes(t,e,i,s,n){const o=t.texture,a=t.transform,l=a.a,u=a.b,c=a.c,h=a.d,p=a.tx,f=a.ty,m=t.bounds,_=m.maxX,g=m.minX,b=m.maxY,v=m.minY,x=o.uvs,T=t.color,E=n<<16|t.roundPixels&65535;e[s+0]=l*g+c*v+p,e[s+1]=h*v+u*g+f,e[s+2]=x.x0,e[s+3]=x.y0,i[s+4]=T,i[s+5]=E,e[s+6]=l*_+c*v+p,e[s+7]=h*v+u*_+f,e[s+8]=x.x1,e[s+9]=x.y1,i[s+10]=T,i[s+11]=E,e[s+12]=l*_+c*b+p,e[s+13]=h*b+u*_+f,e[s+14]=x.x2,e[s+15]=x.y2,i[s+16]=T,i[s+17]=E,e[s+18]=l*g+c*b+p,e[s+19]=h*b+u*g+f,e[s+20]=x.x3,e[s+21]=x.y3,i[s+22]=T,i[s+23]=E}};Bd.extension={type:[y.Batcher],name:"default"};let $i=Bd;function Id(r,t,e,i,s,n,o,a=null){let l=0;e*=t,s*=n;const u=a.a,c=a.b,h=a.c,p=a.d,f=a.tx,m=a.ty;for(;l<o;){const _=r[e],g=r[e+1];i[s]=u*_+h*g+f,i[s+1]=c*_+p*g+m,s+=n,e+=t,l++}}function Fd(r,t,e,i){let s=0;for(t*=e;s<i;)r[t]=0,r[t+1]=0,t+=e,s++}function so(r,t,e,i,s){const 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 h=e*i;for(let p=0;p<s;p++){const f=r[h],m=r[h+1];r[h]=n*f+a*m+u,r[h+1]=o*f+l*m+c,h+=i}}const Y1=new M;class Li{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?pn(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Y1}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 K1=Object.defineProperty,q1=Object.defineProperties,Z1=Object.getOwnPropertyDescriptors,Dd=Object.getOwnPropertySymbols,Q1=Object.prototype.hasOwnProperty,J1=Object.prototype.propertyIsEnumerable,Ud=(r,t,e)=>t in r?K1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ni=(r,t)=>{for(var e in t||(t={}))Q1.call(t,e)&&Ud(r,e,t[e]);if(Dd)for(var e of Dd(t))J1.call(t,e)&&Ud(r,e,t[e]);return r},Xi=(r,t)=>q1(r,Z1(t));const Ve={extension:{type:y.ShapeBuilder,name:"circle"},build(r,t){let e,i,s,n,o,a;if(r.type==="circle"){const T=r;if(o=a=T.radius,o<=0)return!1;e=T.x,i=T.y,s=n=0}else if(r.type==="ellipse"){const T=r;if(o=T.halfWidth,a=T.halfHeight,o<=0||a<=0)return!1;e=T.x,i=T.y,s=n=0}else{const T=r,E=T.width/2,S=T.height/2;e=T.x+E,i=T.y+S,o=a=Math.max(0,Math.min(T.radius,Math.min(E,S))),s=E-o,n=S-a}if(s<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(s?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n,!0;let c=0,h=l*4+(s?2:0)+2,p=h,f=u,m=s+o,_=n,g=e+m,b=e-m,v=i+_;if(t[c++]=g,t[c++]=v,t[--h]=v,t[--h]=b,n){const T=i-_;t[p++]=b,t[p++]=T,t[--f]=T,t[--f]=g}for(let T=1;T<l;T++){const E=Math.PI/2*(T/l),S=s+Math.cos(E)*o,A=n+Math.sin(E)*a,G=e+S,O=e-S,w=i+A,R=i-A;t[c++]=G,t[c++]=w,t[--h]=w,t[--h]=O,t[p++]=O,t[p++]=R,t[--f]=R,t[--f]=G}m=s,_=n+a,g=e+m,b=e-m,v=i+_;const x=i-_;return t[c++]=g,t[c++]=v,t[--f]=x,t[--f]=g,s&&(t[c++]=b,t[c++]=v,t[--f]=x,t[--f]=b),!0},triangulate(r,t,e,i,s,n){if(r.length===0)return;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;const u=l++;for(let c=0;c<r.length;c+=2)t[l*e]=r[c],t[l*e+1]=r[c+1],c>0&&(s[n++]=l,s[n++]=u,s[n++]=l-1),l++;s[n++]=u+1,s[n++]=u,s[n++]=l-1}},kd=Xi(Ni({},Ve),{extension:Xi(Ni({},Ve.extension),{name:"ellipse"})}),$d=Xi(Ni({},Ve),{extension:Xi(Ni({},Ve.extension),{name:"roundedRectangle"})}),no=1e-4,oo=1e-4;function Ld(r){const 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){const o=r[i],a=r[i+1];e+=(o-s)*(a+n),s=o,n=a}return e<0?-1:1}function Nd(r,t,e,i,s,n,o,a){const l=r-e*s,u=t-i*s,c=r+e*n,h=t+i*n;let p,f;o?(p=i,f=-e):(p=-i,f=e);const m=l+p,_=u+f,g=c+p,b=h+f;return a.push(m,_),a.push(g,b),2}function ve(r,t,e,i,s,n,o,a){const l=e-r,u=i-t;let c=Math.atan2(l,u),h=Math.atan2(s-r,n-t);a&&c<h?c+=Math.PI*2:!a&&c>h&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),_=Math.sqrt(l*l+u*u),g=(15*m*Math.sqrt(_)/Math.PI>>0)+1,b=f/g;if(p+=b,a){o.push(r,t),o.push(e,i);for(let v=1,x=p;v<g;v++,x+=b)o.push(r,t),o.push(r+Math.sin(x)*_,t+Math.cos(x)*_);o.push(r,t),o.push(s,n)}else{o.push(e,i),o.push(r,t);for(let v=1,x=p;v<g;v++,x+=b)o.push(r+Math.sin(x)*_,t+Math.cos(x)*_),o.push(r,t);o.push(s,n),o.push(r,t)}return g*2}function Xd(r,t,e,i,s,n){const o=no;if(r.length===0)return;const a=t;let l=a.alignment;if(t.alignment!==.5){let K=Ld(r);e&&(K*=-1),l=(l-.5)*K+.5}const u=new V(r[0],r[1]),c=new V(r[r.length-2],r[r.length-1]),h=i,p=Math.abs(u.x-c.x)<o&&Math.abs(u.y-c.y)<o;if(h){r=r.slice(),p&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const K=(u.x+c.x)*.5,ce=(c.y+u.y)*.5;r.unshift(K,ce),r.push(K,ce)}const f=s,m=r.length/2;let _=r.length;const g=f.length/2,b=a.width/2,v=b*b,x=a.miterLimit*a.miterLimit;let T=r[0],E=r[1],S=r[2],A=r[3],G=0,O=0,w=-(E-A),R=T-S,D=0,k=0,N=Math.sqrt(w*w+R*R);w/=N,R/=N,w*=b,R*=b;const re=l,I=(1-re)*2,U=re*2;h||(a.cap==="round"?_+=ve(T-w*(I-U)*.5,E-R*(I-U)*.5,T-w*I,E-R*I,T+w*U,E+R*U,f,!0)+2:a.cap==="square"&&(_+=Nd(T,E,w,R,I,U,!0,f))),f.push(T-w*I,E-R*I),f.push(T+w*U,E+R*U);for(let K=1;K<m-1;++K){T=r[(K-1)*2],E=r[(K-1)*2+1],S=r[K*2],A=r[K*2+1],G=r[(K+1)*2],O=r[(K+1)*2+1],w=-(E-A),R=T-S,N=Math.sqrt(w*w+R*R),w/=N,R/=N,w*=b,R*=b,D=-(A-O),k=S-G,N=Math.sqrt(D*D+k*k),D/=N,k/=N,D*=b,k*=b;const ce=S-T,ii=E-A,si=S-G,ni=O-A,Nv=ce*si+ii*ni,tn=ii*si-ni*ce,oi=tn<0;if(Math.abs(tn)<.001*Math.abs(Nv)){f.push(S-w*I,A-R*I),f.push(S+w*U,A+R*U),Nv>=0&&(a.join==="round"?_+=ve(S,A,S-w*I,A-R*I,S-D*I,A-k*I,f,!1)+4:_+=2,f.push(S-D*U,A-k*U),f.push(S+D*I,A+k*I));continue}const Xv=(-w+T)*(-R+A)-(-w+S)*(-R+E),Hv=(-D+G)*(-k+A)-(-D+S)*(-k+O),en=(ce*Hv-si*Xv)/tn,rn=(ni*Xv-ii*Hv)/tn,xu=(en-S)*(en-S)+(rn-A)*(rn-A),Re=S+(en-S)*I,Me=A+(rn-A)*I,Ce=S-(en-S)*U,Oe=A-(rn-A)*U,AM=Math.min(ce*ce+ii*ii,si*si+ni*ni),jv=oi?I:U,PM=AM+jv*jv*v;xu<=PM?a.join==="bevel"||xu/v>x?(oi?(f.push(Re,Me),f.push(S+w*U,A+R*U),f.push(Re,Me),f.push(S+D*U,A+k*U)):(f.push(S-w*I,A-R*I),f.push(Ce,Oe),f.push(S-D*I,A-k*I),f.push(Ce,Oe)),_+=2):a.join==="round"?oi?(f.push(Re,Me),f.push(S+w*U,A+R*U),_+=ve(S,A,S+w*U,A+R*U,S+D*U,A+k*U,f,!0)+4,f.push(Re,Me),f.push(S+D*U,A+k*U)):(f.push(S-w*I,A-R*I),f.push(Ce,Oe),_+=ve(S,A,S-w*I,A-R*I,S-D*I,A-k*I,f,!1)+4,f.push(S-D*I,A-k*I),f.push(Ce,Oe)):(f.push(Re,Me),f.push(Ce,Oe)):(f.push(S-w*I,A-R*I),f.push(S+w*U,A+R*U),a.join==="round"?oi?_+=ve(S,A,S+w*U,A+R*U,S+D*U,A+k*U,f,!0)+2:_+=ve(S,A,S-w*I,A-R*I,S-D*I,A-k*I,f,!1)+2:a.join==="miter"&&xu/v<=x&&(oi?(f.push(Ce,Oe),f.push(Ce,Oe)):(f.push(Re,Me),f.push(Re,Me)),_+=2),f.push(S-D*I,A-k*I),f.push(S+D*U,A+k*U),_+=2)}T=r[(m-2)*2],E=r[(m-2)*2+1],S=r[(m-1)*2],A=r[(m-1)*2+1],w=-(E-A),R=T-S,N=Math.sqrt(w*w+R*R),w/=N,R/=N,w*=b,R*=b,f.push(S-w*I,A-R*I),f.push(S+w*U,A+R*U),h||(a.cap==="round"?_+=ve(S-w*(I-U)*.5,A-R*(I-U)*.5,S-w*I,A-R*I,S+w*U,A+R*U,f,!1)+2:a.cap==="square"&&(_+=Nd(S,A,w,R,I,U,!1,f)));const Js=oo*oo;for(let K=g;K<_+g-2;++K)T=f[K*2],E=f[K*2+1],S=f[(K+1)*2],A=f[(K+1)*2+1],G=f[(K+2)*2],O=f[(K+2)*2+1],!(Math.abs(T*(A-O)+S*(O-E)+G*(E-A))<Js)&&n.push(K,K+1,K+2)}function Hd(r,t,e,i){const s=no;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],u=t||Math.abs(n-a)<s&&Math.abs(o-l)<s,c=e,h=r.length/2,p=c.length/2;for(let f=0;f<h;f++)c.push(r[f*2]),c.push(r[f*2+1]);for(let f=0;f<h-1;f++)i.push(p+f,p+f+1);u&&i.push(p+h-1,p)}function jd(r,t,e=2){const i=t&&t.length,s=i?t[0]*e:r.length;let n=zd(r,0,s,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,u;if(i&&(n=sT(r,t,n,e)),r.length>80*e){a=1/0,l=1/0;let c=-1/0,h=-1/0;for(let p=e;p<s;p+=e){const f=r[p],m=r[p+1];f<a&&(a=f),m<l&&(l=m),f>c&&(c=f),m>h&&(h=m)}u=Math.max(c-a,h-l),u=u!==0?32767/u:0}return Er(n,o,e,a,l,u,0),o}function zd(r,t,e,i,s){let n;if(s===uo(r,t,e,i)>0)for(let o=t;o<e;o+=i)n=Kd(o/i|0,r[o],r[o+1],n);else for(let o=e-i;o>=t;o-=i)n=Kd(o/i|0,r[o],r[o+1],n);return n&&We(n,n.next)&&(wr(n),n=n.next),n}function xe(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(We(e,e.next)||Z(e.prev,e,e.next)===0)){if(wr(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Er(r,t,e,i,s,n,o){if(!r)return;!o&&n&&uT(r,i,s,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?eT(r,i,s,n):tT(r)){t.push(l.i,r.i,u.i),wr(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=rT(xe(r),t),Er(r,t,e,i,s,n,2)):o===2&&iT(r,t,e,i,s,n):Er(xe(r),t,e,i,s,n,1);break}}}function tT(r){const t=r.prev,e=r,i=r.next;if(Z(t,e,i)>=0)return!1;const s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,u=i.y,c=Math.min(s,n,o),h=Math.min(a,l,u),p=Math.max(s,n,o),f=Math.max(a,l,u);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&Ar(s,a,n,l,o,u,m.x,m.y)&&Z(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function eT(r,t,e,i){const s=r.prev,n=r,o=r.next;if(Z(s,n,o)>=0)return!1;const a=s.x,l=n.x,u=o.x,c=s.y,h=n.y,p=o.y,f=Math.min(a,l,u),m=Math.min(c,h,p),_=Math.max(a,l,u),g=Math.max(c,h,p),b=ao(f,m,t,e,i),v=ao(_,g,t,e,i);let x=r.prevZ,T=r.nextZ;for(;x&&x.z>=b&&T&&T.z<=v;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&Ar(a,c,l,h,u,p,x.x,x.y)&&Z(x.prev,x,x.next)>=0||(x=x.prevZ,T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ar(a,c,l,h,u,p,T.x,T.y)&&Z(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;x&&x.z>=b;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&Ar(a,c,l,h,u,p,x.x,x.y)&&Z(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;T&&T.z<=v;){if(T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ar(a,c,l,h,u,p,T.x,T.y)&&Z(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function rT(r,t){let e=r;do{const i=e.prev,s=e.next.next;!We(i,s)&&Wd(i,e,e.next,s)&&Pr(i,s)&&Pr(s,i)&&(t.push(i.i,e.i,s.i),wr(e),wr(e.next),e=r=s),e=e.next}while(e!==r);return xe(e)}function iT(r,t,e,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&dT(o,a)){let l=Yd(o,a);o=xe(o,o.next),l=xe(l,l.next),Er(o,t,e,i,s,n,0),Er(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function sT(r,t,e,i){const s=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,u=zd(r,a,l,i,!1);u===u.next&&(u.steiner=!0),s.push(hT(u))}s.sort(nT);for(let n=0;n<s.length;n++)e=oT(s[n],e);return e}function nT(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(t.next.y-t.y)/(t.next.x-t.x);e=i-s}return e}function oT(r,t){const e=aT(r,t);if(!e)return t;const i=Yd(e,r);return xe(i,i.next),xe(e,e.next)}function aT(r,t){let e=t;const i=r.x,s=r.y;let n=-1/0,o;if(We(r,e))return e;do{if(We(r,e.next))return e.next;if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const h=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=i&&h>n&&(n=h,o=e.x<e.next.x?e:e.next,h===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,u=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=l&&i!==e.x&&Vd(s<u?i:n,s,l,u,s<u?n:i,s,e.x,e.y)){const h=Math.abs(s-e.y)/(i-e.x);Pr(e,r)&&(h<c||h===c&&(e.x>o.x||e.x===o.x&&lT(o,e)))&&(o=e,c=h)}e=e.next}while(e!==a);return o}function lT(r,t){return Z(r.prev,r,t.prev)<0&&Z(t.next,r,r.next)<0}function uT(r,t,e,i){let s=r;do s.z===0&&(s.z=ao(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,cT(s)}function cT(r){let t,e=1;do{let i=r,s;r=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let u=0;u<e&&(a++,o=o.nextZ,!!o);u++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,e*=2}while(t>1);return r}function ao(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function hT(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Vd(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Ar(r,t,e,i,s,n,o,a){return!(r===o&&t===a)&&Vd(r,t,e,i,s,n,o,a)}function dT(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!pT(r,t)&&(Pr(r,t)&&Pr(t,r)&&fT(r,t)&&(Z(r.prev,r,t.prev)||Z(r,t.prev,t))||We(r,t)&&Z(r.prev,r,r.next)>0&&Z(t.prev,t,t.next)>0)}function Z(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function We(r,t){return r.x===t.x&&r.y===t.y}function Wd(r,t,e,i){const s=ji(Z(r,t,e)),n=ji(Z(r,t,i)),o=ji(Z(e,i,r)),a=ji(Z(e,i,t));return!!(s!==n&&o!==a||s===0&&Hi(r,e,t)||n===0&&Hi(r,i,t)||o===0&&Hi(e,r,i)||a===0&&Hi(e,t,i))}function Hi(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ji(r){return r>0?1:r<0?-1:0}function pT(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Wd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Pr(r,t){return Z(r.prev,r,r.next)<0?Z(r,t,r.next)>=0&&Z(r,r.prev,t)>=0:Z(r,t,r.prev)<0||Z(r,r.next,t)<0}function fT(r,t){let e=r,i=!1;const s=(r.x+t.x)/2,n=(r.y+t.y)/2;do 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;while(e!==r);return i}function Yd(r,t){const e=lo(r.i,r.x,r.y),i=lo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Kd(r,t,e,i){const s=lo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function wr(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 lo(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function FM(r,t,e,i){const s=t&&t.length,n=s?t[0]*e:r.length;let o=Math.abs(uo(r,0,n,e));if(s)for(let l=0,u=t.length;l<u;l++){const c=t[l]*e,h=l<u-1?t[l+1]*e:r.length;o-=Math.abs(uo(r,c,h,e))}let a=0;for(let l=0;l<i.length;l+=3){const u=i[l]*e,c=i[l+1]*e,h=i[l+2]*e;a+=Math.abs((r[u]-r[h])*(r[c+1]-r[u+1])-(r[u]-r[c])*(r[h+1]-r[u+1]))}return o===0&&a===0?0:Math.abs((a-o)/o)}function uo(r,t,e,i){let s=0;for(let n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}function DM(r){const t=[],e=[],i=r[0][0].length;let s=0,n=0;for(const o of r){for(const a of o)for(let l=0;l<i;l++)t.push(a[l]);n&&(s+=n,e.push(s)),n=o.length}return{vertices:t,holes:e,dimensions:i}}const qd=jd.default||jd;function co(r,t,e,i,s,n,o){const a=qd(r,t,2);if(!a)return;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 mT=[],Zd={extension:{type:y.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,i,s,n){co(r,mT,t,e,i,s,n)}},Qd={extension:{type:y.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,i=e.x,s=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=s,t[2]=i+n,t[3]=s,t[4]=i+n,t[5]=s+o,t[6]=i,t[7]=s+o,!0):!1},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[6],t[i+o+1]=r[7],o+=e,t[i+o]=r[4],t[i+o+1]=r[5],o+=e;const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},Jd={extension:{type:y.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[4],t[i+o+1]=r[5];const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2}};var gT=Object.defineProperty,tp=Object.getOwnPropertySymbols,_T=Object.prototype.hasOwnProperty,bT=Object.prototype.propertyIsEnumerable,ep=(r,t,e)=>t in r?gT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rp=(r,t)=>{for(var e in t||(t={}))_T.call(t,e)&&ep(r,e,t[e]);if(tp)for(var e of tp(t))bT.call(t,e)&&ep(r,e,t[e]);return r};const ip=[{offset:0,color:"white"},{offset:1,color:"black"}],ho=class Eu{constructor(...t){this.uid=Y("fillGradient"),this.type="linear",this.colorStops=[];var e;let i=yT(t);const s=i.type==="radial"?Eu.defaultRadialOptions:Eu.defaultLinearOptions;i=rp(rp({},s),It(i)),this._textureSize=i.textureSize,this._wrapMode=i.wrapMode,i.type==="radial"?(this.center=i.center,this.outerCenter=(e=i.outerCenter)!=null?e:this.center,this.innerRadius=i.innerRadius,this.outerRadius=i.outerRadius,this.scale=i.scale,this.rotation=i.rotation):(this.start=i.start,this.end=i.end),this.textureSpace=i.textureSpace,this.type=i.type,i.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:H.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:s}=this.end,n=i-t,o=s-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=t;t=i,i=g,n*=-1}if(o<0){const g=e;e=s,s=g,o*=-1}}const l=this.colorStops.length?this.colorStops:ip,u=this._textureSize,{canvas:c,context:h}=np(u,1),p=a?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);sp(p,l),h.fillStyle=p,h.fillRect(0,0,u,1),this.texture=new P({source:new se({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),_=new M;_.scale(f/u,1),_.rotate(m),_.translate(t,e),this.textureSpace==="local"&&_.scale(u,u),this.transform=_}buildGradient(){this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:ip,e=this._textureSize,{canvas:i,context:s}=np(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=a-c,p=l-c,f=e/(c*2),m=(n-h)*f,_=(o-p)*f,g=s.createRadialGradient(m,_,u*f,(a-h)*f,(l-p)*f,c*f);sp(g,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=g,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 se({resource:i,addressMode:this._wrapMode})});const b=new M;b.scale(1/f,1/f),b.translate(h,p),this.textureSpace==="local"&&b.scale(e,e),this.transform=b}get styleKey(){return this.uid}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null}};ho.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},ho.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let jt=ho;function sp(r,t){for(let e=0;e<t.length;e++){const i=t[e];r.addColorStop(i.offset,i.color)}}function np(r,t){const e=L.get().createCanvas(r,t),i=e.getContext("2d");return{canvas:e,context:i}}function yT(r){var t,e;let i=(t=r[0])!=null?t:{};return(typeof i=="number"||r[1])&&(i={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:(e=r[5])!=null?e:jt.defaultLinearOptions.textureSize}),i}const vT=new M,xT=new z;function op(r,t,e,i){const s=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const o=e.getBounds(xT);t.width&&o.pad(t.width);const{x:a,y:l}=o,u=1/o.width,c=1/o.height,h=-a*u,p=-l*c,f=s.a,m=s.b,_=s.c,g=s.d;s.a*=u,s.b*=u,s.c*=c,s.d*=c,s.tx=h*f+p*_+s.tx,s.ty=h*m+p*g+s.ty}else s.translate(t.texture.frame.x,t.texture.frame.y),s.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof jt)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&s.append(vT.copyFrom(i).invert()),s}const Rr={};B.handleByMap(y.ShapeBuilder,Rr),B.add(Qd,Zd,Jd,Ve,kd,$d);const TT=new z,ST=new M;function ap(r,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const n=r.instructions[s];if(n.action==="texture")ET(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,u=n.data.hole;o&&u&&lp(u.shapePath,l,!0,i,e),u&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),lp(a,l,o,i,e)}}}function ET(r,t,e){const i=[],s=Rr.rectangle,n=TT;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!s.build(n,i))return;const{vertices:a,uvs:l,indices:u}=e,c=u.length,h=a.length/2;o&&so(i,o),s.triangulate(i,a,2,h,u,c);const p=r.image,f=p.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const m=ot.get(Li);m.indexOffset=c,m.indexSize=u.length-c,m.attributeOffset=h,m.attributeSize=a.length/2-h,m.baseColor=r.style,m.alpha=r.alpha,m.texture=p,m.geometryData=e,t.push(m)}function lp(r,t,e,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:l,transform:u,holes:c})=>{var h;const p=[],f=Rr[l.type];if(!f.build(l,p))return;const m=a.length,_=n.length/2;let g="triangle-list";if(u&&so(p,u),e){const T=(h=l.closePath)!=null?h:!0,E=t;E.pixelLine?(Hd(p,T,n,a),g="line-list"):Xd(p,E,!1,T,n,a)}else if(c){const T=[],E=p.slice();AT(c).forEach(S=>{T.push(E.length/2),E.push(...S)}),co(E,T,n,2,_,a,m)}else f.triangulate(p,n,2,_,a,m);const b=o.length/2,v=t.texture;if(v!==P.WHITE){const T=op(ST,t,l,u);Id(n,2,_,o,b,2,n.length/2-_,T)}else Fd(o,b,2,n.length/2-_);const x=ot.get(Li);x.indexOffset=m,x.indexSize=a.length-m,x.attributeOffset=_,x.attributeSize=n.length/2-_,x.baseColor=t.color,x.alpha=t.alpha,x.texture=v,x.geometryData=s,x.topology=g,i.push(x)})}function AT(r){const t=[];for(let e=0;e<r.length;e++){const i=r[e].shape,s=[];Rr[i.type].build(i,s)&&t.push(s)}return t}class up{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class cp{constructor(){this.instructions=new mn}init(t){this.batcher=new $i({maxTextures:t}),this.instructions.reset()}get geometry(){return this.batcher.geometry}}const po=class Au{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(t){var e;Au.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Au.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),ap(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"?e.isBatchable=e.geometryData.vertices.length<400:e.isBatchable=!0,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=ot.get(cp,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,o=s.indices.length;for(let c=0;c<i.length;c++)i[c].applyTransform=!1;const a=e.batcher;a.ensureAttributeBuffer(n),a.ensureIndexBuffer(o),a.begin();for(let c=0;c<i.length;c++){const h=i[c];a.add(h)}a.finish(e.instructions);const l=a.geometry;l.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),l.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);const u=a.batches;for(let c=0;c<u.length;c++){const h=u[c];h.bindGroup=Mi(h.textures.textures,h.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new up;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){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(ot.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{ot.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};po.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"graphicsContext"},po.defaultOptions={bezierSmoothness:.5};let zi=po;const PT={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},fo=0,mo=1,go=2,_o=3,bo=4,yo=5,vo=class Qv{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<fo)}set blend(t){!!(this.data&1<<fo)!==t&&(this.data^=1<<fo)}get offsets(){return!!(this.data&1<<mo)}set offsets(t){!!(this.data&1<<mo)!==t&&(this.data^=1<<mo)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<go)}set culling(t){!!(this.data&1<<go)!==t&&(this.data^=1<<go)}get depthTest(){return!!(this.data&1<<_o)}set depthTest(t){!!(this.data&1<<_o)!==t&&(this.data^=1<<_o)}get depthMask(){return!!(this.data&1<<yo)}set depthMask(t){!!(this.data&1<<yo)!==t&&(this.data^=1<<yo)}get clockwiseFrontFace(){return!!(this.data&1<<bo)}set clockwiseFrontFace(t){!!(this.data&1<<bo)!==t&&(this.data^=1<<bo)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=PT[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Qv;return t.depthTest=!1,t.blend=!0,t}};vo.default2d=vo.for2d();let Et=vo;function wT(r,t,e,i){e[i++]=(r>>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function Ye(r,t,e){const i=(r>>24&255)/255;t[e++]=(r&255)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class hp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{ot.return(t)}),this.batches.length=0}}class xo{constructor(t,e){this.state=Et.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!!(s.isBatchable||i!==s.isBatchable)}addRenderable(t,e){const 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){const e=this._getGpuDataForRenderable(t).batches;for(let i=0;i<e.length;i++){const s=e[i];s._batcher.updateElement(s)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const s=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=s.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,Ye(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const o=s[n];i.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new hp;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,s=this.renderer.graphicsContext.getGpuContext(i),n=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(o=>{const a=ot.get(Li);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}xo.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"graphics"},B.add(xo),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(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const 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 To{destroy(){}}class So{constructor(t,e){this.localUniforms=new it({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.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,{batched:s}=this._getMeshData(t);if(s){const n=this._getBatchableMesh(t);n.setTexture(t._texture),n.geometry=t._geometry,i.addToBatch(n,e)}else i.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=ke(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Ye(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new To),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){var e,i;return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(i=t._geometry.positions)==null?void 0:i.length},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new To),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Vi;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}So.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"mesh"},B.add(So);class dp{execute(t,e){const i=t.state,s=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=s.gl,a=t.getBuffers(e);s.shader.bind(n),s.state.set(i),s.geometry.bind(a.geometry,n.glProgram);const l=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,l,0)}}function Eo(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let 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 pp(r){return{dynamicUpdate:fp(r,!0),staticUpdate:fp(r,!1)}}function fp(r,t){const 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){const o=r[n];if(t!==o.dynamic)continue;e.push(`offset = index + ${i}`),e.push(o.code);const a=Zt(o.format);i+=a.stride/4}e.push(`
index += stride * 4;
}
`),e.unshift(`
var stride = ${i};
`);const s=e.join(`
`);return new Function("ps","f32v","u32v",s)}class mp{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,s=t.properties;let n=0,o=0;for(const h in s){const p=s[h],f=Zt(p.format);p.dynamic?o+=f.stride:n+=f.stride}this._dynamicStride=o/4,this._staticStride=n/4,this.staticAttributeBuffer=new _e(i*4*n),this.dynamicAttributeBuffer=new _e(i*4*o),this.indexBuffer=Eo(i);const a=new be;let l=0,u=0;this._staticBuffer=new mt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST}),this._dynamicBuffer=new mt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST});for(const h in s){const p=s[h],f=Zt(p.format);p.dynamic?(a.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(a.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}a.addIndex(this.indexBuffer);const c=this.getParticleUpdate(s);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=a}getParticleUpdate(t){const e=RT(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return pp(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new _e(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new _e(this._size*this._dynamicStride*4*4),this.indexBuffer=Eo(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function RT(r){const t=[];for(const e in r){const i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}var gp=`varying vec2 vUV;
varying vec4 vColor;
uniform sampler2D uTexture;
void main(void){
vec4 color = texture2D(uTexture, vUV) * vColor;
gl_FragColor = color;
}`,_p=`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;
}
`,Ao=`
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 bp extends St{constructor(){const t=Tt.from({vertex:_p,fragment:gp}),e=gt.from({fragment:{source:Ao,entryPoint:"mainFragment"},vertex:{source:Ao,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:P.WHITE.source,uSampler:new Rt({}),uniforms:{uTranslationMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new H(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Po{constructor(t,e){this.state=Et.for2d(),this.localUniforms=new it({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 bp,this.state=Et.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new mp({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=ke(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(i.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=i.globalUniforms.globalUniformData.resolution,o.uRound=i._roundPixels|t._roundPixels,Ye(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class wo extends Po{constructor(t){super(t,new dp)}}wo.extension={type:[y.WebGLPipes],name:"particle"};class yp{execute(t,e){const i=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);i.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class Ro extends Po{constructor(t){super(t,new yp)}}Ro.extension={type:[y.WebGPUPipes],name:"particle"},B.add(wo),B.add(Ro);function Wi(r,t){const{texture:e,bounds:i}=r;Gn(i,t._anchor,e);const s=t._style._getFinalPadding();i.minX-=s,i.minY-=s,i.maxX-=s,i.maxY-=s}class Mr{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}class vp extends Mr{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.canvasText.returnTexture(this.texture),this._renderer=null}}class Mo{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t),t._didTextUpdate=!1),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.returnTexture(e.texture),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=e.texture=this._renderer.canvasText.getTexture(t),Wi(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new vp(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Mo.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"text"};const xp={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 Cr{constructor(t,e){this.uid=Y("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=xp[e].addressModeU,t.source.style.addressModeV=xp[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var MT=OT,Co={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},CT=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function OT(r){var t=[];return r.replace(CT,function(e,i,s){var n=i.toLowerCase();for(s=BT(s),n=="m"&&s.length>2&&(t.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==Co[n])return s.unshift(i),t.push(s);if(s.length<Co[n])throw new Error("malformed path data");t.push([i].concat(s.splice(0,Co[n])))}}),t}var GT=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function BT(r){var t=r.match(GT);return t?t.map(Number):[]}var IT=Iu(MT);function Tp(r,t){const e=IT(r),i=[];let s=null,n=0,o=0;for(let a=0;a<e.length;a++){const 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(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:}u!=="Z"&&u!=="z"&&s===null&&(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){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-s)*i,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(i-l)}getBounds(t){return t||(t=new z),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class 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){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),l=i-a,u=n-l,c=o-l,h=n+a,p=o+a,f=t-this.x,m=e-this.y,_=f*f/(u*u)+m*m/(c*c),g=f*f/(h*h)+m*m/(p*p);return _>1&&g<=1}getBounds(t){return t||(t=new z),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function Or(r,t,e,i,s,n){const o=r-e,a=t-i,l=s-e,u=n-i,c=o*l+a*u,h=l*l+u*u;let p=-1;h!==0&&(p=c/h);let f,m;p<0?(f=e,m=i):p>1?(f=s,m=n):(f=e+p*l,m=i+p*u);const _=r-f,g=t-m;return _*_+g*g}let FT,DT;class Ke{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const 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;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const 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){const e=this.getBounds(FT),i=t.getBounds(DT);if(!e.containsRect(i))return!1;const s=t.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new Ke(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],u=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(u-a)*((e-l)/(c-l))+a&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:l}=this,u=l.length-(this.closePath?0:2);for(let c=0;c<u;c+=2){const h=l[c],p=l[c+1],f=l[(c+2)%l.length],m=l[(c+3)%l.length],_=Or(t,e,h,p,f,m),g=Math.sign((f-h)*(e-p)-(m-p)*(t-h));if(_<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new z);const 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){const 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)=>{const a=r-e,l=t-i,u=Math.sqrt(a*a+l*l);return u>=s-n&&u<=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),t.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)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,c=i*(1-s),h=i-c,p=n+u,f=o+u,m=a-u*2,_=l-u*2,g=n+a,b=o+l;return(t>=n-c&&t<=n+h||t>=g-h&&t<=g+c)&&e>=f&&e<=f+_||(e>=o-c&&e<=o+h||e>=b-h&&e<=b+c)&&t>=p&&t<=p+m?!0:t<p&&e<f&&qi(t,e,p,f,u,h,c)||t>g-u&&e<f&&qi(t,e,g-u,f,u,h,c)||t>g-u&&e>b-u&&qi(t,e,g-u,b-u,u,h,c)||t<p&&e>b-u&&qi(t,e,p,b-u,u,h,c)}}const UT=8,Qi=11920929e-14,kT=1,Oo=.01,qe=0,Te=0;function Go(r,t,e,i,s,n,o,a,l,u){const c=Math.min(.99,Math.max(0,u!=null?u:zi.defaultOptions.bezierSmoothness));let h=(kT-c)/1;return h*=h,$T(t,e,i,s,n,o,a,l,r,h),r}function $T(r,t,e,i,s,n,o,a,l,u){Bo(r,t,e,i,s,n,o,a,l,u,0),l.push(o,a)}function Bo(r,t,e,i,s,n,o,a,l,u,c){if(c>UT)return;const h=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,v=(p+m)/2,x=(f+_)/2,T=(m+g)/2,E=(_+b)/2,S=(v+T)/2,A=(x+E)/2;if(c>0){let G=o-r,O=a-t;const w=Math.abs((e-o)*O-(i-a)*G),R=Math.abs((s-o)*O-(n-a)*G);let D,k;if(w>Qi&&R>Qi){if((w+R)*(w+R)<=u*(G*G+O*O)){if(qe<Oo){l.push(S,A);return}const N=Math.atan2(n-i,s-e);if(D=Math.abs(N-Math.atan2(i-t,e-r)),k=Math.abs(Math.atan2(a-n,o-s)-N),D>=h&&(D=2*h-D),k>=h&&(k=2*h-k),D+k<qe){l.push(S,A);return}if(Te!==0){if(D>Te){l.push(e,i);return}if(k>Te){l.push(s,n);return}}}}else if(w>Qi){if(w*w<=u*(G*G+O*O)){if(qe<Oo){l.push(S,A);return}if(D=Math.abs(Math.atan2(n-i,s-e)-Math.atan2(i-t,e-r)),D>=h&&(D=2*h-D),D<qe){l.push(e,i),l.push(s,n);return}if(Te!==0&&D>Te){l.push(e,i);return}}}else if(R>Qi){if(R*R<=u*(G*G+O*O)){if(qe<Oo){l.push(S,A);return}if(D=Math.abs(Math.atan2(a-n,o-s)-Math.atan2(n-i,s-e)),D>=h&&(D=2*h-D),D<qe){l.push(e,i),l.push(s,n);return}if(Te!==0&&D>Te){l.push(s,n);return}}}else if(G=S-(r+o)/2,O=A-(t+a)/2,G*G+O*O<=u){l.push(S,A);return}}Bo(r,t,p,f,v,x,S,A,l,u,c+1),Bo(S,A,T,E,g,b,o,a,l,u,c+1)}const LT=8,NT=11920929e-14,XT=1,HT=.01,Sp=0;function Ep(r,t,e,i,s,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:zi.defaultOptions.bezierSmoothness));let u=(XT-l)/1;return u*=u,jT(t,e,i,s,n,o,r,u),r}function jT(r,t,e,i,s,n,o,a){Io(o,r,t,e,i,s,n,a,0),o.push(s,n)}function Io(r,t,e,i,s,n,o,a,l){if(l>LT)return;const u=Math.PI,c=(t+i)/2,h=(e+s)/2,p=(i+n)/2,f=(s+o)/2,m=(c+p)/2,_=(h+f)/2;let g=n-t,b=o-e;const v=Math.abs((i-n)*b-(s-o)*g);if(v>NT){if(v*v<=a*(g*g+b*b)){if(Sp<HT){r.push(m,_);return}let x=Math.abs(Math.atan2(o-s,n-i)-Math.atan2(s-e,i-t));if(x>=u&&(x=2*u-x),x<Sp){r.push(m,_);return}}}else if(g=m-(t+n)/2,b=_-(e+o)/2,g*g+b*b<=a){r.push(m,_);return}Io(r,t,e,c,h,m,_,a,l+1),Io(r,m,_,p,f,n,o,a,l+1)}function Fo(r,t,e,i,s,n,o,a){let l=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(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);let u=l/a,c=s;u*=o?-1:1;for(let h=0;h<a+1;h++){const p=Math.cos(c),f=Math.sin(c),m=t+p*i,_=e+f*i;r.push(m,_),c+=u}}function Ap(r,t,e,i,s,n){const o=r[r.length-2],a=r[r.length-1]-e,l=o-t,u=s-e,c=i-t,h=Math.abs(a*c-l*u);if(h<1e-8||n===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const p=a*a+l*l,f=u*u+c*c,m=a*u+l*c,_=n*Math.sqrt(p)/h,g=n*Math.sqrt(f)/h,b=_*m/p,v=g*m/f,x=_*c+g*l,T=_*u+g*a,E=l*(g+b),S=a*(g+b),A=c*(_+v),G=u*(_+v),O=Math.atan2(S-T,E-x),w=Math.atan2(G-T,A-x);Fo(r,x+t,T+e,n,O,w,l*u>c*a)}const Gr=Math.PI*2,Do={centerX:0,centerY:0,ang1:0,ang2:0},Uo=({x:r,y:t},e,i,s,n,o,a,l)=>{r*=e,t*=i;const u=s*r-n*t,c=n*r+s*t;return l.x=u+o,l.y=c+a,l};function zT(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Pp=(r,t,e,i)=>{const s=r*i-t*e<0?-1:1;let n=r*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},VT=(r,t,e,i,s,n,o,a,l,u,c,h,p)=>{const f=Math.pow(s,2),m=Math.pow(n,2),_=Math.pow(c,2),g=Math.pow(h,2);let b=f*m-f*g-m*_;b<0&&(b=0),b/=f*g+m*_,b=Math.sqrt(b)*(o===a?-1:1);const v=b*s/n*h,x=b*-n/s*c,T=u*v-l*x+(r+e)/2,E=l*v+u*x+(t+i)/2,S=(c-v)/s,A=(h-x)/n,G=(-c-v)/s,O=(-h-x)/n,w=Pp(1,0,S,A);let R=Pp(S,A,G,O);a===0&&R>0&&(R-=Gr),a===1&&R<0&&(R+=Gr),p.centerX=T,p.centerY=E,p.ang1=w,p.ang2=R};function wp(r,t,e,i,s,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const c=Math.sin(a*Gr/360),h=Math.cos(a*Gr/360),p=h*(t-i)/2+c*(e-s)/2,f=-c*(t-i)/2+h*(e-s)/2;if(p===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),VT(t,e,i,s,n,o,l,u,c,h,p,f,Do);let{ang1:_,ang2:g}=Do;const{centerX:b,centerY:v}=Do;let x=Math.abs(g)/(Gr/4);Math.abs(1-x)<1e-7&&(x=1);const T=Math.max(Math.ceil(x),1);g/=T;let E=r[r.length-2],S=r[r.length-1];const A={x:0,y:0};for(let G=0;G<T;G++){const O=zT(_,g),{x:w,y:R}=Uo(O[0],n,o,h,c,b,v,A),{x:D,y:k}=Uo(O[1],n,o,h,c,b,v,A),{x:N,y:re}=Uo(O[2],n,o,h,c,b,v,A);Go(r,E,S,w,R,D,k,N,re),E=N,S=re,_+=g}}function Rp(r,t,e){var i;const s=(a,l)=>{const u=l.x-a.x,c=l.y-a.y,h=Math.sqrt(u*u+c*c),p=u/h,f=c/h;return{len:h,nx:p,ny:f}},n=(a,l)=>{a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let o=t[t.length-1];for(let a=0;a<t.length;a++){const l=t[a%t.length],u=(i=l.radius)!=null?i:e;if(u<=0){n(a,l),o=l;continue}const c=t[(a+1)%t.length],h=s(l,o),p=s(l,c);if(h.len<1e-4||p.len<1e-4){n(a,l),o=l;continue}let f=Math.asin(h.nx*p.ny-h.ny*p.nx),m=1,_=!1;h.nx*p.nx-h.ny*-p.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,m=-1,_=!0):f>0&&(m=-1,_=!0);const g=f/2;let b,v=Math.abs(Math.cos(g)*u/Math.sin(g));v>Math.min(h.len/2,p.len/2)?(v=Math.min(h.len/2,p.len/2),b=Math.abs(v*Math.sin(g)/Math.cos(g))):b=u;const x=l.x+p.nx*v+-p.ny*b*m,T=l.y+p.ny*v+p.nx*b*m,E=Math.atan2(h.ny,h.nx)+Math.PI/2*m,S=Math.atan2(p.ny,p.nx)-Math.PI/2*m;a===0&&r.moveTo(x+Math.cos(E)*b,T+Math.sin(E)*b),r.arc(x,T,b,E,S,_),o=l}}function Mp(r,t,e,i){var s;const 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++){const u=t[(l+1)%a],c=(s=u.radius)!=null?s:e;if(c<=0){l===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y);continue}const h=t[l],p=t[(l+2)%a],f=n(h,u);let m;if(f<1e-4)m=u;else{const b=Math.min(f/2,c);m=o(u,h,b/f)}const _=n(p,u);let g;if(_<1e-4)g=u;else{const b=Math.min(_/2,c);g=o(u,p,b/_)}l===0?r.moveTo(m.x,m.y):r.lineTo(m.x,m.y),r.quadraticCurveTo(u.x,u.y,g.x,g.y,i)}}const WT=new z;class Cp{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new st,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const 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){this._ensurePoly(!1);const a=this._currentPoly.points;return Fo(a,t,e,i,s,n,o),this}arcTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly.points;return Ap(o,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,o,a){const l=this._currentPoly.points;return wp(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o,a){this._ensurePoly();const l=this._currentPoly;return Go(this._currentPoly.points,l.lastX,l.lastY,t,e,i,s,n,o,a),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly;return Ep(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),t.transform(e));const i=this.shapePrimitives,s=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&i.length-s>1){let n=null;for(let o=s;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const l=a.shape,u=n==null?void 0:n.shape;u&&u.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),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){const s=new Ke(t);return s.closePath=e,this.drawShape(s,i),this}regularPoly(t,e,i,s,n=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/s,u=[];for(let c=0;c<s;c++){const h=a-c*l;u.push(t+i*Math.cos(h),e+i*Math.sin(h))}return this.poly(u,!0,o),this}roundPoly(t,e,i,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(t,e,i,s,o);const l=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,l);const u=-1*Math.PI/2+o,c=Math.PI*2/s,h=(s-2)*Math.PI/s/2;for(let p=0;p<s;p++){const f=p*c+u,m=t+i*Math.cos(f),_=e+i*Math.sin(f),g=f+Math.PI+h,b=f-Math.PI-h,v=m+n*Math.cos(g),x=_+n*Math.sin(g),T=m+n*Math.cos(b),E=_+n*Math.sin(b);p===0?this.moveTo(v,x):this.lineTo(v,x),this.quadraticCurveTo(m,_,T,E,a)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?Mp(this,t,e,s):Rp(this,t,e),this.closePath())}filletRect(t,e,i,s,n){if(n===0)return this.rect(t,e,i,s);const o=Math.min(i,s)/2,a=Math.min(o,Math.max(-o,n)),l=t+i,u=e+s,c=a<0?-a:0,h=Math.abs(a);return this.moveTo(t,e+h).arcTo(t+c,e+c,t+h,e,h).lineTo(l-h,e).arcTo(l-c,e+c,l,e+h,h).lineTo(l,u-h).arcTo(l-c,u-c,t+i-h,u,h).lineTo(t+h,u).arcTo(t+c,u-c,t,u-h,h).closePath()}chamferRect(t,e,i,s,n,o){if(n<=0)return this.rect(t,e,i,s);const a=Math.min(n,Math.min(i,s)/2),l=t+i,u=e+s,c=[t+a,e,l-a,e,l,e+a,l,u-a,l-a,u,t+a,u,t,u-a,t,e+a];for(let h=c.length-1;h>=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-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){let i=this._currentPoly;return i&&this.endPoly(),i=new Ke,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Ke,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,s=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const s=e[i],n=s.shape.getBounds(WT);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class Se{constructor(t,e=!1){this.instructions=[],this.uid=Y("graphicsPath"),this._dirty=!0;var i;this.checkForHoles=e,typeof t=="string"?Tp(t,this):this.instructions=(i=t==null?void 0:t.slice())!=null?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new Cp(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){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(V.shared);let l=0,u=0;if(!o||o.action!=="bezierCurveTo")l=a.x,u=a.y;else{l=o.data[2],u=o.data[3];const c=a.x,h=a.y;l=c+(c-l),u=h+(h-u)}return 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){const s=this.instructions[this.instructions.length-1],n=this.getLastPoint(V.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];const l=n.x,u=n.y;o=l+(l-o),a=u+(u-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,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);const l=-1*Math.PI/2+o,u=i*2,c=Math.PI*2/u,h=[];for(let p=0;p<u;p++){const f=p%2?n:s,m=p*c+l;h.push(t+f*Math.cos(m),e+f*Math.sin(m))}return this.poly(h,!0,a),this}clone(t=!1){const e=new Se;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const s=this.instructions[i];e.instructions.push({action:s.action,data:s.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,s=t.c,n=t.d,o=t.tx,a=t.ty;let l=0,u=0,c=0,h=0,p=0,f=0,m=0,_=0;for(let g=0;g<this.instructions.length;g++){const b=this.instructions[g],v=b.data;switch(b.action){case"moveTo":case"lineTo":l=v[0],u=v[1],v[0]=e*l+s*u+o,v[1]=i*l+n*u+a;break;case"bezierCurveTo":c=v[0],h=v[1],p=v[2],f=v[3],l=v[4],u=v[5],v[0]=e*c+s*h+o,v[1]=i*c+n*h+a,v[2]=e*p+s*f+o,v[3]=i*p+n*f+a,v[4]=e*l+s*u+o,v[5]=i*l+n*u+a;break;case"quadraticCurveTo":c=v[0],h=v[1],l=v[2],u=v[3],v[0]=e*c+s*h+o,v[1]=i*c+n*h+a,v[2]=e*l+s*u+o,v[3]=i*l+n*u+a;break;case"arcToSvg":l=v[5],u=v[6],m=v[0],_=v[1],v[0]=e*m+s*_,v[1]=i*m+n*_,v[5]=e*l+s*u+o,v[6]=i*l+n*u+a;break;case"circle":v[4]=Br(v[3],t);break;case"rect":v[4]=Br(v[4],t);break;case"ellipse":v[8]=Br(v[8],t);break;case"roundRect":v[5]=Br(v[5],t);break;case"addPath":v[0].transform(t);break;case"poly":v[2]=Br(v[2],t);break;default:break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,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);break}return t}}function Br(r,t){return r?r.prepend(t):t.clone()}let ko=0;const Op=500;function Ot(...r){ko!==Op&&(ko++,ko===Op?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function Q(r,t,e){const i=r.getAttribute(t);return i?Number(i):e}function Gp(r,t){const e=r.querySelectorAll("defs");for(let i=0;i<e.length;i++){const s=e[i];for(let n=0;n<s.children.length;n++){const o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=YT(o);break;case"radialgradient":t.defs[o.id]=KT(o);break;default:break}}}}function YT(r){const t=Q(r,"x1",0),e=Q(r,"y1",0),i=Q(r,"x2",1),s=Q(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new jt(t,e,i,s,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const l=r.children[a],u=Q(l,"offset",0),c=H.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(u,c)}return o}function KT(r){return new jt(0,0,1,0)}function $o(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const Lo={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 No(r,t){const e=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in Lo){const a=r.getAttribute(o);a&&Bp(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[u,c]=l.split(":");Lo[u]&&Bp(t,n,u,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function Bp(r,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const s=$o(i);t.strokeStyle.fill=r.defs[s]}else t.strokeStyle.color=H.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const s=$o(i);t.fillStyle.fill=r.defs[s]}else t.fillStyle.color=H.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);break}}var qT=Object.defineProperty,Ip=Object.getOwnPropertySymbols,ZT=Object.prototype.hasOwnProperty,QT=Object.prototype.propertyIsEnumerable,Fp=(r,t,e)=>t in r?qT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t||(t={}))ZT.call(t,e)&&Fp(r,e,t[e]);if(Ip)for(var e of Ip(t))QT.call(t,e)&&Fp(r,e,t[e]);return r};function Dp(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new Se};Gp(r,e);const i=r.children,{fillStyle:s,strokeStyle:n}=No(r,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&Up(a,e,s,n)}return t}function Up(r,t,e,i){const s=r.children,{fillStyle:n,strokeStyle:o}=No(r,t);n&&e?e=Ji(Ji({},e),n):n&&(e=n),o&&i?i=Ji(Ji({},i),o):o&&(i=o);const a=!e&&!i;a&&(e={color:0});let l,u,c,h,p,f,m,_,g,b,v,x,T,E,S,A,G;switch(r.nodeName.toLowerCase()){case"path":E=r.getAttribute("d"),r.getAttribute("fill-rule"),S=new Se(E,!0),t.context.path(S),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"circle":m=Q(r,"cx",0),_=Q(r,"cy",0),g=Q(r,"r",0),t.context.ellipse(m,_,g,g),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":l=Q(r,"x",0),u=Q(r,"y",0),A=Q(r,"width",0),G=Q(r,"height",0),b=Q(r,"rx",0),v=Q(r,"ry",0),b||v?t.context.roundRect(l,u,A,G,b||v):t.context.rect(l,u,A,G),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=Q(r,"cx",0),_=Q(r,"cy",0),b=Q(r,"rx",0),v=Q(r,"ry",0),t.context.beginPath(),t.context.ellipse(m,_,b,v),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=Q(r,"x1",0),h=Q(r,"y1",0),p=Q(r,"x2",0),f=Q(r,"y2",0),t.context.beginPath(),t.context.moveTo(c,h),t.context.lineTo(p,f),i&&t.context.stroke(i);break;case"polygon":T=r.getAttribute("points"),x=T.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(x,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":T=r.getAttribute("points"),x=T.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(x,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Ot(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let O=0;O<s.length;O++)Up(s[O],t,e,i)}var JT=Object.defineProperty,ts=Object.getOwnPropertySymbols,kp=Object.prototype.hasOwnProperty,$p=Object.prototype.propertyIsEnumerable,Lp=(r,t,e)=>t in r?JT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ut=(r,t)=>{for(var e in t||(t={}))kp.call(t,e)&&Lp(r,e,t[e]);if(ts)for(var e of ts(t))$p.call(t,e)&&Lp(r,e,t[e]);return r},tS=(r,t)=>{var e={};for(var i in r)kp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ts)for(var i of ts(r))t.indexOf(i)<0&&$p.call(r,i)&&(e[i]=r[i]);return e};function eS(r){return H.isColorLike(r)}function Np(r){return r instanceof Cr}function Xp(r){return r instanceof jt}function rS(r){return r instanceof P}function iS(r,t,e){const i=H.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=P.WHITE,Ut(Ut({},e),r)}function sS(r,t,e){return r.texture=t,Ut(Ut({},e),r)}function Hp(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Ut(Ut({},e),r)}function jp(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,Ut(Ut({},e),r)}function nS(r,t){const e=Ut(Ut({},t),r),i=H.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function ne(r,t){if(r==null)return null;const e={},i=r;return eS(r)?iS(e,r,t):rS(r)?sS(e,r,t):Np(r)?Hp(e,r,t):Xp(r)?jp(e,r,t):i.fill&&Np(i.fill)?Hp(i,i.fill,t):i.fill&&Xp(i.fill)?jp(i,i.fill,t):nS(i,t)}function Ir(r,t){const e=t,{width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=tS(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=ne(r,u);return c?Ut({width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l},c):null}var oS=Object.defineProperty,zp=Object.getOwnPropertySymbols,aS=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,Vp=(r,t,e)=>t in r?oS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ze=(r,t)=>{for(var e in t||(t={}))aS.call(t,e)&&Vp(r,e,t[e]);if(zp)for(var e of zp(t))lS.call(t,e)&&Vp(r,e,t[e]);return r};const uS=new V,Wp=new M,Xo=class Vt extends pt{constructor(){super(...arguments),this.uid=Y("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Se,this._transform=new M,this._fillStyle=Ze({},Vt.defaultFillStyle),this._strokeStyle=Ze({},Vt.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new st,this._boundsDirty=!0}clone(){const t=new Vt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Ze({},this._fillStyle),t._strokeStyle=Ze({},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,Vt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Ir(t,Vt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ne(t,Vt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ne(t,Vt.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?H.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Se,this}fill(t,e){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=ne(t,Vt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(V.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Ir(t,Vt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,s,n,o),this}arcTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(t,e,i,s,n,o,a){this._tick++;const 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++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*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++,(t=this._activePath)==null||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++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*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++,Dp(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:Ze({},this._fillStyle),strokeStyle:Ze({},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):(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),this):(Wp.set(t,e,i,s,n,o),this._transform.append(Wp),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;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],s=i.action;if(s==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(s==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){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){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let s=!1;for(let n=0;n<i.length;n++){const o=i[n],a=o.data,l=a.path;if(!o.action||!l)continue;const u=a.style,c=l.shapePath.shapePrimitives;for(let h=0;h<c.length;h++){const p=c[h].shape;if(!u||!p)continue;const f=c[h].transform,m=f?f.applyInverse(t,uS):t;if(o.action==="fill")s=p.contains(m.x,m.y);else{const g=u;s=p.strokeContains(m.x,m.y,g.width,g.alignment)}const _=a.hole;if(_){const g=(e=_.shapePath)==null?void 0:e.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){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(e),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(e)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Xo.defaultFillStyle={color:16777215,alpha:1,texture:P.WHITE,matrix:null,fill:null,textureSpace:"local"},Xo.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 ht=Xo;const Yp=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function Kp(r){const t=[];let e=0;for(let i=0;i<Yp.length;i++){const s=`_${Yp[i]}`;t[e++]=r[s]}return e=qp(r._fill,t,e),e=hS(r._stroke,t,e),e=dS(r.dropShadow,t,e),e=cS(r.filters,t,e),t.join("-")}function cS(r,t,e){if(!r)return e;for(const i of r)t[e++]=i.uid;return e}function qp(r,t,e){var i;return r&&(t[e++]=r.color,t[e++]=r.alpha,t[e++]=(i=r.fill)==null?void 0:i.styleKey),e}function hS(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}function dS(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=H.shared.setValue(r.color).toNumber()),e}var pS=Object.defineProperty,fS=Object.defineProperties,mS=Object.getOwnPropertyDescriptors,Zp=Object.getOwnPropertySymbols,gS=Object.prototype.hasOwnProperty,_S=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?pS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,At=(r,t)=>{for(var e in t||(t={}))gS.call(t,e)&&Qp(r,e,t[e]);if(Zp)for(var e of Zp(t))_S.call(t,e)&&Qp(r,e,t[e]);return r},bS=(r,t)=>fS(r,mS(t));const Ho=class ur extends pt{constructor(t={}){super(),yS(t);const e=At(At({},ur.defaultTextStyle),t);for(const i in e){const s=i;this[s]=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){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(At(At({},ur.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(At({},ur.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){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=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 filters(){return this._filters}set filters(t){this._filters=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({},ht.defaultFillStyle),t),()=>{this._fill=ne(At({},this._originalFill),ht.defaultFillStyle)})),this._fill=ne(t===0?"black":t,ht.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({},ht.defaultStrokeStyle),t),()=>{this._stroke=Ir(At({},this._originalStroke),ht.defaultStrokeStyle)})),this._stroke=Ir(t,ht.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Kp(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=ur.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new ur({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,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,s,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(o),(s=this._stroke)!=null&&s.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]=n,e==null||e(s,n),this.update(),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(H.isColorLike(t)||t instanceof jt||t instanceof Cr)}};Ho.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Ho.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 kt=Ho;function yS(r){var t,e,i,s,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=kt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(i=o.dropShadowBlur)!=null?i:a.blur,color:(s=o.dropShadowColor)!=null?s:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(H.isColorLike(a))l.color=a;else if(a instanceof jt||a instanceof Cr)l.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))l=a;else throw new Error("Invalid stroke value.");r.stroke=bS(At({},l),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){let a;r.fontSize==null?r.fontSize=kt.defaultTextStyle.fontSize:typeof r.fontSize=="string"?a=parseInt(r.fontSize,10):a=r.fontSize;const l=new jt({start:{x:0,y:0},end:{x:0,y:(a||0)*1.7}}),u=o.fillGradientStops.map(c=>H.shared.setValue(c).toNumber());u.forEach((c,h)=>{const p=h/(u.length-1);l.addColorStop(p,c)}),r.fill={fill:l}}}const vS=new st;function jo(r,t,e,i){const s=vS;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=rt.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}class Jp{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=L.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=he(t),e=he(e);const s=(t<<17)+(e<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:s}=e,n=(i<<17)+(s<<1);t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Qt=new Jp;let Ee=null,Jt=null;function xS(r,t){Ee||(Ee=L.get().createCanvas(256,128),Jt=Ee.getContext("2d",{willReadFrequently:!0}),Jt.globalCompositeOperation="copy",Jt.globalAlpha=1),(Ee.width<r||Ee.height<t)&&(Ee.width=he(r),Ee.height=he(t))}function tf(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function ef(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function rf(...r){var t,e,i;let s=r[0];s.canvas||(s={canvas:r[0],resolution:r[1]});const{canvas:n}=s,o=Math.min((t=s.resolution)!=null?t:1,1),a=(e=s.width)!=null?e:n.width,l=(i=s.height)!=null?i:n.height;let u=s.output;if(xS(a,l),!Jt)throw new TypeError("Failed to get canvas 2D context");Jt.drawImage(n,0,0,a,l,0,0,a*o,l*o);const c=Jt.getImageData(0,0,a,l).data;let h=0,p=0,f=a-1,m=l-1;for(;p<l&&tf(c,a,p);)++p;if(p===l)return z.EMPTY;for(;tf(c,a,m);)--m;for(;ef(c,a,h,p,m);)++h;for(;ef(c,a,f,p,m);)--f;return++f,++m,Jt.globalCompositeOperation="source-over",Jt.strokeRect(h,p,f-h,m-p),Jt.globalCompositeOperation="copy",u!=null||(u=new z),u.set(h/o,p/o,(f-h)/o,(m-p)/o),u}const TS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Fr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!TS.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const zo={willReadFrequently:!0},zt=class C{static get experimentalLetterSpacingSupported(){let t=C._experimentalLetterSpacingSupported;if(t===void 0){const e=L.get().getCanvasRenderingContext2D().prototype;t=C._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return 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 n;const o=Fr(e),a=C.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const l=C.__context;l.font=o;const u=(s?C._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),c=new Array(u.length);let h=0;for(let g=0;g<u.length;g++){const b=C._measureText(u[g],e.letterSpacing,l);c[g]=b,h=Math.max(h,b)}const p=((n=e._stroke)==null?void 0:n.width)||0;let f=h+p;e.dropShadow&&(f+=e.dropShadow.distance);const m=e.lineHeight||a.fontSize;let _=Math.max(m,a.fontSize+p)+(u.length-1)*(m+e.leading);return e.dropShadow&&(_+=e.dropShadow.distance),new C(t,e,f,_,u,c,m+e.leading,h,a)}static _measureText(t,e,i){let s=!1;C.experimentalLetterSpacingSupported&&(C.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(s)o-=e,l-=e;else{const u=(C.graphemeSegmenter(t).length-1)*e;o+=u,l+=u}return Math.max(o,l)}static _wordWrap(t,e,i=C._canvas){const s=i.getContext("2d",zo);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:u,whiteSpace:c}=e,h=C._collapseSpaces(c),p=C._collapseNewlines(c);let f=!h;const 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=!h,o="",n=0;continue}b=" "}if(h){const x=C.isBreakingSpace(b),T=C.isBreakingSpace(o[o.length-1]);if(x&&T)continue}const v=C._getFromCache(b,u,l,s);if(v>m)if(o!==""&&(a+=C._addLine(o),o="",n=0),C.canBreakWords(b,e.breakWords)){const x=C.wordWrapSplit(b);for(let T=0;T<x.length;T++){let E=x[T],S=E,A=1;for(;x[T+A];){const O=x[T+A];if(!C.canBreakChars(S,O,b,T,e.breakWords))E+=O;else break;S=O,A++}T+=A-1;const G=C._getFromCache(E,u,l,s);G+n>m&&(a+=C._addLine(o),f=!1,o="",n=0),o+=E,n+=G}}else{o.length>0&&(a+=C._addLine(o),o="",n=0);const x=g===_.length-1;a+=C._addLine(b,!x),f=!1,o="",n=0}else v+n>m&&(f=!1,a+=C._addLine(o),o="",n=0),(o.length>0||!C.isBreakingSpace(b)||f)&&(o+=b,n+=v)}return a+=C._addLine(o,!1),a}static _addLine(t,e=!0){return t=C._trimRight(t),t=e?`${t}
`:t,t}static _getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=C._measureText(t,e,s)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!C.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:C._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:C._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(C.isBreakingSpace(n,o)||C._isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),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){if(C._fonts[t])return C._fonts[t];const e=C._context;e.font=t;const i=e.measureText(C.METRICS_STRING+C.BASELINE_SYMBOL),s={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return C._fonts[t]=s,s}static clearMetrics(t=""){t?delete C._fonts[t]:C._fonts={}}static get _canvas(){if(!C.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",zo);if(i!=null&&i.measureText)return C.__canvas=e,e;t=L.get().createCanvas()}catch(e){t=L.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",zo)),C.__context}};zt.METRICS_STRING="|\xC9q\xC5",zt.BASELINE_SYMBOL="M",zt.BASELINE_MULTIPLIER=1.4,zt.HEIGHT_MULTIPLIER=2,zt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let s=0;for(const n of e)i[s++]=n.segment;return i}}return r=>[...r]})(),zt.experimentalLetterSpacing=!1,zt._fonts={},zt._newlines=[10,13],zt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Gt=zt;const sf=1e5;function Dr(r,t,e,i=0){var s;if(r.texture===P.WHITE&&!r.fill)return H.shared.setValue(r.color).setAlpha((s=r.alpha)!=null?s:1).toHexa();if(r.fill){if(r.fill instanceof Cr){const n=r.fill,o=t.createPattern(n.texture.source.resource,"repeat"),a=n.transform.copyTo(M.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),o.setTransform(a),o}else if(r.fill instanceof jt){const n=r.fill,o=n.type==="linear",a=n.textureSpace==="local";let l=1,u=1;a&&e&&(l=e.width+i,u=e.height+i);let c,h=!1;if(o){const{start:p,end:f}=n;c=t.createLinearGradient(p.x*l,p.y*u,f.x*l,f.y*u),h=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:m,outerRadius:_}=n;c=t.createRadialGradient(p.x*l,p.y*u,f*l,m.x*l,m.y*u,_*l)}if(h&&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(_=>{const g=m+_.offset*p;c.addColorStop(Math.floor(g*sf)/sf,H.shared.setValue(_.color).toHex())})}}else n.colorStops.forEach(p=>{c.addColorStop(p.offset,H.shared.setValue(p.color).toHex())});return c}}else{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}return"red"}const nf=new z;let SS=class{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),o=Gt.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),u=Qt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(e,i,n,s,u);const c=i.trim?rf({canvas:u.canvas,width:a,height:l,resolution:1,output:nf}):nf.set(0,0,a,l);return{canvasAndContext:u,frame:c}}returnCanvasAndContext(t){Qt.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){var o,a,l,u,c;const{canvas:h,context:p}=n,f=Fr(e),m=Gt.measureText(t||" ",e),_=m.lines,g=m.lineHeight,b=m.lineWidths,v=m.maxLineWidth,x=m.fontProperties,T=h.height;if(p.resetTransform(),p.scale(s,s),p.textBaseline=e.textBaseline,(o=e._stroke)!=null&&o.width){const G=e._stroke;p.lineWidth=G.width,p.miterLimit=G.miterLimit,p.lineJoin=G.join,p.lineCap=G.cap}p.font=f;let E,S;const A=e.dropShadow?2:1;for(let G=0;G<A;++G){const O=e.dropShadow&&G===0,w=O?Math.ceil(Math.max(1,T)+i*2):0,R=w*s;if(O){p.fillStyle="black",p.strokeStyle="black";const N=e.dropShadow,re=N.color,I=N.alpha;p.shadowColor=H.shared.setValue(re).setAlpha(I).toRgbaString();const U=N.blur*s,Js=N.distance*s;p.shadowBlur=U,p.shadowOffsetX=Math.cos(N.angle)*Js,p.shadowOffsetY=Math.sin(N.angle)*Js+R}else{if(p.fillStyle=e._fill?Dr(e._fill,p,m):null,(a=e._stroke)!=null&&a.width){const N=e._stroke.width*e._stroke.alignment;p.strokeStyle=Dr(e._stroke,p,m,N)}p.shadowColor="black"}let D=(g-x.fontSize)/2;g-x.fontSize<0&&(D=0);const k=(u=(l=e._stroke)==null?void 0:l.width)!=null?u:0;for(let N=0;N<_.length;N++)E=k/2,S=k/2+N*g+x.ascent+D,e.align==="right"?E+=v-b[N]:e.align==="center"&&(E+=(v-b[N])/2),(c=e._stroke)!=null&&c.width&&this._drawLetterSpacing(_[N],e,n,E+i,S+i-w,!0),e._fill!==void 0&&this._drawLetterSpacing(_[N],e,n,E+i,S+i-w)}}_drawLetterSpacing(t,e,i,s,n,o=!1){const{context:a}=i,l=e.letterSpacing;let u=!1;if(Gt.experimentalLetterSpacingSupported&&(Gt.experimentalLetterSpacing?(a.letterSpacing=`${l}px`,a.textLetterSpacing=`${l}px`,u=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),l===0||u){o?a.strokeText(t,s,n):a.fillText(t,s,n);return}let c=s;const h=Gt.graphemeSegmenter(t);let p=a.measureText(t).width,f=0;for(let m=0;m<h.length;++m){const _=h[m];o?a.strokeText(_,c,n):a.fillText(_,c,n);let g="";for(let b=m+1;b<h.length;++b)g+=h[b];f=a.measureText(g).width,c+=p-f+l,p=f}}};const Qe=new SS;class Vo{constructor(t){this._renderer=t}getTexture(t,e,i,s){var n;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof kt||(t.style=new kt(t.style)),t.textureStyle instanceof Rt||(t.textureStyle=new Rt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:a,textureStyle:l}=t,u=(n=t.resolution)!=null?n:this._renderer.resolution,{frame:c,canvasAndContext:h}=Qe.getCanvasAndContext({text:o,style:a,resolution:u}),p=jo(h.canvas,c.width,c.height,u);if(l&&(p.source.style=l),a.trim&&(c.pad(a.padding),p.frame.copyFrom(c),p.updateUvs()),a.filters){const f=this._applyFilters(p,a.filters);return this.returnTexture(p),Qe.returnCanvasAndContext(h),f}return this._renderer.texture.initSource(p._source),Qe.returnCanvasAndContext(h),p}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",rt.returnTexture(t,!0)}renderTextToCanvas(){}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null}}Vo.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"canvasText"},B.add(Vo),B.add(Mo);var ES=Object.defineProperty,es=Object.getOwnPropertySymbols,of=Object.prototype.hasOwnProperty,af=Object.prototype.propertyIsEnumerable,lf=(r,t,e)=>t in r?ES(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,AS=(r,t)=>{for(var e in t||(t={}))of.call(t,e)&&lf(r,e,t[e]);if(es)for(var e of es(t))af.call(t,e)&&lf(r,e,t[e]);return r},PS=(r,t)=>{var e={};for(var i in r)of.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&es)for(var i of es(r))t.indexOf(i)<0&&af.call(r,i)&&(e[i]=r[i]);return e};class Je extends Nt{constructor(t){t instanceof ht&&(t={context:t});const e=t||{},{context:i,roundPixels:s}=e,n=PS(e,["context","roundPixels"]);super(AS({label:"Graphics"},n)),this.renderPipeId="graphics",i?this._context=i:this._context=this._ownedContext=new ht,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s!=null?s:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_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 Je(this._context.clone()):(this._ownedContext=null,new Je(this._context))}lineStyle(t,e,i){const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==ht.defaultStrokeStyle.width||t.color!==ht.defaultStrokeStyle.color||t.alpha!==ht.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 uf={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));
`}},cf={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));
`}},hf={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;
}
`}},df={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 Wo,Yo;class pf extends St{constructor(t){const e=new it({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"}});Wo!=null||(Wo=Xe({name:"sdf-shader",bits:[Bi,Fi(t),uf,hf,je]})),Yo!=null||(Yo=He({name:"sdf-shader",bits:[Ii,Di(t),cf,df,ze]})),super({glProgram:Yo,gpuProgram:Wo,resources:{localUniforms:e,batchSamplers:Ui(t)}})}}class Ko extends pt{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)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}var wS=Object.defineProperty,ff=Object.getOwnPropertySymbols,RS=Object.prototype.hasOwnProperty,MS=Object.prototype.propertyIsEnumerable,mf=(r,t,e)=>t in r?wS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gf=(r,t)=>{for(var e in t||(t={}))RS.call(t,e)&&mf(r,e,t[e]);if(ff)for(var e of ff(t))MS.call(t,e)&&mf(r,e,t[e]);return r};const _f=class Jv extends Ko{constructor(t){var e,i,s;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=gf(gf({},Jv.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=P.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=Fr(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(i=n.resolution)!=null?i:1,this._padding=(s=n.padding)!=null?s:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof Rt?n.textureStyle:new Rt(n.textureStyle)),this.fontMetrics=Gt.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,i,s,n;const o=Gt.graphemeSegmenter(t).filter(T=>!this._currentChars.includes(T)).filter((T,E,S)=>S.indexOf(T)===E);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:l,context:u}=a.canvasAndContext,c=a.texture.source;const h=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const _=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*_;let b=!1;const v=l.width/this.resolution,x=l.height/this.resolution;for(let T=0;T<o.length;T++){const E=o[T],S=Gt.measureText(E,h,l,!1);S.lineHeight=S.height;const A=S.width*_,G=Math.ceil((h.fontStyle==="italic"?2:1)*A),O=S.height*_,w=G+g*2,R=O+g*2;if(b=!1,E!==`
`&&E!=="\r"&&E!==" "&&E!==" "&&(b=!0,m=Math.ceil(Math.max(R,m))),p+w>v&&(f+=m,m=R,p=0,f+m>x)){c.update();const k=this._nextPage();l=k.canvasAndContext.canvas,u=k.canvasAndContext.context,c=k.texture.source,p=0,f=0,m=0}const D=A/_-((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)-((n=(s=h._stroke)==null?void 0:s.width)!=null?n:0);if(this.chars[E]={id:E.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:D,kerning:{}},b){this._drawGlyph(u,S,p+g,f+g,_,h);const k=c.width*_,N=c.height*_,re=new z(p/k*c.width,f/N*c.height,w/k*c.width,R/N*c.height);this.chars[E].texture=new P({source:c,frame:re}),p+=Math.ceil(w)}}c.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning&&this._applyKerning(o,u)}get pageTextures(){return this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s<t.length;s++){const n=t[s];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let l=i[n];l||(l=i[n]=e.measureText(n).width);let u=i[a];u||(u=i[a]=e.measureText(a).width);let c=e.measureText(n+a).width,h=c-(l+u);h&&(this.chars[n].kerning[a]=h),c=e.measureText(n+a).width,h=c-(l+u),h&&(this.chars[a].kerning[n]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Qt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new P({source:new se({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const n={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){var s;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Fr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,o=(s=n==null?void 0:n.width)!=null?s:0;if(n&&(t.lineWidth=o,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Dr(n,t)),e._fill&&(t.fillStyle=Dr(e._fill,t)),e.dropShadow){const a=e.dropShadow,l=H.shared.setValue(a.color).toArray(),u=a.blur*i,c=a.distance*i;t.shadowColor=`rgba(${l[0]*255},${l[1]*255},${l[2]*255},${a.alpha})`,t.shadowBlur=u,t.shadowOffsetX=Math.cos(a.angle)*c,t.shadowOffsetY=Math.sin(a.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,s,n,o){var a;const l=e.text,u=e.fontProperties,c=o._stroke,h=((a=c==null?void 0:c.width)!=null?a:0)*n,p=i+h/2,f=s-h/2,m=u.descent*n,_=e.lineHeight*n;o.stroke&&h&&t.strokeText(l,p,f+_-m),o._fill&&t.fillText(l,p,f+_-m)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];Qt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};_f.defaultOptions={textureSize:512,style:new kt,mipmap:!0};let qo=_f;function Zo(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:[]},u=m=>{const _=n.width;for(let g=0;g<l.index;g++){const 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},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},h=e.baseMeasurementFontSize/t.fontSize,p=t.letterSpacing*h,f=t.wordWrapWidth*h;for(let m=0;m<r.length+1;m++){let _;const g=m===r.length;g||(_=r[m]);const b=e.chars[_]||e.chars[" "];if(/(?:\s)/.test(_)||_==="\r"||_===`
`||g){if(!a&&t.wordWrap&&n.width+l.width-p>f?(c(),u(l),g||n.charPositions.push(0)):(l.start=n.width,u(l),g||n.charPositions.push(0)),_==="\r"||_===`
`)n.width!==0&&c();else if(!g){const v=b.xAdvance+(b.kerning[o]||0)+p;n.width+=v,n.spaceWidth=v,n.spacesIndex.push(n.charPositions.length),n.chars.push(_)}}else{const v=b.kerning[o]||0,x=b.xAdvance+v+p;l.positions[l.index++]=l.width+v,l.chars.push(_),l.width+=x}o=_}return c(),t.align==="center"?CS(s):t.align==="right"?OS(s):t.align==="justify"&&GS(s),s}function CS(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width/2-e.width/2;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function OS(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width-e.width;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function GS(r){const t=r.width;for(let e=0;e<r.lines.length;e++){const i=r.lines[e];let s=0,n=i.spacesIndex[s++],o=0;const 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}}function bf(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(s[0].length===0||s[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const 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(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var BS=Object.defineProperty,yf=Object.getOwnPropertySymbols,IS=Object.prototype.hasOwnProperty,FS=Object.prototype.propertyIsEnumerable,vf=(r,t,e)=>t in r?BS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qo=(r,t)=>{for(var e in t||(t={}))IS.call(t,e)&&vf(r,e,t[e]);if(yf)for(var e of yf(t))FS.call(t,e)&&vf(r,e,t[e]);return r};let rs=0,DS=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null}}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}if(!W.has(s)){const a=new qo(Qo({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions));rs++,rs>50&&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})\``),a.once("destroy",()=>{rs--,W.remove(s)}),W.set(s,a)}const o=W.get(s);return(i=o.ensureCharacters)==null||i.call(o,t),o}getLayout(t,e,i=!0){const s=this.getFont(t,e),n=Gt.graphemeSegmenter(t);return Zo(n,e,s,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,s,n;let o=t[0];typeof o=="string"&&(o={name:o,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(i=t[2])==null?void 0:i.resolution,padding:(s=t[2])==null?void 0:s.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const a=o==null?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=Qo(Qo({},this.defaultOptions),o);const l=o.style,u=l instanceof kt?l:new kt(l),c=u._fill.fill!==null&&u._fill.fill!==void 0,h=new qo({style:u,overrideFill:c,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),p=bf(o.chars);return h.ensureCharacters(p.join("")),W.set(`${a}-bitmap`,h),h.once("destroy",()=>W.remove(`${a}-bitmap`)),h}uninstall(t){const e=`${t}-bitmap`,i=W.get(e);i&&i.destroy()}};const Ur=new DS;class xf extends Je{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Jo{constructor(t){this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Tf(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);Tf(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,s=Ur.getFont(t.text,t._style);i.clear(),s.distanceField.type!=="none"&&(i.customShader||(i.customShader=new pf(this._renderer.limits.maxBatchableTextures)));const n=Gt.graphemeSegmenter(t.text),o=t._style;let a=s.baseLineOffset;const l=Zo(n,o,s,!0);let u=0;const c=o.padding,h=l.scale;let p=l.width,f=l.height+l.offsetY;o._stroke&&(p+=o._stroke.width/h,f+=o._stroke.width/h),i.translate(-t._anchor._x*p-c,-t._anchor._y*f-c).scale(h,h);const m=s.applyFillAsTint?o._fill.color:16777215;for(let _=0;_<l.lines.length;_++){const g=l.lines[_];for(let b=0;b<g.charPositions.length;b++){const v=n[u++],x=s.chars[v];x!=null&&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 t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new xf;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,s=W.get(`${i}-bitmap`),{a:n,b:o,c:a,d:l}=t.groupTransform,u=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),h=(Math.abs(u)+Math.abs(c))/2,p=s.baseRenderedFontSize/t._style.fontSize,f=h*s.distanceField.range*(1/p);e.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){this._renderer=null}}Jo.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"bitmapText"};function Tf(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}B.add(Jo);class Sf extends Mr{constructor(t){super(),this.generatingTexture=!1,this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.htmlText.returnTexturePromise(this.texturePromise),this.texturePromise=null,this._renderer=null}}class ta{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t).catch(s=>{console.error(s)}),t._didTextUpdate=!1,Wi(i,t)),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;e.texturePromise&&(this._renderer.htmlText.returnTexturePromise(e.texturePromise),e.texturePromise=null),e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const i=this._renderer.htmlText.getTexturePromise(t);e.texturePromise=i,e.texture=await i;const s=t.renderGroup||t.parentRenderGroup;s&&(s.structureDidChange=!0),e.generatingTexture=!1,Wi(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Sf(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=P.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}ta.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"htmlText"};function Ef(){const{userAgent:r}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Af="http://www.w3.org/2000/svg",Pf="http://www.w3.org/1999/xhtml";class ea{constructor(){this.svgRoot=document.createElementNS(Af,"svg"),this.foreignObject=document.createElementNS(Af,"foreignObject"),this.domElement=document.createElementNS(Pf,"div"),this.styleElement=document.createElementNS(Pf,"style"),this.image=new Image;const{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 wf(r){const t=r._stroke,e=r._fill,i=[`div { ${[`color: ${H.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: ${r.whiteSpace==="pre"&&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?[Mf(t)]:[],...r.dropShadow?[Rf(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return US(r.tagStyles,i),i.join(" ")}function Rf(r){const t=H.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),i=Math.round(Math.sin(r.angle)*r.distance),s=`${e}px ${i}px`;return r.blur>0?`text-shadow: ${s} ${r.blur}px ${t}`:`text-shadow: ${s} ${t}`}function Mf(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const Cf={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"},Of={fill:r=>`color: ${H.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:Mf,dropShadow:Rf};function US(r,t){for(const e in r){const i=r[e],s=[];for(const n in i)Of[n]?s.push(Of[n](i[n])):Cf[n]&&s.push(Cf[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${s.join(";")} }`)}}var kS=Object.defineProperty,Gf=Object.getOwnPropertySymbols,$S=Object.prototype.hasOwnProperty,LS=Object.prototype.propertyIsEnumerable,Bf=(r,t,e)=>t in r?kS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,If=(r,t)=>{for(var e in t||(t={}))$S.call(t,e)&&Bf(r,e,t[e]);if(Gf)for(var e of Gf(t))LS.call(t,e)&&Bf(r,e,t[e]);return r};class kr extends kt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new kr({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?If({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:If({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=wf(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}function Ff(r,t){const e=t.fontFamily,i=[],s={},n=/font-family:([^;"\s]+)/g,o=r.match(n);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=>{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return i}async function Df(r){const t=await(await L.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,s)=>{e.onloadend=()=>i(e.result),e.onerror=s,e.readAsDataURL(t)})}async function ra(r,t){const e=await Df(t);return`@font-face {
font-family: "${r.fontFamily}";
src: url('${e}');
font-weight: ${r.fontWeight};
font-style: ${r.fontStyle};
}`}const $r=new Map;async function Uf(r,t,e){const i=r.filter(s=>W.has(`${s}-and-url`)).map((s,n)=>{if(!$r.has(s)){const{url:o}=W.get(`${s}-and-url`);n===0?$r.set(s,ra({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:s},o)):$r.set(s,ra({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:s},o))}return $r.get(s)});return(await Promise.all(i)).join(`
`)}function kf(r,t,e,i,s){const{domElement:n,styleElement:o,svgRoot:a}=s;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;const{width:l,height:u}=s.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function $f(r,t){const e=Qt.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),e}function Lf(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 Nf;function ia(r,t,e,i){i||(i=Nf||(Nf=new ea));const{domElement:s,styleElement:n,svgRoot:o}=i;s.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${r}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const l=t.padding*2;return{width:a.width-l,height:a.height-l}}class sa{constructor(t){this._renderer=t,this._createCanvas=t.type===_t.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:s,textureStyle:n}=t,o=ot.get(ea),a=Ff(e,i),l=await Uf(a,i,kr.defaultTextStyle),u=ia(e,i,l,o),c=Math.ceil(Math.ceil(Math.max(1,u.width)+i.padding*2)*s),h=Math.ceil(Math.ceil(Math.max(1,u.height)+i.padding*2)*s),p=o.image,f=2;p.width=(c|0)+f,p.height=(h|0)+f;const m=kf(e,i,s,l,o);await Lf(p,m,Ef()&&a.length>0);const _=p;let g;this._createCanvas&&(g=$f(p,s));const b=jo(g?g.canvas:_,p.width-f,p.height-f,s);return n&&(b.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(b.source),Qt.returnCanvasAndContext(g)),ot.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){rt.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}sa.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"htmlText"},B.add(sa),B.add(ta);var NS=Object.defineProperty,Xf=Object.getOwnPropertySymbols,XS=Object.prototype.hasOwnProperty,HS=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?NS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jf=(r,t)=>{for(var e in t||(t={}))XS.call(t,e)&&Hf(r,e,t[e]);if(Xf)for(var e of Xf(t))HS.call(t,e)&&Hf(r,e,t[e]);return r};const zf=class tx extends be{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=jf(jf({},tx.defaultOptions),i);const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=i.uvs;n||(i.positions?n=new Float32Array(s.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit,l=new mt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),u=new mt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),c=new mt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:X.INDEX|X.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:u,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,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}};zf.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Ae=zf;var jS=Object.defineProperty,zS=Object.defineProperties,VS=Object.getOwnPropertyDescriptors,Vf=Object.getOwnPropertySymbols,WS=Object.prototype.hasOwnProperty,YS=Object.prototype.propertyIsEnumerable,Wf=(r,t,e)=>t in r?jS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yf=(r,t)=>{for(var e in t||(t={}))WS.call(t,e)&&Wf(r,e,t[e]);if(Vf)for(var e of Vf(t))YS.call(t,e)&&Wf(r,e,t[e]);return r},Kf=(r,t)=>zS(r,VS(t));const tr={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);
}
`}},qf=Kf(Yf({},tr),{vertex:Kf(Yf({},tr.vertex),{header:tr.vertex.header.replace("group(1)","group(2)")})}),is={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);
}
`}},Zf={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);
`}},Qf={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 na,oa;class Jf extends St{constructor(){na!=null||(na=Xe({name:"tiling-sprite-shader",bits:[tr,Zf,je]})),oa!=null||(oa=He({name:"tiling-sprite-shader",bits:[is,Qf,ze]}));const t=new it({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:oa,gpuProgram:na,resources:{localUniforms:new it({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){const a=this.resources.tilingUniforms,l=o.width,u=o.height,c=o.textureMatrix,h=a.uniforms.uTextureTransform;h.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.ty/e),h.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=h,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 tm extends Ae{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 em(r,t){const 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 rm(r,t,e,i){let s=0;const n=r.length/(t||2),o=i.a,a=i.b,l=i.c,u=i.d,c=i.tx,h=i.ty;for(e*=t;s<n;){const p=r[e],f=r[e+1];r[e]=o*p+l*f+c,r[e+1]=a*p+u*f+h,e+=t,s++}}function im(r,t){const e=r.texture,i=e.frame.width,s=e.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-o,t[5]=t[7]=1-o;const a=M.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/s),rm(t,2,0,a)}const ss=new tm;class sm{constructor(){this.canBatch=!0,this.geometry=new Ae({indices:ss.indices.slice(),positions:ss.positions.slice(),uvs:ss.uvs.slice()})}destroy(){var t;this.geometry.destroy(),(t=this.shader)==null||t.destroy()}}class aa{constructor(t){this._state=Et.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===i){const{batchableMesh:n}=e;return!n._batcher.checkAndUpdateTexture(n,t.texture)}return i!==s}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:n,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new Vi);const a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=n,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(a,e)}else i.break(e),s.shader||(s.shader=new Jf),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,Ye(t.groupColorAlpha,i.uColor,0),this._state.blendMode=ke(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:ss,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s)}else if(t.didViewUpdate){const{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new sm;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),im(t,i.uvs),em(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===_t.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}aa.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"tilingSprite"},B.add(aa);var KS=Object.defineProperty,nm=Object.getOwnPropertySymbols,qS=Object.prototype.hasOwnProperty,ZS=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?KS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,am=(r,t)=>{for(var e in t||(t={}))qS.call(t,e)&&om(r,e,t[e]);if(nm)for(var e of nm(t))ZS.call(t,e)&&om(r,e,t[e]);return r};const lm=class ex extends Ae{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,s,n;t=am(am({},ex.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(s=this.width)!=null?s:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],l=[],u=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let _=0;_<o;_++){const g=_%this.verticesX,b=_/this.verticesX|0;a.push(g*p,b*f),l.push(g/c,b/h)}const m=c*h;for(let _=0;_<m;_++){const g=_%c,b=_/c|0,v=b*this.verticesX+g,x=b*this.verticesX+g+1,T=(b+1)*this.verticesX+g,E=(b+1)*this.verticesX+g+1;u.push(v,x,T,x,E,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()}};lm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let ns=lm;var QS=Object.defineProperty,um=Object.getOwnPropertySymbols,JS=Object.prototype.hasOwnProperty,t2=Object.prototype.propertyIsEnumerable,cm=(r,t,e)=>t in r?QS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hm=(r,t)=>{for(var e in t||(t={}))JS.call(t,e)&&cm(r,e,t[e]);if(um)for(var e of um(t))t2.call(t,e)&&cm(r,e,t[e]);return r};const dm=class rx extends ns{constructor(t={}){t=hm(hm({},rx.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,i,s,n,o,a,l,u,c,h;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(s=t.originalWidth)!=null?s:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(c=t.anchor)==null?void 0:c.x,this._anchorY=(h=t.anchor)==null?void 0:h.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,c=s+n,h=e>c?1:e/c,p=o+a,f=i>p?1:i/p,m=Math.min(h,f),_=l*e,g=u*i;t[0]=t[8]=t[16]=t[24]=-_,t[2]=t[10]=t[18]=t[26]=s*m-_,t[4]=t[12]=t[20]=t[28]=e-n*m-_,t[6]=t[14]=t[22]=t[30]=e-_,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=o*m-g,t[17]=t[19]=t[21]=t[23]=i-a*m-g,t[25]=t[27]=t[29]=t[31]=i-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};dm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let oe=dm;class pm extends Vi{constructor(){super(),this.geometry=new oe}destroy(){this.geometry.destroy()}}class la{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new pm,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}la.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"nineSliceSprite"},B.add(la);class ua{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){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}ua.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"filter"};function fm(r,t){t.clear();const e=t.matrix;for(let i=0;i<r.length;i++){const s=r[i];s.globalDisplayStatus<7||(t.matrix=s.worldTransform,t.addBounds(s.bounds))}return t.matrix=e,t}const e2=new be({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});let r2=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.outputOffset={x:0,y:0},this.globalFrame={x:0,y:0,width:0,height:0}}};class ca{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new it({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(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=i,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(i.length===0){s.skip=!0;return}const l=s.bounds;if(t.renderables?fm(t.renderables,l):t.filterEffect.filterArea?(l.clear(),l.addRect(t.filterEffect.filterArea),l.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,l),t.container){const m=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;m&&l.applyMatrix(m)}if(this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;const u=this._getPreviousFilterData();let c=o,h=0,p=0;u&&(h=u.bounds.minX,p=u.bounds.minY,c=u.inputTexture.source._resolution),s.outputOffset.x=l.minX-h,s.outputOffset.y=l.minY-p;const f=s.globalFrame;if(f.x=h*c,f.y=p*c,f.width=n.width*c,f.height=n.height*c,s.backTexture=P.EMPTY,s.blendRequired){e.renderTarget.finishRenderPass();const m=e.renderTarget.getRenderTarget(s.outputRenderSurface);s.backTexture=this.getBackTexture(m,l,u==null?void 0:u.bounds)}s.inputTexture=rt.getOptimalTexture(l.width,l.height,s.resolution,s.antialias),e.renderTarget.bind(s.inputTexture,!0),e.globalUniforms.push({offset:l})}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const s=t.source,n=s.resolution,o=s.antialias;if(e.length===0)return i.skip=!0,t;const a=i.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(i,a.rectangle,o,n,0),i.skip)return t;const l=n,u=0,c=0;i.outputOffset.x=-a.minX,i.outputOffset.y=-a.minY;const h=i.globalFrame;h.x=u*l,h.y=c*l,h.width=s.width*l,h.height=s.height*l,i.outputRenderSurface=rt.getOptimalTexture(a.width,a.height,i.resolution,i.antialias),i.backTexture=P.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const p=i.outputRenderSurface;return p.source.alphaMode="premultiplied-alpha",p}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&rt.returnTexture(e.backTexture),rt.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const s=t.colorTexture.source._resolution,n=rt.getOptimalTexture(e.width,e.height,s,!1);let o=e.minX,a=e.minY;i&&(o-=i.minX,a-=i.minY),o=Math.floor(o*s),a=Math.floor(a*s);const l=Math.ceil(e.width*s),u=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:u},{x:0,y:0}),n}applyFilter(t,e,i,s){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface,l=this._filterGlobalUniforms,u=l.uniforms,c=u.uOutputFrame,h=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,_=u.uOutputTexture;a===i?(c[0]=o.outputOffset.x,c[1]=o.outputOffset.y):(c[0]=0,c[1]=0),c[2]=e.frame.width,c[3]=e.frame.height,h[0]=e.source.width,h[1]=e.source.height,h[2]=1/h[0],h[3]=1/h[1],p[0]=e.source.pixelWidth,p[1]=e.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=e.frame.width*h[2]-.5*p[2],f[3]=e.frame.height*h[3]-.5*p[3],m[0]=o.globalFrame.x,m[1]=o.globalFrame.y,m[2]=o.globalFrame.width,m[3]=o.globalFrame.height,i instanceof P&&(i.source.resource=null);const g=this.renderer.renderTarget.getRenderTarget(i);if(n.renderTarget.bind(i,!!s),i instanceof P?(_[0]=i.frame.width,_[1]=i.frame.height):(_[0]=g.width,_[1]=g.height),_[2]=g.isRoot?-1:1,l.update(),n.renderPipes.uniformBatch){const b=n.renderPipes.uniformBatch.getUboResource(l);this._globalFilterBindGroup.setResource(b,0)}else this._globalFilterBindGroup.setResource(l,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:e2,shader:t,state:t._state,topology:"triangle-list"}),n.type===_t.WEBGL&&n.renderTarget.finishRenderPass()}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(M.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/e.texture.frame.width,1/e.texture.frame.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){}_applyFiltersToTexture(t,e){const i=t.inputTexture,s=t.bounds,n=t.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),n.length===1)n[0].apply(this,i,t.outputRenderSurface,e);else{let o=t.inputTexture;const a=rt.getOptimalTexture(s.width,s.height,o.source._resolution,!1);let l=a,u=0;for(u=0;u<n.length-1;++u){n[u].apply(this,o,l,!0);const c=o;o=l,l=c}n[u].apply(this,o,t.outputRenderSurface,e),rt.returnTexture(a)}}_calculateFilterBounds(t,e,i,s,n){var o,a;const l=this.renderer,u=t.bounds,c=t.filters;let h=1/0,p=0,f=!0,m=!1,_=!1,g=!0;for(let b=0;b<c.length;b++){const v=c[b];if(h=Math.min(h,v.resolution==="inherit"?s:v.resolution),p+=v.padding,v.antialias==="off"?f=!1:v.antialias==="inherit"&&f&&(f=i),v.clipToViewport||(g=!1),!(v.compatibleRenderers&l.type)){_=!1;break}if(v.blendRequired&&!((a=(o=l.backBuffer)==null?void 0:o.useBackBuffer)==null||a)){_=!1;break}_=v.enabled||_,m||(m=v.blendRequired)}if(!_){t.skip=!0;return}if(g&&u.fitBounds(0,e.width/s,0,e.height/s),u.scale(h).ceil().scale(1/h).pad((p|0)*n),!u.isPositive){t.skip=!0;return}t.antialias=f,t.resolution=h,t.blendRequired=m}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>1&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new r2),this._filterStackIndex++,t}}ca.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"filter"},B.add(ca),B.add(ua);var i2={__proto__:null};const ha=[];B.handleByNamedList(y.Environment,ha);async function da(r){if(!r)for(let t=0;t<ha.length;t++){const e=ha[t];if(e.value.test()){await e.value.load();return}}}async function s2(r){return da(!r)}let Lr;function pa(){if(typeof Lr=="boolean")return Lr;try{Lr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(r){Lr=!1}return Lr}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))(bt||{});class fa{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,l){const{name:u,items:c}=this;for(let h=0,p=c.length;h<p;h++)c[h][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){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}var n2=Object.defineProperty,mm=Object.getOwnPropertySymbols,o2=Object.prototype.hasOwnProperty,a2=Object.prototype.propertyIsEnumerable,gm=(r,t,e)=>t in r?n2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,os=(r,t)=>{for(var e in t||(t={}))o2.call(t,e)&&gm(r,e,t[e]);if(mm)for(var e of mm(t))a2.call(t,e)&&gm(r,e,t[e]);return r};const l2=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],_m=class ix extends pt{constructor(t){var e;super(),this.uid=Y("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const i=[...l2,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await da(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const s=this._systemsHash[i].constructor.defaultOptions;t=os(os({},s),t)}t=os(os({},ix.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){var i,s;let n=t;if(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,(i=n.clearColor)!=null||(n.clearColor=this.background.colorRgba),(s=n.clear)!=null||(n.clear=this.background.clearBeforeRender)),n.clearColor){const o=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=o?n.clearColor:H.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){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){var e;const i=this;t.target||(t.target=i.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),(e=t.clear)!=null||(t.clear=bt.ALL);const{clear:s,clearColor:n,target:o}=t;H.shared.setValue(n!=null?n:this.background.colorRgba),i.renderTarget.clear(o,s,H.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 fa(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const 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=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=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(!pa())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()}};_m.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Nr=_m,ma;function Xr(r){return ma!==void 0||(ma=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Nr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!L.get().getWebGLRenderingContext())return!1;let i=L.get().createCanvas().getContext("webgl",e);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch(i){return!1}})()),ma}let ga;async function Hr(r={}){return ga!==void 0||(ga=await(async()=>{const t=L.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),ga}var u2=Object.defineProperty,bm=Object.getOwnPropertySymbols,c2=Object.prototype.hasOwnProperty,h2=Object.prototype.propertyIsEnumerable,ym=(r,t,e)=>t in r?u2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jr=(r,t)=>{for(var e in t||(t={}))c2.call(t,e)&&ym(r,e,t[e]);if(bm)for(var e of bm(t))h2.call(t,e)&&ym(r,e,t[e]);return r};const vm=["webgl","webgpu","canvas"];async function xm(r){var t;let e=[];r.preference?(e.push(r.preference),vm.forEach(o=>{o!==r.preference&&e.push(o)})):e=vm.slice();let i,s={};for(let o=0;o<e.length;o++){const a=e[o];if(a==="webgpu"&&await Hr()){const{WebGPURenderer:l}=await Promise.resolve().then(function(){return rR});i=l,s=jr(jr({},r),r.webgpu);break}else if(a==="webgl"&&Xr((t=r.failIfMajorPerformanceCaveat)!=null?t:Nr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Promise.resolve().then(function(){return kw});i=l,s=jr(jr({},r),r.webgl);break}else if(a==="canvas")throw s=jr({},r),new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!i)throw new Error("No available renderer for the current environment");const n=new i;return await n.init(s),n}const d2=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,zr="8.10.1";class _a{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,zr)}static destroy(){}}_a.extension=y.Application;class ba{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,zr)}destroy(){this._renderer=null}}ba.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"initHook",priority:-10};var p2=Object.defineProperty,Tm=Object.getOwnPropertySymbols,f2=Object.prototype.hasOwnProperty,m2=Object.prototype.propertyIsEnumerable,Sm=(r,t,e)=>t in r?p2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,g2=(r,t)=>{for(var e in t||(t={}))f2.call(t,e)&&Sm(r,e,t[e]);if(Tm)for(var e of Tm(t))m2.call(t,e)&&Sm(r,e,t[e]);return r};const Em=class Pu{constructor(...t){this.stage=new lt}async init(t){t=g2({},t),this.renderer=await xm(t),Pu._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Pu._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}};Em._plugins=[];let Am=Em;B.handleByList(y.Application,Am._plugins),B.add(_a);class ya extends Ko{constructor(t,e){var i;super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],l=s[a.id];this.pages.push({texture:l})}),Object.keys(n.chars).forEach(o=>{var a;const l=n.chars[o],{frame:u,source:c}=s[l.page],h=new z(l.x+u.x,l.y+u.y,l.width,l.height),p=new P({source:c,frame:h});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(a=l.kerning)!=null?a:{},texture:p}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(i=n.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){Ur.install(t)}static uninstall(t){Ur.uninstall(t)}}const as={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const s=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in s){const _=s[m].match(/^[a-z]+/gm)[0],g=s[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),b={};for(const v in g){const x=g[v].split("="),T=x[0],E=x[1].replace(/"/gm,""),S=parseFloat(E),A=isNaN(S)?E:S;b[T]=A}n[_].push(b)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=n.info,[l]=n.common,[u]=(t=n.distanceField)!=null?t:[];u&&(o.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const c=n.page;for(let m=0;m<c.length;m++)o.pages.push({id:parseInt(c[m].id,10)||0,file:c[m].file});const h={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const p=n.char;for(let m=0;m<p.length;m++){const _=p[m],g=parseInt(_.id,10);let b=(i=(e=_.letter)!=null?e:_.char)!=null?i:String.fromCharCode(g);b==="space"&&(b=" "),h[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:{}}}const 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[h[g]].kerning[h[_]]=b}return o}},va={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){var t,e;const 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];o&&(i.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=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 h=0;h<a.length;h++)i.pages.push({id:parseInt(a[h].getAttribute("id"),10)||0,file:a[h].getAttribute("file")});const c={};i.baseLineOffset=i.lineHeight-parseInt(n.getAttribute("base"),10);for(let h=0;h<l.length;h++){const p=l[h],f=parseInt(p.getAttribute("id"),10);let m=(e=(t=p.getAttribute("letter"))!=null?t:p.getAttribute("char"))!=null?e:String.fromCharCode(f);m==="space"&&(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 h=0;h<u.length;h++){const p=parseInt(u[h].getAttribute("first"),10),f=parseInt(u[h].getAttribute("second"),10),m=parseInt(u[h].getAttribute("amount"),10);i.chars[c[f]].kerning[c[p]]=m}return i}},xa={test(r){return typeof r=="string"&&r.includes("<font>")?va.test(L.get().parseXML(r)):!1},parse(r){return va.parse(L.get().parseXML(r))}},_2=[".xml",".fnt"],Pm={extension:{type:y.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof ya,getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},wm={extension:{type:y.LoadParser,priority:xt.Normal},name:"loadBitmapFont",test(r){return _2.includes(ft.extname(r).toLowerCase())},async testParse(r){return as.test(r)||xa.test(r)},async parse(r,t,e){const i=as.test(r)?as.parse(r):xa.parse(r),{src:s}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;c<n.length;++c){const h=n[c].file;let p=ft.join(ft.dirname(s),h);p=Ei(p,s),o.push({src:p,data:a})}const l=await e.load(o),u=o.map(c=>l[c.src]);return new ya({data:i,textures:u},s)},async load(r,t){return await(await L.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 Rm{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;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,t&&!this._isLoading&&this._next())}}const Mm={extension:{type:y.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+(n===0?"":n+1)]=s})}),e}};async function Ta(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const Cm={extension:{type:y.DetectionParser,priority:1},test:async()=>Ta("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Om=["png","jpg","jpeg"],Gm={extension:{type:y.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Om],remove:async r=>r.filter(t=>!Om.includes(t))},b2="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ls(r){return b2?!1:document.createElement("video").canPlayType(r)!==""}const Bm={extension:{type:y.DetectionParser,priority:0},test:async()=>ls("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Im={extension:{type:y.DetectionParser,priority:0},test:async()=>ls("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Fm={extension:{type:y.DetectionParser,priority:0},test:async()=>ls("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Dm={extension:{type:y.DetectionParser,priority:0},test:async()=>Ta("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var y2=Object.defineProperty,v2=Object.defineProperties,x2=Object.getOwnPropertyDescriptors,Um=Object.getOwnPropertySymbols,T2=Object.prototype.hasOwnProperty,S2=Object.prototype.propertyIsEnumerable,km=(r,t,e)=>t in r?y2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E2=(r,t)=>{for(var e in t||(t={}))T2.call(t,e)&&km(r,e,t[e]);if(Um)for(var e of Um(t))S2.call(t,e)&&km(r,e,t[e]);return r},A2=(r,t)=>v2(r,x2(t));class $m{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(e.loadParser&&(a=this._parserHash[e.loadParser]),!a){for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.load&&(s=u.test)!=null&&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((n=u.testParse)==null?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=vr(t),o=Ct(t,u=>({alias:[u],src:u,data:{}})),a=o.length,l=o.map(async u=>{const c=ft.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(h){throw delete this.promiseCache[c],delete s[u.src],new Error(`[Loader.load] Failed to load ${c}.
${h}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Ct(t,i=>({alias:[i],src:i})).map(async i=>{var s,n;const o=ft.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],await((n=(s=a.parser)==null?void 0:s.unload)==null?void 0:n.call(s,l,i,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name&&t[e.name],A2(E2({},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 Bt(r,t){const e=r.split("?")[0],i=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const P2=".json",w2="application/json",Lm={extension:{type:y.LoadParser,priority:xt.Low},name:"loadJson",test(r){return Pe(r,w2)||Bt(r,P2)},async load(r){return await(await L.get().fetch(r)).json()}},R2=".txt",M2="text/plain",Nm={name:"loadTxt",extension:{type:y.LoadParser,priority:xt.Low,name:"loadTxt"},test(r){return Pe(r,M2)||Bt(r,R2)},async load(r){return await(await L.get().fetch(r)).text()}};var C2=Object.defineProperty,O2=Object.defineProperties,G2=Object.getOwnPropertyDescriptors,Xm=Object.getOwnPropertySymbols,B2=Object.prototype.hasOwnProperty,I2=Object.prototype.propertyIsEnumerable,Hm=(r,t,e)=>t in r?C2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,F2=(r,t)=>{for(var e in t||(t={}))B2.call(t,e)&&Hm(r,e,t[e]);if(Xm)for(var e of Xm(t))I2.call(t,e)&&Hm(r,e,t[e]);return r},D2=(r,t)=>O2(r,G2(t));const U2=["normal","bold","100","200","300","400","500","600","700","800","900"],k2=[".ttf",".otf",".woff",".woff2"],$2=["font/ttf","font/otf","font/woff","font/woff2"],L2=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jm(r){const t=ft.extname(r),e=ft.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(L2)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const N2=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function X2(r){return N2.test(r)?r:encodeURI(r)}const zm={extension:{type:y.LoadParser,priority:xt.Low},name:"loadWebFont",test(r){return Pe(r,$2)||Bt(r,k2)},async load(r,t){var e,i,s,n,o,a;const l=L.get().getFontFaceSet();if(l){const u=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:jm(r),h=(o=(n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(f=>U2.includes(f)))!=null?o:["normal"],p=(a=t.data)!=null?a:{};for(let f=0;f<h.length;f++){const m=h[f],_=new FontFace(c,`url(${X2(r)})`,D2(F2({},p),{weight:m}));await _.load(),l.add(_),u.push(_)}return W.set(`${c}-and-url`,{url:r,fontFaces:u}),u.length===1?u[0]:u}return null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>{W.remove(`${t.family}-and-url`),L.get().getFontFaceSet().delete(t)})}};function us(r,t=1){var e;const i=(e=ie.RETINA_PREFIX)==null?void 0:e.exec(r);return i?parseFloat(i[1]):t}function ae(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 H2=Object.defineProperty,cs=Object.getOwnPropertySymbols,Vm=Object.prototype.hasOwnProperty,Wm=Object.prototype.propertyIsEnumerable,Ym=(r,t,e)=>t in r?H2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,j2=(r,t)=>{for(var e in t||(t={}))Vm.call(t,e)&&Ym(r,e,t[e]);if(cs)for(var e of cs(t))Wm.call(t,e)&&Ym(r,e,t[e]);return r},z2=(r,t)=>{var e={};for(var i in r)Vm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&cs)for(var i of cs(r))t.indexOf(i)<0&&Wm.call(r,i)&&(e[i]=r[i]);return e};const V2=".svg",W2="image/svg+xml",Km={extension:{type:y.LoadParser,priority:xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Pe(r,W2)||Bt(r,V2)},async load(r,t,e){var i,s;return((s=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?K2(r):Y2(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function Y2(r,t,e,i){var s,n,o,a,l,u;const c=await(await L.get().fetch(r)).blob(),h=URL.createObjectURL(c),p=new Image;p.src=h,p.crossOrigin=i,await p.decode(),URL.revokeObjectURL(h);const f=document.createElement("canvas"),m=f.getContext("2d"),_=((s=t.data)==null?void 0:s.resolution)||us(r),g=(o=(n=t.data)==null?void 0:n.width)!=null?o:p.width,b=(l=(a=t.data)==null?void 0:a.height)!=null?l:p.height;f.width=g*_,f.height=b*_,m.drawImage(p,0,0,g*_,b*_);const v=(u=t.data)!=null?u:{},{parseAsGraphicsContext:x}=v,T=z2(v,["parseAsGraphicsContext"]),E=new se(j2({resource:f,alphaMode:"premultiply-alpha-on-upload",resolution:_},T));return ae(E,e,r)}async function K2(r){const t=await(await L.get().fetch(r)).text(),e=new ht;return e.svg(t),e}const q2=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})();
`;let er=null,Sa=class{constructor(){er||(er=URL.createObjectURL(new Blob([q2],{type:"application/javascript"}))),this.worker=new Worker(er)}};Sa.revokeObjectURL=function(){er&&(URL.revokeObjectURL(er),er=null)};const Z2='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let rr=null,qm=class{constructor(){rr||(rr=URL.createObjectURL(new Blob([Z2],{type:"application/javascript"}))),this.worker=new Worker(rr)}};qm.revokeObjectURL=function(){rr&&(URL.revokeObjectURL(rr),rr=null)};let Zm=0,Ea,Q2=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Sa;e.addEventListener("message",i=>{e.terminate(),Sa.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Ea===void 0&&(Ea=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Ea&&(this._createdWorkers++,t=new qm().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Zm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Zm++,id:i})}};const Aa=new Q2;var J2=Object.defineProperty,Qm=Object.getOwnPropertySymbols,tE=Object.prototype.hasOwnProperty,eE=Object.prototype.propertyIsEnumerable,Jm=(r,t,e)=>t in r?J2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rE=(r,t)=>{for(var e in t||(t={}))tE.call(t,e)&&Jm(r,e,t[e]);if(Qm)for(var e of Qm(t))eE.call(t,e)&&Jm(r,e,t[e]);return r};const iE=[".jpeg",".jpg",".png",".webp",".avif"],sE=["image/jpeg","image/png","image/webp","image/avif"];async function tg(r,t){var e;const i=await L.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const s=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Pa={name:"loadTextures",extension:{type:y.LoadParser,priority:xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Pe(r,sE)||Bt(r,iE)},async load(r,t,e){var i;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Aa.isImageBitmapSupported()?s=await Aa.loadImageBitmap(r,t):s=await tg(r,t):s=await new Promise((o,a)=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)});const n=new se(rE({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||us(r)},t.data));return ae(n,e,r)},unload(r){r.destroy(!0)}};var nE=Object.defineProperty,oE=Object.defineProperties,aE=Object.getOwnPropertyDescriptors,eg=Object.getOwnPropertySymbols,lE=Object.prototype.hasOwnProperty,uE=Object.prototype.propertyIsEnumerable,rg=(r,t,e)=>t in r?nE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wa=(r,t)=>{for(var e in t||(t={}))lE.call(t,e)&&rg(r,e,t[e]);if(eg)for(var e of eg(t))uE.call(t,e)&&rg(r,e,t[e]);return r},ig=(r,t)=>oE(r,aE(t));const sg=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],cE=sg.map(r=>`video/${r.substring(1)}`);function ng(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=ag(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function og(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),t()}function s(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function ag(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const lg={name:"loadVideo",extension:{type:y.LoadParser,name:"loadVideo"},test(r){const t=Pe(r,cE),e=Bt(r,sg);return t||e},async load(r,t,e){var i,s;const n=wa(ig(wa({},xr.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||us(r),alphaMode:((s=t.data)==null?void 0:s.alphaMode)||await Un()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(c=>{const h=a[c];h!==void 0&&o.setAttribute(c,h)}),n.muted===!0&&(o.muted=!0),ng(o,r,n.crossorigin);const l=document.createElement("source");let u;if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=xr.MIME_TYPES[c]||`video/${c}`}return l.src=r,u&&(l.type=u),new Promise(c=>{const h=async()=>{const p=new xr(ig(wa({},n),{resource:o}));o.removeEventListener("canplay",h),t.data.preload&&await og(o),c(ae(p,e,r))};n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",h),o.appendChild(l)})},unload(r){r.destroy(!0)}},Ra={extension:{type:y.ResolveParser,name:"resolveTexture"},test:Pa.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=ie.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},ug={extension:{type:y.ResolveParser,priority:-2,name:"resolveJson"},test:r=>ie.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Ra.parse};class cg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ie,this.loader=new $m,this.cache=W,this._backgroundLoader=new Rm(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,s;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const n=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(s=t.texturePreference)==null?void 0:s.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=vr(t),s=Ct(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(u=>!this.resolver.hasKey(u))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const u=()=>{e==null||e(++a/l)},c=o.map(h=>{const p=s[h];return l+=Object.keys(p).length,this._mapLoadToResolve(p,u).then(f=>{n[h]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return W.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=W.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.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();const e=Ct(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}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){const e=Object.values(t);e.forEach(i=>{W.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Vr=new cg;B.handleByList(y.LoadParser,Vr.loader.parsers).handleByList(y.ResolveParser,Vr.resolver.parsers).handleByList(y.CacheParser,Vr.cache.parsers).handleByList(y.DetectionParser,Vr.detections),B.add(Mm,Gm,Cm,Dm,Bm,Im,Fm,Lm,Nm,zm,Km,Pa,lg,wm,Pm,Ra,ug);const hg={loader:y.LoadParser,resolver:y.ResolveParser,cache:y.CacheParser,detection:y.DetectionParser};B.handle(y.Asset,r=>{const t=r.ref;Object.entries(hg).filter(([e])=>!!t[e]).forEach(([e,i])=>{var s;return B.add(Object.assign(t[e],{extension:(s=t[e].extension)!=null?s:i}))})},r=>{const t=r.ref;Object.keys(hg).filter(e=>!!t[e]).forEach(e=>B.remove(t[e]))});const hE={extension:{type:y.DetectionParser,priority:3},test:async()=>!!(await Hr()||Xr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class Wr extends q{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let hs;function Ma(){if(hs)return hs;const r=document.createElement("canvas").getContext("webgl");return r?(hs=[...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"]:[]],hs):[]}let ds;async function Ca(){if(ds)return ds;const r=await L.get().getNavigator().gpu.requestAdapter();return ds=[...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"]:[]],ds}let Oa;async function Ga(){return Oa!==void 0||(Oa=await(async()=>{const r=await Hr(),t=Xr();if(r&&t){const e=await Ca(),i=Ma();return e.filter(s=>i.includes(s))}else{if(r)return await Ca();if(t)return Ma()}return[]})()),Oa}const dg=["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 ps;async function Yr(){if(ps!==void 0)return ps;const r=await Ga();return ps=[...dg,...r],ps}const dE='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e<s;++e)for(let o=0;o<t;++o){const B=r.getImageTranscodedSizeInBytes(o,e,a),f=new Uint8Array(B);if(!r.transcodeImage(f,o,e,a,1,0))throw new Error("transcodeImage failed");m.push(f)}return m}const w={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function d(r){const a=w[r];if(a)return a;throw new Error(`Unsupported transcoderFormat: ${r}`)}const n={jsUrl:"basis/basis_transcoder.js",wasmUrl:"basis/basis_transcoder.wasm"};let u,i,c;async function l(){if(!c){const r=new URL(n.jsUrl,location.origin).href,a=new URL(n.wasmUrl,location.origin).href;importScripts(r),c=new Promise(t=>{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)}})();\n';let ir=null,pg=class{constructor(){ir||(ir=URL.createObjectURL(new Blob([dE],{type:"application/javascript"}))),this.worker=new Worker(ir)}};pg.revokeObjectURL=function(){ir&&(URL.revokeObjectURL(ir),ir=null)};const fs={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function pE(r){Object.assign(fs,r)}let Kr;const fg={};function fE(r){return Kr||(Kr=new pg().worker,Kr.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load Basis texture",i),fg[i](s)},Kr.postMessage({type:"init",jsUrl:fs.jsUrl,wasmUrl:fs.wasmUrl,supportedTextures:r})),Kr}function mg(r,t){const e=fE(t);return new Promise(i=>{fg[r]=i,e.postMessage({type:"load",url:r})})}const mE={extension:{type:y.LoadParser,priority:xt.High,name:"loadBasis"},name:"loadBasis",test(r){return Bt(r,[".basis"])},async load(r,t,e){const i=await Yr(),s=await mg(r,i),n=new Wr(s);return ae(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function gE(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const s=[];for(let n=0;n<i;++n)for(let o=0;o<e;++o){const a=r.getImageTranscodedSizeInBytes(o,n,t),l=new Uint8Array(a);if(!r.transcodeImage(l,o,n,t,1,0))throw new Error("transcodeImage failed");s.push(l)}return s}const _E={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function bE(r){const t=_E[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const yE={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},vE={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Ba=(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))(Ba||{}),Ia=(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))(Ia||{});function at(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var yt=(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))(yt||{});const Fa={[yt.DXT1]:"bc1-rgba-unorm",[yt.DXT2]:"bc2-rgba-unorm",[yt.DXT3]:"bc2-rgba-unorm",[yt.DXT4]:"bc3-rgba-unorm",[yt.DXT5]:"bc3-rgba-unorm",[yt.ATI1]:"bc4-r-unorm",[yt.BC4U]:"bc4-r-unorm",[yt.BC4S]:"bc4-r-snorm",[yt.ATI2]:"bc5-rg-unorm",[yt.BC5U]:"bc5-rg-unorm",[yt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},vt={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:yE,HEADER_DX10_FIELDS:vE,DXGI_FORMAT:Ba,D3D10_RESOURCE_DIMENSION:Ia,D3DFMT:yt},gg={"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 _g(r,t){const{format:e,fourCC:i,width:s,height:n,dataOffset:o,mipmapCount:a}=TE(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:s,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const l=xE(e,s,n,o,a,r);return{format:e,width:s,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function xE(r,t,e,i,s,n){const o=[],a=gg[r];let l=t,u=e,c=i;for(let h=0;h<s;++h){const p=Math.ceil(Math.max(4,l)/4)*4,f=Math.ceil(Math.max(4,u)/4)*4,m=a?p/4*f/4*a:l*u*4,_=new Uint8Array(n,c,m);o.push(_),c+=m,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return o}function TE(r){const 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");const 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],a=SE(t,n,o,r),l=F.MAGIC_SIZE+F.HEADER_SIZE+(o===F.D3DFMT.DX10?F.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:i,height:e,dataOffset:l,mipmapCount:s}}function SE(r,t,e,i){if(t&F.PIXEL_FORMAT_FLAGS.FOURCC){if(e===F.D3DFMT.DX10){const s=new Uint32Array(i,F.MAGIC_SIZE+F.HEADER_SIZE,F.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(s[F.HEADER_DX10_FIELDS.MISC_FLAG]===F.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(s[F.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===F.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=s[F.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in vt)return vt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Fa)return Fa[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 EE(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!")}function EE(r){const 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(e===255&&i===65280&&s===16711680&&n===4278190080)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&s===255&&n===4278190080)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&s===1023&&n===3221225472)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&s===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&s===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&s===31&&n===32768)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&s===31&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&s===15&&n===61440)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&s===0&&n===65280)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&s===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&s===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration:
bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${n}`)}const AE={extension:{type:y.LoadParser,priority:xt.High,name:"loadDDS"},name:"loadDDS",test(r){return Bt(r,[".dds"])},async load(r,t,e){const i=await Yr(),s=await(await fetch(r)).arrayBuffer(),n=_g(s,i),o=new Wr(n);return ae(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var bg=(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))(bg||{}),PE=(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))(PE||{}),wE=(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))(wE||{});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 yg(r,t){const e=new DataView(r);if(!OE(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:s,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=CE(e),h=tt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!h)throw new Error(`Unknown texture format ${o}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=ME(s,n,o),f=RE(e,s,p,a,l,c,u,i);return{format:h,width:a,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function RE(r,t,e,i,s,n,o,a){const l=i+3&-4,u=s+3&-4;let c=i*s;t===0&&(c=l*u);let h=c*e,p=i,f=s,m=l,_=u,g=n;const b=new Array(o);for(let v=0;v<o;v++){const x=r.getUint32(g,a);let T=g+4;b[v]=new Uint8Array(r.buffer,T,h),T+=h,g+=x+4,g=g%4!==0?g+4-g%4:g,p=p>>1||1,f=f>>1||1,m=p+4-1&-4,_=f+4-1&-4,h=m*_*e}return b}function ME(r,t,e){let i=tt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(tt.TYPES_TO_BYTES_PER_COMPONENT[r]?i=tt.TYPES_TO_BYTES_PER_COMPONENT[r]*tt.FORMATS_TO_COMPONENTS[t]:i=tt.TYPES_TO_BYTES_PER_PIXEL[r]),i===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return i}function CE(r){const 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),h=r.getUint32(tt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:s,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:c,offset:tt.FILE_HEADER_SIZE+h}}function OE(r){for(let t=0;t<tt.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==tt.FILE_IDENTIFIER[t])return!1;return!0}const GE={extension:{type:y.LoadParser,priority:xt.High,name:"loadKTX"},name:"loadKTX",test(r){return Bt(r,".ktx")},async load(r,t,e){const i=await Yr(),s=await(await fetch(r)).arrayBuffer(),n=yg(s,i),o=new Wr(n);return ae(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},BE='(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';let sr=null;class vg{constructor(){sr||(sr=URL.createObjectURL(new Blob([BE],{type:"application/javascript"}))),this.worker=new Worker(sr)}}vg.revokeObjectURL=function(){sr&&(URL.revokeObjectURL(sr),sr=null)};const ms={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function IE(r){Object.assign(ms,r)}let qr;const xg={};function FE(r){return qr||(qr=new vg().worker,qr.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load KTX texture",i),xg[i](s)},qr.postMessage({type:"init",jsUrl:ms.jsUrl,wasmUrl:ms.wasmUrl,supportedTextures:r})),qr}function Tg(r,t){const e=FE(t);return new Promise(i=>{xg[r]=i,e.postMessage({type:"load",url:r})})}const DE={extension:{type:y.LoadParser,priority:xt.High,name:"loadKTX2"},name:"loadKTX2",test(r){return Bt(r,".ktx2")},async load(r,t,e){const i=await Yr(),s=await Tg(r,i),n=new Wr(s);return ae(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Da={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:Sg},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:Sg}};function UE(r){const t=r.format;if(Da[t]){const e=Da[t].convertFunction,i=r.resource;for(let s=0;s<i.length;s++)i[s]=e(i[s]);r.format=Da[t].convertedFormat}}function Sg(r){const t=r.byteLength/3,e=new Uint32Array(t);for(let i=0;i<t;++i)e[i]=r[i*3]+(r[i*3+1]<<8)+(r[i*3+2]<<16)+4278190080;return new Uint8Array(e.buffer)}function kE(r){const t=[];for(let e=0;e<r.numLevels;e++){const i=r.getImageData(e,0,0),s=new Uint8Array(i.byteLength);s.set(i),t.push(s)}return t}const $E={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 Eg(r){const t=$E[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const LE={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function Ag(r){const t=LE[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function NE(r){return r.classId===2?Ag(r.vkFormat):Eg(r.glInternalformat)}const XE={"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 HE(r){const t=XE[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const gs=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],jE={extension:y.ResolveParser,test:r=>Bt(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const s=r.split(".");if(s.length>2){const n=s[s.length-2];gs.includes(n)&&(i=n)}else i=s[s.length-1];return{resolution:parseFloat((e=(t=ie.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let _s;const zE={extension:{type:y.DetectionParser,priority:2},test:async()=>!!(await Hr()||Xr()),add:async r=>{const t=await Ga();return _s=VE(t),[..._s,...r]},remove:async r=>_s?r.filter(t=>!(t in _s)):r};function VE(r){const t=["basis"],e={};return r.forEach(i=>{const s=i.split("-")[0];s&&!e[s]&&(e[s]=!0,t.push(s))}),t.sort((i,s)=>{const n=gs.indexOf(i),o=gs.indexOf(s);return n===-1?1:o===-1?-1:n-o}),t}const WE=new st,Ua=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){const n=(s=t.cullArea)!=null?s:fr(t,i,WE);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!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)}};Ua.shared=new Ua;let Pg=Ua;class wg{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}}wg.extension={priority:10,type:y.Application,name:"culler"};const YE={extension:{type:y.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return i2})}};var KE=Object.defineProperty,bs=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable,Cg=(r,t,e)=>t in r?KE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ka=(r,t)=>{for(var e in t||(t={}))Rg.call(t,e)&&Cg(r,e,t[e]);if(bs)for(var e of bs(t))Mg.call(t,e)&&Cg(r,e,t[e]);return r},qE=(r,t)=>{var e={};for(var i in r)Rg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&bs)for(var i of bs(r))t.indexOf(i)<0&&Mg.call(r,i)&&(e[i]=r[i]);return e};const Og=class wu extends St{constructor(t){t=ka(ka({},wu.defaultOptions),t),super(t),this.enabled=!0,this._state=Et.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1)}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){const e=t,{gpu:i,gl:s}=e,n=qE(e,["gpu","gl"]);let o,a;return i&&(o=gt.from(i)),s&&(a=Tt.from(s)),new wu(ka({gpuProgram:o,glProgram:a},n))}};Og.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let te=Og;var Gg=`
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}
}
`,Bg=`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();
}
`,Ig=`
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;
}`,ZE=Object.defineProperty,Fg=Object.getOwnPropertySymbols,QE=Object.prototype.hasOwnProperty,JE=Object.prototype.propertyIsEnumerable,Dg=(r,t,e)=>t in r?ZE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ug=(r,t)=>{for(var e in t||(t={}))QE.call(t,e)&&Dg(r,e,t[e]);if(Fg)for(var e of Fg(t))JE.call(t,e)&&Dg(r,e,t[e]);return r};class tA extends te{constructor(t){const e=t.gpu,i=kg(Ug({source:Ig},e)),s=gt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),n=t.gl,o=kg(Ug({source:Gg},n)),a=Tt.from({vertex:Bg,fragment:o}),l=new it({uBlend:{value:1,type:"f32"}});super({gpuProgram:s,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:P.EMPTY}})}}function kg(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const eA=`
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;
}
`,rA=`
fn getLuminosity(c: vec3<f32>) -> f32
{
return 0.3*c.r + 0.59*c.g + 0.11*c.b;
}
fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32>
{
var modLum: f32 = lum - getLuminosity(c);
var color: vec3<f32> = c.rgb + modLum;
// clip back into legal range
modLum = getLuminosity(color);
let modLumVec = vec3<f32>(modLum);
let cMin: f32 = min(color.r, min(color.g, color.b));
let cMax: f32 = max(color.r, max(color.g, color.b));
if(cMin < 0.0)
{
color = mix(modLumVec, color, modLum / (modLum - cMin));
}
if(cMax > 1.0)
{
color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum));
}
return color;
}
fn getSaturation(c: vec3<f32>) -> f32
{
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32>
{
var colorSorted = cSorted;
if(colorSorted.z > colorSorted.x)
{
colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
colorSorted.z = s;
}
else
{
colorSorted.y = 0;
colorSorted.z = 0;
}
colorSorted.x = 0;
return colorSorted;
}
fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32>
{
var color = c;
if (color.r <= color.g && color.r <= color.b)
{
if (color.g <= color.b)
{
color = vec3<f32>(setSaturationMinMidMax(color.rgb, s)).rgb;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.rbg, s)).rbg;
}
}
else if (color.g <= color.r && color.g <= color.b)
{
if (color.r <= color.b)
{
color = vec3<f32>(setSaturationMinMidMax(color.grb, s)).grb;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.gbr, s)).gbr;
}
}
else
{
// Using bgr for both fixes part of hue
if (color.r <= color.g)
{
color = vec3<f32>(setSaturationMinMidMax(color.brg, s)).brg;
}
else
{
color = vec3<f32>(setSaturationMinMidMax(color.bgr, s)).bgr;
}
}
return color;
}
`;var 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();
}
`,$g=`
in vec2 vTextureCoord;
out vec4 finalColor;
uniform float uAlpha;
uniform sampler2D uTexture;
void main()
{
finalColor = texture(uTexture, vTextureCoord) * uAlpha;
}
`,$a=`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;
}`,iA=Object.defineProperty,sA=Object.defineProperties,nA=Object.getOwnPropertyDescriptors,vs=Object.getOwnPropertySymbols,Lg=Object.prototype.hasOwnProperty,Ng=Object.prototype.propertyIsEnumerable,Xg=(r,t,e)=>t in r?iA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,La=(r,t)=>{for(var e in t||(t={}))Lg.call(t,e)&&Xg(r,e,t[e]);if(vs)for(var e of vs(t))Ng.call(t,e)&&Xg(r,e,t[e]);return r},oA=(r,t)=>sA(r,nA(t)),aA=(r,t)=>{var e={};for(var i in r)Lg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&vs)for(var i of vs(r))t.indexOf(i)<0&&Ng.call(r,i)&&(e[i]=r[i]);return e};const Hg=class sx extends te{constructor(t){t=La(La({},sx.defaultOptions),t);const e=gt.from({vertex:{source:$a,entryPoint:"mainVertex"},fragment:{source:$a,entryPoint:"mainFragment"}}),i=Tt.from({vertex:ys,fragment:$g,name:"alpha-filter"}),s=t,{alpha:n}=s,o=aA(s,["alpha"]),a=new it({uAlpha:{value:n,type:"f32"}});super(oA(La({},o),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};Hg.defaultOptions={alpha:1};let lA=Hg;const Na={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]},uA=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(`
`);function jg(r){const t=Na[r],e=t.length;let i=uA,s="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const cA=`
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 zg(r,t){const e=Math.ceil(r/2);let i=cA,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i=i.replace("%dimension%",t?"z":"w"),i}function Vg(r,t){const e=zg(t,r),i=jg(t);return Tt.from({vertex:e,fragment:i,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var Wg=`
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 Yg(r,t){const e=Na[t],i=e.length,s=[],n=[],o=[];for(let h=0;h<t;h++){s[h]=`@location(${h}) offset${h}: vec2<f32>,`,r?n[h]=`filteredCord + vec2(${h-i+1} * pixelStrength, 0.0),`:n[h]=`filteredCord + vec2(0.0, ${h-i+1} * pixelStrength),`;const p=h<i?h:t-h-1,f=e[p].toString();o[h]=`finalColor += textureSample(uTexture, uSampler, offset${h}) * ${f};`}const a=s.join(`
`),l=n.join(`
`),u=o.join(`
`),c=Wg.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:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}var hA=Object.defineProperty,Kg=Object.getOwnPropertySymbols,dA=Object.prototype.hasOwnProperty,pA=Object.prototype.propertyIsEnumerable,qg=(r,t,e)=>t in r?hA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xa=(r,t)=>{for(var e in t||(t={}))dA.call(t,e)&&qg(r,e,t[e]);if(Kg)for(var e of Kg(t))pA.call(t,e)&&qg(r,e,t[e]);return r};const Zg=class nx extends te{constructor(t){t=Xa(Xa({},nx.defaultOptions),t);const e=Vg(t.horizontal,t.kernelSize),i=Yg(t.horizontal,t.kernelSize);super(Xa({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,this.passes===1)t.applyFilter(this,e,i,s);else{const n=rt.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer.type===_t.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,o,a,u===0?!0:l);const c=a;a=o,o=c}this._state.blend=!0,t.applyFilter(this,o,i,s),rt.returnTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};Zg.defaultOptions={strength:8,quality:4,kernelSize:5};let xs=Zg;var fA=Object.defineProperty,mA=Object.defineProperties,gA=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,Jg=Object.prototype.propertyIsEnumerable,t_=(r,t,e)=>t in r?fA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zr=(r,t)=>{for(var e in t||(t={}))Qg.call(t,e)&&t_(r,e,t[e]);if(Ts)for(var e of Ts(t))Jg.call(t,e)&&t_(r,e,t[e]);return r},_A=(r,t)=>mA(r,gA(t)),bA=(r,t)=>{var e={};for(var i in r)Qg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ts)for(var i of Ts(r))t.indexOf(i)<0&&Jg.call(r,i)&&(e[i]=r[i]);return e};class e_ extends te{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]!==void 0&&(i.quality=t[1]),t[2]!==void 0&&(i.resolution=t[2]||"inherit"),t[3]!==void 0&&(i.kernelSize=t[3])),i=Zr(Zr({},xs.defaultOptions),i);const s=i,{strength:n,strengthX:o,strengthY:a,quality:l}=s,u=bA(s,["strength","strengthX","strengthY","quality"]);super(_A(Zr({},u),{compatibleRenderers:_t.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new xs(Zr({horizontal:!0},i)),this.blurYFilter=new xs(Zr({horizontal:!1},i)),this.quality=l,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=rt.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,i,s),rt.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,s)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,s))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}e_.defaultOptions={strength:8,quality:4,kernelSize:5};var r_=`
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);
}
`,Ha=`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);
}`,yA=Object.defineProperty,vA=Object.defineProperties,xA=Object.getOwnPropertyDescriptors,i_=Object.getOwnPropertySymbols,TA=Object.prototype.hasOwnProperty,SA=Object.prototype.propertyIsEnumerable,s_=(r,t,e)=>t in r?yA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,EA=(r,t)=>{for(var e in t||(t={}))TA.call(t,e)&&s_(r,e,t[e]);if(i_)for(var e of i_(t))SA.call(t,e)&&s_(r,e,t[e]);return r},AA=(r,t)=>vA(r,xA(t));class PA extends te{constructor(t={}){const e=new it({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:Ha,entryPoint:"mainVertex"},fragment:{source:Ha,entryPoint:"mainFragment"}}),s=Tt.from({vertex:ys,fragment:r_,name:"color-matrix-filter"});super(AA(EA({},t),{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){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=H.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,u=o*(1-i)-a*s,c=o*(1-i)+a*s,h=o*(1-i)+a*s,p=i+o*(1-i),f=o*(1-i)-a*s,m=o*(1-i)-a*s,_=o*(1-i)+a*s,g=i+o*(1-i),b=[l,u,c,0,0,h,p,f,0,0,m,_,g,0,0,0,0,0,1,0];this._loadMatrix(b,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t||(t=.2),e||(e=.15),i||(i=16770432),s||(s=3375104);const o=H.shared,[a,l,u]=o.setValue(i).toArray(),[c,h,p]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,u,t,0,c,h,p,e,0,a-c,l-h,u-p,0,0];this._loadMatrix(f,n)}night(t,e){t||(t=.1);const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var n_=`
in vec2 vTextureCoord;
in vec2 vFilterUv;
out vec4 finalColor;
uniform sampler2D uTexture;
uniform sampler2D uMapTexture;
uniform vec4 uInputClamp;
uniform highp vec4 uInputSize;
uniform mat2 uRotation;
uniform vec2 uScale;
void main()
{
vec4 map = texture(uMapTexture, vFilterUv);
vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale;
finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw));
}
`,o_=`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();
}
`,ja=`
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));
}`,wA=Object.defineProperty,RA=Object.defineProperties,MA=Object.getOwnPropertyDescriptors,Ss=Object.getOwnPropertySymbols,a_=Object.prototype.hasOwnProperty,l_=Object.prototype.propertyIsEnumerable,u_=(r,t,e)=>t in r?wA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CA=(r,t)=>{for(var e in t||(t={}))a_.call(t,e)&&u_(r,e,t[e]);if(Ss)for(var e of Ss(t))l_.call(t,e)&&u_(r,e,t[e]);return r},OA=(r,t)=>RA(r,MA(t)),GA=(r,t)=>{var e={};for(var i in r)a_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ss)for(var i of Ss(r))t.indexOf(i)<0&&l_.call(r,i)&&(e[i]=r[i]);return e};class BA extends te{constructor(...t){let e=t[0];e instanceof Dt&&(e={sprite:e,scale:t[1]});const i=e,{sprite:s,scale:n}=i,o=GA(i,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new V(a,a));const l=new it({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:o_,fragment:n_,name:"displacement-filter"}),c=gt.from({vertex:{source:ja,entryPoint:"mainVertex"},fragment:{source:ja,entryPoint:"mainFragment"}}),h=s.texture.source;super(OA(CA({},o),{gpuProgram:c,glProgram:u,resources:{filterUniforms:l,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,s){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),l=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&l!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/l,n.uRotation[3]=o.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,s)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var c_=`
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;
}
`,za=`
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;
}`,IA=Object.defineProperty,FA=Object.defineProperties,DA=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,h_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,p_=(r,t,e)=>t in r?IA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Va=(r,t)=>{for(var e in t||(t={}))h_.call(t,e)&&p_(r,e,t[e]);if(Es)for(var e of Es(t))d_.call(t,e)&&p_(r,e,t[e]);return r},UA=(r,t)=>FA(r,DA(t)),kA=(r,t)=>{var e={};for(var i in r)h_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Es)for(var i of Es(r))t.indexOf(i)<0&&d_.call(r,i)&&(e[i]=r[i]);return e};const f_=class ox extends te{constructor(t={}){t=Va(Va({},ox.defaultOptions),t);const e=gt.from({vertex:{source:za,entryPoint:"mainVertex"},fragment:{source:za,entryPoint:"mainFragment"}}),i=Tt.from({vertex:ys,fragment:c_,name:"noise-filter"}),s=t,{noise:n,seed:o}=s,a=kA(s,["noise","seed"]);super(UA(Va({},a),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new it({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};f_.defaultOptions={noise:.5};let $A=f_;var m_=`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;
}
`,g_=`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);
}
`,Wa=`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;
}
`,LA=Object.defineProperty,NA=Object.defineProperties,XA=Object.getOwnPropertyDescriptors,As=Object.getOwnPropertySymbols,__=Object.prototype.hasOwnProperty,b_=Object.prototype.propertyIsEnumerable,y_=(r,t,e)=>t in r?LA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HA=(r,t)=>{for(var e in t||(t={}))__.call(t,e)&&y_(r,e,t[e]);if(As)for(var e of As(t))b_.call(t,e)&&y_(r,e,t[e]);return r},jA=(r,t)=>NA(r,XA(t)),zA=(r,t)=>{var e={};for(var i in r)__.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&As)for(var i of As(r))t.indexOf(i)<0&&b_.call(r,i)&&(e[i]=r[i]);return e};class v_ extends te{constructor(t){const e=t,{sprite:i}=e,s=zA(e,["sprite"]),n=new yn(i.texture),o=new it({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:Wa,entryPoint:"mainVertex"},fragment:{source:Wa,entryPoint:"mainFragment"}}),l=Tt.from({vertex:g_,fragment:m_,name:"mask-filter"});super(jA(HA({},s),{gpuProgram:a,glProgram:l,resources:{filterUniforms:o,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,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)}}var VA=`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;
}`;function Ya(r,t,e,i,s,n,o,a){const l=o-e,u=a-i,c=s-e,h=n-i,p=r-e,f=t-i,m=l*l+u*u,_=l*c+u*h,g=l*p+u*f,b=c*c+h*h,v=c*p+h*f,x=1/(m*b-_*_),T=(b*g-_*v)*x,E=(m*v-_*g)*x;return T>=0&&E>=0&&T+E<1}class Ka{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){const 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);if(i<0!=s<0&&i!==0&&s!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==i+s<=0}strokeContains(t,e,i,s=.5){const n=i/2,o=n*n,{x:a,x2:l,x3:u,y:c,y2:h,y3:p}=this;return Or(t,e,a,c,l,p)<=o||Or(t,e,l,h,u,p)<=o||Or(t,e,u,p,a,c)<=o}clone(){return new Ka(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);const 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}}const x_=class ax{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let i=0;for(;e.length&&i<ax.uploadsPerFrame;){const s=e.shift();this.uploadQueueItem(s),i++}e.length?ut.system.addOnce(this._tick,this,Kt.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const i of e)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,Kt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i<this.queue.length;i++){const s=this.queue[i];t[s.uid]||(t[s.uid]=!0,this.queue[e++]=s)}this.queue.length=e}_resolve(){const{resolves:t}=this,e=t.slice(0);t.length=0;for(const i of e)i()}};x_.uploadsPerFrame=4;let T_=x_;var WA=Object.defineProperty,Ps=Object.getOwnPropertySymbols,S_=Object.prototype.hasOwnProperty,E_=Object.prototype.propertyIsEnumerable,A_=(r,t,e)=>t in r?WA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,YA=(r,t)=>{for(var e in t||(t={}))S_.call(t,e)&&A_(r,e,t[e]);if(Ps)for(var e of Ps(t))E_.call(t,e)&&A_(r,e,t[e]);return r},KA=(r,t)=>{var e={};for(var i in r)S_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ps)for(var i of Ps(r))t.indexOf(i)<0&&E_.call(r,i)&&(e[i]=r[i]);return e};class nr extends Nt{constructor(...t){var e;let i=t[0];i instanceof be&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const s=i,{geometry:n,shader:o,texture:a,roundPixels:l,state:u}=s,c=KA(s,["geometry","shader","texture","roundPixels","state"]);super(YA({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=o!=null?o:null,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:P.WHITE,this.state=u!=null?u:Et.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof Ae?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){const u=o[l]*2,c=o[l+1]*2,h=o[l+2]*2;if(Ya(e,i,s[u],s[u+1],s[c],s[c+1],s[h],s[h+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const l=a*2,u=(a+1)*2,c=(a+2)*2;if(Ya(e,i,s[l],s[l+1],s[u],s[u+1],s[c],s[c+1]))return!0}}return!1}destroy(t){var e;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}(e=this._geometry)==null||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}var qA=Object.defineProperty,ZA=Object.defineProperties,QA=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertySymbols,P_=Object.prototype.hasOwnProperty,w_=Object.prototype.propertyIsEnumerable,R_=(r,t,e)=>t in r?qA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JA=(r,t)=>{for(var e in t||(t={}))P_.call(t,e)&&R_(r,e,t[e]);if(ws)for(var e of ws(t))w_.call(t,e)&&R_(r,e,t[e]);return r},tP=(r,t)=>ZA(r,QA(t)),eP=(r,t)=>{var e={};for(var i in r)P_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ws)for(var i of ws(r))t.indexOf(i)<0&&w_.call(r,i)&&(e[i]=r[i]);return e};class Qr extends Dt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:s=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:h,updateAnchor:p=!1}=i,f=eP(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=h;super(tP(JA({},f),{texture:m instanceof P?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=s,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=h,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,Kt.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,s=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(P.from(t[i]));return new Qr(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(P.from(t[i]));return new Qr(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}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(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 M_{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new M,this.observer=e,this.position=new et(this,0,0),this.scale=new et(this,1,1),this.pivot=new et(this,0,0),this.skew=new et(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var rP=Object.defineProperty,Rs=Object.getOwnPropertySymbols,C_=Object.prototype.hasOwnProperty,O_=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?rP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jr=(r,t)=>{for(var e in t||(t={}))C_.call(t,e)&&G_(r,e,t[e]);if(Rs)for(var e of Rs(t))O_.call(t,e)&&G_(r,e,t[e]);return r},iP=(r,t)=>{var e={};for(var i in r)C_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Rs)for(var i of Rs(r))t.indexOf(i)<0&&O_.call(r,i)&&(e[i]=r[i]);return e};const B_=class sn extends Nt{constructor(...t){let e=t[0]||{};e instanceof P&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Jr(Jr({},sn.defaultOptions),e);const i=e!=null?e:{},{texture:s,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=iP(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Jr({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new et({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=s,this._width=u!=null?u:s.width,this._height=c!=null?c:s.height,this._tileTransform=new M_({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new sn(Jr({texture:W.get(t)},e)):new sn(Jr({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){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){typeof t=="number"?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,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){const e=this._width,i=this._height,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};B_.defaultOptions={texture:P.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let I_=B_;var sP=Object.defineProperty,Ms=Object.getOwnPropertySymbols,F_=Object.prototype.hasOwnProperty,D_=Object.prototype.propertyIsEnumerable,U_=(r,t,e)=>t in r?sP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nP=(r,t)=>{for(var e in t||(t={}))F_.call(t,e)&&U_(r,e,t[e]);if(Ms)for(var e of Ms(t))D_.call(t,e)&&U_(r,e,t[e]);return r},oP=(r,t)=>{var e={};for(var i in r)F_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ms)for(var i of Ms(r))t.indexOf(i)<0&&D_.call(r,i)&&(e[i]=r[i]);return e};class Cs extends Nt{constructor(t,e){const i=t,{text:s,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:c}=i,h=oP(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(nP({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s!=null?s:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new et({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c!=null?c:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function Os(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}class qa extends Cs{constructor(...t){const e=Os(t,"Text");super(e,kt),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Rt?e.textureStyle:new Rt(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Qe.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Qe.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=Gt.measureText(this._text,this._style);i=n.width,s=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}class k_ extends T_{resolveQueueItem(t,e){return t instanceof lt?this.resolveContainerQueueItem(t,e):t instanceof q||t instanceof P?e.push(t.source):t instanceof ht&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Dt||t instanceof I_||t instanceof nr?e.push(t.texture.source):t instanceof qa?e.push(t):t instanceof Je?e.push(t.context):t instanceof Qr&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;return s.source}else if(i.action==="fill"){const{texture:s}=i.data.style;return s.source}return null}}class $_ extends Cs{constructor(...t){var e,i,s;const n=Os(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(s=(i=n.style).fill)!=null||(i.fill=16777215),super(n,kt),this.renderPipeId="bitmapText"}updateBounds(){const t=this._bounds,e=this._anchor,i=Ur.measureText(this.text,this._style),s=i.scale,n=i.offsetY*s;let o=i.width*s,a=i.height*s;const l=this._style._stroke;l&&(o+=l.width,a+=l.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}set resolution(t){}get resolution(){return this._resolution}}class L_ extends Cs{constructor(...t){const e=Os(t,"HtmlText");super(e,kr),this.renderPipeId="htmlText",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Rt?e.textureStyle:new Rt(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor,i=ia(this.text,this._style),{width:s,height:n}=i;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}class N_ extends k_{uploadQueueItem(t){t instanceof q?this.uploadTextureSource(t):t instanceof qa?this.uploadText(t):t instanceof L_?this.uploadHTMLText(t):t instanceof $_?this.uploadBitmapText(t):t instanceof ht&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;this.uploadTextureSource(s.source)}else if(i.action==="fill"){const{texture:s}=i.data.style;this.uploadTextureSource(s.source)}return null}}class X_ extends N_{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}X_.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"prepare"};class Za{constructor(){this._tempState=Et.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const s=t.renderer,n=this._didUploadHash[i.uid];s.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=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)}}Za.extension={type:[y.WebGLPipesAdaptor],name:"batch"};function aP(r){const 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},e++,t[e]={sampler:{type:"filtering"},binding:e,visibility:GPUShaderStage.FRAGMENT},e++;return t}function lP(r){const t={};let e=0;for(let i=0;i<r;i++)t[`textureSource${i+1}`]=e++,t[`textureSampler${i+1}`]=e++;return t}const Gs=Et.for2d();class Qa{start(t,e,i){const s=t.renderer,n=s.encoder,o=i.gpuProgram;this._shader=i,this._geometry=e,n.setGeometry(e,o),Gs.blendMode="normal",s.pipeline.getPipeline(e,o,Gs);const a=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){const i=this._shader.gpuProgram,s=t.renderer,n=s.encoder;if(!e.bindGroup){const l=e.textures;e.bindGroup=Mi(l.textures,l.count,s.limits.maxBatchableTextures)}Gs.blendMode=e.blendMode;const o=s.bindGroup.getBindGroup(e.bindGroup,i,1),a=s.pipeline.getPipeline(this._geometry,i,Gs,e.topology);e.bindGroup._touch(s.textureGC.count),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Qa.extension={type:[y.WebGPUPipesAdaptor],name:"batch"};const Ja=class lx{constructor(t,e){this.state=Et.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null);var i,s;this.renderer=t,this._adaptor=e,(s=(i=this._adaptor).init)==null||s.call(i,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new $i({maxTextures:this.renderer.limits.maxBatchableTextures}))),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]=lx.getBatcher(t.batcherName),i.begin()),this._activeBatch=i}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const i in e){const 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){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const s=e[i],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=e.geometry,s=e.shader;this._adaptor.start(this,i,s)}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}};Ja.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"batch"},Ja._availableBatchers=Object.create(null);let tl=Ja;B.handleByMap(y.Batcher,tl._availableBatchers),B.add($i);function uP(r){const t=r.split(/([\n{}])/g).map(i=>i.trim()).filter(i=>i.length);let e="";return t.map(i=>{let s=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),s=e+i),s}).join(`
`)}const H_={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);
`}},j_={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);
`}},cP=new st;let hP=class extends pr{constructor(){super(),this.filters=[new v_({sprite:new Dt(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 el{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(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){const n=t.mask;n.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){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const s=ot.get(hP);if(s.inverse=t.inverse,i){t.mask.mask.measurable=!0;const n=fr(t.mask.mask,!0,cP);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=rt.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const l=s.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:a})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){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(t.action==="popMaskEnd"){e.filter.pop();const s=this._activeMaskStage.pop();i&&rt.returnTexture(s.filterTexture),ot.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}el.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"alphaMask"};class rl{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);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}rl.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"colorMask"};class dP{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Pi(this.mask,t,e)}addLocalBounds(t,e){wi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}}class il{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s,n;const o=t,a=this._renderer;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});const l=o.mask;l.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const u=this._maskHash.get(o);u.instructionsStart=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});const c=i.instructionSize-u.instructionsStart-1;u.instructionsLength=c;const h=a.renderTarget.renderTarget.uid;(n=(s=this._maskStackHash)[h])!=null||(s[h]=0)}pop(t,e,i){const s=t,n=this._renderer;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});const o=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;const s=this._renderer,n=s.renderTarget.renderTarget.uid;let o=(i=(e=this._maskStackHash)[n])!=null?i:e[n]=0;t.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(J.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?s.stencil.setStencilMode(J.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(J.MASK_ACTIVE,o),s.colorMask.setMask(15)):t.action==="popMaskBegin"?(s.colorMask.setMask(0),o!==0?s.stencil.setStencilMode(J.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,bt.STENCIL),s.stencil.setStencilMode(J.DISABLED,o)),o--):t.action==="popMaskEnd"&&(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}}il.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"stencilMask"};var ti=(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))(ti||{});class z_{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class sl{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(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,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){let 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++);const n=this._boundBufferBases[s];if(n&&n._lastBindCallId===this._bindCallId){s++;continue}break}return e=s,this._nextBindBaseIndex=s+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){const{_gl:n}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,i*256,s||256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const s=t.data,n=t.descriptor.usage&X.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return 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(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],s=this._gl;e||s.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=ti.ARRAY_BUFFER;t.descriptor.usage&X.INDEX?i=ti.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&X.UNIFORM&&(i=ti.UNIFORM_BUFFER);const s=new z_(e.createBuffer(),i);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}resetState(){this._boundBufferBases=Object.create(null)}}sl.extension={type:[y.WebGLSystem],name:"buffer"};var pP=Object.defineProperty,fP=Object.defineProperties,mP=Object.getOwnPropertyDescriptors,V_=Object.getOwnPropertySymbols,gP=Object.prototype.hasOwnProperty,_P=Object.prototype.propertyIsEnumerable,W_=(r,t,e)=>t in r?pP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bs=(r,t)=>{for(var e in t||(t={}))gP.call(t,e)&&W_(r,e,t[e]);if(V_)for(var e of V_(t))_P.call(t,e)&&W_(r,e,t[e]);return r},Y_=(r,t)=>fP(r,mP(t));const nl=class ux{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,i;t=Bs(Bs({},ux.defaultOptions),t);let s=this.multiView=t.multiView;if(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=L.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const n=this._renderer.background.alpha<1,o=(e=t.premultipliedAlpha)!=null?e:!0,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:o,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&Ot("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof L.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const s=this.canvas;if(t===2&&(i=s.getContext("webgl2",e)),!i&&(i=s.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=Y_(Bs({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=Y_(Bs({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,s=this.webGLVersion===2,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices}};nl.extension={type:[y.WebGLSystem],name:"context"},nl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let K_=nl;function ol(r,t){var e,i,s;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(i=o.offset)!=null||(o.offset=a.offset),(s=o.instance)!=null||(o.instance=a.instance)):Ot(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}bP(r)}function bP(r){var t,e;const{buffers:i,attributes:s}=r,n={},o={};for(const a in i){const l=i[a];n[l.uid]=0,o[l.uid]=0}for(const a in s){const l=s[a];n[l.buffer.uid]+=Zt(l.format).stride}for(const a in s){const l=s[a];(t=l.stride)!=null||(l.stride=n[l.buffer.uid]),(e=l.start)!=null||(l.start=o[l.buffer.uid]),o[l.buffer.uid]+=Zt(l.format).stride}}var Is=(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))(Is||{}),al=(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))(al||{}),q_=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(q_||{}),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))(j||{});const Z_={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 Q_(r){var t;return(t=Z_[r])!=null?t:Z_.float32}const yP={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ll{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(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=s=>e.bindVertexArrayOES(s),t.deleteVertexArray=s=>e.deleteVertexArrayOES(s));const i=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){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.updateBuffer(s)}}checkCompatibility(t,e){const i=t.attributes,s=e._attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const 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((i=this._geometryVaoHash[t.uid])==null?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const a=this._geometryVaoHash[t.uid];let l=a[o];if(l)return a[e._key]=l,l;ol(t,e._attributeData);const u=t.buffers;l=s.createVertexArray(),s.bindVertexArray(l);for(let c=0;c<u.length;c++){const h=u[c];n.bind(h)}return this.activateVao(t,e),a[e._key]=l,a[o]=l,s.bindVertexArray(null),l}onGeometryDestroy(t,e){const 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){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const s in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[s])}this._geometryVaoHash[i]=null}}activateVao(t,e){var i,s;const n=this._renderer.gl,o=this._renderer.buffer,a=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let l=null;for(const u in a){const c=a[u],h=c.buffer,p=o.getGlBuffer(h),f=e._attributeData[u];if(f){l!==p&&(o.bind(h),l=p);const m=f.location;n.enableVertexAttribArray(m);const _=Zt(c.format),g=Q_(c.format);if(((i=f.format)==null?void 0:i.substring(1,4))==="int"?n.vertexAttribIPointer(m,_.size,g,c.stride,c.offset):n.vertexAttribPointer(m,_.size,g,_.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const b=(s=c.divisor)!=null?s:1;n.vertexAttribDivisor(m,b)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this._renderer,o=this._activeGeometry,a=yP[t||o.topology];if(s!=null||(s=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,u=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;s>1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,u,(i||0)*l,s):n.drawElements(a,e||o.indexBuffer.data.length,u,(i||0)*l)}else s>1?n.drawArraysInstanced(a,i||0,e||o.getSize(),s):n.drawArrays(a,i||0,e||o.getSize());return 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}}ll.extension={type:[y.WebGLSystem],name:"geometry"};var vP=Object.defineProperty,J_=Object.getOwnPropertySymbols,xP=Object.prototype.hasOwnProperty,TP=Object.prototype.propertyIsEnumerable,tb=(r,t,e)=>t in r?vP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eb=(r,t)=>{for(var e in t||(t={}))xP.call(t,e)&&tb(r,e,t[e]);if(J_)for(var e of J_(t))TP.call(t,e)&&tb(r,e,t[e]);return r};const SP=new be({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),ul=class cx{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=eb(eb({},cx.defaultOptions),t);this.useBackBuffer=e,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();const s=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:s,resources:{uTexture:P.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:SP,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)}};ul.extension={type:[y.WebGLSystem],name:"backBuffer",priority:1},ul.defaultOptions={useBackBuffer:!1};let rb=ul;class cl{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}cl.extension={type:[y.WebGLSystem],name:"colorMask"};class hl{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:s,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:c}=t;e.shader.bind(s,o),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}hl.extension={type:[y.WebGLSystem],name:"encoder"};class dl{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Xn(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}dl.extension={type:[y.WebGLSystem],name:"limits"};class ib{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ee=[];ee[J.NONE]=void 0,ee[J.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ee[J.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ee[J.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ee[J.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},ee[J.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class pl{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){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=J.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=ee[t],o=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===J.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}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]))}}pl.extension={type:[y.WebGLSystem],name:"stencil"};class fl{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!pa())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new mt({data:new Float32Array(e.layout.size/4),usage:X.UNIFORM|X.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const s=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(s),o=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new mt({data:new Float32Array(s.layout.size/4),usage:X.UNIFORM|X.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;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const ml={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 sb(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(i=ml[o.data.type],!i)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(i=Math.max(i,e)*o.data.size);const a=i===12?16:i;o.size=i;const l=s%e;l>0&&e-l<a?s+=(e-l)%16:s+=(i-l%i)%i,o.offset=s,s+=i}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}const le=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
var matrix = uv[name].toArray(true);
data[offset] = matrix[0];
data[offset + 1] = matrix[1];
data[offset + 2] = matrix[2];
data[offset + 4] = matrix[3];
data[offset + 5] = matrix[4];
data[offset + 6] = matrix[5];
data[offset + 8] = matrix[6];
data[offset + 9] = matrix[7];
data[offset + 10] = matrix[8];
`,uniform:`
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
v = uv[name];
data[offset] = v.x;
data[offset + 1] = v.y;
data[offset + 2] = v.width;
data[offset + 3] = v.height;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
cv[0] = v.x;
cv[1] = v.y;
cv[2] = v.width;
cv[3] = v.height;
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
}
`},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
v = uv[name];
data[offset] = v.x;
data[offset + 1] = v.y;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.x || cv[1] !== v.y) {
cv[0] = v.x;
cv[1] = v.y;
gl.uniform2f(ud[name].location, v.x, v.y);
}
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
v = uv[name];
data[offset] = v.red;
data[offset + 1] = v.green;
data[offset + 2] = v.blue;
data[offset + 3] = v.alpha;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
cv[0] = v.red;
cv[1] = v.green;
cv[2] = v.blue;
cv[3] = v.alpha;
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
}
`},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
v = uv[name];
data[offset] = v.red;
data[offset + 1] = v.green;
data[offset + 2] = v.blue;
`,uniform:`
cv = ud[name].value;
v = uv[name];
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
cv[0] = v.red;
cv[1] = v.green;
cv[2] = v.blue;
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
}
`}];function gl(r,t,e,i){const 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++){const l=r[a],u=l.data.name;let c=!1,h=0;for(let p=0;p<le.length;p++)if(le[p].test(l.data)){h=l.offset/4,s.push(`name = "${u}";`,`offset += ${h-n};`,le[p][t]||le[p].ubo),c=!0;break}if(!c)if(l.data.size>1)h=l.offset/4,s.push(e(l,h-n));else{const p=i[l.data.type];h=l.offset/4,s.push(`
v = uv.${u};
offset += ${h-n};
${p};
`)}n=h}const o=s.join(`
`);return new Function("uv","data","dataInt32","offset",o)}var EP=Object.defineProperty,AP=Object.defineProperties,PP=Object.getOwnPropertyDescriptors,nb=Object.getOwnPropertySymbols,wP=Object.prototype.hasOwnProperty,RP=Object.prototype.propertyIsEnumerable,ob=(r,t,e)=>t in r?EP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MP=(r,t)=>{for(var e in t||(t={}))wP.call(t,e)&&ob(r,e,t[e]);if(nb)for(var e of nb(t))RP.call(t,e)&&ob(r,e,t[e]);return r},CP=(r,t)=>AP(r,PP(t));function or(r,t){return`
for (let i = 0; i < ${r*t}; i++) {
data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
}
`}const _l={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>":or(3,2),"mat4x2<f32>":or(4,2),"mat2x3<f32>":or(2,3),"mat4x3<f32>":or(4,3),"mat2x4<f32>":or(2,4),"mat3x4<f32>":or(3,4)},ab=CP(MP({},_l),{"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];
`});function lb(r,t){const e=Math.max(ml[r.data.type]/16,1),i=r.data.value.length/r.data.size,s=(4-i%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
v = uv.${r.data.name};
offset += ${t};
arrayOffset = offset;
t = 0;
for(var i=0; i < ${r.data.size*e}; i++)
{
for(var j = 0; j < ${i}; j++)
{
${n}[arrayOffset++] = v[t++];
}
${s!==0?`arrayOffset += ${s};`:""}
}
`}function ub(r){return gl(r,"uboStd40",lb,_l)}class bl extends fl{constructor(){super({createUboElements:sb,generateUboSync:ub})}}bl.extension={type:[y.WebGLSystem],name:"ubo"};class cb{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){const o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(t),u=a.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let l=s.y;t.isRoot&&(l=o.pixelHeight-s.height),t.colorTextures.forEach(h=>{this._renderer.texture.unbind(h)});const u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,a.framebuffer);const 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,u.viewport(s.x,l,s.width,s.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new ib;return t.colorTexture instanceof Xt?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(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){if(!e)return;const s=this._renderTargetSystem;typeof e=="boolean"&&(e=e?bt.ALL:bt.NONE);const n=this._renderer.gl;if(e&bt.COLOR){i!=null||(i=s.defaultClearColor);const o=this._clearColorCache,a=i;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(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)=>{const l=o.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:Ot("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,3553,u,0)}),e.msaa){const o=s.createFramebuffer();e.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=s.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else 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)=>{n!==0&&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)=>{const u=a.source;s.texture.bindSource(u,0);const c=s.texture.getGlSource(u).internalFormat,h=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,h),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,u.pixelWidth,u.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.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){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Xt.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Xt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}function hb(r,t,e,i,s,n){const o=n?1:-1;return r.identity(),r.a=1/i*2,r.d=o*(1/s*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var OP=Object.defineProperty,db=Object.getOwnPropertySymbols,GP=Object.prototype.hasOwnProperty,BP=Object.prototype.propertyIsEnumerable,pb=(r,t,e)=>t in r?OP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IP=(r,t)=>{for(var e in t||(t={}))GP.call(t,e)&&pb(r,e,t[e]);if(db)for(var e of db(t))BP.call(t,e)&&pb(r,e,t[e]);return r};const ar=new Map;function yl(r,t){if(!ar.has(r)){const e=new P({source:new Xt(IP({resource:r},t))}),i=()=>{ar.get(r)===e&&ar.delete(r)};e.once("destroy",i),e.source.once("destroy",i),ar.set(r,e)}return ar.get(r)}function FP(r){return ar.has(r)}function fb(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var DP=Object.defineProperty,mb=Object.getOwnPropertySymbols,UP=Object.prototype.hasOwnProperty,kP=Object.prototype.propertyIsEnumerable,gb=(r,t,e)=>t in r?DP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_b=(r,t)=>{for(var e in t||(t={}))UP.call(t,e)&&gb(r,e,t[e]);if(mb)for(var e of mb(t))kP.call(t,e)&&gb(r,e,t[e]);return r};const bb=class hx{constructor(t={}){if(this.uid=Y("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=_b(_b({},hx.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new q({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof P||t.depthStencilTexture instanceof q?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new 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&&o===0||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)}};bb.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Fs=bb;class vl{constructor(t){this.rootViewPort=new z,this.viewport=new z,this.onRenderTargetChange=new fa("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,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){var n,o;this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=fb(this.rootRenderTarget),(o=(n=this.adaptor).prerender)==null||o.call(n,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const l=n.colorTexture,u=this.viewport,c=l.pixelWidth,h=l.pixelHeight;if(!s&&t instanceof P&&(s=t.frame),s){const p=l._resolution;u.x=s.x*p+.5|0,u.y=s.y*p+.5|0,u.width=s.width*p+.5|0,u.height=s.height*p+.5|0}else u.x=0,u.y=0,u.width=c,u.height=h;return hb(this.projectionMatrix,0,0,u.width/l.resolution,u.height/l.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){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),n}pop(){this._renderTargetStack.pop();const 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),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?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);const{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 Xt.test(t)&&(t=yl(t).source),t instanceof Fs?e=t:t instanceof q&&(e=new Fs({colorTextures:[t]}),t.source instanceof Xt&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const 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 xl extends vl{constructor(t){super(t),this.adaptor=new cb,this.adaptor.init(t,this)}}xl.extension={type:[y.WebGLSystem],name:"renderTarget"};class Ds extends pt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=Y("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Y("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Y("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function yb(r,t){const 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;const o=t._getProgramData(r.glProgram);for(const l in r.groups){const u=r.groups[l];e.push(`
resources = g[${l}].resources;
`);for(const c in u.resources){const h=u.resources[c];if(h instanceof it)if(h.ubo){const p=r._uniformBindMap[l][Number(c)];e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)}else e.push(`
ugS.updateUniformGroup(resources[${c}], p, sD);
`);else if(h instanceof Ds){const p=r._uniformBindMap[l][Number(c)];e.push(`
sS.bindUniformBlock(
resources[${c}],
'${p}',
${r.glProgram._uniformBlockData[p].index}
);
`)}else if(h 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++)}}}const a=[...i,...e].join(`
`);return new Function("r","s","sD",a)}class $P{}class vb{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 Tl(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Sl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function El(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 Sl(2*t);case"bvec3":return Sl(3*t);case"bvec4":return Sl(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 Us=null;const xb={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"},LP={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 Al(r,t){if(!Us){const e=Object.keys(xb);Us={};for(let i=0;i<e.length;++i){const s=e[i];Us[r[s]]=xb[s]}}return Us[t]}function Tb(r,t){const e=Al(r,t);return LP[e]||"float32"}function Sb(r,t,e=!1){const i={},s=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const a=t.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const l=Tb(t,a.type);i[a.name]={location:0,format:l,stride:Zt(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(i);if(e){n.sort((o,a)=>o>a?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 Eb(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){const 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 Ab(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Al(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:El(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):!1),a=[""];o.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function wb(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 Rb(r,t){const e=Tl(r,r.VERTEX_SHADER,t.vertex),i=Tl(r,r.FRAGMENT_SHADER,t.fragment),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||wb(r,s,e,i),t._attributeData=Sb(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Ab(s,r),t._uniformBlockData=Eb(s,r),r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t._uniformData){const l=t._uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:El(l.type,l.size)}}return new vb(s,o)}const ks={textureCount:0,blockIndex:0};class Pl{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}bind(t,e){if(this._setProgram(t.glProgram),e)return;ks.textureCount=0,ks.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,ks)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ks)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,l=s.updateBuffer(a),u=s.freeLocationForBufferBase(l);if(o){const{offset:h,size:p}=t;h===0&&p===a.data.byteLength?s.bindBufferBase(l,u):s.bindBufferRange(l,u,h)}else s.getLastBindBaseLocation(l)!==u&&s.bindBufferBase(l,u);const c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==u&&(n.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(n.program,c,u))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=Rb(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 yb(t,e)}resetState(){this._activeProgram=null}}Pl.extension={type:[y.WebGLSystem],name:"shader"};const Mb={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);"},Cb={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 Ob(r,t){const e=[`
var v = null;
var cv = null;
var cu = null;
var t = 0;
var gl = renderer.gl;
var name = null;
`];for(const i in r.uniforms){if(!t[i]){r.uniforms[i]instanceof it?r.uniforms[i].ubo?e.push(`
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
`):e.push(`
renderer.shader.updateUniformGroup(uv.${i});
`):r.uniforms[i]instanceof Ds&&e.push(`
renderer.shader.bindBufferResource(uv.${i}, "${i}");
`);continue}const s=r.uniformStructures[i];let n=!1;for(let o=0;o<le.length;o++){const a=le[o];if(s.type===a.type&&a.test(s)){e.push(`name = "${i}";`,le[o].uniform),n=!0;break}}if(!n){const o=(s.size===1?Mb:Cb)[s.type].replace("location",`ud["${i}"].location`);e.push(`
cu = ud["${i}"];
cv = cu.value;
v = uv["${i}"];
${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
`))}class wl{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const 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((i=this._uniformGroupSyncHash[t._signature])==null?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const 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 Ob(t,e)}_getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}wl.extension={type:[y.WebGLSystem],name:"uniformGroup"};function NP(r){return r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in"),r=`
out vec4 finalColor;
${r}
`,r}const XP={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 HP(r){return XP[r]}function Gb(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof L.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const jP=0,zP=1,VP=2,WP=3,YP=4,KP=5,Bb=class Ru{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[jP]=this.setBlend,this.map[zP]=this.setOffset,this.map[VP]=this.setCullFace,this.map[WP]=this.setDepthTest,this.map[YP]=this.setFrontFace,this.map[KP]=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=Gb(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&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(Ru._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Ru._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[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){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&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}};Bb.extension={type:[y.WebGLSystem],name:"state"};let Ib=Bb;class Fb{constructor(t){this.target=al.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=j.UNSIGNED_BYTE,this.internalFormat=Is.RGBA,this.format=Is.RGBA,this.samplerType=0}}const Db={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}},qP={"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},Ub={id:"compressed",upload(r,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=r.pixelWidth,s=r.pixelHeight;const n=!!qP[r.format];for(let o=0;o<r.resource.length;o++){const 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)}}},Rl={id:"image",upload(r,t,e,i){const 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),i===2?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):i===2?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}},kb={id:"video",upload(r,t,e,i){if(!r.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Rl.upload(r,t,e,i)}},Ml={linear:9729,nearest:9728},$b={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},$s={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Lb={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Cl(r,t,e,i,s,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=$s[o?"clamp-to-edge":r.addressModeU],c=$s[o?"clamp-to-edge":r.addressModeV],h=$s[o?"clamp-to-edge":r.addressModeW];t[s](l,t.TEXTURE_WRAP_S,u),t[s](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[s](l,t.TEXTURE_WRAP_R,h)}if((!a||r.magFilter!=="linear")&&t[s](l,t.TEXTURE_MAG_FILTER,Ml[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const u=$b[r.minFilter][r.mipmapFilter];t[s](l,t.TEXTURE_MIN_FILTER,u)}}else t[s](l,t.TEXTURE_MIN_FILTER,Ml[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[s](l,t.TEXTURE_COMPARE_FUNC,Lb[r.compare])}function Nb(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 ZP=Object.defineProperty,QP=Object.defineProperties,JP=Object.getOwnPropertyDescriptors,Xb=Object.getOwnPropertySymbols,tw=Object.prototype.hasOwnProperty,ew=Object.prototype.propertyIsEnumerable,Hb=(r,t,e)=>t in r?ZP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,we=(r,t)=>{for(var e in t||(t={}))tw.call(t,e)&&Hb(r,e,t[e]);if(Xb)for(var e of Xb(t))ew.call(t,e)&&Hb(r,e,t[e]);return r},rw=(r,t)=>QP(r,JP(t));function jb(r,t){let e={},i=r.RGBA;return r instanceof L.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(rw(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 zb(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function iw(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e<t;e+=4){const i=r[e+3];if(i!==0){const s=255.001/i;r[e]=r[e]*s+.5,r[e+1]=r[e+1]*s+.5,r[e+2]=r[e+2]*s+.5}}}const sw=4;class Ol{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:Rl,buffer:Db,video:kb,compressed:Ub},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=jb(t,this._renderer.context.extensions),this._mapFormatToType=zb(t),this._mapFormatToFormat=Nb(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){const 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){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=P.EMPTY.source);const s=this.getGlSource(t);i.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,i.bindSampler(e,s))}unbind(t){const e=t.source,i=this._boundTextures,s=this._gl;for(let n=0;n<i.length;n++)if(i[n]===e){this._activateLocation(n);const 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){const e=this._gl,i=new Fb(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const s=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(s))+1}return this._glTextures[t.uid]=i,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),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,Cl(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t;const s=t.alphaMode==="premultiply-alpha-on-upload";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&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.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){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Cl(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,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){const{pixels:e,width:i,height:s}=this.getPixels(t),n=L.get().createCanvas();n.width=i,n.height=s;const o=n.getContext("2d");if(o){const a=o.createImageData(i,s);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const 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(sw*s*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,u.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,c.RGBA,c.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);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Ol.extension={type:[y.WebGLSystem],name:"texture"};class Gl{contextChange(t){const e=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,s=He({name:"graphics",bits:[Ii,Di(i),is,ze]});this.shader=new St({glProgram:s,resources:{localUniforms:e,batchSamplers:Ui(i)}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(a.geometry,s.glProgram);const u=l.instructions;for(let c=0;c<l.instructionSize;c++){const h=u[c];if(h.size){for(let p=0;p<h.textures.count;p++)n.texture.bind(h.textures.textures[p],p);n.geometry.draw(h.topology,h.size,h.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Gl.extension={type:[y.WebGLPipesAdaptor],name:"graphics"};class Bl{init(){const t=He({name:"mesh",bits:[is,j_,ze]});this._shader=new St({glProgram:t,resources:{uTexture:P.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new M}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return}else{s=this._shader;const 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}}Bl.extension={type:[y.WebGLPipesAdaptor],name:"mesh"};class Il{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}}Il.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"customRender"};function Ls(r,t){const e=r.instructionSet,i=e.instructions;for(let s=0;s<e.instructionSize;s++){const n=i[s];t[n.renderPipeId].execute(n)}}const nw=new M;class Fl{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&&(ot.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const s=(i=t._batchableRenderGroup)!=null?i:t._batchableRenderGroup=ot.get(Mr);s.renderable=t.root,s.transform=t.root.relativeGroupTransform,s.texture=t.texture,s.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(s,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=nw.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}),Ls(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}),Ls(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}Fl.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"renderGroup"};function Ns(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const ow=new lt,Vb=Ie|gr|yi;function Dl(r,t=!1){Wb(r);const e=r.childrenToUpdate,i=r.updateTick++;for(const s in e){const n=Number(s),o=e[s],a=o.list,l=o.index;for(let u=0;u<l;u++){const c=a[u];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===n&&Ul(c,i,0)}Ns(a,l),o.index=0}if(t)for(let s=0;s<r.renderGroupChildren.length;s++)Dl(r.renderGroupChildren[s],t)}function Wb(r){const t=r.root;let e;if(r.renderGroupParent){const i=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),r.worldColor=mr(t.groupColor,i.worldColor),e=t.groupAlpha*i.worldAlpha}else r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function Ul(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const s=r.parent;if(s&&!s.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,s.relativeGroupTransform),e&Vb&&Yb(r,s,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&Vb&&Yb(r,ow,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u<o;u++)Ul(n[u],t,e);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Yb(r,t,e){if(e&gr){r.groupColor=mr(r.localColor,t.groupColor);let i=r.localAlpha*t.groupAlpha;i=i<0?0:i>1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&yi&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&Ie&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function Kb(r,t){const{list:e,index:i}=r.childrenRenderablesToUpdate;let s=!1;for(let n=0;n<i;n++){const o=e[n];if(s=t[o.renderPipeId].validateRenderable(o),s)break}return r.structureDidChange=s,s}const aw=new M;class kl{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer;let o=aw;e&&(o=o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const a=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Ls(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 i;if(t.isCachedAsTexture){if(!t.updateCacheTexture)return;e=t}t._parentCacheAsTextureRenderGroup=e;for(let s=t.renderGroupChildren.length-1;s>=0;s--)this._updateCachedRenderGroups(t.renderGroupChildren[s],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const s=t.root.getLocalBounds();s.ceil();const n=t.texture;t.texture&&rt.returnTexture(t.texture);const o=this._renderer,a=t.textureOptions.resolution||o.view.resolution,l=(i=t.textureOptions.antialias)!=null?i:o.view.antialias;t.texture=rt.getOptimalTexture(s.width,s.height,a,l),t._textureBounds||(t._textureBounds=new st),t._textureBounds.copyFrom(s),n!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(rt.returnTexture(t.texture),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?Ns(t.childrenRenderablesToUpdate.list,0):Kb(t,i),Dl(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){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){const n=e[s];n.didViewUpdate&&t.updateRenderable(n)}Ns(e,i)}_buildInstructions(t,e){const i=t.root,s=t.instructionSet;s.reset();const n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(s),o.blendMode.buildStart(),o.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(s,n,null),o.batch.buildEnd(s),o.blendMode.buildEnd(s)}}kl.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"renderGroup"};class $l{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Mr;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}$l.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"sprite"};var lw=Object.defineProperty,qb=Object.getOwnPropertySymbols,uw=Object.prototype.hasOwnProperty,cw=Object.prototype.propertyIsEnumerable,Zb=(r,t,e)=>t in r?lw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qb=(r,t)=>{for(var e in t||(t={}))uw.call(t,e)&&Zb(r,e,t[e]);if(qb)for(var e of qb(t))cw.call(t,e)&&Zb(r,e,t[e]);return r};const Ll=class dx{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new H(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=Qb(Qb({},dx.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(){}};Ll.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"background",priority:0},Ll.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Jb=Ll;const ei={};B.handle(y.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");ei[r.name]=r.ref},r=>{delete ei[r.name]});class Nl{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){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!ei[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!ei[e])return;let i=this._filterHash[e];i||(i=this._filterHash[e]=new pr,i.filters=[new ei[e]]);const s={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=s.renderables,t.add(s)}_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}}Nl.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"blendMode"};var hw=Object.defineProperty,ty=Object.getOwnPropertySymbols,dw=Object.prototype.hasOwnProperty,pw=Object.prototype.propertyIsEnumerable,ey=(r,t,e)=>t in r?hw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xl=(r,t)=>{for(var e in t||(t={}))dw.call(t,e)&&ey(r,e,t[e]);if(ty)for(var e of ty(t))pw.call(t,e)&&ey(r,e,t[e]);return r};const Hl={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},jl=class px{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof lt||t instanceof P?Xl({target:t},e):Xl(Xl({},e),t)}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,px.defaultImageOptions);const{format:e,quality:i}=t,s=this.canvas(t);if(s.toBlob!==void 0)return new Promise((n,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},Hl[e],i)});if(s.toDataURL!==void 0)return s.toDataURL(Hl[e],i);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:Hl[e],quality:i});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof P)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,s=e instanceof P?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof lt&&s.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof P?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),s=document.createElement("a");s.download=(e=t.filename)!=null?e:"image.png",s.href=i.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const s=this.canvas(t),n=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const o=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};jl.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"extract"},jl.defaultImageOptions={format:"png",quality:1};let ry=jl;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 fw=Object.defineProperty,mw=Object.defineProperties,gw=Object.getOwnPropertyDescriptors,iy=Object.getOwnPropertySymbols,_w=Object.prototype.hasOwnProperty,bw=Object.prototype.propertyIsEnumerable,sy=(r,t,e)=>t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yw=(r,t)=>{for(var e in t||(t={}))_w.call(t,e)&&sy(r,e,t[e]);if(iy)for(var e of iy(t))bw.call(t,e)&&sy(r,e,t[e]);return r},vw=(r,t)=>mw(r,gw(t));const xw=new z,Tw=new st,Sw=[0,0,0,0];class zl{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof lt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:H.shared.setValue(o).toArray():o=Sw;const a=((e=t.frame)==null?void 0:e.copyTo(xw))||mi(n,Tw).rectangle;a.width=Math.max(a.width,1/i)|0,a.height=Math.max(a.height,1/i)|0;const l=Xs.create(vw(yw({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:i,antialias:s})),u=M.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:u,target:l,clearColor:o}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}zl.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"textureGenerator"};class Vl{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:s,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new M,worldColor:4294967295,offset:new V},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:i||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:n||a.offset,bindGroup:null},u=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(u);const c=u.uniforms;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,Ye(l.worldColor,c.uWorldColorAlpha,0),u.update();let h;this._renderer.renderPipes.uniformBatch?h=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(u,!1):(h=this._bindGroupPool.pop()||new Ht,this._activeBindGroups.push(h),h.setResource(u,0)),l.bindGroup=h,this._currentGlobalUniformData=l}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===_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 it({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}}Vl.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"globalUniforms"};let Ew=1;class Wl{constructor(){this._tasks=[],this._offset=0}init(){ut.system.add(this._update,this)}repeat(t,e,i=!0){const s=Ew++;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){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const s=t-i.start;i.func(s),i.last=t}}}destroy(){ut.system.remove(this._update,this),this._tasks.length=0}}Wl.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"scheduler",priority:0};let ny=!1;function oy(r){if(!ny){if(L.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${zr} (${r}) http://www.pixijs.com/
`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${zr} - ${r} - http://www.pixijs.com/`);ny=!0}}class Hs{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}`),oy(e)}}}Hs.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"hello",priority:-2},Hs.defaultOptions={hello:!1};function ay(r){let t=!1;for(const i in r)if(r[i]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const i in r){const s=r[i];s&&(e[i]=s)}return e}function ly(r){let t=0;for(let e=0;e<r.length;e++)r[e]==null?t++:r[e-t]=r[e];return r.length-=t,r}var Aw=Object.defineProperty,uy=Object.getOwnPropertySymbols,Pw=Object.prototype.hasOwnProperty,ww=Object.prototype.propertyIsEnumerable,cy=(r,t,e)=>t in r?Aw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hy=(r,t)=>{for(var e in t||(t={}))Pw.call(t,e)&&cy(r,e,t[e]);if(uy)for(var e of uy(t))ww.call(t,e)&&cy(r,e,t[e]);return r};let Rw=0;const Yl=class fx{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(t){t=hy(hy({},fx.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]=ay(e.context[e.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedArrays)ly(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=Rw++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(t._lastUsed===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,i,s;const n=this._now,o=this._managedRenderables,a=this._renderer.renderPipes;let l=0;for(let u=0;u<o.length;u++){const c=o[u];if(c===null){l++;continue}const h=(t=c.renderGroup)!=null?t:c.parentRenderGroup,p=(i=(e=h==null?void 0:h.instructionSet)==null?void 0:e.gcTick)!=null?i:-1;if(((s=h==null?void 0:h.gcTick)!=null?s:0)===p&&(c._lastUsed=n),n-c._lastUsed>this.maxUnusedTime){if(!c.destroyed){const f=a;h&&(h.structureDidChange=!0),f[c.renderPipeId].destroyRenderable(c)}c._lastUsed=-1,l++,c.off("destroyed",this._removeRenderable,this)}else 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){const e=this._managedRenderables.indexOf(t);e>=0&&(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)}};Yl.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"renderableGC",priority:0},Yl.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let dy=Yl;var Mw=Object.defineProperty,py=Object.getOwnPropertySymbols,Cw=Object.prototype.hasOwnProperty,Ow=Object.prototype.propertyIsEnumerable,fy=(r,t,e)=>t in r?Mw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,my=(r,t)=>{for(var e in t||(t={}))Cw.call(t,e)&&fy(r,e,t[e]);if(py)for(var e of py(t))Ow.call(t,e)&&fy(r,e,t[e]);return r};const Kl=class mx{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t=my(my({},mx.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=(e=t.textureGCAMaxIdle)!=null?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(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};Kl.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"textureGC"},Kl.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let gy=Kl;var Gw=Object.defineProperty,_y=Object.getOwnPropertySymbols,Bw=Object.prototype.hasOwnProperty,Iw=Object.prototype.propertyIsEnumerable,by=(r,t,e)=>t in r?Gw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yy=(r,t)=>{for(var e in t||(t={}))Bw.call(t,e)&&by(r,e,t[e]);if(_y)for(var e of _y(t))Iw.call(t,e)&&by(r,e,t[e]);return r};const ql=class gx{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=yy(yy({},gx.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new z(0,0,t.width,t.height),this.canvas=t.canvas||L.get().createCanvas(),this.antialias=!!t.antialias,this.texture=yl(this.canvas,t),this.renderTarget=new Fs({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){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};ql.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"view",priority:0},ql.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let vy=ql;const Zl=[Jb,Vl,Hs,vy,kl,gy,zl,ry,ba,dy,Wl],Ql=[Nl,tl,$l,Fl,el,il,rl,Il],Fw=[...Zl,bl,rb,K_,dl,sl,Ol,xl,ll,wl,Pl,hl,Ib,pl,cl],Dw=[...Ql],Uw=[Za,Bl,Gl],xy=[],Ty=[],Sy=[];B.handleByNamedList(y.WebGLSystem,xy),B.handleByNamedList(y.WebGLPipes,Ty),B.handleByNamedList(y.WebGLPipesAdaptor,Sy),B.add(...Fw,...Dw,...Uw);class Ey extends Nr{constructor(){const t={name:"webgl",type:_t.WEBGL,systems:xy,renderPipes:Ty,renderPipeAdaptors:Sy};super(t)}}var kw={__proto__:null,WebGLRenderer:Ey};class Jl{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 s;const n=this._gpu.device,o=e.layout[i],a=[],l=this._renderer;for(const h in o){const p=(s=t.resources[h])!=null?s:t.resources[o[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const _=m.buffer;f={buffer:l.buffer.getGPUBuffer(_),offset:0,size:_.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=l.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=l.texture.getGpuSource(m).createView({})}a.push({binding:o[h],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],c=n.createBindGroup({layout:u,entries:a});return this._hash[t._key]=c,c}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}Jl.extension={type:[y.WebGPUSystem],name:"bindGroup"};class tu{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){const 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));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Ci(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,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}}tu.extension={type:[y.WebGPUSystem],name:"buffer"};class Ay{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const 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 eu{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}}eu.extension={type:[y.WebGPUSystem],name:"colorMask"};class js{constructor(t){this._renderer=t}async init(t){return this._initPromise?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 L.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}}js.extension={type:[y.WebGPUSystem],name:"device"},js.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var $w=Object.defineProperty,Py=Object.getOwnPropertySymbols,Lw=Object.prototype.hasOwnProperty,Nw=Object.prototype.propertyIsEnumerable,wy=(r,t,e)=>t in r?$w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ry=(r,t)=>{for(var e in t||(t={}))Lw.call(t,e)&&wy(r,e,t[e]);if(Py)for(var e of Py(t))Nw.call(t,e)&&wy(r,e,t[e]);return r};class ru{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){const n=this._renderer.pipeline.getPipeline(t,e,i,s);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const 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){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:s,topology:n,size:o,start:a,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,l!=null?l:e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),l!=null?l:e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=Ry({},this._boundVertexBuffer),s=this._boundIndexBuffer,n=Ry({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in 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}}ru.extension={type:[y.WebGPUSystem],name:"encoder",priority:1};class iu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}iu.extension={type:[y.WebGPUSystem],name:"limits"};class su{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}su.extension={type:[y.WebGPUSystem],name:"stencil"};const ri={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 My(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const s=t[i];let n=ri[s.data.type].size;const o=ri[s.data.type].align;if(!ri[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,o)*s.data.size),e=Math.ceil(e/o)*o,s.size=n,s.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function Cy(r,t){const{size:e,align:i}=ri[r.data.type],s=(i-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
v = uv.${r.data.name};
${t!==0?`offset += ${t};`:""}
arrayOffset = offset;
t = 0;
for(var i=0; i < ${r.data.size*(e/4)}; i++)
{
for(var j = 0; j < ${e/4}; j++)
{
${n}[arrayOffset++] = v[t++];
}
${s!==0?`arrayOffset += ${s};`:""}
}
`}function Oy(r){return gl(r,"uboWgsl",Cy,ab)}class nu extends fl{constructor(){super({createUboElements:My,generateUboSync:Oy})}}nu.extension={type:[y.WebGPUSystem],name:"ubo"};const ue=128;class ou{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 Ay({minUniformOffsetAlignment:ue});const e=256/ue;for(let i=0;i<e;i++){let s=X.UNIFORM|X.COPY_DST;i===0&&(s|=X.COPY_SRC),this._buffers.push(new mt({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){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,s=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/ue),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/ue)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ue)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/ue;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Ds({buffer:e,offset:(t/2|0)*256,size:ue})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Ht({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){const n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),ue,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}}ou.extension={type:[y.WebGPUPipes],name:"uniformBatch"};var Xw=Object.defineProperty,Hw=Object.defineProperties,jw=Object.getOwnPropertyDescriptors,Gy=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Vw=Object.prototype.propertyIsEnumerable,By=(r,t,e)=>t in r?Xw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ww=(r,t)=>{for(var e in t||(t={}))zw.call(t,e)&&By(r,e,t[e]);if(Gy)for(var e of Gy(t))Vw.call(t,e)&&By(r,e,t[e]);return r},Yw=(r,t)=>Hw(r,jw(t));const Kw={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function qw(r,t,e,i,s){return r<<24|t<<16|e<<10|i<<5|s}function Zw(r,t,e,i){return e<<6|r<<3|i<<1|t}class au{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=ee[t],this._updatePipeHash())}setPipeline(t,e,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(ol(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const n=qw(t._layoutKey,e._layoutKey,i.data,i._blendModeId,Kw[s]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,s),this._pipeCache[n])}_createPipeline(t,e,i,s){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(i);a[0].writeMask=this._stencilMode===J.RENDERING_MASK_ADD?0:this._colorMask;const l=this._renderer.shader.getProgramData(e).pipeline,u={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:i.cullMode},layout:l,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(u.depthStencil=Yw(Ww({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),n.createRenderPipeline(u)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const s=Object.keys(t.attributes).sort();for(let o=0;o<s.length;o++){const a=t.attributes[s[o]];e[i++]=a.offset,e[i++]=a.format,e[i++]=a.stride,e[i++]=a.instance}const n=e.join("|");return t._layoutKey=Le(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const s=Object.keys(t.attributeData).sort();for(let o=0;o<s.length;o++){const a=t.attributeData[s[o]];e[i++]=a.location}const n=e.join("|");return t._attributeLocationsKey=Le(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const s=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<s.length;a++){const 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,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(n=>{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){const c=t.attributes[u];((o=c.divisor)!=null?o:1)!==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,s}_updatePipeHash(){const t=Zw(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}}au.extension={type:[y.WebGPUSystem],name:"pipeline"};class Iy{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Fy{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const o=this._renderer,a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:i},{texture:l,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?bt.ALL:bt.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),o=t.colorTextures.map((l,u)=>{const c=n.contexts[u];let h,p;c?h=c.getCurrentTexture().createView():h=this._renderer.texture.getGpuSource(l).createView({mipLevelCount:1}),n.msaaTextures[u]&&(p=h,h=this._renderer.texture.getTextureView(n.msaaTextures[u]));const f=e&bt.COLOR?"clear":"load";return i!=null||(i=s.defaultClearColor),{view:h,resolveTarget:p,clearValue:i,storeOp:"store",loadOp:f}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const 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"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const l=a.createCommandEncoder(),u=this.getDescriptor(t,e,i),c=l.beginRenderPass(u);c.setViewport(s.x,s.y,s.width,s.height,0,1),c.end();const h=l.finish();a.queue.submit([h])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new Iy;return t.colorTextures.forEach((i,s)=>{if(i instanceof Xt){const 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){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,s)=>{const n=e.msaaTextures[s];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class lu extends vl{constructor(t){super(t),this.adaptor=new Fy,this.adaptor.init(t,this)}}lu.extension={type:[y.WebGPUSystem],name:"renderTarget"};class uu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,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}}uu.extension={type:[y.WebGPUSystem],name:"shader"};const dt={};dt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},dt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},dt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},dt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},dt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},dt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},dt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},dt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},dt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},dt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},dt.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},dt.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class cu{constructor(){this.defaultState=new Et,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:dt[t.blendMode]||dt.normal}]}destroy(){this.gpu=null}}cu.extension={type:[y.WebGPUSystem],name:"state"};const Dy={type:"image",upload(r,t,e){const i=r.resource,s=(r.pixelWidth|0)*(r.pixelHeight|0),n=i.byteLength/s;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},hu={"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}},Qw={blockBytes:4,blockWidth:1,blockHeight:1},Uy={type:"compressed",upload(r,t,e){let i=r.pixelWidth,s=r.pixelHeight;const n=hu[r.format]||Qw;for(let o=0;o<r.resource.length;o++){const 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)}}},du={type:"image",upload(r,t,e){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const a=L.get().createCanvas(i.width,i.height);a.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=a}const s=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:o},{width:s,height:n})}},ky={type:"video",upload(r,t,e){du.upload(r,t,e)}};class $y{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) texCoord : vec2<f32>,
};
@vertex
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
var output : VertexOutput;
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
return output;
}
@group(0) @binding(0) var imgSampler : sampler;
@group(0) @binding(1) var img : texture_2d<f32>;
@fragment
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(img, imgSampler, texCoord);
}
`})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(l)}const o=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 h=1;h<t.mipLevelCount;++h){const 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 pu{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:du,buffer:Dy,video:ky,compressed:Uy},this._renderer=t,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){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=hu[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,o={label:t.label,size:{width:s,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return this._gpuSources[t.uid]=a,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),a}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new $y(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}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){const 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(e=this._bindGroupHash[t.uid])!=null?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Ht({0:e,1:e.style,2:new it({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const i=t.source;return(e=this._textureViewHash[i.uid])!=null?e:this._createTextureView(i)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),s=L.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:L.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){const e=this.generateCanvas(t),i=Qt.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:o}=e,a=s.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return Qt.returnCanvasAndContext(i),{pixels:l,width:n,height:o}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}pu.extension={type:[y.WebGPUSystem],name:"texture"};class fu{constructor(){this._maxTextures=0}contextChange(t){const e=new it({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Xe({name:"graphics",bits:[Bi,Fi(this._maxTextures),qf,je]});this.shader=new St({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i),u=n.encoder;u.setGeometry(a.geometry,s.gpuProgram);const c=n.globalUniforms.bindGroup;u.setBindGroup(0,c,s.gpuProgram);const h=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);u.setBindGroup(2,h,s.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m<l.instructionSize;m++){const _=p[m];if(_.topology!==f&&(f=_.topology,u.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,t.state,_.topology)),s.groups[1]=_.bindGroup,!_.gpuBindGroup){const g=_.textures;_.bindGroup=Mi(g.textures,g.count,this._maxTextures),_.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}}fu.extension={type:[y.WebGPUPipesAdaptor],name:"graphics"};class mu{init(){const t=Xe({name:"mesh",bits:[tr,H_,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){const i=t.renderer;let s=e._shader;if(!s)s=this._shader,s.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!s.gpuProgram)return;const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}mu.extension={type:[y.WebGPUPipesAdaptor],name:"mesh"};const Jw=[...Zl,nu,ru,js,iu,tu,pu,lu,uu,cu,au,eu,su,Jl],tR=[...Ql,ou],eR=[Qa,mu,fu],Ly=[],Ny=[],Xy=[];B.handleByNamedList(y.WebGPUSystem,Ly),B.handleByNamedList(y.WebGPUPipes,Ny),B.handleByNamedList(y.WebGPUPipesAdaptor,Xy),B.add(...Jw,...tR,...eR);class Hy extends Nr{constructor(){const t={name:"webgpu",type:_t.WEBGPU,systems:Ly,renderPipes:Ny,renderPipeAdaptors:Xy};super(t)}}var rR={__proto__:null,WebGPURenderer:Hy};const iR={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},sR=new Proxy(iR,{get(r,t){return r[t]}});var gu=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(gu||{});const nR=new Proxy(gu,{get(r,t){return r[t]}});var _u=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(_u||{});const oR=new Proxy(_u,{get(r,t){return r[t]}});class aR{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){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,u=t.y/n+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)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function lR(r){const t=r.toString(),e=t.indexOf("{"),i=t.lastIndexOf("}");if(e===-1||i===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,i).trim()}function uR(r,t){return r.getFastGlobalBounds(!0,t)}var cR=Object.defineProperty,zs=Object.getOwnPropertySymbols,jy=Object.prototype.hasOwnProperty,zy=Object.prototype.propertyIsEnumerable,Vy=(r,t,e)=>t in r?cR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hR=(r,t)=>{for(var e in t||(t={}))jy.call(t,e)&&Vy(r,e,t[e]);if(zs)for(var e of zs(t))zy.call(t,e)&&Vy(r,e,t[e]);return r},dR=(r,t)=>{var e={};for(var i in r)jy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&zs)for(var i of zs(r))t.indexOf(i)<0&&zy.call(r,i)&&(e[i]=r[i]);return e};class pR extends Nt{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const s=t,{render:n}=s,o=dR(s,["render"]);super(hR({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(i=t.addBounds)!=null?i:()=>!1}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function fR(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function mR(r,t){const e=t._scale,i=t._pivot,s=t._position,n=e._x,o=e._y,a=i._x,l=i._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=s._x-(a*r.a+l*r.c),r.ty=s._y-(a*r.b+l*r.d)}function gR(r,t,e){const i=r.a,s=r.b,n=r.c,o=r.d,a=r.tx,l=r.ty,u=t.a,c=t.b,h=t.c,p=t.d;e.a=i*u+s*h,e.b=i*c+s*p,e.c=n*u+o*h,e.d=n*c+o*p,e.tx=a*u+l*h+t.tx,e.ty=a*c+l*p+t.ty}var _R=Object.defineProperty,Wy=Object.getOwnPropertySymbols,bR=Object.prototype.hasOwnProperty,yR=Object.prototype.propertyIsEnumerable,Yy=(r,t,e)=>t in r?_R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ky=(r,t)=>{for(var e in t||(t={}))bR.call(t,e)&&Yy(r,e,t[e]);if(Wy)for(var e of Wy(t))yR.call(t,e)&&Yy(r,e,t[e]);return r};const qy=class _x extends lt{constructor(t={}){t=Ky(Ky({},_x.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;e<t.length;e++){const i=t[e];if(i.parentRenderLayer){if(i.parentRenderLayer===this)continue;i.parentRenderLayer.detach(i)}this.renderLayerChildren.push(i),i.parentRenderLayer=this;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){const i=t[e],s=this.renderLayerChildren.indexOf(i);s!==-1&&this.renderLayerChildren.splice(s,1),i.parentRenderLayer=null;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0)}return t[0]}detachAll(){const t=this.renderLayerChildren;for(let e=0;e<t.length;e++)t[e].parentRenderLayer=null;this.renderLayerChildren.length=0}collectRenderables(t,e,i){const 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)return;const s=this.renderLayerChildren;for(let n=0;n<s.length;n++)s[n]._getGlobalBoundsRecursive(!0,e,this)}};qy.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex};const vR=qy;function Zy(r,t,e,i){const s=e.buffers[0],n=s.data,{verticesX:o,verticesY:a}=e,l=r/(o-1),u=t/(a-1);let c=0;const h=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],b=i[6],v=i[7],x=i[8];for(let T=0;T<n.length;T+=2){const E=c%o*l,S=(c/o|0)*u,A=h*E+p*S+f,G=m*E+_*S+g,O=b*E+v*S+x;n[T]=A/O,n[T+1]=G/O,c++}s.update()}function Qy(r,t){const e=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8];return r[0]=o*c-a*u,r[1]=s*u-i*c,r[2]=i*a-s*o,r[3]=a*l-n*c,r[4]=e*c-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 Jy(r,t,e){const i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=e[0],f=e[1],m=e[2],_=e[3],g=e[4],b=e[5],v=e[6],x=e[7],T=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*h,r[3]=_*i+g*o+b*u,r[4]=_*s+g*a+b*c,r[5]=_*n+g*l+b*h,r[6]=v*i+x*o+T*u,r[7]=v*s+x*a+T*c,r[8]=v*n+x*l+T*h,r}function xR(r,t,e){const i=e[0],s=e[1],n=e[2];return r[0]=t[0]*i+t[1]*s+t[2]*n,r[1]=t[3]*i+t[4]*s+t[5]*n,r[2]=t[6]*i+t[7]*s+t[8]*n,r}const TR=[0,0,0,0,0,0,0,0,0],SR=[0,0,0],Vs=[0,0,0];function tv(r,t,e,i,s,n,o,a,l){const u=TR;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;const c=Qy(r,u);Vs[0]=a,Vs[1]=l,Vs[2]=1;const h=xR(SR,c,Vs),p=r;return r[0]=h[0],r[1]=0,r[2]=0,r[3]=0,r[4]=h[1],r[5]=0,r[6]=0,r[7]=0,r[8]=h[2],Jy(r,p,u)}const ER=[0,0,0,0,0,0,0,0,0],AR=[0,0,0,0,0,0,0,0,0];function ev(r,t,e,i,s,n,o,a,l,u,c,h,p,f,m,_,g){const b=tv(ER,t,e,n,o,u,c,f,m),v=tv(AR,i,s,a,l,h,p,_,g);return Jy(r,Qy(b,b),v)}class rv extends ns{constructor(t){super(t),this._projectionMatrix=[0,0,0,0,0,0,0,0,0];const{width:e,height:i}=t;this.corners=[0,0,e,0,e,i,0,i]}setCorners(t,e,i,s,n,o,a,l){const 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(){const{width:t,height:e}=this,i=this.corners,s=ev(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]);Zy(t,e,this,s)}}var PR=Object.defineProperty,wR=Object.defineProperties,RR=Object.getOwnPropertyDescriptors,Ws=Object.getOwnPropertySymbols,iv=Object.prototype.hasOwnProperty,sv=Object.prototype.propertyIsEnumerable,nv=(r,t,e)=>t in r?PR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bu=(r,t)=>{for(var e in t||(t={}))iv.call(t,e)&&nv(r,e,t[e]);if(Ws)for(var e of Ws(t))sv.call(t,e)&&nv(r,e,t[e]);return r},MR=(r,t)=>wR(r,RR(t)),CR=(r,t)=>{var e={};for(var i in r)iv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ws)for(var i of Ws(r))t.indexOf(i)<0&&sv.call(r,i)&&(e[i]=r[i]);return e};const ov=class bx extends nr{constructor(t){t=bu(bu({},bx.defaultOptions),t);const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=CR(e,["texture","verticesX","verticesY"]),a=new rv(It({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(It(MR(bu({},o),{geometry:a}))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height: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)}};ov.defaultOptions={texture:P.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let OR=ov;var GR=Object.defineProperty,BR=Object.defineProperties,IR=Object.getOwnPropertyDescriptors,Ys=Object.getOwnPropertySymbols,av=Object.prototype.hasOwnProperty,lv=Object.prototype.propertyIsEnumerable,uv=(r,t,e)=>t in r?GR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FR=(r,t)=>{for(var e in t||(t={}))av.call(t,e)&&uv(r,e,t[e]);if(Ys)for(var e of Ys(t))lv.call(t,e)&&uv(r,e,t[e]);return r},DR=(r,t)=>BR(r,IR(t)),UR=(r,t)=>{var e={};for(var i in r)av.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ys)for(var i of Ys(r))t.indexOf(i)<0&&lv.call(r,i)&&(e[i]=r[i]);return e};class kR extends nr{constructor(t){const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=UR(e,["texture","verticesX","verticesY"]),a=new ns(It({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(It(DR(FR({},o),{geometry:a,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const 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;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var $R=Object.defineProperty,cv=Object.getOwnPropertySymbols,LR=Object.prototype.hasOwnProperty,NR=Object.prototype.propertyIsEnumerable,hv=(r,t,e)=>t in r?$R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dv=(r,t)=>{for(var e in t||(t={}))LR.call(t,e)&&hv(r,e,t[e]);if(cv)for(var e of cv(t))NR.call(t,e)&&hv(r,e,t[e]);return r};const pv=class yx extends Ae{constructor(t){const{width:e,points:i,textureScale:s}=dv(dv({},yx.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=s,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];const u=this._width*this.textureScale,c=t.length;for(let p=0;p<c;p++){const f=p*4;if(this.textureScale>0){const m=l.x-t[p].x,_=l.y-t[p].y,g=Math.sqrt(m*m+_*_);l=t[p],a+=g/u}else a=p/(c-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let h=0;for(let p=0;p<c-1;p++){const f=p*2;o[h++]=f,o[h++]=f+1,o[h++]=f+2,o[h++]=f+2,o[h++]=f+1,o[h++]=f+3}i.update(),s.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,s=0,n=0;const o=this.buffers[0].data,a=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let u=0;u<a;u++){const c=t[u],h=u*4;u<t.length-1?i=t[u+1]:i=c,n=-(i.x-e.x),s=i.y-e.y;let p=(1-u/(a-1))*10;p>1&&(p=1);const f=Math.sqrt(s*s+n*n);f<1e-6?(s=0,n=0):(s/=f,n/=f,s*=l,n*=l),o[h]=c.x+s,o[h+1]=c.y+n,o[h+2]=c.x-s,o[h+3]=c.y-n,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};pv.defaultOptions={width:200,points:[],textureScale:0};let fv=pv;var XR=Object.defineProperty,HR=Object.defineProperties,jR=Object.getOwnPropertyDescriptors,Ks=Object.getOwnPropertySymbols,mv=Object.prototype.hasOwnProperty,gv=Object.prototype.propertyIsEnumerable,_v=(r,t,e)=>t in r?XR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yu=(r,t)=>{for(var e in t||(t={}))mv.call(t,e)&&_v(r,e,t[e]);if(Ks)for(var e of Ks(t))gv.call(t,e)&&_v(r,e,t[e]);return r},zR=(r,t)=>HR(r,jR(t)),VR=(r,t)=>{var e={};for(var i in r)mv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ks)for(var i of Ks(r))t.indexOf(i)<0&&gv.call(r,i)&&(e[i]=r[i]);return e};const bv=class vx extends nr{constructor(t){const e=yu(yu({},vx.defaultOptions),t),{texture:i,points:s,textureScale:n}=e,o=VR(e,["texture","points","textureScale"]),a=new fv(It({width:i.height,points:s,textureScale:n}));n>0&&(i.source.style.addressMode="repeat"),super(It(zR(yu({},o),{texture:i,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};bv.defaultOptions={textureScale:0};let WR=bv;var YR=Object.defineProperty,KR=Object.defineProperties,qR=Object.getOwnPropertyDescriptors,qs=Object.getOwnPropertySymbols,yv=Object.prototype.hasOwnProperty,vv=Object.prototype.propertyIsEnumerable,xv=(r,t,e)=>t in r?YR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ZR=(r,t)=>{for(var e in t||(t={}))yv.call(t,e)&&xv(r,e,t[e]);if(qs)for(var e of qs(t))vv.call(t,e)&&xv(r,e,t[e]);return r},QR=(r,t)=>KR(r,qR(t)),JR=(r,t)=>{var e={};for(var i in r)yv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&qs)for(var i of qs(r))t.indexOf(i)<0&&vv.call(r,i)&&(e[i]=r[i]);return e};class tM extends nr{constructor(t){const e=t,{texture:i,vertices:s,uvs:n,indices:o,topology:a}=e,l=JR(e,["texture","vertices","uvs","indices","topology"]),u=new Ae(It({positions:s,uvs:n,indices:o,topology:a}));super(It(QR(ZR({},l),{texture:i,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function eM(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}var rM=Object.defineProperty,Tv=Object.getOwnPropertySymbols,iM=Object.prototype.hasOwnProperty,sM=Object.prototype.propertyIsEnumerable,Sv=(r,t,e)=>t in r?rM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ev=(r,t)=>{for(var e in t||(t={}))iM.call(t,e)&&Sv(r,e,t[e]);if(Tv)for(var e of Tv(t))sM.call(t,e)&&Sv(r,e,t[e]);return r};const Av=class Mu{constructor(t){if(t instanceof P)this.texture=t,bi(this,Mu.defaultOptions,{});else{const e=Ev(Ev({},Mu.defaultOptions),t);bi(this,e,{})}}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){typeof t=="number"?this._tint=t:this._tint=H.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};Av.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let nM=Av;const vu={vertex:{attributeName:"aVertex",format:"float32x2",code:`
const texture = p.texture;
const sx = p.scaleX;
const sy = p.scaleY;
const ax = p.anchorX;
const ay = p.anchorY;
const trim = texture.trim;
const orig = texture.orig;
if (trim)
{
w1 = trim.x - (ax * orig.width);
w0 = w1 + trim.width;
h1 = trim.y - (ay * orig.height);
h0 = h1 + trim.height;
}
else
{
w1 = -ax * (orig.width);
w0 = w1 + orig.width;
h1 = -ay * (orig.height);
h0 = h1 + orig.height;
}
f32v[offset] = w1 * sx;
f32v[offset + 1] = h1 * sy;
f32v[offset + stride] = w0 * sx;
f32v[offset + stride + 1] = h1 * sy;
f32v[offset + (stride * 2)] = w0 * sx;
f32v[offset + (stride * 2) + 1] = h0 * sy;
f32v[offset + (stride * 3)] = w1 * sx;
f32v[offset + (stride * 3) + 1] = h0 * sy;
`,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:`
var x = p.x;
var y = p.y;
f32v[offset] = x;
f32v[offset + 1] = y;
f32v[offset + stride] = x;
f32v[offset + stride + 1] = y;
f32v[offset + (stride * 2)] = x;
f32v[offset + (stride * 2) + 1] = y;
f32v[offset + (stride * 3)] = x;
f32v[offset + (stride * 3) + 1] = y;
`,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:`
var rotation = p.rotation;
f32v[offset] = rotation;
f32v[offset + stride] = rotation;
f32v[offset + (stride * 2)] = rotation;
f32v[offset + (stride * 3)] = rotation;
`,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:`
var uvs = p.texture.uvs;
f32v[offset] = uvs.x0;
f32v[offset + 1] = uvs.y0;
f32v[offset + stride] = uvs.x1;
f32v[offset + stride + 1] = uvs.y1;
f32v[offset + (stride * 2)] = uvs.x2;
f32v[offset + (stride * 2) + 1] = uvs.y2;
f32v[offset + (stride * 3)] = uvs.x3;
f32v[offset + (stride * 3) + 1] = uvs.y3;
`,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:`
const c = p.color;
u32v[offset] = c;
u32v[offset + stride] = c;
u32v[offset + (stride * 2)] = c;
u32v[offset + (stride * 3)] = c;
`,dynamic:!1}};var oM=Object.defineProperty,aM=Object.defineProperties,lM=Object.getOwnPropertyDescriptors,Zs=Object.getOwnPropertySymbols,Pv=Object.prototype.hasOwnProperty,wv=Object.prototype.propertyIsEnumerable,Rv=(r,t,e)=>t in r?oM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lr=(r,t)=>{for(var e in t||(t={}))Pv.call(t,e)&&Rv(r,e,t[e]);if(Zs)for(var e of Zs(t))wv.call(t,e)&&Rv(r,e,t[e]);return r},Mv=(r,t)=>aM(r,lM(t)),uM=(r,t)=>{var e={};for(var i in r)Pv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Zs)for(var i of Zs(r))t.indexOf(i)<0&&wv.call(r,i)&&(e[i]=r[i]);return e};const cM=new st(0,0,0,0),Cv=class Cu extends Nt{constructor(t={}){t=Mv(lr(lr({},Cu.defaultOptions),t),{dynamicProperties:lr(lr({},Cu.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:s,roundPixels:n,texture:o,particles:a}=e,l=uM(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(lr({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=s,this._properties={};for(const u in vu){const c=vu[u],h=i[u];this._properties[u]=Mv(lr({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e<t.length;e++)this.particleChildren.push(t[e]);return this.onViewUpdate(),t[0]}removeParticle(...t){let e=!1;for(let i=0;i<t.length;i++){const s=this.particleChildren.indexOf(t[i]);s>-1&&(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 cM}updateBounds(){}destroy(t=!1){var e,i,s;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const n=typeof t=="boolean"?t:t==null?void 0:t.textureSource,o=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(s=this.shader)==null||s.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const i=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),i}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};Cv.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let hM=Cv;var dM=Object.defineProperty,Qs=Object.getOwnPropertySymbols,Ov=Object.prototype.hasOwnProperty,Gv=Object.prototype.propertyIsEnumerable,Bv=(r,t,e)=>t in r?dM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pM=(r,t)=>{for(var e in t||(t={}))Ov.call(t,e)&&Bv(r,e,t[e]);if(Qs)for(var e of Qs(t))Gv.call(t,e)&&Bv(r,e,t[e]);return r},fM=(r,t)=>{var e={};for(var i in r)Ov.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Qs)for(var i of Qs(r))t.indexOf(i)<0&&Gv.call(r,i)&&(e[i]=r[i]);return e};const Iv=class xx extends Nt{constructor(t){var e,i,s,n,o,a,l,u,c,h;t instanceof P&&(t={texture:t});const p=t,{width:f,height:m,anchor:_,leftWidth:g,rightWidth:b,topHeight:v,bottomHeight:x,texture:T,roundPixels:E}=p,S=fM(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(pM({label:"NineSliceSprite"},S)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=g!=null?g:(e=T==null?void 0:T.defaultBorders)==null?void 0:e.left)!=null?i:oe.defaultOptions.leftWidth,this._topHeight=(n=v!=null?v:(s=T==null?void 0:T.defaultBorders)==null?void 0:s.top)!=null?n:oe.defaultOptions.topHeight,this._rightWidth=(a=b!=null?b:(o=T==null?void 0:T.defaultBorders)==null?void 0:o.right)!=null?a:oe.defaultOptions.rightWidth,this._bottomHeight=(u=x!=null?x:(l=T==null?void 0:T.defaultBorders)==null?void 0:l.bottom)!=null?u:oe.defaultOptions.bottomHeight,this._width=(c=f!=null?f:T.width)!=null?c:oe.defaultOptions.width,this._height=(h=m!=null?m:T.height)!=null?h:oe.defaultOptions.height,this.allowChildren=!1,this.texture=T!=null?T:xx.defaultOptions.texture,this.roundPixels=E!=null?E:!1,this._anchor=new et({_onUpdate:()=>{this.onViewUpdate()}}),_?this.anchor=_:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,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}};Iv.defaultOptions={texture:P.EMPTY};let Fv=Iv;class mM extends Fv{constructor(...t){let e=t[0];e instanceof P&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}async function gM(r,t,e=200){const i=await t.extract.base64(r);await t.encoder.commandFinished;const s=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var _M=Object.defineProperty,bM=Object.defineProperties,yM=Object.getOwnPropertyDescriptors,Dv=Object.getOwnPropertySymbols,vM=Object.prototype.hasOwnProperty,xM=Object.prototype.propertyIsEnumerable,Uv=(r,t,e)=>t in r?_M(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kv=(r,t)=>{for(var e in t||(t={}))vM.call(t,e)&&Uv(r,e,t[e]);if(Dv)for(var e of Dv(t))xM.call(t,e)&&Uv(r,e,t[e]);return r},TM=(r,t)=>bM(r,yM(t));const SM=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let EM=0;function $v(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=SM[EM++]);let i="";for(let o=0;o<t;o++)i+=" ";let s=r.label;!s&&r instanceof Dt&&(s=`sprite:${r.texture.label}`);let n=`%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++){const a=r.children[o];$v(a,t,kv({},e))}}function Lv(r,t=0,e={index:0,color:"#000000"}){let i="";for(let n=0;n<t;n++)i+=" ";const 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++){const o=r.renderGroupChildren[n];Lv(o,t,TM(kv({},e),{index:n}))}}return d.AbstractBitmapFont=Ko,d.AbstractRenderer=Nr,d.AbstractText=Cs,d.AccessibilitySystem=th,d.AlphaFilter=lA,d.AlphaMask=Bn,d.AlphaMaskPipe=el,d.AnimatedSprite=Qr,d.Application=Am,d.ApplicationInitHook=_a,d.Assets=Vr,d.AssetsClass=cg,d.BLEND_TO_NPM=Oh,d.BUFFER_TYPE=ti,d.BackgroundLoader=Rm,d.BackgroundSystem=Jb,d.Batch=Uh,d.BatchGeometry=jh,d.BatchTextureArray=Bh,d.BatchableGraphics=Li,d.BatchableHTMLText=Sf,d.BatchableMesh=Vi,d.BatchableSprite=Mr,d.BatchableText=vp,d.Batcher=Xh,d.BatcherPipe=tl,d.BigPool=ot,d.BindGroup=Ht,d.BindGroupSystem=Jl,d.BitmapFont=ya,d.BitmapFontManager=Ur,d.BitmapText=$_,d.BitmapTextGraphics=xf,d.BitmapTextPipe=Jo,d.BlendModeFilter=tA,d.BlendModePipe=Nl,d.BlurFilter=e_,d.BlurFilterPass=xs,d.Bounds=st,d.BrowserAdapter=ch,d.Buffer=mt,d.BufferImageSource=_i,d.BufferResource=Ds,d.BufferUsage=X,d.CLEAR=bt,d.Cache=W,d.CanvasPool=Qt,d.CanvasPoolClass=Jp,d.CanvasSource=Xt,d.CanvasTextGenerator=Qe,d.CanvasTextMetrics=Gt,d.CanvasTextPipe=Mo,d.CanvasTextSystem=Vo,d.Circle=Yi,d.Color=H,d.ColorMask=In,d.ColorMaskPipe=rl,d.ColorMatrixFilter=PA,d.CompressedSource=Wr,d.Container=lt,d.Culler=Pg,d.CullerPlugin=wg,d.CustomRenderPipe=Il,d.D3D10_RESOURCE_DIMENSION=Ia,d.D3DFMT=yt,d.DATA_URI=d2,d.DDS=F,d.DEG_TO_RAD=Zu,d.DEPRECATED_SCALE_MODES=_u,d.DEPRECATED_WRAP_MODES=gu,d.DOMAdapter=L,d.DOMContainer=H0,d.DOMPipe=Cn,d.DRAW_MODES=sR,d.DXGI_FORMAT=Ba,d.DXGI_TO_TEXTURE_FORMAT=vt,d.DefaultBatcher=$i,d.DefaultShader=Gd,d.DisplacementFilter=BA,d.DynamicBitmapFont=qo,d.Ellipse=Ki,d.EventBoundary=ih,d.EventEmitter=pt,d.EventSystem=Mn,d.EventsTicker=qt,d.ExtensionType=y,d.ExtractSystem=ry,d.FOURCC_TO_TEXTURE_FORMAT=Fa,d.FederatedContainer=oh,d.FederatedEvent=Fe,d.FederatedMouseEvent=_r,d.FederatedPointerEvent=Mt,d.FederatedWheelEvent=ge,d.FillGradient=jt,d.FillPattern=Cr,d.Filter=te,d.FilterEffect=pr,d.FilterPipe=ua,d.FilterSystem=ca,d.FontStylePromiseCache=$r,d.GAUSSIAN_VALUES=Na,d.GL_FORMATS=Is,d.GL_INTERNAL_FORMAT=bg,d.GL_TARGETS=al,d.GL_TYPES=j,d.GL_WRAP_MODES=q_,d.GenerateTextureSystem=zl,d.Geometry=be,d.GlBackBufferSystem=rb,d.GlBatchAdaptor=Za,d.GlBuffer=z_,d.GlBufferSystem=sl,d.GlColorMaskSystem=cl,d.GlContextSystem=K_,d.GlEncoderSystem=hl,d.GlGeometrySystem=ll,d.GlGraphicsAdaptor=Gl,d.GlLimitsSystem=dl,d.GlMeshAdaptor=Bl,d.GlParticleContainerAdaptor=dp,d.GlParticleContainerPipe=wo,d.GlProgram=Tt,d.GlProgramData=vb,d.GlRenderTarget=ib,d.GlRenderTargetAdaptor=cb,d.GlRenderTargetSystem=xl,d.GlShaderSystem=Pl,d.GlStateSystem=Ib,d.GlStencilSystem=pl,d.GlTexture=Fb,d.GlTextureSystem=Ol,d.GlUboSystem=bl,d.GlUniformGroupSystem=wl,d.GlobalUniformSystem=Vl,d.GpuBatchAdaptor=Qa,d.GpuBlendModesToPixi=dt,d.GpuBufferSystem=tu,d.GpuColorMaskSystem=eu,d.GpuDeviceSystem=js,d.GpuEncoderSystem=ru,d.GpuGraphicsAdaptor=fu,d.GpuGraphicsContext=up,d.GpuLimitsSystem=iu,d.GpuMeshAdapter=mu,d.GpuMipmapGenerator=$y,d.GpuParticleContainerAdaptor=yp,d.GpuParticleContainerPipe=Ro,d.GpuProgram=gt,d.GpuRenderTarget=Iy,d.GpuRenderTargetAdaptor=Fy,d.GpuRenderTargetSystem=lu,d.GpuShaderSystem=uu,d.GpuStateSystem=cu,d.GpuStencilModesToPixi=ee,d.GpuStencilSystem=su,d.GpuTextureSystem=pu,d.GpuUboSystem=nu,d.GpuUniformBatchPipe=ou,d.Graphics=Je,d.GraphicsContext=ht,d.GraphicsContextRenderData=cp,d.GraphicsContextSystem=zi,d.GraphicsGpuData=hp,d.GraphicsPath=Se,d.GraphicsPipe=xo,d.HTMLText=L_,d.HTMLTextPipe=ta,d.HTMLTextRenderData=ea,d.HTMLTextStyle=kr,d.HTMLTextSystem=sa,d.HelloSystem=Hs,d.IGLUniformData=$P,d.ImageSource=se,d.InstructionSet=mn,d.KTX=tt,d.Loader=$m,d.LoaderParserPriority=xt,d.MaskEffectManager=di,d.MaskEffectManagerClass=rc,d.MaskFilter=v_,d.Matrix=M,d.Mesh=nr,d.MeshGeometry=Ae,d.MeshGpuData=To,d.MeshPipe=So,d.MeshPlane=kR,d.MeshRope=WR,d.MeshSimple=tM,d.NOOP=bn,d.NineSliceGeometry=oe,d.NineSlicePlane=mM,d.NineSliceSprite=Fv,d.NineSliceSpriteGpuData=pm,d.NineSliceSpritePipe=la,d.NoiseFilter=$A,d.ObservablePoint=et,d.PI_2=Ku,d.Particle=nM,d.ParticleBuffer=mp,d.ParticleContainer=hM,d.ParticleContainerPipe=Po,d.ParticleShader=bp,d.PerspectiveMesh=OR,d.PerspectivePlaneGeometry=rv,d.PipelineSystem=au,d.PlaneGeometry=ns,d.Point=V,d.Polygon=Ke,d.Pool=hi,d.PoolGroupClass=Qu,d.PrepareBase=T_,d.PrepareQueue=k_,d.PrepareSystem=X_,d.PrepareUpload=N_,d.QuadGeometry=tm,d.RAD_TO_DEG=qu,d.Rectangle=z,d.RenderContainer=pR,d.RenderGroup=Ic,d.RenderGroupPipe=Fl,d.RenderGroupSystem=kl,d.RenderLayer=vR,d.RenderTarget=Fs,d.RenderTargetSystem=vl,d.RenderTexture=Xs,d.RenderableGCSystem=dy,d.RendererInitHook=ba,d.RendererType=_t,d.ResizePlugin=Pn,d.Resolver=ie,d.RopeGeometry=fv,d.RoundedRectangle=Zi,d.SCALE_MODES=oR,d.STENCIL_MODES=J,d.SVGParser=Dp,d.SchedulerSystem=Wl,d.ScissorMask=dP,d.SdfShader=pf,d.Shader=St,d.ShaderStage=Ne,d.ShapePath=Cp,d.SharedRenderPipes=Ql,d.SharedSystems=Zl,d.Sprite=Dt,d.SpritePipe=$l,d.Spritesheet=On,d.State=Et,d.StencilMask=Fn,d.StencilMaskPipe=il,d.SystemRunner=fa,d.TEXTURE_FORMAT_BLOCK_SIZE=gg,d.Text=qa,d.TextStyle=kt,d.Texture=P,d.TextureGCSystem=gy,d.TextureMatrix=yn,d.TexturePool=rt,d.TexturePoolClass=Bc,d.TextureSource=q,d.TextureStyle=Rt,d.TextureUvs=aR,d.Ticker=ut,d.TickerListener=Ti,d.TickerPlugin=wn,d.TilingSprite=I_,d.TilingSpriteGpuData=sm,d.TilingSpritePipe=aa,d.TilingSpriteShader=Jf,d.Transform=M_,d.Triangle=Ka,d.UNIFORM_TO_ARRAY_SETTERS=Cb,d.UNIFORM_TO_SINGLE_SETTERS=Mb,d.UNIFORM_TYPES_MAP=Td,d.UNIFORM_TYPES_VALUES=ro,d.UPDATE_BLEND=yi,d.UPDATE_COLOR=gr,d.UPDATE_PRIORITY=Kt,d.UPDATE_TRANSFORM=v0,d.UPDATE_VISIBLE=Ie,d.UboBatch=Ay,d.UboSystem=fl,d.UniformGroup=it,d.VERSION=zr,d.VideoSource=xr,d.ViewContainer=Nt,d.ViewSystem=vy,d.ViewableBuffer=_e,d.WGSL_ALIGN_SIZE_DATA=ri,d.WGSL_TO_STD40_SIZE=ml,d.WRAP_MODES=nR,d.WebGLRenderer=Ey,d.WebGPURenderer=Hy,d.WorkerManager=Aa,d.accessibilityTarget=eh,d.addBits=Kn,d.addMaskBounds=Pi,d.addMaskLocalBounds=wi,d.addProgramDefines=Wh,d.alphaFrag=$g,d.alphaWgsl=$a,d.applyMatrix=rm,d.applyProjectiveTransformationToPlane=Zy,d.applyStyleParams=Cl,d.assignWithIgnore=bi,d.autoDetectEnvironment=s2,d.autoDetectRenderer=xm,d.autoDetectSource=h1,d.basisTranscoderUrls=fs,d.bgr2rgb=Be,d.bitmapFontCachePlugin=Pm,d.bitmapFontTextParser=as,d.bitmapFontXMLParser=va,d.bitmapFontXMLStringParser=xa,d.blendTemplateFrag=Gg,d.blendTemplateVert=Bg,d.blendTemplateWgsl=Ig,d.blockDataMap=hu,d.blurTemplateWgsl=Wg,d.boundsPool=Lt,d.browserExt=YE,d.buildAdaptiveBezier=Go,d.buildAdaptiveQuadratic=Ep,d.buildArc=Fo,d.buildArcTo=Ap,d.buildArcToSvg=wp,d.buildCircle=Ve,d.buildContextBatches=ap,d.buildEllipse=kd,d.buildLine=Xd,d.buildPixelLine=Hd,d.buildPolygon=Zd,d.buildRectangle=Qd,d.buildRoundedRectangle=$d,d.buildSimpleUvs=Fd,d.buildTriangle=Jd,d.buildUvs=Id,d.cacheAsTextureMixin=Ju,d.cacheTextureArray=Mm,d.calculateProjection=hb,d.checkChildrenDidChange=fn,d.checkDataUrl=Pe,d.checkExtension=Bt,d.checkMaxIfStatementsInShader=Xn,d.childrenHelperMixin=tc,d.cleanArray=ly,d.cleanHash=ay,d.clearList=Ns,d.closePointEps=no,d.collectAllRenderables=fR,d.collectRenderablesMixin=ec,d.color32BitToUniform=Ye,d.colorBit=Bi,d.colorBitGl=Ii,d.colorMatrixFilterFrag=r_,d.colorMatrixFilterWgsl=Ha,d.colorToUniform=wT,d.compareModeToGlCompare=Lb,d.compileHighShader=cd,d.compileHighShaderGl=hd,d.compileHighShaderGlProgram=He,d.compileHighShaderGpuProgram=Xe,d.compileHooks=qn,d.compileInputs=Zn,d.compileOutputs=ud,d.compileShader=Tl,d.compute2DProjection=ev,d.convertFormatIfRequired=UE,d.convertToList=Ct,d.copySearchParams=Ei,d.createIdFromString=Le,d.createIndicesForQuads=Eo,d.createLevelBuffers=gE,d.createLevelBuffersFromKTX=kE,d.createStringVariations=ph,d.createTexture=ae,d.createUboElementsSTD40=sb,d.createUboElementsWGSL=My,d.createUboSyncFunction=gl,d.createUboSyncFunctionSTD40=ub,d.createUboSyncFunctionWGSL=Oy,d.crossOrigin=ng,d.cullingMixin=Yu,d.curveEps=oo,d.defaultFilterVert=ys,d.defaultValue=El,d.definedProps=It,d.deprecation=Ch,d.detectAvif=Cm,d.detectBasis=hE,d.detectCompressed=zE,d.detectDefaults=Gm,d.detectMp4=Bm,d.detectOgv=Im,d.detectVideoAlphaMode=Un,d.detectWebm=Fm,d.detectWebp=Dm,d.determineCrossOrigin=ag,d.displacementFrag=n_,d.displacementVert=o_,d.displacementWgsl=ja,d.earcut=qd,d.effectsMixin=oc,d.ensureAttributes=ol,d.ensureIsBuffer=jn,d.ensurePrecision=Yh,d.ensureTextOptions=Os,d.executeInstructions=Ls,d.extensions=B,d.extractAttributesFromGlProgram=Sb,d.extractAttributesFromGpuProgram=id,d.extractFontFamilies=Ff,d.extractStructAndGroups=Gi,d.extractSvgUrlId=$o,d.fastCopy=Ci,d.findMixin=ac,d.fontStringFromTextStyle=Fr,d.formatShader=uP,d.fragmentGPUTemplate=md,d.fragmentGlTemplate=_d,d.generateArraySyncSTD40=lb,d.generateArraySyncWGSL=Cy,d.generateBlurFragSource=jg,d.generateBlurGlProgram=Vg,d.generateBlurProgram=Yg,d.generateBlurVertSource=zg,d.generateGPULayout=aP,d.generateGpuLayoutGroups=sd,d.generateLayout=lP,d.generateLayoutHash=nd,d.generateParticleUpdateFunction=pp,d.generateProgram=Rb,d.generateShaderSyncCode=yb,d.generateTextStyleKey=Kp,d.generateTextureBatchBit=Fi,d.generateTextureBatchBitGl=Di,d.generateTextureMatrix=op,d.generateUniformsSync=Ob,d.getAdjustedBlendModeBlend=ke,d.getAttributeInfoFromFormat=Zt,d.getBatchSamplersUniformGroup=Ui,d.getBitmapTextLayout=Zo,d.getCanvasBoundingBox=rf,d.getCanvasFillStyle=Dr,d.getCanvasTexture=yl,d.getDefaultUniformValue=Sd,d.getFastGlobalBounds=uR,d.getFastGlobalBoundsMixin=uc,d.getFontCss=Uf,d.getFontFamilyName=jm,d.getGeometryBounds=Hh,d.getGlTypeFromFormat=Q_,d.getGlobalBounds=fr,d.getGlobalMixin=dc,d.getGlobalRenderableBounds=fm,d.getLocalBounds=mi,d.getMaxFragmentPrecision=Vh,d.getMaxTexturesPerBatch=Gh,d.getOrientationOfPoints=Ld,d.getPo2TextureFromSource=jo,d.getResolutionOfUrl=us,d.getSVGUrl=kf,d.getSupportedCompressedTextureFormats=Ga,d.getSupportedGPUCompressedTextureFormats=Ca,d.getSupportedGlCompressedTextureFormats=Ma,d.getSupportedTextureFormats=Yr,d.getTemporaryCanvasFromImage=$f,d.getTestContext=Nn,d.getTextureBatchBindGroup=Mi,d.getTextureDefaultMatrix=eM,d.getTextureFormatFromKTXTexture=NE,d.getUboData=Eb,d.getUniformData=Ab,d.getUrlExtension=gh,d.glFormatToGPUFormat=Eg,d.glUploadBufferImageResource=Db,d.glUploadCompressedTextureResource=Ub,d.glUploadImageResource=Rl,d.glUploadVideoResource=kb,d.globalUniformsBit=bd,d.globalUniformsBitGl=yd,d.globalUniformsUBOBitGl=I1,d.gpuFormatToBasisTranscoderFormat=bE,d.gpuFormatToKTXBasisTranscoderFormat=HE,d.gpuUploadBufferImageResource=Dy,d.gpuUploadCompressedTextureResource=Uy,d.gpuUploadImageResource=du,d.gpuUploadVideoResource=ky,d.groupD8=$,d.hasCachedCanvasTexture=FP,d.hslWgsl=VA,d.hslgl=eA,d.hslgpu=rA,d.injectBits=Qn,d.insertVersion=Kh,d.isMobile=Yc,d.isPow2=gn,d.isRenderingToScreen=fb,d.isSafari=Ef,d.isSingleItem=vr,d.isWebGLSupported=Xr,d.isWebGPUSupported=Hr,d.ktxTranscoderUrls=ms,d.loadBasis=mE,d.loadBasisOnWorker=mg,d.loadBitmapFont=wm,d.loadDDS=AE,d.loadEnvironmentExtensions=da,d.loadFontAsBase64=Df,d.loadFontCSS=ra,d.loadImageBitmap=tg,d.loadJson=Lm,d.loadKTX=GE,d.loadKTX2=DE,d.loadKTX2onWorker=Tg,d.loadSVGImage=Lf,d.loadSvg=Km,d.loadTextures=Pa,d.loadTxt=Nm,d.loadVideoTextures=lg,d.loadWebFont=zm,d.localUniformBit=tr,d.localUniformBitGl=is,d.localUniformBitGroup2=qf,d.localUniformMSDFBit=uf,d.localUniformMSDFBitGl=cf,d.log2=qx,d.logDebugTexture=gM,d.logProgramError=wb,d.logRenderGroupScene=Lv,d.logScene=$v,d.mSDFBit=hf,d.mSDFBitGl=df,d.mapFormatToGlFormat=Nb,d.mapFormatToGlInternalFormat=jb,d.mapFormatToGlType=zb,d.mapGlToVertexFormat=Tb,d.mapSize=HP,d.mapType=Al,d.mapWebGLBlendModesToPixi=Gb,d.maskFrag=m_,d.maskVert=g_,d.maskWgsl=Wa,d.matrixPool=ct,d.measureHtmlText=ia,d.measureMixin=fc,d.migrateFragmentFromV7toV8=NP,d.mipmapScaleModeToGlFilter=$b,d.multiplyColors=mr,d.multiplyHexColors=pn,d.nextPow2=he,d.noiseFrag=c_,d.noiseWgsl=za,d.nonCompressedFormats=dg,d.normalizeExtensionPriority=cr,d.onRenderMixin=mc,d.parseDDS=_g,d.parseFunctionBody=lR,d.parseKTX=yg,d.parseSVGDefinitions=Gp,d.parseSVGFloatAttribute=Q,d.parseSVGPath=Tp,d.parseSVGStyle=No,d.particleData=vu,d.particlesFrag=gp,d.particlesVert=_p,d.particlesWgsl=Ao,d.path=ft,d.pointInTriangle=Ya,d.preloadVideo=og,d.removeItems=dn,d.removeStructAndGroupDuplicates=od,d.resetUids=Hx,d.resolveCharacters=bf,d.resolveCompressedTextureUrl=jE,d.resolveJsonUrl=ug,d.resolveTextureUrl=Ra,d.resourceToTexture=Ph,d.roundPixelsBit=je,d.roundPixelsBitGl=ze,d.roundedShapeArc=Rp,d.roundedShapeQuadraticCurve=Mp,d.sayHello=oy,d.scaleModeToGlFilter=Ml,d.setBasisTranscoderPath=pE,d.setKTXTranscoderPath=IE,d.setPositions=em,d.setProgramName=qh,d.setUvs=im,d.shapeBuilders=Rr,d.sortMixin=gc,d.spritesheetAsset=yh,d.squaredDistanceToLineSegment=Or,d.stripVersion=Zh,d.styleAttributes=Lo,d.testImageFormat=Ta,d.testVideoFormat=ls,d.textStyleToCSS=wf,d.textureBit=H_,d.textureBitGl=j_,d.textureFrom=wh,d.tilingBit=Zf,d.tilingBitGl=Qf,d.toFillStyle=ne,d.toLocalGlobalMixin=_c,d.toStrokeStyle=Ir,d.transformVertices=so,d.triangulateWithHoles=co,d.uboSyncFunctionsSTD40=_l,d.uboSyncFunctionsWGSL=ab,d.uid=Y,d.uniformParsers=le,d.unpremultiplyAlpha=iw,d.unsafeEvalSupported=pa,d.updateLocalTransform=mR,d.updateQuadBounds=Gn,d.updateRenderGroupTransform=Wb,d.updateRenderGroupTransforms=Dl,d.updateTextBounds=Wi,d.updateTransformAndChildren=Ul,d.updateTransformBackwards=fi,d.updateWorldTransform=gR,d.v8_0_0=p1,d.v8_3_4=f1,d.validFormats=gs,d.validateRenderables=Kb,d.vertexGPUTemplate=fd,d.vertexGlTemplate=gd,d.vkFormatToGPUFormat=Ag,d.warn=Ot,d.wrapModeToGlAddress=$s,d}({});
//# sourceMappingURL=pixi.min.js.map