PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.8.7
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.8.7
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
desktop-mode / assets / vendor / pixi.min.js

pixi.min.js in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.8.7, at assets/vendor/pixi.min.js

2,330 lines 777.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var CB=Object.defineProperty;var S1=Object.getOwnPropertySymbols;var MB=Object.prototype.hasOwnProperty,RB=Object.prototype.propertyIsEnumerable;var w1=(d,ie,ne)=>ie in d?CB(d,ie,{enumerable:!0,configurable:!0,writable:!0,value:ne}):d[ie]=ne,P1=(d,ie)=>{for(var ne in ie||(ie={}))MB.call(ie,ne)&&w1(d,ne,ie[ne]);if(S1)for(var ne of S1(ie))RB.call(ie,ne)&&w1(d,ne,ie[ne]);return d};/*!
2 * PixiJS - v8.18.1
3 * Compiled Tue, 14 Apr 2026 20:01:42 UTC
4 *
5 * PixiJS is licensed under the MIT License.
6 * http://www.opensource.org/licenses/mit-license
7 */var PIXI=(function(d){"use strict";"use strict";var ie=Object.defineProperty,ne=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Gh=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ih=(r,t)=>{for(var e in t||(t={}))iS.call(t,e)&&Gh(r,e,t[e]);if(Oh)for(var e of Oh(t))nS.call(t,e)&&Gh(r,e,t[e]);return r},sS=(r,t)=>ne(r,rS(t)),S=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(S||{});const Ea=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=sS(Ih({},t),{ref:r})}if(typeof r=="object")r=Ih({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ni=(r,t)=>{var e;return(e=Ea(r).priority)!=null?e:t},X={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ea).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...r){return r.map(Ea).forEach(t=>{t.type.forEach(e=>{var i,n;const s=this._addHandlers,a=this._queue;s[e]?(n=s[e])==null||n.call(s,t):(a[e]=a[e]||[],(i=a[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const n=this._addHandlers,s=this._removeHandlers;n[r]=t,s[r]=e;const a=this._queue;return a[r]&&((i=a[r])==null||i.forEach(o=>t(o)),delete a[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(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,s)=>ni(s.value,e)-ni(n.value,e)))},i=>{const n=t.findIndex(s=>s.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,s)=>ni(s,e)-ni(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var OB=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Bh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function GB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function IB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function BB(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function i(){var n=!1;try{n=this instanceof i}catch(s){}return n?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 n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),e}var rn={exports:{}},FB=rn.exports,Fh;function aS(){return Fh||(Fh=1,(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 n(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(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 a(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function o(){this._events=new i,this._eventsCount=0}o.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},o.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},o.prototype.listenerCount=function(u){var c=e?e+u:u,h=this._events[c];return h?h.fn?1:h.length:0},o.prototype.emit=function(u,c,h,p,f,m){var g=e?e+u:u;if(!this._events[g])return!1;var _=this._events[g],y=arguments.length,b,x;if(_.fn){switch(_.once&&this.removeListener(u,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,h),!0;case 4:return _.fn.call(_.context,c,h,p),!0;case 5:return _.fn.call(_.context,c,h,p,f),!0;case 6:return _.fn.call(_.context,c,h,p,f,m),!0}for(x=1,b=new Array(y-1);x<y;x++)b[x-1]=arguments[x];_.fn.apply(_.context,b)}else{var v=_.length,w;for(x=0;x<v;x++)switch(_[x].once&&this.removeListener(u,_[x].fn,void 0,!0),y){case 1:_[x].fn.call(_[x].context);break;case 2:_[x].fn.call(_[x].context,c);break;case 3:_[x].fn.call(_[x].context,c,h);break;case 4:_[x].fn.call(_[x].context,c,h,p);break;default:if(!b)for(w=1,b=new Array(y-1);w<y;w++)b[w-1]=arguments[w];_[x].fn.apply(_[x].context,b)}}return!0},o.prototype.on=function(u,c,h){return s(this,u,c,h,!1)},o.prototype.once=function(u,c,h){return s(this,u,c,h,!0)},o.prototype.removeListener=function(u,c,h,p){var f=e?e+u:u;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!p||m.once)&&(!h||m.context===h)&&a(this,f);else{for(var g=0,_=[],y=m.length;g<y;g++)(m[g].fn!==c||p&&!m[g].once||h&&m[g].context!==h)&&_.push(m[g]);_.length?this._events[f]=_.length===1?_[0]:_:a(this,f)}return this},o.prototype.removeAllListeners=function(u){var c;return u?(c=e?e+u:u,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,r.exports=o})(rn)),rn.exports}var oS=aS(),Nt=Bh(oS),lS={grad:.9,turn:360,rad:360/(2*Math.PI)},Re=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Gt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},se=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Dh=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Uh=function(r){return{r:se(r.r,0,255),g:se(r.g,0,255),b:se(r.b,0,255),a:se(r.a)}},Aa=function(r){return{r:Gt(r.r),g:Gt(r.g),b:Gt(r.b),a:Gt(r.a,3)}},uS=/^#([0-9a-f]{3,8})$/i,nn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},$h=function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=Math.max(t,e,i),a=s-Math.min(t,e,i),o=a?s===t?(e-i)/a:s===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:s?a/s*100:0,v:s/255*100,a:n}},kh=function(r){var t=r.h,e=r.s,i=r.v,n=r.a;t=t/360*6,e/=100,i/=100;var s=Math.floor(t),a=i*(1-e),o=i*(1-(t-s)*e),l=i*(1-(1-t+s)*e),u=s%6;return{r:255*[i,o,a,a,l,i][u],g:255*[l,i,i,o,a,a][u],b:255*[a,a,l,i,i,o][u],a:n}},Lh=function(r){return{h:Dh(r.h),s:se(r.s,0,100),l:se(r.l,0,100),a:se(r.a)}},Nh=function(r){return{h:Gt(r.h),s:Gt(r.s),l:Gt(r.l),a:Gt(r.a,3)}},Xh=function(r){return kh((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},si=function(r){return{h:(t=$h(r)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},cS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,dS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ca={string:[[function(r){var t=uS.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?Gt(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?Gt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=dS.exec(r)||pS.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Uh({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=cS.exec(r)||hS.exec(r);if(!t)return null;var e,i,n=Lh({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(lS[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Xh(n)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return Re(t)&&Re(e)&&Re(i)?Uh({r:Number(t),g:Number(e),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=Lh({h:Number(t),s:Number(e),l:Number(i),a:Number(s)});return Xh(a)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=(function(o){return{h:Dh(o.h),s:se(o.s,0,100),v:se(o.v,0,100),a:se(o.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(s)});return kh(a)},"hsv"]]},jh=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]},Hh=function(r){return typeof r=="string"?jh(r.trim(),Ca.string):typeof r=="object"&&r!==null?jh(r,Ca.object):[null,void 0]},DB=function(r){return Hh(r)[1]},Ma=function(r,t){var e=si(r);return{h:e.h,s:se(e.s+100*t,0,100),l:e.l,a:e.a}},Ra=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},zh=function(r,t){var e=si(r);return{h:e.h,s:e.s,l:se(e.l+100*t,0,100),a:e.a}},sn=(function(){function r(t){this.parsed=Hh(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 Gt(Ra(this.rgba),2)},r.prototype.isDark=function(){return Ra(this.rgba)<.5},r.prototype.isLight=function(){return Ra(this.rgba)>=.5},r.prototype.toHex=function(){return t=Aa(this.rgba),e=t.r,i=t.g,n=t.b,a=(s=t.a)<1?nn(Gt(255*s)):"","#"+nn(e)+nn(i)+nn(n)+a;var t,e,i,n,s,a},r.prototype.toRgb=function(){return Aa(this.rgba)},r.prototype.toRgbString=function(){return t=Aa(this.rgba),e=t.r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},r.prototype.toHsl=function(){return Nh(si(this.rgba))},r.prototype.toHslString=function(){return t=Nh(si(this.rgba)),e=t.h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},r.prototype.toHsv=function(){return t=$h(this.rgba),{h:Gt(t.h),s:Gt(t.s),v:Gt(t.v),a:Gt(t.a,3)};var t},r.prototype.invert=function(){return be({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),be(Ma(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),be(Ma(this.rgba,-t))},r.prototype.grayscale=function(){return be(Ma(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),be(zh(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),be(zh(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"?be({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Gt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=si(this.rgba);return typeof t=="number"?be({h:t,s:e.s,l:e.l,a:e.a}):Gt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===be(t).toHex()},r})(),be=function(r){return r instanceof sn?r:new sn(r)},Wh=[],fS=function(r){r.forEach(function(t){Wh.indexOf(t)<0&&(t(sn,Ca),Wh.push(t))})},UB=function(){return new sn({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function mS(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 n in e)i[e[n]]=n;var s={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,u=i[this.toHex()];if(u)return u;if(a!=null&&a.closest){var c=this.toRgb(),h=1/0,p="black";if(!s.length)for(var f in e)s[f]=new r(e[f]).toRgb();for(var m in e){var g=(o=c,l=s[m],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));g<h&&(h=g,p=m)}return p}},t.string.push([function(a){var o=a.toLowerCase(),l=o==="transparent"?"#0000":e[o];return l?new r(l).toRgb():null},"name"])}var gS=Object.defineProperty,Vh=Object.getOwnPropertySymbols,_S=Object.prototype.hasOwnProperty,yS=Object.prototype.propertyIsEnumerable,Yh=(r,t,e)=>t in r?gS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bS=(r,t)=>{for(var e in t||(t={}))_S.call(t,e)&&Yh(r,e,t[e]);if(Vh)for(var e of Vh(t))yS.call(t,e)&&Yh(r,e,t[e]);return r};fS([mS]);const vr=class tn{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 tn)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?bS({},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((n,s)=>n===e[s]);if(t!==null&&e!==null){const n=Object.keys(t),s=Object.keys(e);return n.length!==s.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=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(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,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,n,s]=tn._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,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,n=this._int>>8&255,s=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,i,n,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,n=(a&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,s=255]=t,e/=255,i/=255,n/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=tn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=be(t);a.isValid()&&({r:e,g:i,b:n,a:s}=a.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=s,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((n,s)=>{t[s]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof tn||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}};vr.shared=new vr,vr._temp=new vr,vr.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let tt=vr;const Kh={cullArea:null,cullable:!1,cullableChildren:!0},qh=Math.PI*2,Zh=180/Math.PI,Qh=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}static get shared(){return Oa.x=0,Oa.y=0,Oa}}const Oa=new lt;class U{constructor(t=1,e=0,i=0,n=1,s=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a}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,n,s,a){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a,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 lt;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new lt;const i=this.a,n=this.b,s=this.c,a=this.d,o=this.tx,l=this.ty,u=1/(i*a+s*-n),c=t.x,h=t.y;return e.x=a*u*c+-s*u*h+(l*s-o*a)*u,e.y=i*u*h+-n*u*c+(-l*i+o*n)*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),n=this.a,s=this.c,a=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,s=t.c,a=t.d,o=t.tx,l=t.ty,u=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*u+n*h,this.b=i*c+n*p,this.c=s*u+a*h,this.d=s*c+a*p,this.tx=o*u+l*h+e.tx,this.ty=o*c+l*p+e.ty,this}setTransform(t,e,i,n,s,a,o,l,u){return this.a=Math.cos(o+u)*s,this.b=Math.sin(o+u)*s,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*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,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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,n=this.c,s=this.d,a=t.pivot,o=-Math.atan2(-n,s),l=Math.atan2(i,e),u=Math.abs(o+l);return u<1e-5||Math.abs(qh-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(n*n+s*s),t.position.x=this.tx+(a.x*e+a.y*n),t.position.y=this.ty+(a.x*i+a.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-n*s)/a,this.ty=-(t*this.ty-e*s)/a,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 U;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 xS.identity()}static get shared(){return vS.identity()}}const vS=new U,xS=new U;class bt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new bt(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 ai={default:-1};function ht(r="default"){return ai[r]===void 0&&(ai[r]=-1),++ai[r]}function TS(){for(const r in ai)delete ai[r]}const qe={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class Jh{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,this._count++),(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(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class td{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 Jh(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}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const Et=new td;qe.register(Et);const ed={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 Ga(r,t,e){const i=r.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const s=i-e;for(n=t;n<s;++n)r[n]=r[n+e];r.length=s}const rd={allowChildren:!0,removeChildren(r=0,t){var e;const i=t!=null?t:this.children.length,n=i-r,s=[];if(n>0&&n<=i){for(let o=i-1;o>=r;o--){const l=this.children[o];l&&(s.push(l),l.parent=null)}Ga(this.children,r,i);const a=this.renderGroup||this.parentRenderGroup;a&&a.removeChildren(s);for(let o=0;o<s.length;++o){const l=s[o];(e=l.parentRenderLayer)==null||e.detach(l),this.emit("childRemoved",l,this,o),s[o].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(n===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const i=r.parent===this;if(r.parent){const s=r.parent.children.indexOf(r);if(i){if(s===t)return r;r.parent.children.splice(s,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(r),this.sortableChildren&&(this.sortDirty=!0),i||(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 n=this.renderGroup||this.parentRenderGroup;n&&(n.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},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},id={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,n=i.length;for(let s=0;s<n;s++)i[s].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:i}=t;for(let n=0;n<this.effects.length;n++){const s=this.effects[n];i[s.pipe].push(s,this,r)}this.collectRenderablesSimple(r,t,e);for(let n=this.effects.length-1;n>=0;n--){const s=this.effects[n];i[s.pipe].pop(s,this,r)}}};class oi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class nd{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return Et.get(i.maskClass,t)}return t}returnMaskEffect(t){Et.return(t)}}const an=new nd;X.handleByList(S.MaskEffect,an._effectClasses);var SS=Object.defineProperty,sd=Object.getOwnPropertySymbols,wS=Object.prototype.hasOwnProperty,PS=Object.prototype.propertyIsEnumerable,ad=(r,t,e)=>t in r?SS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,od=(r,t)=>{for(var e in t||(t={}))wS.call(t,e)&&ad(r,e,t[e]);if(sd)for(var e of sd(t))PS.call(t,e)&&ad(r,e,t[e]);return r};const ld={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_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),an.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=an.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=od(od({},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 oi);r=r;const i=(r==null?void 0:r.length)>0,n=((t=e.filters)==null?void 0:t.length)>0,s=i!==n;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(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 oi),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},ud={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 n=e[i];if(n.label===r||r instanceof RegExp&&r.test(n.label))return n}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(r,!0);if(n)return n}return null},getChildrenByLabel(r,t=!1,e=[]){const i=this.children;for(let n=0;n<i.length;n++){const s=i[n];(s.label===r||r instanceof RegExp&&r.test(s.label))&&e.push(s)}if(t)for(let n=0;n<i.length;n++)i[n].getChildrenByLabel(r,!0,e);return e}},on=[new lt,new lt,new lt,new lt];class ut{constructor(t=0,e=0,i=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new ut(0,0,0,0)}clone(){return new ut(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,n=.5){const{width:s,height:a}=this;if(s<=0||a<=0)return!1;const o=this.x,l=this.y,u=i*(1-n),c=i-u,h=o-u,p=o+s+u,f=l-u,m=l+a+u,g=o+c,_=o+s-c,y=l+c,b=l+a-c;return t>=h&&t<=p&&e>=f&&e<=m&&!(t>g&&t<_&&e>y&&e<b)}intersects(t,e){if(!e){const E=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=E)return!1;const M=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>M}const i=this.left,n=this.right,s=this.top,a=this.bottom;if(n<=i||a<=s)return!1;const o=on[0].set(t.left,t.top),l=on[1].set(t.left,t.bottom),u=on[2].set(t.right,t.top),c=on[3].set(t.right,t.bottom);if(u.x<=o.x||l.y<=o.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(o,o),e.apply(l,l),e.apply(u,u),e.apply(c,c),Math.max(o.x,l.x,u.x,c.x)<=i||Math.min(o.x,l.x,u.x,c.x)>=n||Math.max(o.y,l.y,u.y,c.y)<=s||Math.min(o.y,l.y,u.y,c.y)>=a))return!1;const p=h*(l.y-o.y),f=h*(o.x-l.x),m=p*i+f*s,g=p*n+f*s,_=p*i+f*a,y=p*n+f*a;if(Math.max(m,g,_,y)<=p*o.x+f*o.y||Math.min(m,g,_,y)>=p*c.x+f*c.y)return!1;const b=h*(o.y-u.y),x=h*(u.x-o.x),v=b*i+x*s,w=b*n+x*s,T=b*i+x*a,P=b*n+x*a;return!(Math.max(v,w,T,P)<=b*o.x+x*o.y||Math.min(v,w,T,P)>=b*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),n=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=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=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}getBounds(t){return t||(t=new ut),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,s=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&n>=this.x&&n<this.x+this.width&&s>=this.y&&s<this.y+this.height}set(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this}}const cd=new U;class Mt{constructor(t=1/0,e=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=cd,this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new ut);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=cd,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,s){s||(s=this.matrix);const a=s.a,o=s.b,l=s.c,u=s.d,c=s.tx,h=s.ty;let p=this.minX,f=this.minY,m=this.maxX,g=this.maxY,_=a*t+l*e+c,y=o*t+u*e+h;_<p&&(p=_),y<f&&(f=y),_>m&&(m=_),y>g&&(g=y),_=a*i+l*e+c,y=o*i+u*e+h,_<p&&(p=_),y<f&&(f=y),_>m&&(m=_),y>g&&(g=y),_=a*t+l*n+c,y=o*t+u*n+h,_<p&&(p=_),y<f&&(f=y),_>m&&(m=_),y>g&&(g=y),_=a*i+l*n+c,y=o*i+u*n+h,_<p&&(p=_),y<f&&(f=y),_>m&&(m=_),y>g&&(g=y),this.minX=p,this.minY=f,this.maxX=m,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.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,n=this.maxX,s=this.maxY,{a,b:o,c:l,d:u,tx:c,ty:h}=t;let p=a*e+l*i+c,f=o*e+u*i+h;this.minX=p,this.minY=f,this.maxX=p,this.maxY=f,p=a*n+l*i+c,f=o*n+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=a*e+l*s+c,f=o*e+u*s+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=a*n+l*s+c,f=o*n+u*s+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,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>n&&(this.maxY=n),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 Mt(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,n){let s=this.minX,a=this.minY,o=this.maxX,l=this.maxY;n||(n=this.matrix);const u=n.a,c=n.b,h=n.c,p=n.d,f=n.tx,m=n.ty;for(let g=e;g<i;g+=2){const _=t[g],y=t[g+1],b=u*_+h*y+f,x=c*_+p*y+m;s=b<s?b:s,a=x<a?x:a,o=b>o?b:o,l=x>l?x:l}this.minX=s,this.minY=a,this.maxX=o,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 Dt=Et.getPool(U),ve=Et.getPool(Mt),ES=new U,hd={getFastGlobalBounds(r,t){t||(t=new Mt),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 n=!!this.effects.length;if((this.renderGroup||n)&&(i=ve.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const a=this.bounds;i.addFrame(a.minX,a.minY,a.maxX,a.maxY,this.groupTransform)}const s=this.children;for(let a=0;a<s.length;a++)s[a]._getGlobalBoundsRecursive(r,i,e)}if(n){let s=!1;const a=this.renderGroup||this.parentRenderGroup;for(let o=0;o<this.effects.length;o++)this.effects[o].addBounds&&(s||(s=!0,i.applyMatrix(a.worldTransform)),this.effects[o].addBounds(i,!0));s&&i.applyMatrix(a.worldTransform.copyTo(ES).invert()),t.addBounds(i),ve.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),ve.return(i))}};function li(r,t,e){e.clear();let i,n;return r.parent?t?i=r.parent.worldTransform:(n=Dt.get().identity(),i=ln(r,n)):i=U.IDENTITY,dd(r,e,i,t),n&&Dt.return(n),e.isValid||e.set(0,0,0,0),e}function dd(r,t,e,i){var n,s;if(!r.visible||!r.measurable)return;let a;i?a=r.worldTransform:(r.updateLocalTransform(),a=Dt.get(),a.appendFrom(r.localTransform,e));const o=t,l=!!r.effects.length;if(l&&(t=ve.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{const u=r.bounds;u&&!u.isEmpty()&&(t.matrix=a,t.addBounds(u));for(let c=0;c<r.children.length;c++)dd(r.children[c],t,a,i)}if(l){for(let u=0;u<r.effects.length;u++)(s=(n=r.effects[u]).addBounds)==null||s.call(n,t);o.addBounds(t,U.IDENTITY),ve.return(t)}i||Dt.return(a)}function ln(r,t){const e=r.parent;return e&&(ln(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Oe(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,i=r>>8&255,n=r&255,s=t>>16&255,a=t>>8&255,o=t&255,l=e*s/255|0,u=i*a/255|0,c=n*o/255|0;return(l<<16)+(u<<8)+c}const pd=16777215;function ui(r,t){return r===pd?t:t===pd?r:Oe(r,t)}function xe(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const fd={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new U,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=ln(this,Dt.get().identity());return r.appendFrom(this.localTransform,e),Dt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?xe(this.renderGroup.worldColor):this.parentRenderGroup?xe(ui(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=ui(t,e.localColor),e=e.parent;return xe(t)}};function un(r,t,e){return t.clear(),e||(e=U.IDENTITY),md(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function md(r,t,e,i,n){var s,a;let o;if(n)o=Dt.get(),o=e.copyTo(o);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;o=Dt.get(),o.appendFrom(c,e)}const l=t,u=!!r.effects.length;if(u&&(t=ve.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.renderPipeId&&(t.matrix=o,t.addBounds(r.bounds));const c=r.children;for(let h=0;h<c.length;h++)md(c[h],t,o,i,!1)}if(u){for(let c=0;c<r.effects.length;c++)(a=(s=r.effects[c]).addLocalBounds)==null||a.call(s,t,i);l.addBounds(t,U.IDENTITY),ve.return(t)}Dt.return(o)}function Ia(r,t){const e=r.children;for(let i=0;i<e.length;i++){const n=e[i],s=n.uid,a=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,o=t.index;(t.data[o]!==s||t.data[o+1]!==a)&&(t.data[t.index]=s,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,n.children.length&&Ia(n,t)}return t.didChange}const AS=new U,gd={_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 Mt});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),Ia(this,r),r.didChange&&un(this,r.localBounds,AS),r.localBounds},getBounds(r,t){return li(this,r,t||new Mt)}},_d={_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}},yd={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(CS))}};function CS(r,t){return r._zIndex-t._zIndex}const bd={getGlobalPosition(r=new lt,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const i=this.getGlobalTransform(Dt.get(),e);return t=i.apply(r,t),Dt.return(i),t},toLocal(r,t,e,i){t&&(r=t.toGlobal(r,e,i));const n=this.getGlobalTransform(Dt.get(),i);return e=n.applyInverse(r,e),Dt.return(n),e}};class cn{constructor(){this.uid=ht("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}function Ze(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 Ba(r){return!(r&r-1)&&!!r}function MS(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 he(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var RS=Object.defineProperty,vd=Object.getOwnPropertySymbols,OS=Object.prototype.hasOwnProperty,GS=Object.prototype.propertyIsEnumerable,xd=(r,t,e)=>t in r?RS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Td=(r,t)=>{for(var e in t||(t={}))OS.call(t,e)&&xd(r,e,t[e]);if(vd)for(var e of vd(t))GS.call(t,e)&&xd(r,e,t[e]);return r};const Sd=Object.create(null);function IS(r){const t=Sd[r];return t===void 0&&(Sd[r]=ht("resource")),t}const wd=class E1 extends Nt{constructor(t={}){var e,i,n,s,a,o,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Td(Td({},E1.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=(n=t.addressModeW)!=null?n:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(s=t.magFilter)!=null?s:this.magFilter,this.minFilter=(a=t.minFilter)!=null?a:this.minFilter,this.mipmapFilter=(o=t.mipmapFilter)!=null?o:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=IS(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};wd.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Jt=wd;var BS=Object.defineProperty,Pd=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,DS=Object.prototype.propertyIsEnumerable,Ed=(r,t,e)=>t in r?BS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ad=(r,t)=>{for(var e in t||(t={}))FS.call(t,e)&&Ed(r,e,t[e]);if(Pd)for(var e of Pd(t))DS.call(t,e)&&Ed(r,e,t[e]);return r};const Cd=class A1 extends Nt{constructor(t={}){var e,i,n,s;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ht("textureSource"),this._resourceType="textureSource",this._resourceId=ht("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Ad(Ad({},A1.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&&(n=this.resourceHeight)!=null?n:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=(s=t.viewDimension)!=null?s:t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Jt(he(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=ht("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*i),s=Math.round(e*i);return this.width=n/i,this.height=s/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===s?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=s,this.emit("resize",this),this._resourceId=ht("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=Ba(this.pixelWidth)&&Ba(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Cd.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ft=Cd;const Qe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Je=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],tr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],er=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Fa=[],Md=[],hn=Math.sign;function US(){for(let r=0;r<16;r++){const t=[];Fa.push(t);for(let e=0;e<16;e++){const i=hn(Qe[r]*Qe[e]+tr[r]*Je[e]),n=hn(Je[r]*Qe[e]+er[r]*Je[e]),s=hn(Qe[r]*tr[e]+tr[r]*er[e]),a=hn(Je[r]*tr[e]+er[r]*er[e]);for(let o=0;o<16;o++)if(Qe[o]===i&&Je[o]===n&&tr[o]===s&&er[o]===a){t.push(o);break}}}for(let r=0;r<16;r++){const t=new U;t.set(Qe[r],Je[r],tr[r],er[r],0,0),Md.push(t)}}US();const W={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=>Qe[r],uY:r=>Je[r],vX:r=>tr[r],vY:r=>er[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Fa[r][t],sub:(r,t)=>Fa[r][W.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?W.S:W.N:Math.abs(t)*2<=Math.abs(r)?r>0?W.E:W.W:t>0?r>0?W.SE:W.SW:r>0?W.NE:W.NW,matrixAppendRotationInv:(r,t,e=0,i=0,n=0,s=0)=>{const a=Md[W.inv(t)],o=a.a,l=a.b,u=a.c,c=a.d,h=e-Math.min(0,o*n,u*s,o*n+u*s),p=i-Math.min(0,l*n,c*s,l*n+c*s),f=r.a,m=r.b,g=r.c,_=r.d;r.a=o*f+l*g,r.b=o*m+l*_,r.c=u*f+c*g,r.d=u*m+c*_,r.tx=h*f+p*g+r.tx,r.ty=h*m+p*_+r.ty},transformRectCoords:(r,t,e,i)=>{const{x:n,y:s,width:a,height:o}=r,{x:l,y:u,width:c,height:h}=t;return e===W.E?(i.set(n+l,s+u,a,o),i):e===W.S?i.set(c-s-o+l,n+u,o,a):e===W.W?i.set(c-n-a+l,h-s-o+u,a,o):e===W.N?i.set(s+l,h-n-a+u,o,a):i.set(n+l,s+u,a,o)}},Da=()=>{};var $S=Object.defineProperty,kS=Object.defineProperties,LS=Object.getOwnPropertyDescriptors,Rd=Object.getOwnPropertySymbols,NS=Object.prototype.hasOwnProperty,XS=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jS=(r,t)=>{for(var e in t||(t={}))NS.call(t,e)&&Od(r,e,t[e]);if(Rd)for(var e of Rd(t))XS.call(t,e)&&Od(r,e,t[e]);return r},HS=(r,t)=>kS(r,LS(t));class dn extends ft{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(HS(jS({},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}}dn.extension=S.TextureSource;const Gd=new U;class Ua{constructor(t,e){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),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 n=0;n<t.length;n+=2){const s=t[n],a=t[n+1];e[n]=s*i.a+a*i.c+i.tx,e[n+1]=s*i.b+a*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,n=t.trim;n&&(Gd.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Gd));const s=t.source,a=this.uClampFrame,o=this.clampMargin/s._resolution,l=this.clampOffset/s._resolution;return a[0]=(t.frame.x+o+l)/s.width,a[1]=(t.frame.y+o+l)/s.height,a[2]=(t.frame.x+t.frame.width-o+l)/s.width,a[3]=(t.frame.y+t.frame.height-o+l)/s.height,this.uClampOffset[0]=this.clampOffset/s.pixelWidth,this.uClampOffset[1]=this.clampOffset/s.pixelHeight,this.isSimple=t.frame.width===s.width&&t.frame.height===s.height&&t.rotate===0,!0}}class D extends Nt{constructor({source:t,label:e,frame:i,orig:n,trim:s,defaultAnchor:a,defaultBorders:o,rotate:l,dynamic:u}={}){var c;if(super(),this.uid=ht("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new ut,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(c=t==null?void 0:t.source)!=null?c:new ft,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=n||this.frame,this.trim=s,this.rotate=l!=null?l:0,this.defaultAnchor=a,this.defaultBorders=o,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 Ua(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:n}=this._source,s=e.x/i,a=e.y/n,o=e.width/i,l=e.height/n;let u=this.rotate;if(u){const c=o/2,h=l/2,p=s+c,f=a+h;u=W.add(u,W.NW),t.x0=p+c*W.uX(u),t.y0=f+h*W.uY(u),u=W.add(u,2),t.x1=p+c*W.uX(u),t.y1=f+h*W.uY(u),u=W.add(u,2),t.x2=p+c*W.uX(u),t.y2=f+h*W.uY(u),u=W.add(u,2),t.x3=p+c*W.uX(u),t.y3=f+h*W.uY(u)}else t.x0=s,t.y0=a,t.x1=s+o,t.y1=a,t.x2=s+o,t.y2=a+l,t.x3=s,t.y3=a+l}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return this._source}}D.EMPTY=new D({label:"EMPTY",source:new ft({label:"EMPTY"})}),D.EMPTY.destroy=Da,D.WHITE=new D({source:new dn({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),D.WHITE.destroy=Da;var zS=Object.defineProperty,WS=Object.defineProperties,VS=Object.getOwnPropertyDescriptors,Id=Object.getOwnPropertySymbols,YS=Object.prototype.hasOwnProperty,KS=Object.prototype.propertyIsEnumerable,Bd=(r,t,e)=>t in r?zS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qS=(r,t)=>{for(var e in t||(t={}))YS.call(t,e)&&Bd(r,e,t[e]);if(Id)for(var e of Id(t))KS.call(t,e)&&Bd(r,e,t[e]);return r},ZS=(r,t)=>WS(r,VS(t));let QS=0;class Fd{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Jt(this.textureOptions)}createTexture(t,e,i,n){const s=new ft(ZS(qS({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1,autoGenerateMipmaps:n}));return new D({source:s,label:`texturePool_${QS++}`})}getOptimalTexture(t,e,i=1,n,s=!1){let a=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);a=Ze(a),o=Ze(o);const l=n?1:0,u=s?1:0,c=(a<<17)+(o<<2)+(u<<1)+l;this._texturePool[c]||(this._texturePool[c]=[]);let h=this._texturePool[c].pop();return h||(h=this.createTexture(a,o,n,s)),h.source._resolution=i,h.source.width=a/i,h.source.height=o/i,h.source.pixelWidth=a,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=c,h}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 n=0;n<i.length;n++)i[n].destroy(!0)}this._texturePool={}}}const vt=new Fd;qe.register(vt);class pn{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,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 cn,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 n=e[i];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(vt.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let 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 n=0;n<i.length;n++)this._getChildren(i[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new U),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new U),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new U),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function fn(r,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(r[i]=t[i])}const $a=new bt(null),ka=new bt(null),La=new bt(null,1,1),Na=new bt(null),ci=1,mn=2,xr=4,JS=8;class dt extends Nt{constructor(t={}){var e,i;super(),this.uid=ht("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new bt(this,0,0),this._scale=La,this._pivot=ka,this._origin=Na,this._skew=$a,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=[],fn(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){X.mixin(dt,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 n=0;n<t.length;n++)this.addChild(t[n]);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 n=0;n<t.length;n++)this.removeChild(t[n]);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=Et.get(pn,this),this.groupTransform=U.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Et.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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*Zh}set angle(t){this.rotation=t*Qh}get pivot(){return this._pivot===ka&&(this._pivot=new bt(this,0,0)),this._pivot}set pivot(t){this._pivot===ka&&(this._pivot=new bt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===$a&&(this._skew=new bt(this,0,0)),this._skew}set skew(t){this._skew===$a&&(this._skew=new bt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===La&&(this._scale=new bt(this,1,1)),this._scale}set scale(t){this._scale===La&&(this._scale=new bt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Na&&(this._origin=new bt(this,0,0)),this._origin}set origin(t){this._origin===Na&&(this._origin=new bt(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const n=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,n.width),e!==void 0&&this._setHeight(e,n.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,n=this._pivot,s=this._origin,a=this._position,o=i._x,l=i._y,u=n._x,c=n._y,h=-s._x,p=-s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*l,e.d=this._sy*l,e.tx=a._x-(u*e.a+c*e.c)+(h*e.a+p*e.c)-h,e.ty=a._y-(u*e.b+c*e.d)+(h*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=ci,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=tt.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=ci,this._onUpdate())}get tint(){return xe(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=mn,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|=xr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xr,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|=xr,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._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let n=0;n<i.length;++n)i[n].destroy(t);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}}X.mixin(dt,rd,hd,bd,_d,gd,ld,ud,yd,Kh,ed,fd,id);var Te=(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))(Te||{});class gn{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}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 Dd=class re{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 gn(null,null,1/0),this.deltaMS=1/re.targetFPMS,this.elapsedMS=1/re.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=Te.NORMAL){return this._addListener(new gn(t,e,i))}addOnce(t,e,i=Te.NORMAL){return this._addListener(new gn(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 s=t-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=t-s%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*re.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.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(Math.max(0,t)/1e3,re.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!re._shared){const t=re._shared=new re;t.autoStart=!0,t._protected=!0}return re._shared}static get system(){if(!re._system){const t=re._system=new re;t.autoStart=!0,t._protected=!0}return re._system}};Dd.targetFPMS=.06;let Ot=Dd;class Xa{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,n=this._canvas.height,s=e.width/i*this._renderer.resolution,a=e.height/n*this._renderer.resolution,o=e.left,l=e.top,u=`translate(${o}px, ${l}px) scale(${s}, ${a})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const i=this.canvas.width,n=this.canvas.height,s=e.contentRect.width/i*this._renderer.resolution,a=e.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==a)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=a)}}),this._observer.observe(this._canvas)):this._tickerAttached||Ot.shared.add(this.updateTranslation,this,Te.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ot.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Tr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Tr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,n,s){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 ja=/iPhone/i,Ud=/iPod/i,$d=/iPad/i,kd=/\biOS-universal(?:.+)Mac\b/i,Ha=/\bAndroid(?:.+)Mobile\b/i,Ld=/Android/i,Sr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,_n=/Silk/i,Ge=/Windows Phone/i,Nd=/\bWindows(?:.+)ARM\b/i,Xd=/BlackBerry/i,jd=/BB10/i,Hd=/Opera Mini/i,zd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Wd=/Mobile(?:.+)Firefox\b/i,Vd=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function t2(r){return function(t){return t.test(r)}}function Yd(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 n=t2(e),s={apple:{phone:n(ja)&&!n(Ge),ipod:n(Ud),tablet:!n(ja)&&(n($d)||Vd(t))&&!n(Ge),universal:n(kd),device:(n(ja)||n(Ud)||n($d)||n(kd)||Vd(t))&&!n(Ge)},amazon:{phone:n(Sr),tablet:!n(Sr)&&n(_n),device:n(Sr)||n(_n)},android:{phone:!n(Ge)&&n(Sr)||!n(Ge)&&n(Ha),tablet:!n(Ge)&&!n(Sr)&&!n(Ha)&&(n(_n)||n(Ld)),device:!n(Ge)&&(n(Sr)||n(_n)||n(Ha)||n(Ld))||n(/\bokhttp\b/i)},windows:{phone:n(Ge),tablet:n(Nd),device:n(Ge)||n(Nd)},other:{blackberry:n(Xd),blackberry10:n(jd),opera:n(Hd),firefox:n(Wd),chrome:n(zd),device:n(Xd)||n(jd)||n(Hd)||n(Wd)||n(zd)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}var Kd;const qd=((Kd=Yd.default)!=null?Kd:Yd)(globalThis.navigator);var e2=Object.defineProperty,Zd=Object.getOwnPropertySymbols,r2=Object.prototype.hasOwnProperty,i2=Object.prototype.propertyIsEnumerable,Qd=(r,t,e)=>t in r?e2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jd=(r,t)=>{for(var e in t||(t={}))r2.call(t,e)&&Qd(r,e,t[e]);if(Zd)for(var e of Zd(t))i2.call(t,e)&&Qd(r,e,t[e]);return r};const n2=9,tp=100,s2=0,a2=0,ep=2,rp=1,o2=-1e3,l2=-1e3,u2=2,za=class C1{constructor(t,e=qd){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width=`${rp}px`,t.style.height=`${rp}px`,t.style.position="absolute",t.style.top=`${o2}px`,t.style.left=`${l2}px`,t.style.zIndex=u2.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${s2}px`,this._div.style.left=`${a2}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=ep.toString(),this._canvasObserver=new Xa({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var t,e;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(t=i._accessibleDiv)!=null&&t.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(e=this._div)!=null&&e.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){const e=C1.defaultOptions,i={accessibilityOptions:Jd(Jd({},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._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const 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 n=this._children[i];e.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Ga(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const n=this._children[i];if(!n._accessibleActive||!n._accessibleDiv)continue;const s=n._accessibleDiv,a=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const o=n.worldTransform;s.style.left=`${o.tx+a.x*o.a}px`,s.style.top=`${o.ty+a.y*o.d}px`,s.style.width=`${a.width*o.a}px`,s.style.height=`${a.height*o.d}px`}else this._capHitArea(a),s.style.left=`${a.x}px`,s.style.top=`${a.y}px`,s.style.width=`${a.width}px`,s.style.height=`${a.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height: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._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=`
8 color: transparent;
9 pointer-events: none;
10 padding: 0;
11 margin: 0;
12 border: 0;
13 outline: 0;
14 background: transparent;
15 box-sizing: border-box;
16 user-select: none;
17 -webkit-user-select: none;
18 -moz-user-select: none;
19 -ms-user-select: none;
20 `,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${tp}px`,e.style.height=`${tp}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=ep.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:i}=t.target,n=this._renderer.events.rootBoundary,s=Object.assign(new Tr(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(a=>n.dispatchEvent(s,a))}_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!==n2||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};za.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"accessibility"},za.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let ip=za;const np={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};X.add(ip),X.mixin(dt,np);class Wa{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Xa({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],n=i.element;if(!i.parent||i.globalDisplayStatus<7)n==null||n.remove(),t.splice(e,1),e--;else{this._domElement.contains(n)||(n.style.position="absolute",n.style.pointerEvents="auto",this._domElement.appendChild(n));const s=i.worldTransform,a=i._anchor,o=i.width*a.x,l=i.height*a.y;n.style.transformOrigin=`${o}px ${l}px`,n.style.transform=`matrix(${s.a}, ${s.b}, ${s.c}, ${s.d}, ${s.tx-o}, ${s.ty-l})`,n.style.opacity=i.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Wa.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"dom"};class Se extends dt{constructor(t){var e;super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Mt(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=(e=t.autoGarbageCollect)!=null?e:!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:n}=t;return i>=e.minX&&i<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const s=n[this.renderPipeId];s!=null&&s.addRenderable&&s.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,o=a.length;for(let l=0;l<o;l++)a[l].collectRenderables(t,e,i);n.blendMode.popBlendMode(t)}}var c2=Object.defineProperty,yn=Object.getOwnPropertySymbols,sp=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,op=(r,t,e)=>t in r?c2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h2=(r,t)=>{for(var e in t||(t={}))sp.call(t,e)&&op(r,e,t[e]);if(yn)for(var e of yn(t))ap.call(t,e)&&op(r,e,t[e]);return r},d2=(r,t)=>{var e={};for(var i in r)sp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&yn)for(var i of yn(r))t.indexOf(i)<0&&ap.call(r,i)&&(e[i]=r[i]);return e};class p2 extends Se{constructor(t={}){const e=t,{element:i,anchor:n}=e,s=d2(e,["element","anchor"]);super(h2({label:"DOMContainer"},s)),this.renderPipeId="dom",this.batched=!1,this._anchor=new lt(0,0),n&&(this.anchor=n),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:n}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=n}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}}X.add(Wa);let f2=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||(Ot.system.add(this._tickerUpdate,this,Te.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ot.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};const we=new f2;class hi extends Tr{constructor(){super(...arguments),this.client=new lt,this.movement=new lt,this.offset=new lt,this.global=new lt,this.screen=new lt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,n,s,a,o,l,u,c,h,p,f,m,g){throw new Error("Method not implemented.")}}class ae extends hi{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 rr extends hi{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}rr.DOM_DELTA_PIXEL=0,rr.DOM_DELTA_LINE=1,rr.DOM_DELTA_PAGE=2;const m2=2048,g2=new lt,di=new lt;class lp{constructor(t){this.dispatch=new Nt,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,n)=>i.priority-n.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,n=e.length;i<n;i++)e[i].fn(t)}hitTest(t,e){we.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,g2.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,s=i.length-1;n<s;n++)if(t.currentTarget=i[n],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 n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],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 n=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)n.forEach(a=>{t.currentTarget=i[s],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<m2&&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,n,s,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.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,n,s,a||s(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),o=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:l&&!s(t,i)&&n(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.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,n,s);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 a=this._isInteractive(e),o=t.isInteractive();return a&&n(t,i)?o?[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,di),!t.hitArea.contains(di.x,di.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const n=t.effects[i];if(n.containsPoint&&!n.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,di),t.containsPoint(di)):!1}notifyTarget(t,e){var i,n;if(!t.currentTarget.isInteractive())return;e!=null||(e=t.type);const s=`on${e}`;(n=(i=t.currentTarget)[s])==null||n.call(i,t);const a=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,a),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof ae))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 n=e.button===2;this.dispatchEvent(e,n?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,n;if(!(t instanceof ae))return;this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const a=s.pointerType==="mouse"||s.pointerType==="pen",o=this.trackingData(t.pointerId),l=this.findMountedTarget(o.overTargets);if(((e=o.overTargets)==null?void 0:e.length)>0&&l!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,l);if(this.dispatchEvent(p,"pointerout"),a&&this.dispatchEvent(p,"mouseout"),!s.composedPath().includes(l)){const f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!s.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),a&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(l!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(s,h);this.dispatchEvent(p,"pointerover"),a&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==s.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(s,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),a&&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(s,"pointermove"),c&&u.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&u.push("globaltouchmove")),a&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&u.push("globalmousemove"),this.cursor=(n=s.target)==null?void 0:n.cursor),u.length>0&&this.all(s,u),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof ae))return;const i=this.trackingData(t.pointerId),n=this.createPointerEvent(t),s=n.pointerType==="mouse"||n.pointerType==="pen";this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover"),n.pointerType==="mouse"&&(this.cursor=(e=n.target)==null?void 0:e.cursor);const a=this.clonePointerEvent(n,"pointerenter");for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),s&&this.notifyTarget(a,"mouseenter"),a.target=a.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(a)}mapPointerOut(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const a=this.createPointerEvent(t,"pointerleave",n);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof ae))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 o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let a=s;if(s&&!i.composedPath().includes(s)){let o=s;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,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")}o=o.parent}delete n.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const l=n.clicksByButton[t.button];if(l.target===o.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=e,o.detail=l.clickCount,o.pointerType==="mouse"){const u=o.button===2;this.dispatchEvent(o,u?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof rr))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 n;const s=this.allocateEvent(ae);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(n=i!=null?i:this.hitTest(s.global.x,s.global.y))!=null?n:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(rr);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(ae);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 ae&&e instanceof ae&&(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 hi&&e instanceof hi&&(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 n=0,s=i.length;n<s&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(e,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}var _2=Object.defineProperty,up=Object.getOwnPropertySymbols,y2=Object.prototype.hasOwnProperty,b2=Object.prototype.propertyIsEnumerable,cp=(r,t,e)=>t in r?_2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v2=(r,t)=>{for(var e in t||(t={}))y2.call(t,e)&&cp(r,e,t[e]);if(up)for(var e of up(t))b2.call(t,e)&&cp(r,e,t[e]);return r};const x2=1,T2={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Va=class xh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new lp(null),we.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new ae(null),this._rootWheelEvent=new rr(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(v2({},xh.defaultEventFeatures),{set:(e,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[i]=n,!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:n,resolution:s}=this.renderer;this.setTargetElement(n),this.resolution=s,xh._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(){we.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,n=e.length;i<n;i++){const s=e[i],a=this._bootstrapEvent(this._rootPointerEvent,s);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,we.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const s=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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":"",n=this._normalizeToPointerData(t);for(let s=0,a=n.length;s<a;s++){const o=this._bootstrapEvent(this._rootPointerEvent,n[s]);o.type+=i,this.rootBoundary.mapEvent(o)}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,n=e.length;i<n;i++){const s=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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,we.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;we.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;we.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 n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*s,t.y=(i-n.top)*(this.domElement.height/n.height)*s}_normalizeToPointerData(t){var e,i,n,s;const a=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let o=0,l=t.changedTouches.length;o<l;o++){const u=t.changedTouches[o];typeof u.button=="undefined"&&(u.button=0),typeof u.buttons=="undefined"&&(u.buttons=1),typeof u.isPrimary=="undefined"&&(u.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof u.width=="undefined"&&(u.width=u.radiusX||1),typeof u.height=="undefined"&&(u.height=u.radiusY||1),typeof u.tiltX=="undefined"&&(u.tiltX=0),typeof u.tiltY=="undefined"&&(u.tiltY=0),typeof u.pointerType=="undefined"&&(u.pointerType="touch"),typeof u.pointerId=="undefined"&&(u.pointerId=u.identifier||0),typeof u.pressure=="undefined"&&(u.pressure=u.force||.5),typeof u.twist=="undefined"&&(u.twist=0),typeof u.tangentialPressure=="undefined"&&(u.tangentialPressure=0),typeof u.layerX=="undefined"&&(u.layerX=u.offsetX=u.clientX),typeof u.layerY=="undefined"&&(u.layerY=u.offsetY=u.clientY),u.isNormalized=!0,u.type=t.type,(e=u.altKey)!=null||(u.altKey=t.altKey),(i=u.ctrlKey)!=null||(u.ctrlKey=t.ctrlKey),(n=u.metaKey)!=null||(u.metaKey=t.metaKey),(s=u.shiftKey)!=null||(u.shiftKey=t.shiftKey),a.push(u)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const o=t;typeof o.isPrimary=="undefined"&&(o.isPrimary=!0),typeof o.width=="undefined"&&(o.width=1),typeof o.height=="undefined"&&(o.height=1),typeof o.tiltX=="undefined"&&(o.tiltX=0),typeof o.tiltY=="undefined"&&(o.tiltY=0),typeof o.pointerType=="undefined"&&(o.pointerType="mouse"),typeof o.pointerId=="undefined"&&(o.pointerId=x2),typeof o.pressure=="undefined"&&(o.pressure=.5),typeof o.twist=="undefined"&&(o.twist=0),typeof o.tangentialPressure=="undefined"&&(o.tangentialPressure=0),o.isNormalized=!0,a.push(o)}else a.push(t);return a}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=T2[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}};Va.extension={name:"events",type:[S.WebGLSystem,S.CanvasSystem,S.WebGPUSystem],priority:-1},Va.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ya=Va;const hp={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:Ya.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,n=typeof e=="object"?e.signal:void 0,s=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const o=typeof t=="function"?t:t.handleEvent,l=this;n&&n.addEventListener("abort",()=>{l.off(r,o,a)}),s?l.once(r,o,a):l.on(r,o,a)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,n=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,n)},dispatchEvent(r){if(!(r instanceof Tr))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}};X.add(Ya),X.mixin(dt,hp);var te=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(te||{});const dp={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let pp=dp;const H={get(){return pp},set(r){pp=r}};function de(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function pi(r){return r.split("?")[0].split("#")[0]}function S2(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function w2(r,t,e){return r.replace(new RegExp(S2(t),"g"),e)}function P2(r,t){let e="",i=0,n=-1,s=0,a=-1;for(let o=0;o<=r.length;++o){if(o<r.length)a=r.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(n===o-1||s===1))if(n!==o-1&&s===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("/")),n=o,s=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=o,s=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(n+1,o)}`:e=r.slice(n+1,o),i=o-n-1;n=o,s=0}else a===46&&s!==-1?++s:s=-1}return e}const zt={toPosix(r){return w2(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){de(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(de(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=pi(this.toPosix(t!=null?t:H.get().getBaseUrl())),n=pi(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?zt.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(de(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=P2(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return de(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 n=r[i];if(de(n),n.length>0)if(e===void 0)e=n;else{const s=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(de(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,n=!0;const s=this.getProtocol(r),a=r;r=r.slice(s.length);for(let o=r.length-1;o>=1;--o)if(t=r.charCodeAt(o),t===47){if(!n){i=o;break}}else n=!1;return i===-1?e?"/":this.isUrl(a)?s+r:s:e&&i===1?"//":s+r.slice(0,i)},rootname(r){de(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){de(r),t&&de(t),r=pi(this.toPosix(r));let e=0,i=-1,n=!0,s;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let a=t.length-1,o=-1;for(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){e=s+1;break}}else o===-1&&(n=!1,o=s+1),a>=0&&(l===t.charCodeAt(a)?--a===-1&&(i=s):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=r.length),r.slice(e,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){e=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(e,i)},extname(r){de(r),r=pi(this.toPosix(r));let t=-1,e=0,i=-1,n=!0,s=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}i===-1&&(n=!1,i=a+1),o===46?t===-1?t=a:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){de(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=pi(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let n;const s="";t.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let a=-1,o=0,l=-1,u=!0,c=r.length-1,h=0;for(;c>=n;--c){if(e=r.charCodeAt(c),e===47){if(!u){o=c+1;break}continue}l===-1&&(u=!1,l=c+1),e===46?a===-1?a=c:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===o+1?l!==-1&&(o===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(o,l)):(o===0&&i?(t.name=r.slice(1,a),t.base=r.slice(1,l)):(t.name=r.slice(o,a),t.base=r.slice(o,l)),t.ext=r.slice(a,l)),t.dir=this.dirname(r),s&&(t.dir=s+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},oe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function fp(r,t,e,i,n){const s=t[e];for(let a=0;a<s.length;a++){const o=s[a];e<t.length-1?fp(r.replace(i[e],o),t,e+1,i,n):n.push(r.replace(i[e],o))}}function mp(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const n=[];e.forEach(s=>{const a=s.substring(1,s.length-1).split(",");n.push(a)}),fp(r,n,0,e,i)}else i.push(r);return i}const fi=r=>!Array.isArray(r);var E2=Object.defineProperty,A2=Object.defineProperties,C2=Object.getOwnPropertyDescriptors,gp=Object.getOwnPropertySymbols,M2=Object.prototype.hasOwnProperty,R2=Object.prototype.propertyIsEnumerable,_p=(r,t,e)=>t in r?E2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ir=(r,t)=>{for(var e in t||(t={}))M2.call(t,e)&&_p(r,e,t[e]);if(gp)for(var e of gp(t))R2.call(t,e)&&_p(r,e,t[e]);return r},O2=(r,t)=>A2(r,C2(t));class $e{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,n;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(n=t.extractAssetIdFromBundle)!=null?n: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 oe(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(s=>{var a;return(a=s==null?void 0:s.src)!=null?a:s}):n!=null&&n.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([s,a])=>typeof a=="string"||Array.isArray(a)?{alias:s,src:a}:ir({alias:s},a))),n.forEach(s=>{const a=s.src,o=s.alias;let l;if(typeof o=="string"){const u=this._createBundleAssetId(t,o);i.push(u),l=[o,u]}else{const u=o.map(c=>this._createBundleAssetId(t,c));i.push(...u),l=[...o,...u]}this.add(O2(ir({},s),{alias:l,src:a}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;oe(e).forEach(n=>{const{src:s}=n;let{data:a,format:o,loadParser:l,parser:u}=n;const c=oe(s).map(m=>typeof m=="string"?mp(m):Array.isArray(m)?m:[m]),h=this.getAlias(n),p=[],f=m=>{const g=this._parsers.find(_=>_.test(m));return ir({src:m},g==null?void 0:g.parse(m))};c.forEach(m=>{m.forEach(g=>{var _,y,b,x;let v={};if(typeof g!="object"?v=f(g):(a=(_=g.data)!=null?_:a,o=(y=g.format)!=null?y:o,(g.loadParser||g.parser)&&(l=(b=g.loadParser)!=null?b:l,u=(x=g.parser)!=null?x:u),v=ir(ir({},f(g.src)),g)),!h)throw new Error(`[Resolver] alias is undefined for this asset: ${v.src}`);v=this._buildResolvedAsset(v,{aliases:h,data:a,format:o,loadParser:l,parser:u,progressSize:n.progressSize}),p.push(v)})}),h.forEach(m=>{this._assetMap[m]=p})})}resolveBundle(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{const s=this._bundles[n];if(s){const a=this.resolve(s),o={};for(const l in a){const u=a[l];o[this._extractAssetIdFromBundle(n,l)]=u}i[n]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const a=this._getPreferredOrder(s);a==null||a.priority.forEach(o=>{a.params[o].forEach(l=>{const u=s.filter(c=>c[o]?c[o]===l:!1);u.length&&(s=u)})}),this._resolverHash[n]=s[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),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],n=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(n)return n}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,n;const{aliases:s,data:a,loadParser:o,parser:l,format:u,progressSize:c}=e;return(this._basePath||this._rootPath)&&(t.src=zt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=s!=null?s:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=ir(ir({},a||{}),t.data),t.loadParser=o!=null?o:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(n=u!=null?u:t.format)!=null?n:yp(t.src),c!==void 0&&(t.progressSize=c),t}}$e.RETINA_PREFIX=/@([0-9\.]+)x/;function yp(r){return r.split(".").pop().split("?").shift().split("#").shift()}const bn=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},bp=class en{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof ft&&(i={texture:t,data:e});const{texture:n,data:s,cachePrefix:a=""}=i;this.cachePrefix=a,this._texture=n instanceof D?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=s;const o=parseFloat(s.meta.scale);o?(this.resolution=o,n.source.resolution=this.resolution):this.resolution=n.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<=en.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const n=e?1/0:en.BATCH_SIZE;for(;i-t<n&&i<this._frameKeys.length;){const s=this._frameKeys[i],a=this._frames[s],o=a.frame;if(o){let l=null,u=null;const c=a.trimmed!==!1&&a.sourceSize?a.sourceSize:a.frame,h=new ut(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);a.rotated?l=new ut(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):l=new ut(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),a.trimmed!==!1&&a.spriteSourceSize&&(u=new ut(Math.floor(a.spriteSourceSize.x)/this.resolution,Math.floor(a.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new D({source:this.textureSource,frame:l,orig:h,trim:u,rotate:a.rotated?2:0,defaultAnchor:a.anchor,defaultBorders:a.borders,label:s.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const n=t[e][i];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*en.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*en.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=[]}};bp.BATCH_SIZE=1e3;let Ka=bp;const G2=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function vp(r,t,e){const i={};if(r.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=zt.dirname(r[0]);t.linkedSheets.forEach((s,a)=>{const o=vp([`${n}/${t.data.meta.related_multi_packs[a]}`],s,!0);Object.assign(i,o)})}return i}const xp={extension:S.Asset,cache:{test:r=>r instanceof Ka,getCacheableAssets:(r,t)=>vp(r,t,!1)},resolver:{extension:{type:S.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&G2.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:te.Normal,name:"spritesheetLoader"},async testParse(r,t){return zt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,n,s;const{texture:a,imageFilename:o,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let c=zt.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(a instanceof D)h=a;else{const m=bn(c+(o!=null?o:r.meta.image),t.src);h=(await e.load([{src:m,data:l}]))[m]}const p=new Ka({texture:h.source,data:r,cachePrefix:u});await p.parse();const f=(n=r==null?void 0:r.meta)==null?void 0:n.related_multi_packs;if(Array.isArray(f)){const m=[];for(const _ of f){if(typeof _!="string")continue;let y=c+_;(s=t.data)!=null&&s.ignoreMultiPack||(y=bn(y,t.src),m.push(e.load({src:y,data:{textureOptions:l,ignoreMultiPack:!0}})))}const g=await Promise.all(m);p.linkedSheets=g,g.forEach(_=>{_.linkedSheets=[p].concat(p.linkedSheets.filter(y=>y!==_))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};X.add(xp);function qa(r,t,e){const{width:i,height:n}=e.orig,s=e.trim;if(s){const a=s.width,o=s.height;r.minX=s.x-t._x*i,r.maxX=r.minX+a,r.minY=s.y-t._y*n,r.maxY=r.minY+o}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*n,r.maxY=r.minY+n}var I2=Object.defineProperty,vn=Object.getOwnPropertySymbols,Tp=Object.prototype.hasOwnProperty,Sp=Object.prototype.propertyIsEnumerable,wp=(r,t,e)=>t in r?I2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B2=(r,t)=>{for(var e in t||(t={}))Tp.call(t,e)&&wp(r,e,t[e]);if(vn)for(var e of vn(t))Sp.call(t,e)&&wp(r,e,t[e]);return r},F2=(r,t)=>{var e={};for(var i in r)Tp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&vn)for(var i of vn(r))t.indexOf(i)<0&&Sp.call(r,i)&&(e[i]=r[i]);return e};class pe extends Se{constructor(t=D.EMPTY){t instanceof D&&(t={texture:t});const e=t,{texture:i=D.EMPTY,anchor:n,roundPixels:s,width:a,height:o}=e,l=F2(e,["texture","anchor","roundPixels","width","height"]);super(B2({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=s!=null?s:!1,a!==void 0&&(this.width=a),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof D?new pe(t):new pe(D.from(t,e))}set texture(t){t||(t=D.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 qa(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:n,height:s}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var 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 D2=new Mt;function xn(r,t,e){const i=D2;r.measurable=!0,li(r,e,i),t.addBoundsMask(i),r.measurable=!1}function Tn(r,t,e){const i=ve.get();r.measurable=!0;const n=Dt.get().identity(),s=Pp(r,e,n);un(r,i,s),r.measurable=!1,t.addBoundsMask(i),Dt.return(n),ve.return(i)}function Pp(r,t,e){return r&&r!==t&&(Pp(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Za{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof pe),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||xn(this.mask,t,e)}addLocalBounds(t,e){Tn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof pe}}Za.extension=S.MaskEffect;class Qa{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"}}Qa.extension=S.MaskEffect;class Ja{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){xn(this.mask,t,e)}addLocalBounds(t,e){Tn(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}}Ja.extension=S.MaskEffect;class fe extends ft{constructor(t){t.resource||(t.resource=H.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}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"))}}fe.extension=S.TextureSource;class ke extends ft{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ke.extension=S.TextureSource;let to;async function eo(){return to!=null||(to=(async()=>{var r;const t=H.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),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 s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(n),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),to}var U2=Object.defineProperty,$2=Object.defineProperties,k2=Object.getOwnPropertyDescriptors,Ep=Object.getOwnPropertySymbols,L2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,Ap=(r,t,e)=>t in r?U2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ro=(r,t)=>{for(var e in t||(t={}))L2.call(t,e)&&Ap(r,e,t[e]);if(Ep)for(var e of Ep(t))N2.call(t,e)&&Ap(r,e,t[e]);return r},X2=(r,t)=>$2(r,k2(t));const Sn=class M1 extends ft{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=ro(ro({},M1.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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ot.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await eo(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ot.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||(Ot.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Sn.extension=S.TextureSource,Sn.defaultOptions=X2(ro({},ft.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Sn.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let wr=Sn,j2=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=oe(t);let n;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.test(e)){n=u.getCacheableAssets(i,e);break}}const s=new Map(Object.entries(n||{}));n||i.forEach(l=>{s.set(l,e)});const a=[...s.keys()],o={cacheKeys:a,keys:i};i.forEach(l=>{this._cacheMap.set(l,o)}),a.forEach(l=>{const u=n?n[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,s.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 it=new j2,io=[];X.handleByList(S.TextureSource,io);function H2(r={}){return no(r)}function no(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let n=0;n<io.length;n++){const s=io[n];if(s.test(e))return new s(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Cp(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,n=e?r:{resource:r};if(!t&&it.has(i))return it.get(i);const s=new D({source:no(n)});return s.on("destroy",()=>{it.has(i)&&it.remove(i)}),t||it.set(i,s),s}function Mp(r,t=!1){return typeof r=="string"?it.get(r):r instanceof ft?new D({source:r}):Cp(r,t)}D.from=Mp,ft.from=no,X.add(Za,Qa,Ja,wr,ke,fe,dn);let Pr;function Rp(r){const t=H.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function so(){if(Pr!==void 0)return Pr;try{const r=Rp("#ff00ff"),t=Rp("#ffff00"),e=H.get().createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const i=e.getImageData(2,0,1,1);if(!i)Pr=!1;else{const n=i.data;Pr=n[0]===255&&n[1]===0&&n[2]===0}}catch(r){Pr=!1}return Pr}const Q={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:so(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{var t,e;const i=r.source,n=i==null?void 0:i.resource;if(!n)return null;const s=i.alphaMode==="premultiplied-alpha",a=(t=i.resourceWidth)!=null?t:i.pixelWidth,o=(e=i.resourceHeight)!=null?e:i.pixelHeight,l=a!==i.pixelWidth||o!==i.pixelHeight;if(s){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&n instanceof OffscreenCanvas)&&!l)return n;const u=Q._unpremultipliedCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d"),p=h.createImageData(i.pixelWidth,i.pixelHeight),f=p.data,m=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(i.format==="bgra8unorm")for(let g=0;g<f.length&&g+3<m.length;g+=4)f[g]=m[g+2],f[g+1]=m[g+1],f[g+2]=m[g],f[g+3]=m[g+3];else f.set(m.subarray(0,f.length));return h.putImageData(p,0,0),Q._canvasSourceCache.set(i,{canvas:c,resourceId:i._resourceId}),c}if(s){const u=H.get().createCanvas(i.pixelWidth,i.pixelHeight),c=u.getContext("2d",{willReadFrequently:!0});u.width=i.pixelWidth,u.height=i.pixelHeight,c.drawImage(n,0,0);const h=c.getImageData(0,0,u.width,u.height),p=h.data;for(let f=0;f<p.length;f+=4){const m=p[f+3];if(m>0){const g=255/m;p[f]=Math.min(255,p[f]*g+.5),p[f+1]=Math.min(255,p[f+1]*g+.5),p[f+2]=Math.min(255,p[f+2]*g+.5)}}return c.putImageData(h,0,0),Q._unpremultipliedCache.set(i,{canvas:u,resourceId:i._resourceId}),u}if(l){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d");return c.width=i.pixelWidth,c.height=i.pixelHeight,h.drawImage(n,0,0),Q._canvasSourceCache.set(i,{canvas:c,resourceId:i._resourceId}),c}return n},getTintedCanvas:(r,t)=>{const e=r.texture,i=tt.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),s=n[i],a=e.source._resourceId;if((s==null?void 0:s.tintId)===a)return s;const o=s&&"getContext"in s?s:H.get().createCanvas();if(Q.tintMethod(e,t,o),o.tintId=a,Q.convertTintToImage&&o.toDataURL!==void 0){const l=H.get().createImage();l.src=o.toDataURL(),l.tintId=a,n[i]=l}else n[i]=o;return n[i]},getTintedPattern:(r,t)=>{const e=tt.shared.setValue(t).toHex(),i=r.patternCache||(r.patternCache={}),n=r.source._resourceId;let s=i[e];return(s==null?void 0:s.tintId)===n||(Q.canvas||(Q.canvas=H.get().createCanvas()),Q.tintMethod(r,t,Q.canvas),s=Q.canvas.getContext("2d").createPattern(Q.canvas,"repeat"),s.tintId=n,i[e]=s),s},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const i=r;if(!i.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);i.setTransform(e?s.inverse():s)},tintWithMultiply:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="multiply";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.globalCompositeOperation="destination-atop",s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithOverlay:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="destination-atop";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithPerPixel:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore();const f=t>>16&255,m=t>>8&255,g=t&255,_=s.getImageData(0,0,c,h),y=_.data;for(let b=0;b<y.length;b+=4)y[b]=y[b]*f/255,y[b+1]=y[b+1]*m/255,y[b+2]=y[b+2]*g/255;s.putImageData(_,0,0)},_applyInverseRotation:(r,t,e,i)=>{const n=W.inv(t),s=W.uX(n),a=W.uY(n),o=W.vX(n),l=W.vY(n),u=-Math.min(0,s*e,o*i,s*e+o*i),c=-Math.min(0,a*e,l*i,a*e+l*i);r.transform(s,a,o,l,u,c)}};Q.tintMethod=Q.canUseMultiply?Q.tintWithMultiply:Q.tintWithPerPixel;class Op{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=H.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Ze(t),e=Ze(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let s=this._canvasPool[n].pop();return s||(s=this._createCanvasAndContext(t,e)),s}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,s=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[s].push(t)}clear(){this._canvasPool={}}}const me=new Op;qe.register(me);function mi(r,t,e,i,n,s){const a=r-e,o=t-i,l=n-e,u=s-i,c=a*l+o*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=n,m=s):(f=e+p*l,m=i+p*u);const g=r-f,_=t-m;return g*g+_*_}function ao(r,t,e,i,n,s,a,o){const l=a-e,u=o-i,c=n-e,h=s-i,p=r-e,f=t-i,m=l*l+u*u,g=l*c+u*h,_=l*p+u*f,y=c*c+h*h,b=c*p+h*f,x=1/(m*y-g*g),v=(y*_-g*b)*x,w=(m*b-g*_)*x;return v>=0&&w>=0&&v+w<1}class wn{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new wn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=i}strokeContains(t,e,i,n=.5){if(this.radius===0)return!1;const s=this.x-t,a=this.y-e,o=this.radius,l=(1-n)*i,u=Math.sqrt(s*s+a*a);return u<=o+l&&u>o-(i-l)}getBounds(t){return t||(t=new ut),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class Pn{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new Pn(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,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:s,halfHeight:a}=this;if(s<=0||a<=0)return!1;const o=i*(1-n),l=i-o,u=s-l,c=a-l,h=s+o,p=a+o,f=t-this.x,m=e-this.y,g=f*f/(u*u)+m*m/(c*c),_=f*f/(h*h)+m*m/(p*p);return g>1&&_<=1}getBounds(t){return t||(t=new ut),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}let z2,W2;class Er{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,s=e.length;n<s;n++)i.push(e[n].x,e[n].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let n=0;n<i;n+=2){const s=e[n],a=e[n+1],o=e[(n+2)%i],l=e[(n+3)%i];t+=(o-s)*(l+a)}return t<0}containsPolygon(t){const e=this.getBounds(z2),i=t.getBounds(W2);if(!e.containsRect(i))return!1;const n=t.points;for(let s=0;s<n.length;s+=2){const a=n[s],o=n[s+1];if(!this.contains(a,o))return!1}return!0}clone(){const t=this.points.slice(),e=new Er(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let s=0,a=n-1;s<n;a=s++){const o=this.points[s*2],l=this.points[s*2+1],u=this.points[a*2],c=this.points[a*2+1];l>e!=c>e&&t<(u-o)*((e-l)/(c-l))+o&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const s=i*i,a=s*(1-n),o=s-a,{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],g=mi(t,e,h,p,f,m),_=Math.sign((f-h)*(e-p)-(m-p)*(t-h));if(g<=(_<0?o:a))return!0}return!1}getBounds(t){t||(t=new ut);const e=this.points;let i=1/0,n=-1/0,s=1/0,a=-1/0;for(let o=0,l=e.length;o<l;o+=2){const u=e[o],c=e[o+1];i=u<i?u:i,n=u>n?u:n,s=c<s?c:s,a=c>a?c:a}return t.x=i,t.width=n-i,t.y=s,t.height=a-s,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const En=(r,t,e,i,n,s,a)=>{const o=r-e,l=t-i,u=Math.sqrt(o*o+l*l);return u>=n-s&&u<=n+a};class An{constructor(t=0,e=0,i=0,n=0,s=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s}getBounds(t){return t||(t=new ut),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new An(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 n=t-(this.x+i),s=e-(this.y+i);const a=i*i;if(n*n+s*s<=a||(n=t-(this.x+this.width-i),n*n+s*s<=a)||(s=e-(this.y+this.height-i),n*n+s*s<=a)||(n=t-(this.x+i),n*n+s*s<=a))return!0}return!1}strokeContains(t,e,i,n=.5){const{x:s,y:a,width:o,height:l,radius:u}=this,c=i*(1-n),h=i-c,p=s+u,f=a+u,m=o-u*2,g=l-u*2,_=s+o,y=a+l;return(t>=s-c&&t<=s+h||t>=_-h&&t<=_+c)&&e>=f&&e<=f+g||(e>=a-c&&e<=a+h||e>=y-h&&e<=y+c)&&t>=p&&t<=p+m?!0:t<p&&e<f&&En(t,e,p,f,u,h,c)||t>_-u&&e<f&&En(t,e,_-u,f,u,h,c)||t>_-u&&e>y-u&&En(t,e,_-u,y-u,u,h,c)||t<p&&e>y-u&&En(t,e,p,y-u,u,h,c)}}class oo{constructor(t=0,e=0,i=0,n=0,s=0,a=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=n,this.x3=s,this.y3=a}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),n=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=n<0&&i!==0&&n!==0)return!1;const s=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return s===0||s<0==i+n<=0}strokeContains(t,e,i,n=.5){const s=i/2,a=s*s,{x:o,x2:l,x3:u,y:c,y2:h,y3:p}=this;return mi(t,e,o,c,l,p)<=a||mi(t,e,l,h,u,p)<=a||mi(t,e,u,p,o,c)<=a}clone(){return new oo(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new ut);const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),n=Math.min(this.y,this.y2,this.y3),s=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=n,t.width=i-e,t.height=s-n,t}}const Gp=new U;function lo(r,t){var e;t.clear();const i=t.matrix;for(let n=0;n<r.length;n++){const s=r[n];if(s.globalDisplayStatus<7)continue;const a=(e=s.renderGroup)!=null?e:s.parentRenderGroup;a!=null&&a.isCachedAsTexture?t.matrix=Gp.copyFrom(a.textureOffsetInverseTransform).append(s.worldTransform):a!=null&&a._parentCacheAsTextureRenderGroup?t.matrix=Gp.copyFrom(a._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=i,t}const V2=new Mt;function Cn(r,t,e,i,n=!1){const s=V2;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const a=vt.getOptimalTexture(s.width,s.height,i,!1,n);return a.source.uploadMethodId="image",a.source.resource=r,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=t/i,a.frame.height=e/i,a.source.emit("update",a.source),a.updateUvs(),a}function uo(r){return typeof r.getCanvasFilterString=="function"}let Y2=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Mt,this.cssFilterString=""}};class co{constructor(t){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=t}push(t){const e=this._pushFilterFrame(),i=t.filterEffect.filters;if(e.skip=!1,e.useClip=!1,e.filters=i,e.container=t.container,e.cssFilterString="",i.every(l=>!l.enabled)){e.skip=!0;return}const n=[],s=1;for(const l of i){if(!l.enabled)continue;if(!uo(l)){this._warnUnsupportedFilter(l);continue}const u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&n.push(u)}if(n.length===0&&s===1){e.skip=!0;return}e.cssFilterString=n.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const a=this.renderer.canvasContext.activeContext,o=a.filter||"none";if(this._savedStates.push({filter:o,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;a.save(),a.setTransform(1,0,0,1,0,0),a.beginPath(),a.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),a.clip()}else e.useClip=!1;s!==1&&(this._alphaMultiplier*=s),e.cssFilterString&&(a.filter=o!=="none"?`${o} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const i=this.renderer.canvasContext.activeContext;t.useClip?i.restore():i.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){var i,n;if(!(e!=null&&e.length)||e.every(x=>!x.enabled))return t;const s=[],a=1;for(const x of e){if(!x.enabled)continue;if(!uo(x)){this._warnUnsupportedFilter(x);continue}const v=x.getCanvasFilterString();if(v===null){this._warnUnsupportedFilter(x);continue}v&&s.push(v)}if(s.length===0&&a===1)return t;const o=Q.getCanvasSource(t);if(!o)return t;const l=t.frame,u=(n=(i=t.source._resolution)!=null?i:t.source.resolution)!=null?n:1,c=l.width,h=l.height,p=me.getOptimalCanvasAndContext(c,h,u),{canvas:f,context:m}=p;m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,f.width,f.height),s.length&&(m.filter=s.join(" ")),a!==1&&(m.globalAlpha=a);const g=l.x*u,_=l.y*u,y=c*u,b=h*u;return m.drawImage(o,g,_,y,b,0,0,y,b),m.filter="none",m.globalAlpha=1,Cn(f,c,h,u)}_calculateFilterArea(t,e){if(t.renderables?lo(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=t.container.renderGroup||t.container.parentRenderGroup,n=i==null?void 0:i.cacheToLocalTransform;n&&e.applyMatrix(n)}}_warnUnsupportedFilter(t){var e;const i=((e=t==null?void 0:t.constructor)==null?void 0:e.name)||"Filter";this._warnedFilterTypes.has(i)||(this._warnedFilterTypes.add(i),console.warn(`CanvasRenderer: filter "${i}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new Y2),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}co.extension={type:[S.CanvasSystem],name:"filter"};class ho{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}}ho.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};const po=Object.create(null),Ip=Object.create(null);function Ar(r,t){let e=Ip[r];return e===void 0&&(po[t]===void 0&&(po[t]=1),Ip[r]=e=po[t]++),e}let gi;function fo(){return(!gi||gi!=null&&gi.isContextLost())&&(gi=H.get().createCanvas().getContext("webgl",{})),gi}let Mn;function Bp(){if(!Mn){Mn="mediump";const r=fo();r&&r.getShaderPrecisionFormat&&(Mn=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Mn}function Fp(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),`
21
22 #ifdef GL_ES // This checks if it is WebGL1
23 #define in varying
24 #define finalColor gl_FragColor
25 #define texture texture2D
26 #endif
27 ${r}
28 `):`
29
30 #ifdef GL_ES // This checks if it is WebGL1
31 #define in attribute
32 #define out varying
33 #endif
34 ${r}
35 `}function Dp(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float;
36 ${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Up(r,t){return t?`#version 300 es
37 ${r}`:r}const K2={},q2={};function $p(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?K2:q2;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
38 ${r}`}function kp(r,t){return t?r.replace("#version 300 es",""):r}var Z2=Object.defineProperty,Lp=Object.getOwnPropertySymbols,Q2=Object.prototype.hasOwnProperty,J2=Object.prototype.propertyIsEnumerable,Np=(r,t,e)=>t in r?Z2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xp=(r,t)=>{for(var e in t||(t={}))Q2.call(t,e)&&Np(r,e,t[e]);if(Lp)for(var e of Lp(t))J2.call(t,e)&&Np(r,e,t[e]);return r};const mo={stripVersion:kp,ensurePrecision:Dp,addProgramDefines:Fp,setProgramName:$p,insertVersion:Up},_i=Object.create(null),jp=class Th{constructor(t){t=Xp(Xp({},Th.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Bp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,s=t.vertex;Object.keys(mo).forEach(a=>{const o=i[a];n=mo[a](n,o,!0),s=mo[a](s,o,!1)}),this.fragment=n,this.vertex=s,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ar(`${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,_i[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return _i[e]||(_i[e]=new Th(t),_i[e]._cacheKey=e),_i[e]}};jp.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Wt=jp;const Hp={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 Ie(r){var t;return(t=Hp[r])!=null?t:Hp.float32}const tw={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},zp=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Wp(r,t){var e;let i;for(;(i=zp.exec(r))!==null;){const n=(e=tw[i[3]])!=null?e:"float32";t[i[2]]={location:parseInt(i[1],10),format:n,stride:Ie(n).stride,offset:0,instance:!1,start:0}}zp.lastIndex=0}function ew(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Vp({source:r,entryPoint:t}){const e={},i=ew(r),n=i.indexOf(`fn ${t}(`);if(n===-1)return e;const s=i.indexOf("->",n);if(s===-1)return e;const a=i.substring(n,s);if(Wp(a,e),Object.keys(e).length===0){const o=a.match(/\(\s*\w+\s*:\s*(\w+)/);if(o){const l=o[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=i.match(u);c&&Wp(c[1],e)}}return e}function Rn(r){var t,e,i;const n=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,s=/@group\((\d+)\)/,a=/@binding\((\d+)\)/,o=/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(n))==null?void 0:t.map(m=>({group:parseInt(m.match(s)[1],10),binding:parseInt(m.match(a)[1],10),name:m.match(o)[2],isUniform:m.match(o)[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 g=m.match(h)[1],_=m.match(c).reduce((y,b)=>{const[x,v]=b.split(":");return y[x.trim()]=v.trim(),y},{});return _?{name:g,members:_}:null}).filter(({name:m})=>p.some(g=>g.type===m||g.type.includes(`<${m}>`))))!=null?i:[];return{groups:p,structs:f}}var Le=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Le||{});function Yp({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:Le.VERTEX|Le.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Le.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"||i.type.startsWith("texture_2d<")?t[i.group].push({binding:i.binding,visibility:Le.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):i.type==="texture_2d_array"||i.type.startsWith("texture_2d_array<")?t[i.group].push({binding:i.binding,visibility:Le.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(i.type==="texture_cube"||i.type.startsWith("texture_cube<"))&&t[i.group].push({binding:i.binding,visibility:Le.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function Kp({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 qp(r,t){const e=new Set,i=new Set,n=[...r.structs,...t.structs].filter(a=>e.has(a.name)?!1:(e.add(a.name),!0)),s=[...r.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:n,groups:s}}const yi=Object.create(null);class Xt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:n,vertex:s,layout:a,gpuLayout:o,name:l}=t;if(this.name=l,this.fragment=n,this.vertex=s,n.source===s.source){const u=Rn(n.source);this.structsAndGroups=u}else{const u=Rn(s.source),c=Rn(n.source);this.structsAndGroups=qp(u,c)}this.layout=a!=null?a:Kp(this.structsAndGroups),this.gpuLayout=o!=null?o:Yp(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=Ar(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Vp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,yi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return yi[e]||(yi[e]=new Xt(t),yi[e]._cacheKey=e),yi[e]}}class Pe{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,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,n;const s=this.resources[e];t!==s&&((i=s==null?void 0:s.off)==null||i.call(s,"change",this.onResourceChange,this),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const n in i)i[n]._gcLastUsed=t,i[n]._touched=e}destroy(){var t;const e=this.resources;for(const i in e){const n=e[i];(t=n==null?void 0:n.off)==null||t.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var It=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(It||{});const go=["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>"],Zp=go.reduce((r,t)=>(r[t]=!0,r),{});function Qp(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var rw=Object.defineProperty,Jp=Object.getOwnPropertySymbols,iw=Object.prototype.hasOwnProperty,nw=Object.prototype.propertyIsEnumerable,tf=(r,t,e)=>t in r?rw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ef=(r,t)=>{for(var e in t||(t={}))iw.call(t,e)&&tf(r,e,t[e]);if(Jp)for(var e of Jp(t))nw.call(t,e)&&tf(r,e,t[e]);return r};const rf=class R1{constructor(t,e){this._touched=0,this.uid=ht("uniform"),this._resourceType="uniformGroup",this._resourceId=ht("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,n;e=ef(ef({},R1.defaultOptions),e),this.uniformStructures=t;const s={};for(const a in t){const o=t[a];if(o.name=a,o.size=(i=o.size)!=null?i:1,!Zp[o.type]){const l=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,c]=l;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${u}', size: ${c} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${go.join(", ")}`)}(n=o.value)!=null||(o.value=Qp(o.type,o.size)),s[a]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ar(Object.keys(s).map(a=>`${a}-${t[a].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};rf.defaultOptions={ubo:!1,isStatic:!1};let At=rf;var sw=Object.defineProperty,On=Object.getOwnPropertySymbols,nf=Object.prototype.hasOwnProperty,sf=Object.prototype.propertyIsEnumerable,af=(r,t,e)=>t in r?sw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aw=(r,t)=>{for(var e in t||(t={}))nf.call(t,e)&&af(r,e,t[e]);if(On)for(var e of On(t))sf.call(t,e)&&af(r,e,t[e]);return r},ow=(r,t)=>{var e={};for(var i in r)nf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&On)for(var i of On(r))t.indexOf(i)<0&&sf.call(r,i)&&(e[i]=r[i]);return e};class ee extends Nt{constructor(t){super(),this.uid=ht("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:n,resources:s,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=It.WEBGPU),i&&(a|=It.WEBGL)),this.compatibleRenderers=a;const l={};if(!s&&!n&&(s={}),s&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const u in o)for(const c in o[u]){const h=o[u][c];l[h]={group:u,binding:c,name:h}}else if(e&&n&&!o){const u=e.structsAndGroups.groups;o={},u.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c})}else if(s){n={},o={},e&&e.structsAndGroups.groups.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c});let u=0;for(const c in s)l[c]||(n[99]||(n[99]=new Pe,this._ownedBindGroups.push(n[99])),l[c]={group:99,binding:u,name:c},o[99]=o[99]||{},o[99][u]=c,u++);for(const c in s){const h=c;let p=s[c];!p.source&&!p._resourceType&&(p=new At(p));const f=l[h];f&&(n[f.group]||(n[f.group]=new Pe,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(p,f.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,l)}addResource(t,e,i){var n,s;(n=this._uniformBindMap)[e]||(n[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new Pe,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const s=e[n];Object.defineProperty(i,s.name,{get(){return t[s.group].getResource(s.binding)},set(a){t[s.group].setResource(a,s.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:i,gl:n}=e,s=ow(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new ee(aw({gpuProgram:a,glProgram:o},s))}}const lw={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},_o=0,yo=1,bo=2,vo=3,xo=4,To=5,So=class O1{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<_o)}set blend(t){!!(this.data&1<<_o)!==t&&(this.data^=1<<_o)}get offsets(){return!!(this.data&1<<yo)}set offsets(t){!!(this.data&1<<yo)!==t&&(this.data^=1<<yo)}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<<bo)}set culling(t){!!(this.data&1<<bo)!==t&&(this.data^=1<<bo)}get depthTest(){return!!(this.data&1<<vo)}set depthTest(t){!!(this.data&1<<vo)!==t&&(this.data^=1<<vo)}get depthMask(){return!!(this.data&1<<To)}set depthMask(t){!!(this.data&1<<To)!==t&&(this.data^=1<<To)}get clockwiseFrontFace(){return!!(this.data&1<<xo)}set clockwiseFrontFace(t){!!(this.data&1<<xo)!==t&&(this.data^=1<<xo)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=lw[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new O1;return t.depthTest=!1,t.blend=!0,t}};So.default2d=So.for2d();let Vt=So;var uw=Object.defineProperty,Gn=Object.getOwnPropertySymbols,of=Object.prototype.hasOwnProperty,lf=Object.prototype.propertyIsEnumerable,uf=(r,t,e)=>t in r?uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wo=(r,t)=>{for(var e in t||(t={}))of.call(t,e)&&uf(r,e,t[e]);if(Gn)for(var e of Gn(t))lf.call(t,e)&&uf(r,e,t[e]);return r},cw=(r,t)=>{var e={};for(var i in r)of.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Gn)for(var i of Gn(r))t.indexOf(i)<0&&lf.call(r,i)&&(e[i]=r[i]);return e};const cf=class Sh extends ee{constructor(t){t=wo(wo({},Sh.defaultOptions),t),super(t),this.enabled=!0,this._state=Vt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,n){t.applyFilter(this,e,i,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:n}=e,s=cw(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new Sh(wo({gpuProgram:a,glProgram:o},s))}};cf.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ee=cf;var bi=`in vec2 aPosition;
39 out vec2 vTextureCoord;
40
41 uniform vec4 uInputSize;
42 uniform vec4 uOutputFrame;
43 uniform vec4 uOutputTexture;
44
45 vec4 filterVertexPosition( void )
46 {
47 vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
48
49 position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
50 position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
51
52 return vec4(position, 0.0, 1.0);
53 }
54
55 vec2 filterTextureCoord( void )
56 {
57 return aPosition * (uOutputFrame.zw * uInputSize.zw);
58 }
59
60 void main(void)
61 {
62 gl_Position = filterVertexPosition();
63 vTextureCoord = filterTextureCoord();
64 }
65 `,hf=`in vec2 vTextureCoord;
66 out vec4 finalColor;
67 uniform sampler2D uTexture;
68 void main() {
69 finalColor = texture(uTexture, vTextureCoord);
70 }
71 `,Po=`struct GlobalFilterUniforms {
72 uInputSize: vec4<f32>,
73 uInputPixel: vec4<f32>,
74 uInputClamp: vec4<f32>,
75 uOutputFrame: vec4<f32>,
76 uGlobalFrame: vec4<f32>,
77 uOutputTexture: vec4<f32>,
78 };
79
80 @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
81 @group(0) @binding(1) var uTexture: texture_2d<f32>;
82 @group(0) @binding(2) var uSampler: sampler;
83
84 struct VSOutput {
85 @builtin(position) position: vec4<f32>,
86 @location(0) uv: vec2<f32>
87 };
88
89 fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
90 {
91 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
92
93 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
94 position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
95
96 return vec4(position, 0.0, 1.0);
97 }
98
99 fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
100 {
101 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
102 }
103
104 @vertex
105 fn mainVertex(
106 @location(0) aPosition: vec2<f32>,
107 ) -> VSOutput {
108 return VSOutput(
109 filterVertexPosition(aPosition),
110 filterTextureCoord(aPosition)
111 );
112 }
113
114 @fragment
115 fn mainFragment(
116 @location(0) uv: vec2<f32>,
117 ) -> @location(0) vec4<f32> {
118 return textureSample(uTexture, uSampler, uv);
119 }
120 `;class df extends Ee{constructor(){const t=Xt.from({vertex:{source:Po,entryPoint:"mainVertex"},fragment:{source:Po,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Wt.from({vertex:bi,fragment:hf,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var at=(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))(at||{});class Yt extends Nt{constructor(t){let{data:e,size:i}=t;const{usage:n,label:s,shrinkToFit:a}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ht("buffer"),this._resourceType="buffer",this._resourceId=ht("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 o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:s},this.shrinkToFit=a!=null?a:!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&at.STATIC)}set static(t){t?this.descriptor.usage|=at.STATIC:this.descriptor.usage&=~at.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 n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLength<n.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=ht("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)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Eo(r,t){if(!(r instanceof Yt)){let e=t?at.INDEX:at.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=at.INDEX|at.COPY_DST):(r=new Float32Array(r),e=at.VERTEX|at.COPY_DST)),r=new Yt({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function pf(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 n=i.buffer.data;let s=1/0,a=1/0,o=-1/0,l=-1/0;const u=n.BYTES_PER_ELEMENT,c=(i.offset||0)/u,h=(i.stride||8)/u;for(let p=c;p<n.length;p+=h){const f=n[p],m=n[p+1];f>o&&(o=f),m>l&&(l=m),f<s&&(s=f),m<a&&(a=m)}return e.minX=s,e.minY=a,e.maxX=o,e.maxY=l,e}function hw(r){return(r instanceof Yt||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=Eo(r.buffer,!1),r}class nr extends Nt{constructor(t={}){var e;super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ht("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Mt,this._boundsDirty=!0;const{attributes:i,indexBuffer:n,topology:s}=t;if(this.buffers=[],this.attributes={},i)for(const a in i)this.addAttribute(a,i[a]);this.instanceCount=(e=t.instanceCount)!=null?e:1,n&&this.addIndex(n),this.topology=s||"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=hw(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=Eo(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,pf(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const dw=new nr({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});let pw=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Mt,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}};class Ao{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new At({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Pe({}),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,n=this._pushFilterData();n.skip=!1,n.filters=i,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const s=e.renderTarget.renderTarget.colorTexture.source,a=s.resolution,o=s.antialias;if(i.every(f=>!f.enabled)){n.skip=!0;return}const l=n.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,o,a,1),n.skip)return;const u=this._getPreviousFilterData(),c=this._findFilterResolution(a);let h=0,p=0;u&&(h=u.bounds.minX,p=u.bounds.minY),this._calculateGlobalFrame(n,h,p,c,s.width,s.height),this._setupFilterTextures(n,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,s=n.resolution,a=n.antialias;if(e.every(c=>!c.enabled))return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,a,s,0),i.skip)return t;const l=s;this._calculateGlobalFrame(i,0,0,l,n.width,n.height),i.outputRenderSurface=vt.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=D.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const u=i.outputRenderSurface;return u.source.alphaMode="premultiplied-alpha",u}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&vt.returnTexture(e.backTexture),vt.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,s=vt.getOptimalTexture(e.width,e.height,n,!1);let a=e.minX,o=e.minY;i&&(a-=i.minX,o-=i.minY),a=Math.floor(a*n),o=Math.floor(o*n);const l=Math.ceil(e.width*n),u=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,s,{x:a,y:o},{width:l,height:u},{x:0,y:0}),s}applyFilter(t,e,i,n){const s=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===i,l=s.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let c=0,h=0;if(o){const f=this._findPreviousFilterOffset();c=f.x,h=f.y}this._updateFilterUniforms(e,i,a,c,h,u,o,n);const p=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,e,s)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,n=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),s=e.worldTransform.copyTo(U.shared),a=e.renderGroup||e.parentRenderGroup;return a&&a.cacheToLocalTransform&&s.prepend(a.cacheToLocalTransform),s.invert(),n.prepend(s),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new df),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const n=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(n,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:dw,shader:t,state:t._state,topology:"triangle-list"}),i.type===It.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=D.EMPTY,t.inputTexture=vt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const s=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(s,e,n==null?void 0:n.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,n,s,a){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=s*n,o.height=a*n}_updateFilterUniforms(t,e,i,n,s,a,o,l){const u=this._filterGlobalUniforms.uniforms,c=u.uOutputFrame,h=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,g=u.uOutputTexture;o?(c[0]=i.bounds.minX-n,c[1]=i.bounds.minY-s):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],p[0]=t.source.pixelWidth,p[1]=t.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=t.frame.width*h[2]-.5*p[2],f[3]=t.frame.height*h[3]-.5*p[3];const _=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=n*a,m[1]=s*a,m[2]=_.source.width*a,m[3]=_.source.height*a,e instanceof D&&(e.source.resource=null);const y=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof D?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=y.width,g[1]=y.height),g[2]=y.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const n=this._filterStack[i];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?lo(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,n=t.bounds,s=t.filters,a=t.firstEnabledIndex,o=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),a===o)s[a].apply(this,i,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=vt.getOptimalTexture(n.width,n.height,l.source._resolution,!1);let c=u;for(let h=a;h<o;h++){const p=s[h];if(!p.enabled)continue;p.apply(this,l,c,!0);const f=l;l=c,c=f}s[o].apply(this,l,t.outputRenderSurface,e),vt.returnTexture(u)}}_calculateFilterBounds(t,e,i,n,s){var a,o;const l=this.renderer,u=t.bounds,c=t.filters;let h=1/0,p=0,f=!0,m=!1,g=!1,_=!0,y=-1,b=-1;for(let x=0;x<c.length;x++){const v=c[x];if(v.enabled){if(y===-1&&(y=x),b=x,h=Math.min(h,v.resolution==="inherit"?n:v.resolution),p+=v.padding,v.antialias==="off"?f=!1:v.antialias==="inherit"&&f&&(f=i),v.clipToViewport||(_=!1),!(v.compatibleRenderers&l.type)){g=!1;break}if(v.blendRequired&&!((o=(a=l.backBuffer)==null?void 0:a.useBackBuffer)==null||o)){g=!1;break}g=!0,m||(m=v.blendRequired)}}if(!g){t.skip=!0;return}if(_&&u.fitBounds(0,e.width/n,0,e.height/n),u.scale(h).ceil().scale(1/h).pad((p|0)*s),!u.isPositive){t.skip=!0;return}t.antialias=f,t.resolution=h,t.blendRequired=m,t.firstEnabledIndex=y,t.lastEnabledIndex=b}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new pw),this._filterStackIndex++,t}}Ao.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"},X.add(Ao,co),X.add(ho);var fw={__proto__:null};const Co=[];X.handleByNamedList(S.Environment,Co);async function Mo(r){if(!r)for(let t=0;t<Co.length;t++){const e=Co[t];if(e.value.test()){await e.value.load();return}}}async function mw(r){return Mo(!r)}let vi;function Ro(){if(typeof vi=="boolean")return vi;try{vi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(r){vi=!1}return vi}function ff(r,t,e=2){const i=t&&t.length,n=i?t[0]*e:r.length;let s=mf(r,0,n,e,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,u;if(i&&(s=vw(r,t,s,e)),r.length>80*e){o=r[0],l=r[1];let c=o,h=l;for(let p=e;p<n;p+=e){const f=r[p],m=r[p+1];f<o&&(o=f),m<l&&(l=m),f>c&&(c=f),m>h&&(h=m)}u=Math.max(c-o,h-l),u=u!==0?32767/u:0}return xi(s,a,e,o,l,u,0),a}function mf(r,t,e,i,n){let s;if(n===Io(r,t,e,i)>0)for(let a=t;a<e;a+=i)s=bf(a/i|0,r[a],r[a+1],s);else for(let a=e-i;a>=t;a-=i)s=bf(a/i|0,r[a],r[a+1],s);return s&&Cr(s,s.next)&&(wi(s),s=s.next),s}function sr(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(Cr(e,e.next)||xt(e.prev,e,e.next)===0)){if(wi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function xi(r,t,e,i,n,s,a){if(!r)return;!a&&s&&Pw(r,i,n,s);let o=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(s?_w(r,i,n,s):gw(r)){t.push(l.i,r.i,u.i),wi(r),r=u.next,o=u.next;continue}if(r=u,r===o){a?a===1?(r=yw(sr(r),t),xi(r,t,e,i,n,s,2)):a===2&&bw(r,t,e,i,n,s):xi(sr(r),t,e,i,n,s,1);break}}}function gw(r){const t=r.prev,e=r,i=r.next;if(xt(t,e,i)>=0)return!1;const n=t.x,s=e.x,a=i.x,o=t.y,l=e.y,u=i.y,c=Math.min(n,s,a),h=Math.min(o,l,u),p=Math.max(n,s,a),f=Math.max(o,l,u);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&Ti(n,o,s,l,a,u,m.x,m.y)&&xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function _w(r,t,e,i){const n=r.prev,s=r,a=r.next;if(xt(n,s,a)>=0)return!1;const o=n.x,l=s.x,u=a.x,c=n.y,h=s.y,p=a.y,f=Math.min(o,l,u),m=Math.min(c,h,p),g=Math.max(o,l,u),_=Math.max(c,h,p),y=Oo(f,m,t,e,i),b=Oo(g,_,t,e,i);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=y&&v&&v.z<=b;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=b;){if(v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function yw(r,t){let e=r;do{const i=e.prev,n=e.next.next;!Cr(i,n)&&_f(i,e,e.next,n)&&Si(i,n)&&Si(n,i)&&(t.push(i.i,e.i,n.i),wi(e),wi(e.next),e=r=n),e=e.next}while(e!==r);return sr(e)}function bw(r,t,e,i,n,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Cw(a,o)){let l=yf(a,o);a=sr(a,a.next),l=sr(l,l.next),xi(a,t,e,i,n,s,0),xi(l,t,e,i,n,s,0);return}o=o.next}a=a.next}while(a!==r)}function vw(r,t,e,i){const n=[];for(let s=0,a=t.length;s<a;s++){const o=t[s]*i,l=s<a-1?t[s+1]*i:r.length,u=mf(r,o,l,i,!1);u===u.next&&(u.steiner=!0),n.push(Aw(u))}n.sort(xw);for(let s=0;s<n.length;s++)e=Tw(n[s],e);return e}function xw(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),n=(t.next.y-t.y)/(t.next.x-t.x);e=i-n}return e}function Tw(r,t){const e=Sw(r,t);if(!e)return t;const i=yf(e,r);return sr(i,i.next),sr(e,e.next)}function Sw(r,t){let e=t;const i=r.x,n=r.y;let s=-1/0,a;if(Cr(r,e))return e;do{if(Cr(r,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const h=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=i&&h>s&&(s=h,a=e.x<e.next.x?e:e.next,h===i))return a}e=e.next}while(e!==t);if(!a)return null;const o=a,l=a.x,u=a.y;let c=1/0;e=a;do{if(i>=e.x&&e.x>=l&&i!==e.x&&gf(n<u?i:s,n,l,u,n<u?s:i,n,e.x,e.y)){const h=Math.abs(n-e.y)/(i-e.x);Si(e,r)&&(h<c||h===c&&(e.x>a.x||e.x===a.x&&ww(a,e)))&&(a=e,c=h)}e=e.next}while(e!==o);return a}function ww(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function Pw(r,t,e,i){let n=r;do n.z===0&&(n.z=Oo(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,Ew(n)}function Ew(r){let t,e=1;do{let i=r,n;r=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let u=0;u<e&&(o++,a=a.nextZ,!!a);u++);let l=e;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;i=a}s.nextZ=null,e*=2}while(t>1);return r}function Oo(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|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 Aw(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 gf(r,t,e,i,n,s,a,o){return(n-a)*(t-o)>=(r-a)*(s-o)&&(r-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(n-a)*(i-o)}function Ti(r,t,e,i,n,s,a,o){return!(r===a&&t===o)&&gf(r,t,e,i,n,s,a,o)}function Cw(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Mw(r,t)&&(Si(r,t)&&Si(t,r)&&Rw(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Cr(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Cr(r,t){return r.x===t.x&&r.y===t.y}function _f(r,t,e,i){const n=Bn(xt(r,t,e)),s=Bn(xt(r,t,i)),a=Bn(xt(e,i,r)),o=Bn(xt(e,i,t));return!!(n!==s&&a!==o||n===0&&In(r,e,t)||s===0&&In(r,i,t)||a===0&&In(e,r,i)||o===0&&In(e,t,i))}function In(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 Bn(r){return r>0?1:r<0?-1:0}function Mw(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&&_f(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Si(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function Rw(r,t){let e=r,i=!1;const n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function yf(r,t){const e=Go(r.i,r.x,r.y),i=Go(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function bf(r,t,e,i){const n=Go(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function wi(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 Go(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function kB(r,t,e,i){const n=t&&t.length,s=n?t[0]*e:r.length;let a=Math.abs(Io(r,0,s,e));if(n)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;a-=Math.abs(Io(r,c,h,e))}let o=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;o+=Math.abs((r[u]-r[h])*(r[c+1]-r[u+1])-(r[u]-r[c])*(r[h+1]-r[u+1]))}return a===0&&o===0?0:Math.abs((o-a)/a)}function Io(r,t,e,i){let n=0;for(let s=t,a=e-i;s<e;s+=i)n+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return n}function LB(r){const t=[],e=[],i=r[0][0].length;let n=0,s=0;for(const a of r){for(const o of a)for(let l=0;l<i;l++)t.push(o[l]);s&&(n+=s,e.push(n)),s=a.length}return{vertices:t,holes:e,dimensions:i}}const vf=ff.default||ff;var Kt=(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))(Kt||{});class Bo{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,s,a,o,l){const{name:u,items:c}=this;for(let h=0,p=c.length;h<p;h++)c[h][u](t,e,i,n,s,a,o,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 Ow=Object.defineProperty,xf=Object.getOwnPropertySymbols,Gw=Object.prototype.hasOwnProperty,Iw=Object.prototype.propertyIsEnumerable,Tf=(r,t,e)=>t in r?Ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fn=(r,t)=>{for(var e in t||(t={}))Gw.call(t,e)&&Tf(r,e,t[e]);if(xf)for(var e of xf(t))Iw.call(t,e)&&Tf(r,e,t[e]);return r};const Bw=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Sf=class G1 extends Nt{constructor(t){var e;super(),this.tick=0,this.uid=ht("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=[...Bw,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Mo(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const n=this._systemsHash[i].constructor.defaultOptions;t=Fn(Fn({},n),t)}t=Fn(Fn({},G1.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,n;this.tick++;let s=t;if(s instanceof dt&&(s={container:s},e&&(s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,(i=s.clearColor)!=null||(s.clearColor=this.background.colorRgba),(n=s.clear)!=null||(s.clear=this.background.clearBeforeRender)),s.clearColor){const a=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=a?s.clearColor:tt.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),s.container.visible&&(s.container.enableRenderGroup(),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s))}resize(t,e,i){const n=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!==n&&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=Kt.ALL);const{clear:n,clearColor:s,target:a,mipLevel:o,layer:l}=t;tt.shared.setValue(s!=null?s:this.background.colorRgba),i.renderTarget.clear(a,n,tt.shared.toArray(),o!=null?o:0,l!=null?l:0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Bo(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 n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,s)=>(n[s.name]=s.value,n),{});t.forEach(n=>{const s=n.value,a=n.name,o=i[a];this.renderPipes[a]=new s(this,o?new o:null),this.runners.destroy.add(this.renderPipes[a])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&qe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ro())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()}};Sf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Mr=Sf,Fo;function Pi(r){return Fo!==void 0||(Fo=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Mr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!H.get().getWebGLRenderingContext())return!1;let i=H.get().createCanvas().getContext("webgl",e);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch(i){return!1}})()),Fo}let Do;async function Ei(r={}){return Do!==void 0||(Do=await(async()=>{const t=H.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Do}var Fw=Object.defineProperty,wf=Object.getOwnPropertySymbols,Dw=Object.prototype.hasOwnProperty,Uw=Object.prototype.propertyIsEnumerable,Pf=(r,t,e)=>t in r?Fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rr=(r,t)=>{for(var e in t||(t={}))Dw.call(t,e)&&Pf(r,e,t[e]);if(wf)for(var e of wf(t))Uw.call(t,e)&&Pf(r,e,t[e]);return r};const Ef=["webgl","webgpu","canvas"];async function Af(r){var t;let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Ef.forEach(a=>{a!==r.preference&&e.push(a)})):e=Ef.slice();let i,n={};for(let a=0;a<e.length;a++){const o=e[a];if(o==="webgpu"&&await Ei()){const{WebGPURenderer:l}=await Promise.resolve().then(function(){return rG});i=l,n=Rr(Rr({},r),r.webgpu);break}else if(o==="webgl"&&Pi((t=r.failIfMajorPerformanceCaveat)!=null?t:Mr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Promise.resolve().then(function(){return O3});i=l,n=Rr(Rr({},r),r.webgl);break}else if(o==="canvas"){const{CanvasRenderer:l}=await Promise.resolve().then(function(){return IO});i=l,n=Rr(Rr({},r),r.canvasOptions);break}}if(delete n.webgpu,delete n.webgl,delete n.canvasOptions,!i)throw new Error("No available renderer for the current environment");const s=new i;return await s.init(n),s}const $w=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,Ai="8.18.1";class Uo{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Ai)}static destroy(){}}Uo.extension=S.Application;class $o{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Ai)}destroy(){this._renderer=null}}$o.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"initHook",priority:-10};class ko{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:s}=this._resizeTo;e=n,i=s}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}}ko.extension=S.Application;class Lo{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ot.shared:new Ot,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Lo.extension=S.Application,X.add(ko),X.add(Lo);var kw=Object.defineProperty,Cf=Object.getOwnPropertySymbols,Lw=Object.prototype.hasOwnProperty,Nw=Object.prototype.propertyIsEnumerable,Mf=(r,t,e)=>t in r?kw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xw=(r,t)=>{for(var e in t||(t={}))Lw.call(t,e)&&Mf(r,e,t[e]);if(Cf)for(var e of Cf(t))Nw.call(t,e)&&Mf(r,e,t[e]);return r};const Rf=class wh{constructor(...t){this.stage=new dt}async init(t){t=Xw({},t),this.stage||(this.stage=new dt),this.renderer=await Af(t),wh._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const i=wh._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Rf._plugins=[];let Of=Rf;X.handleByList(S.Application,Of._plugins),X.add(Uo);const Dn={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const n=r.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in n){const g=n[m].match(/^[a-z]+/gm)[0],_=n[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),y={};for(const b in _){const x=_[b].split("="),v=x[0],w=x[1].replace(/"/gm,""),T=parseFloat(w),P=isNaN(T)?w:T;y[v]=P}s[g].push(y)}const a={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[o]=s.info,[l]=s.common,[u]=(t=s.distanceField)!=null?t:[];u&&(a.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),a.fontSize=parseInt(o.size,10),a.fontFamily=o.face,a.lineHeight=parseInt(l.lineHeight,10);const c=s.page;for(let m=0;m<c.length;m++)a.pages.push({id:parseInt(c[m].id,10)||0,file:c[m].file});const h={};a.baseLineOffset=a.lineHeight-parseInt(l.base,10);const p=s.char;for(let m=0;m<p.length;m++){const g=p[m],_=parseInt(g.id,10);let y=(i=(e=g.letter)!=null?e:g.char)!=null?i:String.fromCharCode(_);y==="space"&&(y=" "),h[_]=y,a.chars[y]={id:_,page:parseInt(g.page,10)||0,x:parseInt(g.x,10),y:parseInt(g.y,10),width:parseInt(g.width,10),height:parseInt(g.height,10),xOffset:parseInt(g.xoffset,10),yOffset:parseInt(g.yoffset,10),xAdvance:parseInt(g.xadvance,10),kerning:{}}}const f=s.kerning||[];for(let m=0;m<f.length;m++){const g=parseInt(f[m].first,10),_=parseInt(f[m].second,10),y=parseInt(f[m].amount,10);a.chars[h[_]]&&(a.chars[h[_]].kerning[h[g]]=y)}return a}},No={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},n=r.getElementsByTagName("info")[0],s=r.getElementsByTagName("common")[0],a=r.getElementsByTagName("distanceField")[0];a&&(i.distanceField={type:a.getAttribute("fieldType"),range:parseInt(a.getAttribute("distanceRange"),10)});const o=r.getElementsByTagName("page"),l=r.getElementsByTagName("char"),u=r.getElementsByTagName("kerning");i.fontSize=parseInt(n.getAttribute("size"),10),i.fontFamily=n.getAttribute("face"),i.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let h=0;h<o.length;h++)i.pages.push({id:parseInt(o[h].getAttribute("id"),10)||0,file:o[h].getAttribute("file")});const c={};i.baseLineOffset=i.lineHeight-parseInt(s.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]]&&(i.chars[c[f]].kerning[c[p]]=m)}return i}},Xo={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?No.test(H.get().parseXML(r)):!1},parse(r){return No.parse(H.get().parseXML(r))}},jw=[".xml",".fnt"],Gf={extension:{type:S.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},If={extension:{type:S.LoadParser,priority:te.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return jw.includes(zt.extname(r).toLowerCase())},async testParse(r){return Dn.test(r)||Xo.test(r)},async parse(r,t,e){const i=Dn.test(r)?Dn.parse(r):Xo.parse(r),{src:n}=t,{pages:s}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let h=0;h<s.length;++h){const p=s[h].file;let f=zt.join(zt.dirname(n),p);f=bn(f,n),a.push({src:f,data:o})}const[l,{BitmapFont:u}]=await Promise.all([e.load(a),Promise.resolve().then(function(){return zI})]),c=a.map(h=>l[h.src]);return new u({data:i,textures:c},n)},async load(r,t){return await(await H.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Bf{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 Ff={extension:{type:S.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof D),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((n,s)=>{e[i+(s===0?"":s+1)]=n})}),e}};async function jo(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 Df={extension:{type:S.DetectionParser,priority:1},test:async()=>jo("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Uf=["png","jpg","jpeg"],$f={extension:{type:S.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Uf],remove:async r=>r.filter(t=>!Uf.includes(t))},Hw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ci(r){return Hw?!1:document.createElement("video").canPlayType(r)!==""}const kf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Lf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Nf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Xf={extension:{type:S.DetectionParser,priority:0},test:async()=>jo("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var zw=Object.defineProperty,Ww=Object.defineProperties,Vw=Object.getOwnPropertyDescriptors,jf=Object.getOwnPropertySymbols,Yw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Or=(r,t)=>{for(var e in t||(t={}))Yw.call(t,e)&&Hf(r,e,t[e]);if(jf)for(var e of jf(t))Kw.call(t,e)&&Hf(r,e,t[e]);return r},qw=(r,t)=>Ww(r,Vw(t));const zf=class va{constructor(){this.loadOptions=Or({},va.defaultOptions),this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var n,s;let a=null,o=null;if((e.parser||e.loadParser)&&(o=this._parserHash[e.parser||e.loadParser]),!o){for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.load&&(n=u.test)!=null&&n.call(u,t,e,this)){o=u;break}}if(!o)return null}a=await o.load(t,e,this),i.parser=o;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];u.parse&&u.parse&&await((s=u.testParse)==null?void 0:s.call(u,a,e,this))&&(a=await u.parse(a,e,this)||a,i.parser=u)}return a})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?qw(Or(Or({},va.defaultOptions),this.loadOptions),{onProgress:e}):Or(Or(Or({},va.defaultOptions),this.loadOptions),e||{}),{onProgress:n,onError:s,strategy:a,retryCount:o,retryDelay:l}=i;let u=0;const c={},h=fi(t),p=oe(t,g=>({alias:[g],src:g,data:{}})),f=p.reduce((g,_)=>g+(_.progressSize||1),0),m=p.map(async g=>{const _=zt.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(_,g,{onProgress:n,onError:s,strategy:a,retryCount:o,retryDelay:l},c),u+=g.progressSize||1,n&&n(u/f))});return await Promise.all(m),h?c[p[0].src]:c}async unload(t){const e=oe(t,i=>({alias:[i],src:i})).map(async i=>{var n,s;const a=zt.toAbsolute(i.src),o=this.promiseCache[a];if(o){const l=await o.promise;delete this.promiseCache[a],await((s=(n=o.parser)==null?void 0:n.unload)==null?void 0:s.call(n,l,i,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id||t[e.name]||t[e.id],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,n){let s=0;const{onError:a,strategy:o,retryCount:l,retryDelay:u}=i,c=h=>new Promise(p=>setTimeout(p,h));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),n[e.src]=await this.promiseCache[t].promise;return}catch(h){delete this.promiseCache[t],delete n[e.src],s++;const p=o!=="retry"||s>l;if(o==="retry"&&!p){a&&a(h,e),await c(u);continue}if(o==="skip"){a&&a(h,e);return}a&&a(h,e);const f=new Error(`[Loader.load] Failed to load ${t}.
121 ${h}`);throw h instanceof Error&&h.stack&&(f.stack=h.stack),f}}};zf.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let Wf=zf;function ar(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 le(r,t){const e=r.split("?")[0],i=zt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Zw=".json",Qw="application/json",Vf={extension:{type:S.LoadParser,priority:te.Low},name:"loadJson",id:"json",test(r){return ar(r,Qw)||le(r,Zw)},async load(r){return await(await H.get().fetch(r)).json()}},Jw=".txt",tP="text/plain",Yf={name:"loadTxt",id:"text",extension:{type:S.LoadParser,priority:te.Low,name:"loadTxt"},test(r){return ar(r,tP)||le(r,Jw)},async load(r){return await(await H.get().fetch(r)).text()}};var eP=Object.defineProperty,rP=Object.defineProperties,iP=Object.getOwnPropertyDescriptors,Kf=Object.getOwnPropertySymbols,nP=Object.prototype.hasOwnProperty,sP=Object.prototype.propertyIsEnumerable,qf=(r,t,e)=>t in r?eP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aP=(r,t)=>{for(var e in t||(t={}))nP.call(t,e)&&qf(r,e,t[e]);if(Kf)for(var e of Kf(t))sP.call(t,e)&&qf(r,e,t[e]);return r},oP=(r,t)=>rP(r,iP(t));const lP=["normal","bold","100","200","300","400","500","600","700","800","900"],uP=[".ttf",".otf",".woff",".woff2"],cP=["font/ttf","font/otf","font/woff","font/woff2"],hP=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Zf(r){const t=zt.extname(r),e=zt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=e.length>0;for(const s of e)if(!s.match(hP)){i=!1;break}let n=e.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const dP=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function pP(r){return dP.test(r)?r:encodeURI(r)}const Qf={extension:{type:S.LoadParser,priority:te.Low},name:"loadWebFont",id:"web-font",test(r){return ar(r,cP)||le(r,uP)},async load(r,t){var e,i,n,s,a,o;const l=H.get().getFontFaceSet();if(l){const u=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:Zf(r),h=(a=(s=(n=t.data)==null?void 0:n.weights)==null?void 0:s.filter(f=>lP.includes(f)))!=null?a:["normal"],p=(o=t.data)!=null?o:{};for(let f=0;f<h.length;f++){const m=h[f],g=new FontFace(c,`url('${pP(r)}')`,oP(aP({},p),{weight:m}));await g.load(),l.add(g),u.push(g)}return it.has(`${c}-and-url`)?it.get(`${c}-and-url`).entries.push({url:r,faces:u}):it.set(`${c}-and-url`,{entries:[{url:r,faces:u}]}),u.length===1?u[0]:u}return null},unload(r){const t=Array.isArray(r)?r:[r],e=t[0].family,i=it.get(`${e}-and-url`),n=i.entries.find(s=>s.faces.some(a=>t.indexOf(a)!==-1));n.faces=n.faces.filter(s=>t.indexOf(s)===-1),n.faces.length===0&&(i.entries=i.entries.filter(s=>s!==n)),t.forEach(s=>{H.get().getFontFaceSet().delete(s)}),i.entries.length===0&&it.remove(`${e}-and-url`)}};var Ho,Jf;function fP(){if(Jf)return Ho;Jf=1,Ho=e;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(s){var a=[];return s.replace(t,function(o,l,u){var c=l.toLowerCase();for(u=n(u),c=="m"&&u.length>2&&(a.push([l].concat(u.splice(0,2))),c="l",l=l=="m"?"l":"L");;){if(u.length==r[c])return u.unshift(l),a.push(u);if(u.length<r[c])throw new Error("malformed path data");a.push([l].concat(u.splice(0,r[c])))}}),a}var i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function n(s){var a=s.match(i);return a?a.map(Number):[]}return Ho}var mP=fP(),gP=Bh(mP);function tm(r,t){const e=gP(r),i=[];let n=null,s=0,a=0;for(let o=0;o<e.length;o++){const l=e[o],u=l[0],c=l;switch(u){case"M":s=c[1],a=c[2],t.moveTo(s,a);break;case"m":s+=c[1],a+=c[2],t.moveTo(s,a);break;case"H":s=c[1],t.lineTo(s,a);break;case"h":s+=c[1],t.lineTo(s,a);break;case"V":a=c[1],t.lineTo(s,a);break;case"v":a+=c[1],t.lineTo(s,a);break;case"L":s=c[1],a=c[2],t.lineTo(s,a);break;case"l":s+=c[1],a+=c[2],t.lineTo(s,a);break;case"C":s=c[5],a=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],s,a);break;case"c":t.bezierCurveTo(s+c[1],a+c[2],s+c[3],a+c[4],s+c[5],a+c[6]),s+=c[5],a+=c[6];break;case"S":s=c[3],a=c[4],t.bezierCurveToShort(c[1],c[2],s,a);break;case"s":t.bezierCurveToShort(s+c[1],a+c[2],s+c[3],a+c[4]),s+=c[3],a+=c[4];break;case"Q":s=c[3],a=c[4],t.quadraticCurveTo(c[1],c[2],s,a);break;case"q":t.quadraticCurveTo(s+c[1],a+c[2],s+c[3],a+c[4]),s+=c[3],a+=c[4];break;case"T":s=c[1],a=c[2],t.quadraticCurveToShort(s,a);break;case"t":s+=c[1],a+=c[2],t.quadraticCurveToShort(s,a);break;case"A":s=c[6],a=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],s,a);break;case"a":s+=c[6],a+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],s,a);break;case"Z":case"z":t.closePath(),i.length>0&&(n=i.pop(),n?(s=n.startX,a=n.startY):(s=0,a=0)),n=null;break;default:}u!=="Z"&&u!=="z"&&n===null&&(n={startX:s,startY:a},i.push(n))}return t}const em={};function Un(r,t,e){let i=2166136261;for(let n=0;n<t;n++)i^=r[n].uid,i=Math.imul(i,16777619),i>>>=0;return em[i]||_P(r,t,i,e)}function _P(r,t,e,i){const n={};let s=0;for(let o=0;o<i;o++){const l=o<t?r[o]:D.EMPTY.source;n[s++]=l.source,n[s++]=l.style}const a=new Pe(n);return em[e]=a,a}class or{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const rm=new Set,zo="8.0.0",yP="8.3.4",Gr={quiet:!1,noColor:!1},Mi=((r,t,e=3)=>{if(Gr.quiet||rm.has(t))return;let i=new Error().stack;const n=`${t}
122 Deprecated since v${r}`,s=typeof console.groupCollapsed=="function"&&!Gr.noColor;typeof i=="undefined"?console.warn("PixiJS Deprecation Warning: ",n):(i=i.split(`
123 `).splice(e).join(`
124 `),s?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(i))),rm.add(t)});Object.defineProperties(Mi,{quiet:{get:()=>Gr.quiet,set:r=>{Gr.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Gr.noColor,set:r=>{Gr.noColor=r},enumerable:!0,configurable:!1}});function $n(r,t,e,i){if(e!=null||(e=0),i!=null||(i=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(i&7)){const n=i/8;new Float64Array(t,0,n).set(new Float64Array(r,e,n))}else if(!(e&3)&&!(i&3)){const n=i/4;new Float32Array(t,0,n).set(new Float32Array(r,e,n))}else new Uint8Array(t).set(new Uint8Array(r,e,i))}const im={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var wt=(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))(wt||{});function Ir(r,t){return t.alphaMode==="no-premultiply-alpha"&&im[r]||r}const bP=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
125 `);function vP(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
126 else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Wo(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=bP.replace(/%forloop%/gi,vP(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 Br=null;function nm(){var r;if(Br)return Br;const t=fo();return Br=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Br=Wo(Br,t),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),Br}class sm{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 xP=Object.defineProperty,am=Object.getOwnPropertySymbols,TP=Object.prototype.hasOwnProperty,SP=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?xP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lm=(r,t)=>{for(var e in t||(t={}))TP.call(t,e)&&om(r,e,t[e]);if(am)for(var e of am(t))SP.call(t,e)&&om(r,e,t[e]);return r};class um{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new sm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Ri=[];let kn=0;qe.register({clear:()=>{if(Ri.length>0)for(const r of Ri)r&&r.destroy();Ri.length=0,kn=0}});function cm(){return kn>0?Ri[--kn]:new um}function hm(r){r.elements=null,Ri[kn++]=r}let Oi=0;const dm=class I1{constructor(t){this.uid=ht("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=lm(lm({},I1.defaultOptions),t),t.maxTextures||(Mi("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=nm());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new or(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)hm(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const 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=cm(),n=i.textures;n.clear();const s=e[this.elementStart];let a=Ir(s.blendMode,s.texture._source),o=s.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",m=[];const g=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const y=e[_];e[_]=null;const b=y.texture._source,x=Ir(y.blendMode,b),v=a!==x||o!==y.topology;if(b._batchTick===Oi&&!v){y._textureId=b._textureBindLocation,h+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,l,u,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,l,u,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize)),y._batch=i,m.push(y);continue}b._batchTick=Oi,(n.count>=g||v)&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),f="renderBatch",p=h,a=x,o=y.topology,i=cm(),n=i.textures,n.clear(),m=[],++Oi),y._textureId=b._textureBindLocation=n.count,n.ids[b.uid]=n.count,n.textures[n.count++]=b,y._batch=i,m.push(y),h+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,l,u,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,l,u,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),p=h,++Oi),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=h}_finishBatch(t,e,i,n,s,a,o,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=n,t.blendMode=s,t.topology=a,t.start=e,t.size=i,t.elements=u,++Oi,this.batches[this.batchIndex++]=t,o.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 or(e);$n(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 n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let s=0;s<e.length;s++)n[s]=e[s];else $n(e.buffer,n.buffer);this.indexBuffer=n}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,n){const s=t.indices,a=t.indexSize,o=t.indexOffset,l=t.attributeOffset;for(let u=0;u<a;u++)e[i++]=n+s[u+o]-l}destroy(t={}){var e;if(this.batches!==null){for(let i=0;i<this.batchIndex;i++)hm(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};dm.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let pm=dm;const wP=new Float32Array(1),PP=new Uint32Array(1);class fm extends nr{constructor(){const t=new Yt({data:wP,label:"attribute-batch-buffer",usage:at.VERTEX|at.COPY_DST,shrinkToFit:!1}),e=new Yt({data:PP,label:"index-batch-buffer",usage:at.INDEX|at.COPY_DST,shrinkToFit:!1}),i=24;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})}}function Vo(r,t,e){if(r)for(const i in r){const n=i.toLocaleLowerCase(),s=t[n];if(s){let a=r[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&s.push(`//----${e}----//`),s.push(a)}}}const EP=/\{\{(.*?)\}\}/g;function Yo(r){var t,e;const i={};return((e=(t=r.match(EP))==null?void 0:t.map(n=>n.replace(/[{()}]/g,"")))!=null?e:[]).forEach(n=>{i[n]=[]}),i}function mm(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function Ko(r,t,e=!1){const i=[];mm(t,i),r.forEach(o=>{o.header&&mm(o.header,i)});const n=i;e&&n.sort();const s=n.map((o,l)=>` @location(${l}) ${o},`).join(`
127 `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
128 ${s}
129 `),a}function gm(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function AP(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function CP(r){const t=/@.*?\s+/g;return r.replace(t,"")}function _m(r,t){const e=[];gm(t,e),r.forEach(l=>{l.header&&gm(l.header,e)});let i=0;const n=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
130 `),s=e.sort().map(l=>` var ${CP(l)};`).join(`
131 `),a=`return VSOutput(
132 ${e.sort().map(l=>` ${AP(l)}`).join(`,
133 `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
134 ${n}
135 `),o=o.replace("{{start}}",`
136 ${s}
137 `),o=o.replace("{{return}}",`
138 ${a}
139 `),o}function qo(r,t){let e=r;for(const i in t){const n=t[i];n.join(`
140 `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
141 ${n.join(`
142 `)}
143 //----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const lr=Object.create(null),Zo=new Map;let MP=0;function ym({template:r,bits:t}){const e=vm(r,t);if(lr[e])return lr[e];const{vertex:i,fragment:n}=RP(r,t);return lr[e]=xm(i,n,t),lr[e]}function bm({template:r,bits:t}){const e=vm(r,t);return lr[e]||(lr[e]=xm(r.vertex,r.fragment,t)),lr[e]}function RP(r,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let n=Ko(e,r.vertex,!0);n=_m(e,n);const s=Ko(i,r.fragment,!0);return{vertex:n,fragment:s}}function vm(r,t){return t.map(e=>(Zo.has(e)||Zo.set(e,MP++),Zo.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function xm(r,t,e){const i=Yo(r),n=Yo(t);return e.forEach(s=>{Vo(s.vertex,i,s.name),Vo(s.fragment,n,s.name)}),{vertex:qo(r,i),fragment:qo(t,n)}}const Tm=`
144 @in aPosition: vec2<f32>;
145 @in aUV: vec2<f32>;
146
147 @out @builtin(position) vPosition: vec4<f32>;
148 @out vUV : vec2<f32>;
149 @out vColor : vec4<f32>;
150
151 {{header}}
152
153 struct VSOutput {
154 {{struct}}
155 };
156
157 @vertex
158 fn main( {{in}} ) -> VSOutput {
159
160 var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
161 var modelMatrix = mat3x3<f32>(
162 1.0, 0.0, 0.0,
163 0.0, 1.0, 0.0,
164 0.0, 0.0, 1.0
165 );
166 var position = aPosition;
167 var uv = aUV;
168
169 {{start}}
170
171 vColor = vec4<f32>(1., 1., 1., 1.);
172
173 {{main}}
174
175 vUV = uv;
176
177 var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
178
179 vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
180
181 vColor *= globalUniforms.uWorldColorAlpha;
182
183 {{end}}
184
185 {{return}}
186 };
187 `,Sm=`
188 @in vUV : vec2<f32>;
189 @in vColor : vec4<f32>;
190
191 {{header}}
192
193 @fragment
194 fn main(
195 {{in}}
196 ) -> @location(0) vec4<f32> {
197
198 {{start}}
199
200 var outColor:vec4<f32>;
201
202 {{main}}
203
204 var finalColor:vec4<f32> = outColor * vColor;
205
206 {{end}}
207
208 return finalColor;
209 };
210 `,wm=`
211 in vec2 aPosition;
212 in vec2 aUV;
213
214 out vec4 vColor;
215 out vec2 vUV;
216
217 {{header}}
218
219 void main(void){
220
221 mat3 worldTransformMatrix = uWorldTransformMatrix;
222 mat3 modelMatrix = mat3(
223 1.0, 0.0, 0.0,
224 0.0, 1.0, 0.0,
225 0.0, 0.0, 1.0
226 );
227 vec2 position = aPosition;
228 vec2 uv = aUV;
229
230 {{start}}
231
232 vColor = vec4(1.);
233
234 {{main}}
235
236 vUV = uv;
237
238 mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
239
240 gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
241
242 vColor *= uWorldColorAlpha;
243
244 {{end}}
245 }
246 `,Pm=`
247
248 in vec4 vColor;
249 in vec2 vUV;
250
251 out vec4 finalColor;
252
253 {{header}}
254
255 void main(void) {
256
257 {{start}}
258
259 vec4 outColor;
260
261 {{main}}
262
263 finalColor = outColor * vColor;
264
265 {{end}}
266 }
267 `,Em={name:"global-uniforms-bit",vertex:{header:`
268 struct GlobalUniforms {
269 uProjectionMatrix:mat3x3<f32>,
270 uWorldTransformMatrix:mat3x3<f32>,
271 uWorldColorAlpha: vec4<f32>,
272 uResolution: vec2<f32>,
273 }
274
275 @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
276 `}},OP={name:"global-uniforms-ubo-bit",vertex:{header:`
277 uniform globalUniforms {
278 mat3 uProjectionMatrix;
279 mat3 uWorldTransformMatrix;
280 vec4 uWorldColorAlpha;
281 vec2 uResolution;
282 };
283 `}},Am={name:"global-uniforms-bit",vertex:{header:`
284 uniform mat3 uProjectionMatrix;
285 uniform mat3 uWorldTransformMatrix;
286 uniform vec4 uWorldColorAlpha;
287 uniform vec2 uResolution;
288 `}};var GP=Object.defineProperty,Cm=Object.getOwnPropertySymbols,IP=Object.prototype.hasOwnProperty,BP=Object.prototype.propertyIsEnumerable,Mm=(r,t,e)=>t in r?GP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FP=(r,t)=>{for(var e in t||(t={}))IP.call(t,e)&&Mm(r,e,t[e]);if(Cm)for(var e of Cm(t))BP.call(t,e)&&Mm(r,e,t[e]);return r};function Fr({bits:r,name:t}){const e=ym({template:{fragment:Sm,vertex:Tm},bits:[Em,...r]});return Xt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Dr({bits:r,name:t}){return new Wt(FP({name:t},bm({template:{vertex:wm,fragment:Pm},bits:[Am,...r]})))}const Ln={name:"color-bit",vertex:{header:`
289 @in aColor: vec4<f32>;
290 `,main:`
291 vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
292 `}},Nn={name:"color-bit",vertex:{header:`
293 in vec4 aColor;
294 `,main:`
295 vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
296 `}},Qo={};function DP(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(`
297 `)}function UP(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(`
298 `)}function Xn(r){return Qo[r]||(Qo[r]={name:"texture-batch-bit",vertex:{header:`
299 @in aTextureIdAndRound: vec2<u32>;
300 @out @interpolate(flat) vTextureId : u32;
301 `,main:`
302 vTextureId = aTextureIdAndRound.y;
303 `,end:`
304 if(aTextureIdAndRound.x == 1)
305 {
306 vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
307 }
308 `},fragment:{header:`
309 @in @interpolate(flat) vTextureId: u32;
310
311 ${DP(r)}
312 `,main:`
313 var uvDx = dpdx(vUV);
314 var uvDy = dpdy(vUV);
315
316 ${UP(r)}
317 `}}),Qo[r]}const Jo={};function $P(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(`
318 `)}function jn(r){return Jo[r]||(Jo[r]={name:"texture-batch-bit",vertex:{header:`
319 in vec2 aTextureIdAndRound;
320 out float vTextureId;
321
322 `,main:`
323 vTextureId = aTextureIdAndRound.y;
324 `,end:`
325 if(aTextureIdAndRound.x == 1.)
326 {
327 gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
328 }
329 `},fragment:{header:`
330 in float vTextureId;
331
332 uniform sampler2D uTextures[${r}];
333
334 `,main:`
335
336 ${$P(r)}
337 `}}),Jo[r]}const Ur={name:"round-pixels-bit",vertex:{header:`
338 fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
339 {
340 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
341 }
342 `}},$r={name:"round-pixels-bit",vertex:{header:`
343 vec2 roundPixels(vec2 position, vec2 targetSize)
344 {
345 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
346 }
347 `}},Rm={};function Hn(r){let t=Rm[r];if(t)return t;const e=new Int32Array(r);for(let i=0;i<r;i++)e[i]=i;return t=Rm[r]=new At({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}class tl extends ee{constructor(t){const e=Dr({name:"batch",bits:[Nn,jn(t),$r]}),i=Fr({name:"batch",bits:[Ln,Xn(t),Ur]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Hn(t)}}),this.maxTextures=t}}let Gi=null;const Om=class B1 extends pm{constructor(t){super(t),this.geometry=new fm,this.name=B1.extension.name,this.vertexSize=6,Gi!=null||(Gi=new tl(t.maxTextures)),this.shader=Gi}packAttributes(t,e,i,n,s){const a=s<<16|t.roundPixels&65535,o=t.transform,l=o.a,u=o.b,c=o.c,h=o.d,p=o.tx,f=o.ty,{positions:m,uvs:g}=t,_=t.color,y=t.attributeOffset,b=y+t.attributeSize;for(let x=y;x<b;x++){const v=x*2,w=m[v],T=m[v+1];e[n++]=l*w+c*T+p,e[n++]=h*T+u*w+f,e[n++]=g[v],e[n++]=g[v+1],i[n++]=_,i[n++]=a}}packQuadAttributes(t,e,i,n,s){const a=t.texture,o=t.transform,l=o.a,u=o.b,c=o.c,h=o.d,p=o.tx,f=o.ty,m=t.bounds,g=m.maxX,_=m.minX,y=m.maxY,b=m.minY,x=a.uvs,v=t.color,w=s<<16|t.roundPixels&65535;e[n+0]=l*_+c*b+p,e[n+1]=h*b+u*_+f,e[n+2]=x.x0,e[n+3]=x.y0,i[n+4]=v,i[n+5]=w,e[n+6]=l*g+c*b+p,e[n+7]=h*b+u*g+f,e[n+8]=x.x1,e[n+9]=x.y1,i[n+10]=v,i[n+11]=w,e[n+12]=l*g+c*y+p,e[n+13]=h*y+u*g+f,e[n+14]=x.x2,e[n+15]=x.y2,i[n+16]=v,i[n+17]=w,e[n+18]=l*_+c*y+p,e[n+19]=h*y+u*_+f,e[n+20]=x.x3,e[n+21]=x.y3,i[n+22]=v,i[n+23]=w}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Gi=new tl(t),this.shader=Gi)}destroy(){this.shader=null,super.destroy()}};Om.extension={type:[S.Batcher],name:"default"};let zn=Om;class Ut{constructor(t){this.items=Object.create(null);const{renderer:e,type:i,onUnload:n,priority:s,name:a}=t;this._renderer=e,e.gc.addResourceHash(this,"items",i,s!=null?s:0),this._onUnload=n,this.name=a}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){var i;if(!this.items[t.uid])return;const n=t._gpuData[this._renderer.uid];n&&((i=this._onUnload)==null||i.call(this,t,...e),n.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function el(r,t,e,i,n,s,a,o=null){let l=0;e*=t,n*=s;const u=o.a,c=o.b,h=o.c,p=o.d,f=o.tx,m=o.ty;for(;l<a;){const g=r[e],_=r[e+1];i[n]=u*g+h*_+f,i[n+1]=c*g+p*_+m,n+=s,e+=t,l++}}function rl(r,t,e,i){let n=0;for(t*=e;n<i;)r[t]=0,r[t+1]=0,t+=e,n++}function Wn(r,t,e,i,n){const s=t.a,a=t.b,o=t.c,l=t.d,u=t.tx,c=t.ty;e||(e=0),i||(i=2),n||(n=r.length/i-e);let h=e*i;for(let p=0;p<n;p++){const f=r[h],m=r[h+1];r[h]=s*f+o*m+u,r[h+1]=a*f+l*m+c,h+=i}}const kP=new U;class Vn{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?Oe(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)||kP}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}var LP=Object.defineProperty,NP=Object.defineProperties,XP=Object.getOwnPropertyDescriptors,Gm=Object.getOwnPropertySymbols,jP=Object.prototype.hasOwnProperty,HP=Object.prototype.propertyIsEnumerable,Im=(r,t,e)=>t in r?LP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yn=(r,t)=>{for(var e in t||(t={}))jP.call(t,e)&&Im(r,e,t[e]);if(Gm)for(var e of Gm(t))HP.call(t,e)&&Im(r,e,t[e]);return r},Kn=(r,t)=>NP(r,XP(t));const kr={extension:{type:S.ShapeBuilder,name:"circle"},build(r,t){let e,i,n,s,a,o;if(r.type==="circle"){const v=r;if(a=o=v.radius,a<=0)return!1;e=v.x,i=v.y,n=s=0}else if(r.type==="ellipse"){const v=r;if(a=v.halfWidth,o=v.halfHeight,a<=0||o<=0)return!1;e=v.x,i=v.y,n=s=0}else{const v=r,w=v.width/2,T=v.height/2;e=v.x+w,i=v.y+T,a=o=Math.max(0,Math.min(v.radius,Math.min(w,T))),n=w-a,s=T-o}if(n<0||s<0)return!1;const l=Math.ceil(2.3*Math.sqrt(a+o)),u=l*8+(n?4:0)+(s?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+n,t[1]=t[3]=i+s,t[2]=t[4]=e-n,t[5]=t[7]=i-s,!0;let c=0,h=l*4+(n?2:0)+2,p=h,f=u,m=n+a,g=s,_=e+m,y=e-m,b=i+g;if(t[c++]=_,t[c++]=b,t[--h]=b,t[--h]=y,s){const v=i-g;t[p++]=y,t[p++]=v,t[--f]=v,t[--f]=_}for(let v=1;v<l;v++){const w=Math.PI/2*(v/l),T=n+Math.cos(w)*a,P=s+Math.sin(w)*o,E=e+T,M=e-T,C=i+P,A=i-P;t[c++]=E,t[c++]=C,t[--h]=C,t[--h]=M,t[p++]=M,t[p++]=A,t[--f]=A,t[--f]=E}m=n,g=s+o,_=e+m,y=e-m,b=i+g;const x=i-g;return t[c++]=_,t[c++]=b,t[--f]=x,t[--f]=_,n&&(t[c++]=y,t[c++]=b,t[--f]=x,t[--f]=y),!0},triangulate(r,t,e,i,n,s){if(r.length===0)return;let a=0,o=0;for(let c=0;c<r.length;c+=2)a+=r[c],o+=r[c+1];a/=r.length/2,o/=r.length/2;let l=i;t[l*e]=a,t[l*e+1]=o;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&&(n[s++]=l,n[s++]=u,n[s++]=l-1),l++;n[s++]=u+1,n[s++]=u,n[s++]=l-1}},Bm=Kn(Yn({},kr),{extension:Kn(Yn({},kr.extension),{name:"ellipse"})}),Fm=Kn(Yn({},kr),{extension:Kn(Yn({},kr.extension),{name:"roundedRectangle"})}),il=1e-4,nl=1e-4;function Dm(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,n=r[t-2],s=r[t-1];i<t;i+=2){const a=r[i],o=r[i+1];e+=(a-n)*(o+s),n=a,s=o}return e<0?-1:1}function Um(r,t,e,i,n,s,a,o){const l=r-e*n,u=t-i*n,c=r+e*s,h=t+i*s;let p,f;a?(p=i,f=-e):(p=-i,f=e);const m=l+p,g=u+f,_=c+p,y=h+f;return o.push(m,g),o.push(_,y),2}function ur(r,t,e,i,n,s,a,o){const l=e-r,u=i-t;let c=Math.atan2(l,u),h=Math.atan2(n-r,s-t);o&&c<h?c+=Math.PI*2:!o&&c>h&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),g=Math.sqrt(l*l+u*u),_=(15*m*Math.sqrt(g)/Math.PI>>0)+1,y=f/_;if(p+=y,o){a.push(r,t),a.push(e,i);for(let b=1,x=p;b<_;b++,x+=y)a.push(r,t),a.push(r+Math.sin(x)*g,t+Math.cos(x)*g);a.push(r,t),a.push(n,s)}else{a.push(e,i),a.push(r,t);for(let b=1,x=p;b<_;b++,x+=y)a.push(r+Math.sin(x)*g,t+Math.cos(x)*g),a.push(r,t);a.push(n,s),a.push(r,t)}return _*2}function qn(r,t,e,i,n,s){const a=il;if(r.length===0)return;const o=t;let l=o.alignment;if(t.alignment!==.5){let j=Dm(r);e&&(j*=-1),l=(l-.5)*j+.5}const u=new lt(r[0],r[1]),c=new lt(r[r.length-2],r[r.length-1]),h=i,p=Math.abs(u.x-c.x)<a&&Math.abs(u.y-c.y)<a;if(h){r=r.slice(),p&&(r.pop(),r.pop(),c.set(r[r.length-2],r[r.length-1]));const j=(u.x+c.x)*.5,J=(c.y+u.y)*.5;r.unshift(j,J),r.push(j,J)}const f=n,m=r.length/2;let g=r.length;const _=f.length/2,y=o.width/2,b=y*y,x=o.miterLimit*o.miterLimit;let v=r[0],w=r[1],T=r[2],P=r[3],E=0,M=0,C=-(w-P),A=v-T,G=0,F=0,R=Math.sqrt(C*C+A*A);C/=R,A/=R,C*=y,A*=y;const B=l,O=(1-B)*2,I=B*2;h||(o.cap==="round"?g+=ur(v-C*(O-I)*.5,w-A*(O-I)*.5,v-C*O,w-A*O,v+C*I,w+A*I,f,!0)+2:o.cap==="square"&&(g+=Um(v,w,C,A,O,I,!0,f))),f.push(v-C*O,w-A*O),f.push(v+C*I,w+A*I);for(let j=1;j<m-1;++j){v=r[(j-1)*2],w=r[(j-1)*2+1],T=r[j*2],P=r[j*2+1],E=r[(j+1)*2],M=r[(j+1)*2+1],C=-(w-P),A=v-T,R=Math.sqrt(C*C+A*A),C/=R,A/=R,C*=y,A*=y,G=-(P-M),F=T-E,R=Math.sqrt(G*G+F*F),G/=R,F/=R,G*=y,F*=y;const J=T-v,K=w-P,N=T-E,k=M-P,$=J*N+K*k,z=K*N-k*J,rt=z<0;if(Math.abs(z)<.001*Math.abs($)){f.push(T-C*O,P-A*O),f.push(T+C*I,P+A*I),$>=0&&(o.join==="round"?g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+4:g+=2,f.push(T-G*I,P-F*I),f.push(T+G*O,P+F*O));continue}const _t=(-C+v)*(-A+P)-(-C+T)*(-A+w),et=(-G+E)*(-F+P)-(-G+T)*(-F+M),st=(J*et-N*_t)/z,nt=(k*_t-K*et)/z,ot=(st-T)*(st-T)+(nt-P)*(nt-P),gt=T+(st-T)*O,yt=P+(nt-P)*O,pt=T-(st-T)*I,Y=P-(nt-P)*I,Rt=Math.min(J*J+K*K,N*N+k*k),Ct=rt?O:I,ce=Rt+Ct*Ct*b;ot<=ce?o.join==="bevel"||ot/b>x?(rt?(f.push(gt,yt),f.push(T+C*I,P+A*I),f.push(gt,yt),f.push(T+G*I,P+F*I)):(f.push(T-C*O,P-A*O),f.push(pt,Y),f.push(T-G*O,P-F*O),f.push(pt,Y)),g+=2):o.join==="round"?rt?(f.push(gt,yt),f.push(T+C*I,P+A*I),g+=ur(T,P,T+C*I,P+A*I,T+G*I,P+F*I,f,!0)+4,f.push(gt,yt),f.push(T+G*I,P+F*I)):(f.push(T-C*O,P-A*O),f.push(pt,Y),g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+4,f.push(T-G*O,P-F*O),f.push(pt,Y)):(f.push(gt,yt),f.push(pt,Y)):(f.push(T-C*O,P-A*O),f.push(T+C*I,P+A*I),o.join==="round"?rt?g+=ur(T,P,T+C*I,P+A*I,T+G*I,P+F*I,f,!0)+2:g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+2:o.join==="miter"&&ot/b<=x&&(rt?(f.push(pt,Y),f.push(pt,Y)):(f.push(gt,yt),f.push(gt,yt)),g+=2),f.push(T-G*O,P-F*O),f.push(T+G*I,P+F*I),g+=2)}v=r[(m-2)*2],w=r[(m-2)*2+1],T=r[(m-1)*2],P=r[(m-1)*2+1],C=-(w-P),A=v-T,R=Math.sqrt(C*C+A*A),C/=R,A/=R,C*=y,A*=y,f.push(T-C*O,P-A*O),f.push(T+C*I,P+A*I),h||(o.cap==="round"?g+=ur(T-C*(O-I)*.5,P-A*(O-I)*.5,T-C*O,P-A*O,T+C*I,P+A*I,f,!1)+2:o.cap==="square"&&(g+=Um(T,P,C,A,O,I,!1,f)));const L=nl*nl;for(let j=_;j<g+_-2;++j)v=f[j*2],w=f[j*2+1],T=f[(j+1)*2],P=f[(j+1)*2+1],E=f[(j+2)*2],M=f[(j+2)*2+1],!(Math.abs(v*(P-M)+T*(M-w)+E*(w-P))<L)&&s.push(j,j+1,j+2)}function $m(r,t,e,i){const n=il;if(r.length===0)return;const s=r[0],a=r[1],o=r[r.length-2],l=r[r.length-1],u=t||Math.abs(s-o)<n&&Math.abs(a-l)<n,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 sl(r,t,e,i,n,s,a){const o=vf(r,t,2);if(!o)return;for(let u=0;u<o.length;u+=3)s[a++]=o[u]+n,s[a++]=o[u+1]+n,s[a++]=o[u+2]+n;let l=n*i;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=i}const zP=[],km={extension:{type:S.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,i,n,s){sl(r,zP,t,e,i,n,s)}},Lm={extension:{type:S.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,i=e.x,n=e.y,s=e.width,a=e.height;return s>0&&a>0?(t[0]=i,t[1]=n,t[2]=i+s,t[3]=n,t[4]=i+s,t[5]=n+a,t[6]=i,t[7]=n+a,!0):!1},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[6],t[i+a+1]=r[7],a+=e,t[i+a]=r[4],t[i+a+1]=r[5],a+=e;const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2,n[s++]=o+1,n[s++]=o+3,n[s++]=o+2}},Nm={extension:{type:S.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[4],t[i+a+1]=r[5];const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2}};var WP=Object.defineProperty,Xm=Object.getOwnPropertySymbols,VP=Object.prototype.hasOwnProperty,YP=Object.prototype.propertyIsEnumerable,jm=(r,t,e)=>t in r?WP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hm=(r,t)=>{for(var e in t||(t={}))VP.call(t,e)&&jm(r,e,t[e]);if(Xm)for(var e of Xm(t))YP.call(t,e)&&jm(r,e,t[e]);return r};const zm=[{offset:0,color:"white"},{offset:1,color:"black"}],al=class Ph{constructor(...t){this.uid=ht("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let i=KP(t);const n=i.type==="radial"?Ph.defaultRadialOptions:Ph.defaultLinearOptions;i=Hm(Hm({},n),he(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(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:tt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,s=i-t,a=n-e;const o=s<0||a<0;if(this._wrapMode==="clamp-to-edge"){if(s<0){const _=t;t=i,i=_,s*=-1}if(a<0){const _=e;e=n,n=_,a*=-1}}const l=this.colorStops.length?this.colorStops:zm,u=this._textureSize,{canvas:c,context:h}=Vm(u,1),p=o?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Wm(p,l),h.fillStyle=p,h.fillRect(0,0,u,1),this.texture=new D({source:new ke({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(s*s+a*a),m=Math.atan2(a,s),g=new U;g.scale(f/u,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(u,u),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:zm,e=this._textureSize,{canvas:i,context:n}=Vm(e,e),{x:s,y:a}=this.center,{x:o,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=o-c,p=l-c,f=e/(c*2),m=(s-h)*f,g=(a-p)*f,_=n.createRadialGradient(m,g,u*f,(o-h)*f,(l-p)*f,c*f);Wm(_,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=_,n.translate(m,g),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-m,-g),n.fillRect(0,0,e,e),this.texture=new D({source:new ke({resource:i,addressMode:this._wrapMode})});const y=new U;y.scale(1/f,1/f),y.translate(h,p),this.textureSpace==="local"&&y.scale(e,e),this.transform=y}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};al.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},al.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let $t=al;function Wm(r,t){for(let e=0;e<t.length;e++){const i=t[e];r.addColorStop(i.offset,i.color)}}function Vm(r,t){const e=H.get().createCanvas(r,t),i=e.getContext("2d");return{canvas:e,context:i}}function KP(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:$t.defaultLinearOptions.textureSize}),i}const qP=new U,ZP=new ut;function ol(r,t,e,i){const n=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const a=e.getBounds(ZP);t.width&&a.pad(t.width);const{x:o,y:l}=a,u=1/a.width,c=1/a.height,h=-o*u,p=-l*c,f=n.a,m=n.b,g=n.c,_=n.d;n.a*=u,n.b*=u,n.c*=c,n.d*=c,n.tx=h*f+p*g+n.tx,n.ty=h*m+p*_+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const s=t.texture.source.style;return!(t.fill instanceof $t)&&s.addressMode==="clamp-to-edge"&&(s.addressMode="repeat",s.update()),i&&n.append(qP.copyFrom(i).invert()),n}const Ne={};X.handleByMap(S.ShapeBuilder,Ne),X.add(Lm,km,Nm,kr,Bm,Fm);const QP=new ut,JP=new U;function Ym(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 n=0;n<r.instructions.length;n++){const s=r.instructions[n];if(s.action==="texture")tE(s.data,i,e);else if(s.action==="fill"||s.action==="stroke"){const a=s.action==="stroke",o=s.data.path.shapePath,l=s.data.style,u=s.data.hole;a&&u&&Km(u.shapePath,l,!0,i,e),u&&(o.shapePrimitives[o.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),Km(o,l,a,i,e)}}}function tE(r,t,e){const i=[],n=Ne.rectangle,s=QP;s.x=r.dx,s.y=r.dy,s.width=r.dw,s.height=r.dh;const a=r.transform;if(!n.build(s,i))return;const{vertices:o,uvs:l,indices:u}=e,c=u.length,h=o.length/2;a&&Wn(i,a),n.triangulate(i,o,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=Et.get(Vn);m.indexOffset=c,m.indexSize=u.length-c,m.attributeOffset=h,m.attributeSize=o.length/2-h,m.baseColor=r.style,m.alpha=r.alpha,m.texture=p,m.geometryData=e,t.push(m)}function Km(r,t,e,i,n){const{vertices:s,uvs:a,indices:o}=n;r.shapePrimitives.forEach(({shape:l,transform:u,holes:c})=>{var h;const p=[],f=Ne[l.type];if(!f.build(l,p))return;const m=o.length,g=s.length/2;let _="triangle-list";if(u&&Wn(p,u),e){const v=(h=l.closePath)!=null?h:!0,w=t;w.pixelLine?($m(p,v,s,o),_="line-list"):qn(p,w,!1,v,s,o)}else if(c){const v=[],w=p.slice();eE(c).forEach(T=>{v.push(w.length/2),w.push(...T)}),sl(w,v,s,2,g,o,m)}else f.triangulate(p,s,2,g,o,m);const y=a.length/2,b=t.texture;if(b!==D.WHITE){const v=ol(JP,t,l,u);el(s,2,g,a,y,2,s.length/2-g,v)}else rl(a,y,2,s.length/2-g);const x=Et.get(Vn);x.indexOffset=m,x.indexSize=o.length-m,x.attributeOffset=g,x.attributeSize=s.length/2-g,x.baseColor=t.color,x.alpha=t.alpha,x.texture=b,x.geometryData=n,x.topology=_,i.push(x)})}function eE(r){const t=[];for(let e=0;e<r.length;e++){const i=r[e].shape,n=[];Ne[i.type].build(i,n)&&t.push(n)}return t}class qm{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{Et.return(t)}),this.graphicsData&&Et.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Zm{constructor(){this.instructions=new cn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new zn({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const ll=class Eh{constructor(t){this._renderer=t,this._managedContexts=new Ut({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Eh.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Eh.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),Ym(t,i);const n=t.batchMode;t.customShader||n==="no-batch"?i.isBatchable=!1:n==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=Et.get(Zm,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:n,geometryData:s}=i;i.graphicsData=e;const a=s.vertices.length,o=s.indices.length;for(let h=0;h<n.length;h++)n[h].applyTransform=!1;const l=e.batcher;l.ensureAttributeBuffer(a),l.ensureIndexBuffer(o),l.begin();for(let h=0;h<n.length;h++){const p=n[h];l.add(p)}l.finish(e.instructions);const u=l.geometry;u.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),u.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let h=0;h<c.length;h++){const p=c[h];p.bindGroup=Un(p.textures.textures,p.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new qm;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};ll.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"graphicsContext"},ll.defaultOptions={bezierSmoothness:.5};let Zn=ll;const rE=8,Qn=11920929e-14,iE=1,ul=.01,Lr=0,cr=0;function cl(r,t,e,i,n,s,a,o,l,u){const c=Math.min(.99,Math.max(0,u!=null?u:Zn.defaultOptions.bezierSmoothness));let h=(iE-c)/1;return h*=h,nE(t,e,i,n,s,a,o,l,r,h),r}function nE(r,t,e,i,n,s,a,o,l,u){hl(r,t,e,i,n,s,a,o,l,u,0),l.push(a,o)}function hl(r,t,e,i,n,s,a,o,l,u,c){if(c>rE)return;const h=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+n)/2,g=(i+s)/2,_=(n+a)/2,y=(s+o)/2,b=(p+m)/2,x=(f+g)/2,v=(m+_)/2,w=(g+y)/2,T=(b+v)/2,P=(x+w)/2;if(c>0){let E=a-r,M=o-t;const C=Math.abs((e-a)*M-(i-o)*E),A=Math.abs((n-a)*M-(s-o)*E);let G,F;if(C>Qn&&A>Qn){if((C+A)*(C+A)<=u*(E*E+M*M)){if(Lr<ul){l.push(T,P);return}const R=Math.atan2(s-i,n-e);if(G=Math.abs(R-Math.atan2(i-t,e-r)),F=Math.abs(Math.atan2(o-s,a-n)-R),G>=h&&(G=2*h-G),F>=h&&(F=2*h-F),G+F<Lr){l.push(T,P);return}if(cr!==0){if(G>cr){l.push(e,i);return}if(F>cr){l.push(n,s);return}}}}else if(C>Qn){if(C*C<=u*(E*E+M*M)){if(Lr<ul){l.push(T,P);return}if(G=Math.abs(Math.atan2(s-i,n-e)-Math.atan2(i-t,e-r)),G>=h&&(G=2*h-G),G<Lr){l.push(e,i),l.push(n,s);return}if(cr!==0&&G>cr){l.push(e,i);return}}}else if(A>Qn){if(A*A<=u*(E*E+M*M)){if(Lr<ul){l.push(T,P);return}if(G=Math.abs(Math.atan2(o-s,a-n)-Math.atan2(s-i,n-e)),G>=h&&(G=2*h-G),G<Lr){l.push(e,i),l.push(n,s);return}if(cr!==0&&G>cr){l.push(n,s);return}}}else if(E=T-(r+a)/2,M=P-(t+o)/2,E*E+M*M<=u){l.push(T,P);return}}hl(r,t,p,f,b,x,T,P,l,u,c+1),hl(T,P,v,w,_,y,a,o,l,u,c+1)}const sE=8,aE=11920929e-14,oE=1,lE=.01,Qm=0;function Jm(r,t,e,i,n,s,a,o){const l=Math.min(.99,Math.max(0,o!=null?o:Zn.defaultOptions.bezierSmoothness));let u=(oE-l)/1;return u*=u,uE(t,e,i,n,s,a,r,u),r}function uE(r,t,e,i,n,s,a,o){dl(a,r,t,e,i,n,s,o,0),a.push(n,s)}function dl(r,t,e,i,n,s,a,o,l){if(l>sE)return;const u=Math.PI,c=(t+i)/2,h=(e+n)/2,p=(i+s)/2,f=(n+a)/2,m=(c+p)/2,g=(h+f)/2;let _=s-t,y=a-e;const b=Math.abs((i-s)*y-(n-a)*_);if(b>aE){if(b*b<=o*(_*_+y*y)){if(Qm<lE){r.push(m,g);return}let x=Math.abs(Math.atan2(a-n,s-i)-Math.atan2(n-e,i-t));if(x>=u&&(x=2*u-x),x<Qm){r.push(m,g);return}}}else if(_=m-(t+s)/2,y=g-(e+a)/2,_*_+y*y<=o){r.push(m,g);return}dl(r,t,e,c,h,m,g,o,l+1),dl(r,m,g,p,f,s,a,o,l+1)}function pl(r,t,e,i,n,s,a,o){let l=Math.abs(n-s);(!a&&n>s||a&&s>n)&&(l=2*Math.PI-l),o||(o=Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI)))),o=Math.max(o,3);let u=l/o,c=n;u*=a?-1:1;for(let h=0;h<o+1;h++){const p=Math.cos(c),f=Math.sin(c),m=t+p*i,g=e+f*i;r.push(m,g),c+=u}}function tg(r,t,e,i,n,s){const a=r[r.length-2],o=r[r.length-1]-e,l=a-t,u=n-e,c=i-t,h=Math.abs(o*c-l*u);if(h<1e-8||s===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const p=o*o+l*l,f=u*u+c*c,m=o*u+l*c,g=s*Math.sqrt(p)/h,_=s*Math.sqrt(f)/h,y=g*m/p,b=_*m/f,x=g*c+_*l,v=g*u+_*o,w=l*(_+y),T=o*(_+y),P=c*(g+b),E=u*(g+b),M=Math.atan2(T-v,w-x),C=Math.atan2(E-v,P-x);pl(r,x+t,v+e,s,M,C,l*u>c*o)}const Ii=Math.PI*2,fl={centerX:0,centerY:0,ang1:0,ang2:0},ml=({x:r,y:t},e,i,n,s,a,o,l)=>{r*=e,t*=i;const u=n*r-s*t,c=s*r+n*t;return l.x=u+a,l.y=c+o,l};function cE(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(r),s=Math.sin(r),a=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-s*i,y:s+n*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const eg=(r,t,e,i)=>{const n=r*i-t*e<0?-1:1;let s=r*e+t*i;return s>1&&(s=1),s<-1&&(s=-1),n*Math.acos(s)},hE=(r,t,e,i,n,s,a,o,l,u,c,h,p)=>{const f=Math.pow(n,2),m=Math.pow(s,2),g=Math.pow(c,2),_=Math.pow(h,2);let y=f*m-f*_-m*g;y<0&&(y=0),y/=f*_+m*g,y=Math.sqrt(y)*(a===o?-1:1);const b=y*n/s*h,x=y*-s/n*c,v=u*b-l*x+(r+e)/2,w=l*b+u*x+(t+i)/2,T=(c-b)/n,P=(h-x)/s,E=(-c-b)/n,M=(-h-x)/s,C=eg(1,0,T,P);let A=eg(T,P,E,M);o===0&&A>0&&(A-=Ii),o===1&&A<0&&(A+=Ii),p.centerX=v,p.centerY=w,p.ang1=C,p.ang2=A};function rg(r,t,e,i,n,s,a,o=0,l=0,u=0){if(s===0||a===0)return;const c=Math.sin(o*Ii/360),h=Math.cos(o*Ii/360),p=h*(t-i)/2+c*(e-n)/2,f=-c*(t-i)/2+h*(e-n)/2;if(p===0&&f===0)return;s=Math.abs(s),a=Math.abs(a);const m=Math.pow(p,2)/Math.pow(s,2)+Math.pow(f,2)/Math.pow(a,2);m>1&&(s*=Math.sqrt(m),a*=Math.sqrt(m)),hE(t,e,i,n,s,a,l,u,c,h,p,f,fl);let{ang1:g,ang2:_}=fl;const{centerX:y,centerY:b}=fl;let x=Math.abs(_)/(Ii/4);Math.abs(1-x)<1e-7&&(x=1);const v=Math.max(Math.ceil(x),1);_/=v;let w=r[r.length-2],T=r[r.length-1];const P={x:0,y:0};for(let E=0;E<v;E++){const M=cE(g,_),{x:C,y:A}=ml(M[0],s,a,h,c,y,b,P),{x:G,y:F}=ml(M[1],s,a,h,c,y,b,P),{x:R,y:B}=ml(M[2],s,a,h,c,y,b,P);cl(r,w,T,C,A,G,F,R,B),w=R,T=B,g+=_}}function ig(r,t,e){var i;const n=(o,l)=>{const u=l.x-o.x,c=l.y-o.y,h=Math.sqrt(u*u+c*c),p=u/h,f=c/h;return{len:h,nx:p,ny:f}},s=(o,l)=>{o===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let a=t[t.length-1];for(let o=0;o<t.length;o++){const l=t[o%t.length],u=(i=l.radius)!=null?i:e;if(u<=0){s(o,l),a=l;continue}const c=t[(o+1)%t.length],h=n(l,a),p=n(l,c);if(h.len<1e-4||p.len<1e-4){s(o,l),a=l;continue}let f=Math.asin(h.nx*p.ny-h.ny*p.nx),m=1,g=!1;h.nx*p.nx-h.ny*-p.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,m=-1,g=!0):f>0&&(m=-1,g=!0);const _=f/2;let y,b=Math.abs(Math.cos(_)*u/Math.sin(_));b>Math.min(h.len/2,p.len/2)?(b=Math.min(h.len/2,p.len/2),y=Math.abs(b*Math.sin(_)/Math.cos(_))):y=u;const x=l.x+p.nx*b+-p.ny*y*m,v=l.y+p.ny*b+p.nx*y*m,w=Math.atan2(h.ny,h.nx)+Math.PI/2*m,T=Math.atan2(p.ny,p.nx)-Math.PI/2*m;o===0&&r.moveTo(x+Math.cos(w)*y,v+Math.sin(w)*y),r.arc(x,v,y,w,T,g),a=l}}function ng(r,t,e,i){var n;const s=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),a=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c}),o=t.length;for(let l=0;l<o;l++){const u=t[(l+1)%o],c=(n=u.radius)!=null?n: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)%o],f=s(h,u);let m;if(f<1e-4)m=u;else{const y=Math.min(f/2,c);m=a(u,h,y/f)}const g=s(p,u);let _;if(g<1e-4)_=u;else{const y=Math.min(g/2,c);_=a(u,p,y/g)}l===0?r.moveTo(m.x,m.y):r.lineTo(m.x,m.y),r.quadraticCurveTo(u.x,u.y,_.x,_.y,i)}}const dE=new ut;class sg{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Mt,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,n=i[i.length-2],s=i[i.length-1];return(n!==t||s!==e)&&i.push(t,e),this}arc(t,e,i,n,s,a){this._ensurePoly(!1);const o=this._currentPoly.points;return pl(o,t,e,i,n,s,a),this}arcTo(t,e,i,n,s){this._ensurePoly();const a=this._currentPoly.points;return tg(a,t,e,i,n,s),this}arcToSvg(t,e,i,n,s,a,o){const l=this._currentPoly.points;return rg(l,this._currentPoly.lastX,this._currentPoly.lastY,a,o,t,e,i,n,s),this}bezierCurveTo(t,e,i,n,s,a,o){this._ensurePoly();const l=this._currentPoly;return cl(this._currentPoly.points,l.lastX,l.lastY,t,e,i,n,s,a,o),this}quadraticCurveTo(t,e,i,n,s){this._ensurePoly();const a=this._currentPoly;return Jm(this._currentPoly.points,a.lastX,a.lastY,t,e,i,n,s),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,n=i.length;for(let s=0;s<t.instructions.length;s++){const a=t.instructions[s];this[a.action](...a.data)}if(t.checkForHoles&&i.length-n>1){let s=null;for(let a=n;a<i.length;a++){const o=i[a];if(o.shape.type==="polygon"){const l=o.shape,u=s==null?void 0:s.shape;u&&u.containsPolygon(l)?(s.holes||(s.holes=[]),s.holes.push(o),i.copyWithin(a,a+1),i.length--,a--):s=o}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,n,s){return this.drawShape(new ut(t,e,i,n),s),this}circle(t,e,i,n){return this.drawShape(new wn(t,e,i),n),this}poly(t,e,i){const n=new Er(t);return n.closePath=e,this.drawShape(n,i),this}regularPoly(t,e,i,n,s=0,a){n=Math.max(n|0,3);const o=-1*Math.PI/2+s,l=Math.PI*2/n,u=[];for(let c=0;c<n;c++){const h=o-c*l;u.push(t+i*Math.cos(h),e+i*Math.sin(h))}return this.poly(u,!0,a),this}roundPoly(t,e,i,n,s,a=0,o){if(n=Math.max(n|0,3),s<=0)return this.regularPoly(t,e,i,n,a);const l=i*Math.sin(Math.PI/n)-.001;s=Math.min(s,l);const u=-1*Math.PI/2+a,c=Math.PI*2/n,h=(n-2)*Math.PI/n/2;for(let p=0;p<n;p++){const f=p*c+u,m=t+i*Math.cos(f),g=e+i*Math.sin(f),_=f+Math.PI+h,y=f-Math.PI-h,b=m+s*Math.cos(_),x=g+s*Math.sin(_),v=m+s*Math.cos(y),w=g+s*Math.sin(y);p===0?this.moveTo(b,x):this.lineTo(b,x),this.quadraticCurveTo(m,g,v,w,o)}return this.closePath()}roundShape(t,e,i=!1,n){return t.length<3?this:(i?ng(this,t,e,n):ig(this,t,e),this.closePath())}filletRect(t,e,i,n,s){if(s===0)return this.rect(t,e,i,n);const a=Math.min(i,n)/2,o=Math.min(a,Math.max(-a,s)),l=t+i,u=e+n,c=o<0?-o:0,h=Math.abs(o);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,n,s,a){if(s<=0)return this.rect(t,e,i,n);const o=Math.min(s,Math.min(i,n)/2),l=t+i,u=e+n,c=[t+o,e,l-o,e,l,e+o,l,u-o,l-o,u,t+o,u,t,u-o,t,e+o];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,a)}ellipse(t,e,i,n,s){return this.drawShape(new Pn(t,e,i,n),s),this}roundRect(t,e,i,n,s,a){return this.drawShape(new An(t,e,i,n,s),a),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 Er,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 Er,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const s=e.transform,a=i;i=s.a*i+s.c*n+s.tx,n=s.b*a+s.d*n+s.ty}this._currentPoly.points.push(i,n)}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 n=e[i],s=n.shape.getBounds(dE);n.transform?t.addRect(s,n.transform):t.addRect(s)}return t}}class ge{constructor(t,e=!1){this.instructions=[],this.uid=ht("graphicsPath"),this._dirty=!0;var i;this.checkForHoles=e,typeof t=="string"?tm(t,this):this.instructions=(i=t==null?void 0:t.slice())!=null?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new sg(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,n,s){const a=this.instructions[this.instructions.length-1],o=this.getLastPoint(lt.shared);let l=0,u=0;if(!a||a.action!=="bezierCurveTo")l=o.x,u=o.y;else{l=a.data[2],u=a.data[3];const c=o.x,h=o.y;l=c+(c-l),u=h+(h-u)}return this.instructions.push({action:"bezierCurveTo",data:[l,u,t,e,i,n,s]}),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 n=this.instructions[this.instructions.length-1],s=this.getLastPoint(lt.shared);let a=0,o=0;if(!n||n.action!=="quadraticCurveTo")a=s.x,o=s.y;else{a=n.data[0],o=n.data[1];const l=s.x,u=s.y;a=l+(l-a),o=u+(u-o)}return this.instructions.push({action:"quadraticCurveTo",data:[a,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,n,s){return this.instructions.push({action:"rect",data:[t,e,i,n,s]}),this._dirty=!0,this}circle(t,e,i,n){return this.instructions.push({action:"circle",data:[t,e,i,n]}),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,n,s,a,o){s||(s=n/2);const l=-1*Math.PI/2+a,u=i*2,c=Math.PI*2/u,h=[];for(let p=0;p<u;p++){const f=p%2?s:n,m=p*c+l;h.push(t+f*Math.cos(m),e+f*Math.sin(m))}return this.poly(h,!0,o),this}clone(t=!1){const e=new ge;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const n=this.instructions[i];e.instructions.push({action:n.action,data:n.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,n=t.c,s=t.d,a=t.tx,o=t.ty;let l=0,u=0,c=0,h=0,p=0,f=0,m=0,g=0;for(let _=0;_<this.instructions.length;_++){const y=this.instructions[_],b=y.data;switch(y.action){case"moveTo":case"lineTo":l=b[0],u=b[1],b[0]=e*l+n*u+a,b[1]=i*l+s*u+o;break;case"bezierCurveTo":c=b[0],h=b[1],p=b[2],f=b[3],l=b[4],u=b[5],b[0]=e*c+n*h+a,b[1]=i*c+s*h+o,b[2]=e*p+n*f+a,b[3]=i*p+s*f+o,b[4]=e*l+n*u+a,b[5]=i*l+s*u+o;break;case"quadraticCurveTo":c=b[0],h=b[1],l=b[2],u=b[3],b[0]=e*c+n*h+a,b[1]=i*c+s*h+o,b[2]=e*l+n*u+a,b[3]=i*l+s*u+o;break;case"arcToSvg":l=b[5],u=b[6],m=b[0],g=b[1],b[0]=e*m+n*g,b[1]=i*m+s*g,b[5]=e*l+n*u+a,b[6]=i*l+s*u+o;break;case"circle":b[4]=Nr(b[3],t);break;case"rect":b[4]=Nr(b[4],t);break;case"ellipse":b[8]=Nr(b[8],t);break;case"roundRect":b[5]=Nr(b[5],t);break;case"addPath":b[0].transform(t);break;case"poly":b[2]=Nr(b[2],t);break;case"regularPoly":case"chamferRect":b[5]=Nr(b[5],t);break;case"closePath":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 Nr(r,t){return r?r.prepend(t):t.clone()}let gl=0;const ag=500;function ue(...r){gl!==ag&&(gl++,gl===ag?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function Tt(r,t,e){const i=r.getAttribute(t);return i?Number(i):e}function og(r,t){const e=r.querySelectorAll("defs");for(let i=0;i<e.length;i++){const n=e[i];for(let s=0;s<n.children.length;s++){const a=n.children[s];switch(a.nodeName.toLowerCase()){case"lineargradient":t.defs[a.id]=pE(a);break;case"radialgradient":t.defs[a.id]=fE(a);break;default:break}}}}function pE(r){const t=Tt(r,"x1",0),e=Tt(r,"y1",0),i=Tt(r,"x2",1),n=Tt(r,"y2",0),s=r.getAttribute("gradientUnits")||"objectBoundingBox",a=new $t(t,e,i,n,s==="objectBoundingBox"?"local":"global");for(let o=0;o<r.children.length;o++){const l=r.children[o],u=Tt(l,"offset",0),c=tt.shared.setValue(l.getAttribute("stop-color")).toNumber();a.addColorStop(u,c)}return a}function fE(r){return new $t(0,0,1,0)}function _l(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const yl={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 bl(r,t){const e=r.getAttribute("style"),i={},n={},s={strokeStyle:i,fillStyle:n,useFill:!1,useStroke:!1};for(const a in yl){const o=r.getAttribute(a);o&&lg(t,s,a,o.trim())}if(e){const a=e.split(";");for(let o=0;o<a.length;o++){const l=a[o].trim(),[u,c]=l.split(":");yl[u]&&lg(t,s,u,c.trim())}}return{strokeStyle:s.useStroke?i:null,fillStyle:s.useFill?n:null,useFill:s.useFill,useStroke:s.useStroke}}function lg(r,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const n=_l(i);t.strokeStyle.fill=r.defs[n]}else t.strokeStyle.color=tt.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 n=_l(i);t.fillStyle.fill=r.defs[n]}else t.fillStyle.color=tt.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}}function ug(r){if(r.length<=2)return!0;const t=r.map(o=>o.area).sort((o,l)=>l-o),[e,i]=t,n=t[t.length-1],s=e/i,a=i/n;return!(s>3&&a<2)}function mE(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function cg(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function hg(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],n=[];for(let u=0;u<e.length;u+=2)u+1<e.length&&(i.push(e[u]),n.push(e[u+1]));if(i.length===0||n.length===0)return 0;const s=Math.min(...i),a=Math.max(...i),o=Math.min(...n),l=Math.max(...n);return(a-s)*(l-o)}function vl(r,t){const e=new ge(r,!1);for(const i of e.instructions)t.instructions.push(i)}var gE=Object.defineProperty,dg=Object.getOwnPropertySymbols,_E=Object.prototype.hasOwnProperty,yE=Object.prototype.propertyIsEnumerable,pg=(r,t,e)=>t in r?gE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jn=(r,t)=>{for(var e in t||(t={}))_E.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))yE.call(t,e)&&pg(r,e,t[e]);return r};function fg(r,t){if(typeof r=="string"){const a=document.createElement("div");a.innerHTML=r.trim(),r=a.querySelector("svg")}const e={context:t,defs:{},path:new ge};og(r,e);const i=r.children,{fillStyle:n,strokeStyle:s}=bl(r,e);for(let a=0;a<i.length;a++){const o=i[a];o.nodeName.toLowerCase()!=="defs"&&mg(o,e,n,s)}return t}function mg(r,t,e,i){const n=r.children,{fillStyle:s,strokeStyle:a}=bl(r,t);s&&e?e=Jn(Jn({},e),s):s&&(e=s),a&&i?i=Jn(Jn({},i),a):a&&(i=a);const o=!e&&!i;o&&(e={color:0});let l,u,c,h,p,f,m,g,_,y,b,x,v,w,T,P,E;switch(r.nodeName.toLowerCase()){case"path":{w=r.getAttribute("d");const M=r.getAttribute("fill-rule"),C=cg(w),A=M==="evenodd",G=C.length>1;if(A&&G){const F=C.map(R=>({path:R,area:hg(R)}));if(F.sort((R,B)=>B.area-R.area),C.length>3||!ug(F))for(let R=0;R<F.length;R++){const B=F[R],O=R===0;t.context.beginPath();const I=new ge(void 0,!0);vl(B.path,I),t.context.path(I),O?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let R=0;R<F.length;R++){const B=F[R],O=R%2===1;t.context.beginPath();const I=new ge(void 0,!0);vl(B.path,I),t.context.path(I),O?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const F=M?M==="evenodd":!0;T=new ge(w,F),t.context.path(T),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":m=Tt(r,"cx",0),g=Tt(r,"cy",0),_=Tt(r,"r",0),t.context.ellipse(m,g,_,_),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":l=Tt(r,"x",0),u=Tt(r,"y",0),P=Tt(r,"width",0),E=Tt(r,"height",0),y=Tt(r,"rx",0),b=Tt(r,"ry",0),y||b?t.context.roundRect(l,u,P,E,y||b):t.context.rect(l,u,P,E),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=Tt(r,"cx",0),g=Tt(r,"cy",0),y=Tt(r,"rx",0),b=Tt(r,"ry",0),t.context.beginPath(),t.context.ellipse(m,g,y,b),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=Tt(r,"x1",0),h=Tt(r,"y1",0),p=Tt(r,"x2",0),f=Tt(r,"y2",0),t.context.beginPath(),t.context.moveTo(c,h),t.context.lineTo(p,f),i&&t.context.stroke(i);break;case"polygon":v=r.getAttribute("points"),x=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(x,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":v=r.getAttribute("points"),x=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(x,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{ue(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}o&&(e=null);for(let M=0;M<n.length;M++)mg(n[M],t,e,i)}const gg={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 Xr{constructor(t,e){this.uid=ht("fillPattern"),this._tick=0,this.transform=new U,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=gg[e].addressModeU,t.source.style.addressModeV=gg[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var bE=Object.defineProperty,ts=Object.getOwnPropertySymbols,_g=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,bg=(r,t,e)=>t in r?bE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_e=(r,t)=>{for(var e in t||(t={}))_g.call(t,e)&&bg(r,e,t[e]);if(ts)for(var e of ts(t))yg.call(t,e)&&bg(r,e,t[e]);return r},vE=(r,t)=>{var e={};for(var i in r)_g.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&&yg.call(r,i)&&(e[i]=r[i]);return e};function xE(r){return tt.isColorLike(r)}function vg(r){return r instanceof Xr}function xg(r){return r instanceof $t}function TE(r){return r instanceof D}function SE(r,t,e){const i=tt.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=D.WHITE,_e(_e({},e),r)}function wE(r,t,e){return r.texture=t,_e(_e({},e),r)}function Tg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,_e(_e({},e),r)}function Sg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,_e(_e({},e),r)}function PE(r,t){const e=_e(_e({},t),r),i=tt.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function Xe(r,t){if(r==null)return null;const e={},i=r;return xE(r)?SE(e,r,t):TE(r)?wE(e,r,t):vg(r)?Tg(e,r,t):xg(r)?Sg(e,r,t):i.fill&&vg(i.fill)?Tg(i,i.fill,t):i.fill&&xg(i.fill)?Sg(i,i.fill,t):PE(i,t)}function Bi(r,t){const e=t,{width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l}=e,u=vE(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=Xe(r,u);return c?_e({width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l},c):null}function wg(r,t){let e=1;const i=r.shapePath.shapePrimitives;for(let n=0;n<i.length;n++){const s=i[n].shape;if(s.type!=="polygon")continue;const a=s.points,o=a.length;if(o<6)continue;const l=s.closePath;for(let u=0;u<o;u+=2){if(!l&&(u===0||u===o-2))continue;const c=(u-2+o)%o,h=(u+2)%o,p=a[c],f=a[c+1],m=a[u],g=a[u+1],_=a[h],y=a[h+1],b=p-m,x=f-g,v=_-m,w=y-g,T=b*b+x*x,P=v*v+w*w;if(T<1e-12||P<1e-12)continue;let E=(b*v+x*w)/Math.sqrt(T*P);E<-1?E=-1:E>1&&(E=1);const M=Math.sqrt((1-E)*.5);if(M<1e-6)continue;const C=Math.min(1/M,t);C>e&&(e=C)}}return e}var EE=Object.defineProperty,Pg=Object.getOwnPropertySymbols,AE=Object.prototype.hasOwnProperty,CE=Object.prototype.propertyIsEnumerable,Eg=(r,t,e)=>t in r?EE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jr=(r,t)=>{for(var e in t||(t={}))AE.call(t,e)&&Eg(r,e,t[e]);if(Pg)for(var e of Pg(t))CE.call(t,e)&&Eg(r,e,t[e]);return r};const ME=new lt,Ag=new U,xl=class Me extends Nt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ht("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ge,this._transform=new U,this._fillStyle=jr({},Me.defaultFillStyle),this._strokeStyle=jr({},Me.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Mt,this._boundsDirty=!0}clone(){const t=new Me;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=jr({},this._fillStyle),t._strokeStyle=jr({},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=Xe(t,Me.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Bi(t,Me.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Xe(t,Me.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Xe(t,Me.defaultStrokeStyle),this}texture(t,e,i,n,s,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:s||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?tt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ge,this}fill(t,e){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=Xe(t,Me.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Bi(t,Me.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,n,s,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,n,s,a),this}arcTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}arcToSvg(t,e,i,n,s,a,o){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,i,n,s,l.a*a+l.c*o+l.tx,l.b*a+l.d*o+l.ty),this}bezierCurveTo(t,e,i,n,s,a,o){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*n+l.tx,l.b*i+l.d*n+l.ty,l.a*s+l.c*a+l.tx,l.b*s+l.d*a+l.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,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,n=this._activePath.instructions,s=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=s,n[0].data[1]=a,this):(this._activePath.moveTo(s,a),this)}quadraticCurveTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,s){return this._tick++,this._activePath.roundRect(t,e,i,n,s,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,s=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,n,s,a),this}roundPoly(t,e,i,n,s,a){return this._tick++,this._activePath.roundPoly(t,e,i,n,s,a),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,s){return this._tick++,this._activePath.filletRect(t,e,i,n,s),this}chamferRect(t,e,i,n,s,a){return this._tick++,this._activePath.chamferRect(t,e,i,n,s,a),this}star(t,e,i,n,s=0,a=0){return this._tick++,this._activePath.star(t,e,i,n,s,a,this._transform.clone()),this}svg(t){return this._tick++,fg(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:jr({},this._fillStyle),strokeStyle:jr({},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,n,s,a){return t instanceof U?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,s,a),this)}transform(t,e,i,n,s,a){return t instanceof U?(this._transform.append(t),this):(Ag.set(t,e,i,n,s,a),this._transform.append(Ag),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],n=i.action;if(n==="fill"){const s=i.data;t.addBounds(s.path.bounds)}else if(n==="texture"){const s=i.data;t.addFrame(s.dx,s.dy,s.dx+s.dw,s.dy+s.dh,s.transform)}if(n==="stroke"){const s=i.data,a=s.style.alignment;let o=s.style.width*(1-a);s.style.join==="miter"&&(o*=wg(s.path,s.style.miterLimit));const l=s.path.bounds;t.addFrame(l.minX-o,l.minY-o,l.maxX+o,l.maxY+o)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let n=!1;for(let s=0;s<i.length;s++){const a=i[s],o=a.data,l=o.path;if(!a.action||!l)continue;const u=o.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,ME):t;if(a.action==="fill")n=p.contains(m.x,m.y);else{const _=u;n=p.strokeContains(m.x,m.y,_.width,_.alignment)}const g=o.hole;if(g){const _=(e=g.shapePath)==null?void 0:e.shapePrimitives;if(_)for(let y=0;y<_.length;y++)_[y].shape.contains(m.x,m.y)&&(n=!1)}if(n)return!0}}return n}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(!this.destroyed){if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}}};xl.defaultFillStyle={color:16777215,alpha:1,texture:D.WHITE,matrix:null,fill:null,textureSpace:"local"},xl.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:D.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let kt=xl;function je(r,t=1){var e;const i=(e=$e.RETINA_PREFIX)==null?void 0:e.exec(r);return i?parseFloat(i[1]):t}function He(r,t,e){r.label=e,r._sourceOrigin=e;const i=new D({source:r,label:e}),n=()=>{delete t.promiseCache[e],it.has(e)&&it.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&n()}),i.once("destroy",()=>{r.destroyed||n()}),i}var RE=Object.defineProperty,es=Object.getOwnPropertySymbols,Cg=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable,Rg=(r,t,e)=>t in r?RE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,OE=(r,t)=>{for(var e in t||(t={}))Cg.call(t,e)&&Rg(r,e,t[e]);if(es)for(var e of es(t))Mg.call(t,e)&&Rg(r,e,t[e]);return r},GE=(r,t)=>{var e={};for(var i in r)Cg.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&&Mg.call(r,i)&&(e[i]=r[i]);return e};const IE=".svg",BE="image/svg+xml",Og={extension:{type:S.LoadParser,priority:te.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return ar(r,BE)||le(r,IE)},async load(r,t,e){var i,n;return((n=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?n:this.config.parseAsGraphicsContext)?DE(r):FE(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function FE(r,t,e,i){var n,s,a,o,l,u;const c=await H.get().fetch(r),h=H.get().createImage();h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await c.text())}`,h.crossOrigin=i,await h.decode();const p=(s=(n=t.data)==null?void 0:n.width)!=null?s:h.width,f=(o=(a=t.data)==null?void 0:a.height)!=null?o:h.height,m=((l=t.data)==null?void 0:l.resolution)||je(r),g=Math.ceil(p*m),_=Math.ceil(f*m),y=H.get().createCanvas(g,_),b=y.getContext("2d");b.imageSmoothingEnabled=!0,b.imageSmoothingQuality="high",b.drawImage(h,0,0,p*m,f*m);const x=(u=t.data)!=null?u:{},{parseAsGraphicsContext:v}=x,w=GE(x,["parseAsGraphicsContext"]),T=new ke(OE({resource:y,alphaMode:"premultiply-alpha-on-upload",resolution:m},w));return He(T,e,r)}async function DE(r){const t=await(await H.get().fetch(r)).text(),e=new kt;return e.svg(t),e}const UE=`(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)})})();
348 `;let Hr=null,Tl=class{constructor(){Hr||(Hr=URL.createObjectURL(new Blob([UE],{type:"application/javascript"}))),this.worker=new Worker(Hr)}};Tl.revokeObjectURL=function(){Hr&&(URL.revokeObjectURL(Hr),Hr=null)};const $E='(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 zr=null,Gg=class{constructor(){zr||(zr=URL.createObjectURL(new Blob([$E],{type:"application/javascript"}))),this.worker=new Worker(zr)}};Gg.revokeObjectURL=function(){zr&&(URL.revokeObjectURL(zr),zr=null)};let Ig=0,Sl,kE=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 Tl;e.addEventListener("message",i=>{e.terminate(),Tl.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(){Sl===void 0&&(Sl=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Sl&&(this._createdWorkers++,t=new Gg().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((n,s)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:s})});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[Ig]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ig++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const wl=new kE;var LE=Object.defineProperty,Bg=Object.getOwnPropertySymbols,NE=Object.prototype.hasOwnProperty,XE=Object.prototype.propertyIsEnumerable,Fg=(r,t,e)=>t in r?LE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jE=(r,t)=>{for(var e in t||(t={}))NE.call(t,e)&&Fg(r,e,t[e]);if(Bg)for(var e of Bg(t))XE.call(t,e)&&Fg(r,e,t[e]);return r};const HE=[".jpeg",".jpg",".png",".webp",".avif"],zE=["image/jpeg","image/png","image/webp","image/avif"];async function Dg(r,t){var e;const i=await H.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const n=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(n,{premultiplyAlpha:"none"}):createImageBitmap(n)}const Pl={name:"loadTextures",id:"texture",extension:{type:S.LoadParser,priority:te.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ar(r,zE)||le(r,HE)},async load(r,t,e){var i;let n=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await wl.isImageBitmapSupported()?n=await wl.loadImageBitmap(r,t):n=await Dg(r,t):n=await new Promise((a,o)=>{n=H.get().createImage(),n.crossOrigin=this.config.crossOrigin,n.src=r,n.complete?a(n):(n.onload=()=>{a(n)},n.onerror=o)});const s=new ke(jE({resource:n,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||je(r)},t.data));return He(s,e,r)},unload(r){r.destroy(!0)}};var WE=Object.defineProperty,VE=Object.defineProperties,YE=Object.getOwnPropertyDescriptors,Ug=Object.getOwnPropertySymbols,KE=Object.prototype.hasOwnProperty,qE=Object.prototype.propertyIsEnumerable,$g=(r,t,e)=>t in r?WE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,El=(r,t)=>{for(var e in t||(t={}))KE.call(t,e)&&$g(r,e,t[e]);if(Ug)for(var e of Ug(t))qE.call(t,e)&&$g(r,e,t[e]);return r},kg=(r,t)=>VE(r,YE(t));const ZE=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Al,Cl;function Lg(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Xg(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Ng(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",n),r.load();function i(){s(),t()}function n(a){s(),e(a)}function s(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",n)}})}function Xg(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function QE(){const r=[],t=[];for(const e of ZE){const i=wr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ci(i)&&(r.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:r,validVideoMime:t}}const jg={name:"loadVideo",id:"video",extension:{type:S.LoadParser,name:"loadVideo"},test(r){if(!Al||!Cl){const{validVideoExtensions:i,validVideoMime:n}=QE();Al=i,Cl=n}const t=ar(r,Cl),e=le(r,Al);return t||e},async load(r,t,e){var i,n;const s=El(kg(El({},wr.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r),alphaMode:((n=t.data)==null?void 0:n.alphaMode)||await eo()}),t.data),a=document.createElement("video"),o={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(o).forEach(c=>{const h=o[c];h!==void 0&&a.setAttribute(c,h)}),s.muted===!0&&(a.muted=!0),Lg(a,r,s.crossorigin);const l=document.createElement("source");let u;if(s.mime)u=s.mime;else 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=wr.MIME_TYPES[c]||`video/${c}`}return l.src=r,u&&(l.type=u),new Promise((c,h)=>{s.preload&&!s.autoPlay&&a.load(),a.addEventListener("canplay",p),a.addEventListener("error",f),l.addEventListener("error",f),a.appendChild(l);async function p(){const g=new wr(kg(El({},s),{resource:a}));m(),t.data.preload&&await Ng(a),c(He(g,e,r))}function f(g){m(),h(g)}function m(){a.removeEventListener("canplay",p),a.removeEventListener("error",f),l.removeEventListener("error",f)}})},unload(r){r.destroy(!0)}},Ml={extension:{type:S.ResolveParser,name:"resolveTexture"},test:Pl.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Hg={extension:{type:S.ResolveParser,priority:-2,name:"resolveJson"},test:r=>$e.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Ml.parse};var JE=Object.defineProperty,zg=Object.getOwnPropertySymbols,tA=Object.prototype.hasOwnProperty,eA=Object.prototype.propertyIsEnumerable,Wg=(r,t,e)=>t in r?JE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vg=(r,t)=>{for(var e in t||(t={}))tA.call(t,e)&&Wg(r,e,t[e]);if(zg)for(var e of zg(t))eA.call(t,e)&&Wg(r,e,t[e]);return r};class Yg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new $e,this.loader=new Wf,this.cache=it,this._backgroundLoader=new Bf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,n;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 s=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,a=typeof s=="number"?[s]:s,o=await this._detectFormats({preferredFormats:(n=t.texturePreference)==null?void 0:n.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:a}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=Vg(Vg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=fi(t),n=oe(t).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(u=>!this.resolver.hasKey(u))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),s=this.resolver.resolve(n),a=await this._mapLoadToResolve(s,e);return i?a[n[0]]:a}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 n=this.resolver.resolveBundle(t),s={},a=Object.keys(n);let o=0;const l=[],u=()=>{e==null||e(l.reduce((h,p)=>h+p,0)/o)},c=a.map((h,p)=>{const f=n[h],m=Object.values(f),g=[...new Set(m.flat())].reduce((_,y)=>_+(y.progressSize||1),0);return l.push(0),o+=g,this._mapLoadToResolve(f,_=>{l[p]=_*g,u()}).then(_=>{s[h]=_})});return await Promise.all(c),i?s[t[0]]:s}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 it.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=it.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const s={};return i.forEach(a=>{const o=n[a.src],l=[a.src];a.alias&&l.push(...a.alias),l.forEach(u=>{s[u]=o}),it.set(l,o)}),s}async unload(t){this._initialized||await this.init();const e=oe(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=oe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{it.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,n)=>e.indexOf(i)===n),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 Fi=new Yg;X.handleByList(S.LoadParser,Fi.loader.parsers).handleByList(S.ResolveParser,Fi.resolver.parsers).handleByList(S.CacheParser,Fi.cache.parsers).handleByList(S.DetectionParser,Fi.detections),X.add(Ff,$f,Df,Xf,kf,Lf,Nf,Vf,Yf,Qf,Og,Pl,jg,If,Gf,Ml,Hg);const Kg={loader:S.LoadParser,resolver:S.ResolveParser,cache:S.CacheParser,detection:S.DetectionParser};X.handle(S.Asset,r=>{const t=r.ref;Object.entries(Kg).filter(([e])=>!!t[e]).forEach(([e,i])=>{var n;return X.add(Object.assign(t[e],{extension:(n=t[e].extension)!=null?n:i}))})},r=>{const t=r.ref;Object.keys(Kg).filter(e=>!!t[e]).forEach(e=>X.remove(t[e]))});const rA={extension:{type:S.DetectionParser,priority:3},test:async()=>!!(await Ei()||Pi()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var iA=Object.defineProperty,nA=Object.defineProperties,sA=Object.getOwnPropertyDescriptors,qg=Object.getOwnPropertySymbols,aA=Object.prototype.hasOwnProperty,oA=Object.prototype.propertyIsEnumerable,Zg=(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={}))aA.call(t,e)&&Zg(r,e,t[e]);if(qg)for(var e of qg(t))oA.call(t,e)&&Zg(r,e,t[e]);return r},uA=(r,t)=>nA(r,sA(t));class Di extends ft{constructor(t){super(uA(lA({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let rs;function Rl(){if(rs)return rs;const r=H.get().createCanvas(1,1).getContext("webgl");return r?(rs=[...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"]:[]],rs):[]}let is;async function Ol(){if(is)return is;const r=await H.get().getNavigator().gpu.requestAdapter();return is=[...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"]:[]],is}let Gl;async function Il(){return Gl!==void 0||(Gl=await(async()=>{const r=await Ei(),t=Pi();if(r&&t){const e=await Ol(),i=Rl();return e.filter(n=>i.includes(n))}else{if(r)return await Ol();if(t)return Rl()}return[]})()),Gl}const Qg=["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 ns;async function Ui(){if(ns!==void 0)return ns;const r=await Il();return ns=[...Qg,...r],ns}const cA='(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 Wr=null,Jg=class{constructor(){Wr||(Wr=URL.createObjectURL(new Blob([cA],{type:"application/javascript"}))),this.worker=new Worker(Wr)}};Jg.revokeObjectURL=function(){Wr&&(URL.revokeObjectURL(Wr),Wr=null)};const ss={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function hA(r){Object.assign(ss,r)}let $i;const t_={};function dA(r){return $i||($i=new Jg().worker,$i.onmessage=t=>{const{success:e,url:i,textureOptions:n}=t.data;e||console.warn("Failed to load Basis texture",i),t_[i](n)},$i.postMessage({type:"init",jsUrl:ss.jsUrl,wasmUrl:ss.wasmUrl,supportedTextures:r})),$i}function e_(r,t){const e=dA(t);return new Promise(i=>{t_[r]=i,e.postMessage({type:"load",url:r})})}var pA=Object.defineProperty,fA=Object.defineProperties,mA=Object.getOwnPropertyDescriptors,r_=Object.getOwnPropertySymbols,gA=Object.prototype.hasOwnProperty,_A=Object.prototype.propertyIsEnumerable,i_=(r,t,e)=>t in r?pA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yA=(r,t)=>{for(var e in t||(t={}))gA.call(t,e)&&i_(r,e,t[e]);if(r_)for(var e of r_(t))_A.call(t,e)&&i_(r,e,t[e]);return r},bA=(r,t)=>fA(r,mA(t));const vA={extension:{type:S.LoadParser,priority:te.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return le(r,[".basis"])},async load(r,t,e){var i;const n=await Ui(),s=await e_(r,n),a=new Di(bA(yA({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function xA(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const n=[];for(let s=0;s<i;++s)for(let a=0;a<e;++a){const o=r.getImageTranscodedSizeInBytes(a,s,t),l=new Uint8Array(o);if(!r.transcodeImage(l,a,s,t,1,0))throw new Error("transcodeImage failed");n.push(l)}return n}const TA={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function SA(r){const t=TA[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const wA={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},PA={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var Bl=(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))(Bl||{}),Fl=(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))(Fl||{});function Bt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var qt=(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=Bt("UYVY")]="UYVY",r[r.R8G8_B8G8=Bt("RGBG")]="R8G8_B8G8",r[r.YUY2=Bt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Bt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Bt("DXT1")]="DXT1",r[r.DXT2=Bt("DXT2")]="DXT2",r[r.DXT3=Bt("DXT3")]="DXT3",r[r.DXT4=Bt("DXT4")]="DXT4",r[r.DXT5=Bt("DXT5")]="DXT5",r[r.ATI1=Bt("ATI1")]="ATI1",r[r.AT1N=Bt("AT1N")]="AT1N",r[r.ATI2=Bt("ATI2")]="ATI2",r[r.AT2N=Bt("AT2N")]="AT2N",r[r.BC4U=Bt("BC4U")]="BC4U",r[r.BC4S=Bt("BC4S")]="BC4S",r[r.BC5U=Bt("BC5U")]="BC5U",r[r.BC5S=Bt("BC5S")]="BC5S",r[r.DX10=Bt("DX10")]="DX10",r))(qt||{});const Dl={[qt.DXT1]:"bc1-rgba-unorm",[qt.DXT2]:"bc2-rgba-unorm",[qt.DXT3]:"bc2-rgba-unorm",[qt.DXT4]:"bc3-rgba-unorm",[qt.DXT5]:"bc3-rgba-unorm",[qt.ATI1]:"bc4-r-unorm",[qt.BC4U]:"bc4-r-unorm",[qt.BC4S]:"bc4-r-snorm",[qt.ATI2]:"bc5-rg-unorm",[qt.BC5U]:"bc5-rg-unorm",[qt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Zt={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"},Z={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:wA,HEADER_DX10_FIELDS:PA,DXGI_FORMAT:Bl,D3D10_RESOURCE_DIMENSION:Fl,D3DFMT:qt},n_={"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 s_(r,t){const{format:e,fourCC:i,width:n,height:s,dataOffset:a,mipmapCount:o}=AA(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(o<=1)return{format:e,width:n,height:s,resource:[new Uint8Array(r,a)],alphaMode:"no-premultiply-alpha"};const l=EA(e,n,s,a,o,r);return{format:e,width:n,height:s,resource:l,alphaMode:"no-premultiply-alpha"}}function EA(r,t,e,i,n,s){const a=[],o=n_[r];let l=t,u=e,c=i;for(let h=0;h<n;++h){const p=Math.ceil(Math.max(4,l)/4)*4,f=Math.ceil(Math.max(4,u)/4)*4,m=o?p/4*f/4*o:l*u*4,g=new Uint8Array(s,c,m);a.push(g),c+=m,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return a}function AA(r){const t=new Uint32Array(r,0,Z.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[Z.HEADER_FIELDS.MAGIC]!==Z.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[Z.HEADER_FIELDS.HEIGHT],i=t[Z.HEADER_FIELDS.WIDTH],n=Math.max(1,t[Z.HEADER_FIELDS.MIPMAP_COUNT]),s=t[Z.HEADER_FIELDS.PF_FLAGS],a=t[Z.HEADER_FIELDS.FOURCC],o=CA(t,s,a,r),l=Z.MAGIC_SIZE+Z.HEADER_SIZE+(a===Z.D3DFMT.DX10?Z.HEADER_DX10_SIZE:0);return{format:o,fourCC:a,width:i,height:e,dataOffset:l,mipmapCount:n}}function CA(r,t,e,i){if(t&Z.PIXEL_FORMAT_FLAGS.FOURCC){if(e===Z.D3DFMT.DX10){const n=new Uint32Array(i,Z.MAGIC_SIZE+Z.HEADER_SIZE,Z.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(n[Z.HEADER_DX10_FIELDS.MISC_FLAG]===Z.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(n[Z.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===Z.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const s=n[Z.HEADER_DX10_FIELDS.DXGI_FORMAT];if(s in Zt)return Zt[s];throw new Error(`DDSParser cannot parse texture data with DXGI format ${s}`)}if(e in Dl)return Dl[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&Z.PIXEL_FORMAT_FLAGS.RGB||t&Z.PIXEL_FORMAT_FLAGS.RGBA)return MA(r);throw t&Z.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&Z.PIXEL_FORMAT_FLAGS.LUMINANCE||t&Z.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&Z.PIXEL_FORMAT_FLAGS.ALPHA||t&Z.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 MA(r){const t=r[Z.HEADER_FIELDS.RGB_BITCOUNT],e=r[Z.HEADER_FIELDS.R_BIT_MASK],i=r[Z.HEADER_FIELDS.G_BIT_MASK],n=r[Z.HEADER_FIELDS.B_BIT_MASK],s=r[Z.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&n===16711680&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&n===255&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&n===1023&&s===3221225472)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&n===31&&s===32768)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&n===31&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&n===15&&s===61440)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&n===0&&s===65280)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration:
349 bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${s}`)}var RA=Object.defineProperty,OA=Object.defineProperties,GA=Object.getOwnPropertyDescriptors,a_=Object.getOwnPropertySymbols,IA=Object.prototype.hasOwnProperty,BA=Object.prototype.propertyIsEnumerable,o_=(r,t,e)=>t in r?RA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FA=(r,t)=>{for(var e in t||(t={}))IA.call(t,e)&&o_(r,e,t[e]);if(a_)for(var e of a_(t))BA.call(t,e)&&o_(r,e,t[e]);return r},DA=(r,t)=>OA(r,GA(t));const UA={extension:{type:S.LoadParser,priority:te.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return le(r,[".dds"])},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=s_(s,n),o=new Di(DA(FA({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var l_=(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))(l_||{}),$A=(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))($A||{}),kA=(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))(kA||{});const Pt={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 u_(r,t){const e=new DataView(r);if(!jA(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:n,glFormat:s,glInternalFormat:a,pixelWidth:o,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=XA(e),h=Pt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[a];if(!h)throw new Error(`Unknown texture format ${a}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=NA(n,s,a),f=LA(e,n,p,o,l,c,u,i);return{format:h,width:o,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function LA(r,t,e,i,n,s,a,o){const l=i+3&-4,u=n+3&-4;let c=i*n;t===0&&(c=l*u);let h=c*e,p=i,f=n,m=l,g=u,_=s;const y=new Array(a);for(let b=0;b<a;b++){const x=r.getUint32(_,o);let v=_+4;y[b]=new Uint8Array(r.buffer,v,h),v+=h,_+=x+4,_=_%4!==0?_+4-_%4:_,p=p>>1||1,f=f>>1||1,m=p+4-1&-4,g=f+4-1&-4,h=m*g*e}return y}function NA(r,t,e){let i=Pt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(Pt.TYPES_TO_BYTES_PER_COMPONENT[r]?i=Pt.TYPES_TO_BYTES_PER_COMPONENT[r]*Pt.FORMATS_TO_COMPONENTS[t]:i=Pt.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 XA(r){const t=r.getUint32(Pt.FIELDS.ENDIANNESS,!0)===Pt.ENDIANNESS,e=r.getUint32(Pt.FIELDS.GL_TYPE,t),i=r.getUint32(Pt.FIELDS.GL_FORMAT,t),n=r.getUint32(Pt.FIELDS.GL_INTERNAL_FORMAT,t),s=r.getUint32(Pt.FIELDS.PIXEL_WIDTH,t),a=r.getUint32(Pt.FIELDS.PIXEL_HEIGHT,t)||1,o=r.getUint32(Pt.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(Pt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(Pt.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(Pt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(Pt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(a===0||o!==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:n,pixelWidth:s,pixelHeight:a,numberOfMipmapLevels:c,offset:Pt.FILE_HEADER_SIZE+h}}function jA(r){for(let t=0;t<Pt.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==Pt.FILE_IDENTIFIER[t])return!1;return!0}var HA=Object.defineProperty,zA=Object.defineProperties,WA=Object.getOwnPropertyDescriptors,c_=Object.getOwnPropertySymbols,VA=Object.prototype.hasOwnProperty,YA=Object.prototype.propertyIsEnumerable,h_=(r,t,e)=>t in r?HA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KA=(r,t)=>{for(var e in t||(t={}))VA.call(t,e)&&h_(r,e,t[e]);if(c_)for(var e of c_(t))YA.call(t,e)&&h_(r,e,t[e]);return r},qA=(r,t)=>zA(r,WA(t));const ZA={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return le(r,".ktx")},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=u_(s,n),o=new Di(qA(KA({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},QA='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e<o.length;e++)o[e]=n(o[e]);r.format=s[t].convertedFormat}}function i(r){const t=r.byteLength/3,n=new Uint32Array(t);for(let o=0;o<t;++o)n[o]=r[o*3]+(r[o*3+1]<<8)+(r[o*3+2]<<16)+4278190080;return new Uint8Array(n.buffer)}function d(r){const t=[];for(let n=0;n<r.numLevels;n++){const o=r.getImageData(n,0,0),e=new Uint8Array(o.byteLength);e.set(o),t.push(e)}return t}const w={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function p(r){const t=w[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const h={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function F(r){const t=h[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function U(r){return r.classId===2?F(r.vkFormat):p(r.glInternalformat)}const y={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function T(r){const t=y[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const a={jsUrl:"",wasmUrl:""};let l,u,c;async function g(){if(!c){const r=new URL(a.jsUrl,location.origin).href,t=new URL(a.wasmUrl,location.origin).href;importScripts(r),c=new Promise(n=>{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=T(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=(async r=>{var t;const n=r.data;try{const o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}catch(o){self.postMessage({type:"error",err:o,url:n.url})}})})();\n';let Vr=null;class d_{constructor(){Vr||(Vr=URL.createObjectURL(new Blob([QA],{type:"application/javascript"}))),this.worker=new Worker(Vr)}}d_.revokeObjectURL=function(){Vr&&(URL.revokeObjectURL(Vr),Vr=null)};const as={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function JA(r){Object.assign(as,r)}let ki;const p_={},f_={};function tC(r){return ki||(ki=new d_().worker,ki.onmessage=t=>{const{err:e,success:i,url:n,textureOptions:s}=t.data;if(e){f_[n](e);return}i||console.warn("Failed to load KTX texture",n),p_[n](s)},ki.postMessage({type:"init",jsUrl:as.jsUrl,wasmUrl:as.wasmUrl,supportedTextures:r})),ki}function m_(r,t){const e=tC(t);return new Promise((i,n)=>{p_[r]=i,f_[r]=n,e.postMessage({type:"load",url:r})})}var eC=Object.defineProperty,rC=Object.defineProperties,iC=Object.getOwnPropertyDescriptors,g_=Object.getOwnPropertySymbols,nC=Object.prototype.hasOwnProperty,sC=Object.prototype.propertyIsEnumerable,__=(r,t,e)=>t in r?eC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aC=(r,t)=>{for(var e in t||(t={}))nC.call(t,e)&&__(r,e,t[e]);if(g_)for(var e of g_(t))sC.call(t,e)&&__(r,e,t[e]);return r},oC=(r,t)=>rC(r,iC(t));const lC={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return le(r,".ktx2")},async load(r,t,e){var i;const n=await Ui(),s=await m_(r,n),a=new Di(oC(aC({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ul={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:y_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:y_}};function uC(r){const t=r.format;if(Ul[t]){const e=Ul[t].convertFunction,i=r.resource;for(let n=0;n<i.length;n++)i[n]=e(i[n]);r.format=Ul[t].convertedFormat}}function y_(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 cC(r){const t=[];for(let e=0;e<r.numLevels;e++){const i=r.getImageData(e,0,0),n=new Uint8Array(i.byteLength);n.set(i),t.push(n)}return t}const hC={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 b_(r){const t=hC[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const dC={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function v_(r){const t=dC[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function pC(r){return r.classId===2?v_(r.vkFormat):b_(r.glInternalformat)}const fC={"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 mC(r){const t=fC[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const os=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],gC={extension:S.ResolveParser,test:r=>le(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const n=r.split(".");if(n.length>2){const s=n[n.length-2];os.includes(s)&&(i=s)}else i=n[n.length-1];return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let ls;const _C={extension:{type:S.DetectionParser,priority:2},test:async()=>!!(await Ei()||Pi()),add:async r=>{const t=await Il();return ls=yC(t),[...ls,...r]},remove:async r=>ls?r.filter(t=>!(t in ls)):r};function yC(r){const t=["basis"],e={};return r.forEach(i=>{const n=i.split("-")[0];n&&!e[n]&&(e[n]=!0,t.push(n))}),t.sort((i,n)=>{const s=os.indexOf(i),a=os.indexOf(n);return s===-1?1:a===-1?-1:s-a}),t}const bC=new Mt,vC=new U,Li=new ut,$l=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){if(t.cullable&&t.measurable&&t.includeInBuild)if(t.cullArea){Li.x=e.x,Li.y=e.y,Li.width=e.width,Li.height=e.height;const n=i?t.worldTransform:t.getGlobalTransform(vC,i);t.culled=!Li.intersects(t.cullArea,n)}else{const n=li(t,i,bC);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)}};$l.shared=new $l;let x_=$l;class T_{static init(t){this._renderRef=this.render.bind(this),this.render=()=>{var e;const i=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;x_.shared.cull(this.stage,this.renderer.screen,i),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}T_.extension={priority:10,type:S.Application,name:"culler"};const xC={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return fw})}};var S_=`
350 in vec2 vTextureCoord;
351 in vec4 vColor;
352
353 out vec4 finalColor;
354
355 uniform float uBlend;
356
357 uniform sampler2D uTexture;
358 uniform sampler2D uBackTexture;
359
360 {FUNCTIONS}
361
362 void main()
363 {
364 vec4 back = texture(uBackTexture, vTextureCoord);
365 vec4 front = texture(uTexture, vTextureCoord);
366 float blendedAlpha = front.a + back.a * (1.0 - front.a);
367
368 {MAIN}
369 }
370 `,w_=`in vec2 aPosition;
371 out vec2 vTextureCoord;
372 out vec2 backgroundUv;
373
374 uniform vec4 uInputSize;
375 uniform vec4 uOutputFrame;
376 uniform vec4 uOutputTexture;
377
378 vec4 filterVertexPosition( void )
379 {
380 vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
381
382 position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
383 position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
384
385 return vec4(position, 0.0, 1.0);
386 }
387
388 vec2 filterTextureCoord( void )
389 {
390 return aPosition * (uOutputFrame.zw * uInputSize.zw);
391 }
392
393 void main(void)
394 {
395 gl_Position = filterVertexPosition();
396 vTextureCoord = filterTextureCoord();
397 }
398 `,P_=`
399 struct GlobalFilterUniforms {
400 uInputSize:vec4<f32>,
401 uInputPixel:vec4<f32>,
402 uInputClamp:vec4<f32>,
403 uOutputFrame:vec4<f32>,
404 uGlobalFrame:vec4<f32>,
405 uOutputTexture:vec4<f32>,
406 };
407
408 struct BlendUniforms {
409 uBlend:f32,
410 };
411
412 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
413 @group(0) @binding(1) var uTexture: texture_2d<f32>;
414 @group(0) @binding(2) var uSampler : sampler;
415 @group(0) @binding(3) var uBackTexture: texture_2d<f32>;
416
417 @group(1) @binding(0) var<uniform> blendUniforms : BlendUniforms;
418
419
420 struct VSOutput {
421 @builtin(position) position: vec4<f32>,
422 @location(0) uv : vec2<f32>
423 };
424
425 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
426 {
427 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
428
429 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
430 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
431
432 return vec4(position, 0.0, 1.0);
433 }
434
435 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
436 {
437 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
438 }
439
440 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
441 {
442 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
443 }
444
445 @vertex
446 fn mainVertex(
447 @location(0) aPosition : vec2<f32>,
448 ) -> VSOutput {
449 return VSOutput(
450 filterVertexPosition(aPosition),
451 filterTextureCoord(aPosition)
452 );
453 }
454
455 {FUNCTIONS}
456
457 @fragment
458 fn mainFragment(
459 @location(0) uv: vec2<f32>
460 ) -> @location(0) vec4<f32> {
461
462
463 var back = textureSample(uBackTexture, uSampler, uv);
464 var front = textureSample(uTexture, uSampler, uv);
465 var blendedAlpha = front.a + back.a * (1.0 - front.a);
466
467 var out = vec4<f32>(0.0,0.0,0.0,0.0);
468
469 {MAIN}
470
471 return out;
472 }`,TC=Object.defineProperty,E_=Object.getOwnPropertySymbols,SC=Object.prototype.hasOwnProperty,wC=Object.prototype.propertyIsEnumerable,A_=(r,t,e)=>t in r?TC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C_=(r,t)=>{for(var e in t||(t={}))SC.call(t,e)&&A_(r,e,t[e]);if(E_)for(var e of E_(t))wC.call(t,e)&&A_(r,e,t[e]);return r};class PC extends Ee{constructor(t){const e=t.gpu,i=M_(C_({source:P_},e)),n=Xt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),s=t.gl,a=M_(C_({source:S_},s)),o=Wt.from({vertex:w_,fragment:a}),l=new At({uBlend:{value:1,type:"f32"}});super({gpuProgram:n,glProgram:o,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:D.EMPTY}})}}function M_(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const EC=`
473 float getLuminosity(vec3 c) {
474 return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
475 }
476
477 vec3 setLuminosity(vec3 c, float lum) {
478 float modLum = lum - getLuminosity(c);
479 vec3 color = c.rgb + vec3(modLum);
480
481 // clip back into legal range
482 modLum = getLuminosity(color);
483 vec3 modLumVec = vec3(modLum);
484
485 float cMin = min(color.r, min(color.g, color.b));
486 float cMax = max(color.r, max(color.g, color.b));
487
488 if(cMin < 0.0) {
489 color = mix(modLumVec, color, modLum / (modLum - cMin));
490 }
491
492 if(cMax > 1.0) {
493 color = mix(modLumVec, color, (1.0 - modLum) / (cMax - modLum));
494 }
495
496 return color;
497 }
498
499 float getSaturation(vec3 c) {
500 return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
501 }
502
503 vec3 setSaturationMinMidMax(vec3 cSorted, float s) {
504 vec3 colorSorted = cSorted;
505
506 if(colorSorted.z > colorSorted.x) {
507 colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
508 colorSorted.z = s;
509 }
510 else {
511 colorSorted.y = 0.0;
512 colorSorted.z = 0.0;
513 }
514
515 colorSorted.x = 0.0;
516
517 return colorSorted;
518 }
519
520 vec3 setSaturation(vec3 c, float s) {
521 vec3 color = c;
522
523 if(color.r <= color.g && color.r <= color.b) {
524 if(color.g <= color.b) {
525 color = setSaturationMinMidMax(color.rgb, s).rgb;
526 }
527 else {
528 color = setSaturationMinMidMax(color.rbg, s).rbg;
529 }
530 }
531 else if(color.g <= color.r && color.g <= color.b) {
532 if(color.r <= color.b) {
533 color = setSaturationMinMidMax(color.grb, s).grb;
534 }
535 else {
536 color = setSaturationMinMidMax(color.gbr, s).gbr;
537 }
538 }
539 else {
540 // Using bgr for both fixes part of hue
541 if(color.r <= color.g) {
542 color = setSaturationMinMidMax(color.brg, s).brg;
543 }
544 else {
545 color = setSaturationMinMidMax(color.bgr, s).bgr;
546 }
547 }
548
549 return color;
550 }
551 `,AC=`
552 fn getLuminosity(c: vec3<f32>) -> f32
553 {
554 return 0.3*c.r + 0.59*c.g + 0.11*c.b;
555 }
556
557 fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32>
558 {
559 var modLum: f32 = lum - getLuminosity(c);
560 var color: vec3<f32> = c.rgb + modLum;
561
562 // clip back into legal range
563 modLum = getLuminosity(color);
564 let modLumVec = vec3<f32>(modLum);
565
566 let cMin: f32 = min(color.r, min(color.g, color.b));
567 let cMax: f32 = max(color.r, max(color.g, color.b));
568
569 if(cMin < 0.0)
570 {
571 color = mix(modLumVec, color, modLum / (modLum - cMin));
572 }
573
574 if(cMax > 1.0)
575 {
576 color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum));
577 }
578
579 return color;
580 }
581
582 fn getSaturation(c: vec3<f32>) -> f32
583 {
584 return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
585 }
586
587 fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32>
588 {
589 var colorSorted = cSorted;
590
591 if(colorSorted.z > colorSorted.x)
592 {
593 colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
594 colorSorted.z = s;
595 }
596 else
597 {
598 colorSorted.y = 0;
599 colorSorted.z = 0;
600 }
601
602 colorSorted.x = 0;
603
604 return colorSorted;
605 }
606
607 fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32>
608 {
609 var color = c;
610
611 if (color.r <= color.g && color.r <= color.b)
612 {
613 if (color.g <= color.b)
614 {
615 color = vec3<f32>(setSaturationMinMidMax(color.rgb, s)).rgb;
616 }
617 else
618 {
619 color = vec3<f32>(setSaturationMinMidMax(color.rbg, s)).rbg;
620 }
621 }
622 else if (color.g <= color.r && color.g <= color.b)
623 {
624 if (color.r <= color.b)
625 {
626 color = vec3<f32>(setSaturationMinMidMax(color.grb, s)).grb;
627 }
628 else
629 {
630 color = vec3<f32>(setSaturationMinMidMax(color.gbr, s)).gbr;
631 }
632 }
633 else
634 {
635 // Using bgr for both fixes part of hue
636 if (color.r <= color.g)
637 {
638 color = vec3<f32>(setSaturationMinMidMax(color.brg, s)).brg;
639 }
640 else
641 {
642 color = vec3<f32>(setSaturationMinMidMax(color.bgr, s)).bgr;
643 }
644 }
645
646 return color;
647 }
648 `;var R_=`
649 in vec2 vTextureCoord;
650
651 out vec4 finalColor;
652
653 uniform float uAlpha;
654 uniform sampler2D uTexture;
655
656 void main()
657 {
658 finalColor = texture(uTexture, vTextureCoord) * uAlpha;
659 }
660 `,kl=`struct GlobalFilterUniforms {
661 uInputSize:vec4<f32>,
662 uInputPixel:vec4<f32>,
663 uInputClamp:vec4<f32>,
664 uOutputFrame:vec4<f32>,
665 uGlobalFrame:vec4<f32>,
666 uOutputTexture:vec4<f32>,
667 };
668
669 struct AlphaUniforms {
670 uAlpha:f32,
671 };
672
673 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
674 @group(0) @binding(1) var uTexture: texture_2d<f32>;
675 @group(0) @binding(2) var uSampler : sampler;
676
677 @group(1) @binding(0) var<uniform> alphaUniforms : AlphaUniforms;
678
679 struct VSOutput {
680 @builtin(position) position: vec4<f32>,
681 @location(0) uv : vec2<f32>
682 };
683
684 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
685 {
686 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
687
688 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
689 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
690
691 return vec4(position, 0.0, 1.0);
692 }
693
694 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
695 {
696 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
697 }
698
699 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
700 {
701 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
702 }
703
704 fn getSize() -> vec2<f32>
705 {
706 return gfu.uGlobalFrame.zw;
707 }
708
709 @vertex
710 fn mainVertex(
711 @location(0) aPosition : vec2<f32>,
712 ) -> VSOutput {
713 return VSOutput(
714 filterVertexPosition(aPosition),
715 filterTextureCoord(aPosition)
716 );
717 }
718
719 @fragment
720 fn mainFragment(
721 @location(0) uv: vec2<f32>,
722 @builtin(position) position: vec4<f32>
723 ) -> @location(0) vec4<f32> {
724
725 var sample = textureSample(uTexture, uSampler, uv);
726
727 return sample * alphaUniforms.uAlpha;
728 }`,CC=Object.defineProperty,MC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,us=Object.getOwnPropertySymbols,O_=Object.prototype.hasOwnProperty,G_=Object.prototype.propertyIsEnumerable,I_=(r,t,e)=>t in r?CC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ll=(r,t)=>{for(var e in t||(t={}))O_.call(t,e)&&I_(r,e,t[e]);if(us)for(var e of us(t))G_.call(t,e)&&I_(r,e,t[e]);return r},OC=(r,t)=>MC(r,RC(t)),GC=(r,t)=>{var e={};for(var i in r)O_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&us)for(var i of us(r))t.indexOf(i)<0&&G_.call(r,i)&&(e[i]=r[i]);return e};const B_=class F1 extends Ee{constructor(t){t=Ll(Ll({},F1.defaultOptions),t);const e=Xt.from({vertex:{source:kl,entryPoint:"mainVertex"},fragment:{source:kl,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:R_,name:"alpha-filter"}),n=t,{alpha:s}=n,a=GC(n,["alpha"]),o=new At({uAlpha:{value:s,type:"f32"}});super(OC(Ll({},a),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:o}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};B_.defaultOptions={alpha:1};let IC=B_;const Nl={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]},BC=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(`
729 `);function F_(r){const t=Nl[r],e=t.length;let i="";const n="finalColor = ",s=" + ",a="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let o=0;o<r;o++){const l=o===0?n:s,u=o<e?o:r-o-1,c=a.replace("%index%",o.toString()).replace("%value%",t[u].toString());i+=`${l}${c}
730 `}return BC.replace("%blur%",`${i};`).replace("%size%",r.toString())}const FC=`
731 in vec2 aPosition;
732
733 uniform float uStrength;
734
735 out vec2 vBlurTexCoords[%size%];
736
737 uniform vec4 uInputSize;
738 uniform vec4 uOutputFrame;
739 uniform vec4 uOutputTexture;
740
741 vec4 filterVertexPosition( void )
742 {
743 vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
744
745 position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
746 position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
747
748 return vec4(position, 0.0, 1.0);
749 }
750
751 vec2 filterTextureCoord( void )
752 {
753 return aPosition * (uOutputFrame.zw * uInputSize.zw);
754 }
755
756 void main(void)
757 {
758 gl_Position = filterVertexPosition();
759
760 float pixelStrength = uInputSize.%dimension% * uStrength;
761
762 vec2 textureCoord = filterTextureCoord();
763 %blur%
764 }`;function D_(r,t){const e=Math.ceil(r/2);let i=FC,n="",s;t?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let a=0;a<r;a++){let o=s.replace("%index%",a.toString());o=o.replace("%sampleIndex%",`${a-(e-1)}.0`),n+=o,n+=`
765 `}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i=i.replace("%dimension%",t?"z":"w"),i}function U_(r,t){const e=D_(t,r),i=F_(t);return Wt.from({vertex:e,fragment:i,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var $_=`
766
767 struct GlobalFilterUniforms {
768 uInputSize:vec4<f32>,
769 uInputPixel:vec4<f32>,
770 uInputClamp:vec4<f32>,
771 uOutputFrame:vec4<f32>,
772 uGlobalFrame:vec4<f32>,
773 uOutputTexture:vec4<f32>,
774 };
775
776 struct BlurUniforms {
777 uStrength:f32,
778 };
779
780 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
781 @group(0) @binding(1) var uTexture: texture_2d<f32>;
782 @group(0) @binding(2) var uSampler : sampler;
783
784 @group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
785
786
787 struct VSOutput {
788 @builtin(position) position: vec4<f32>,
789 %blur-struct%
790 };
791
792 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
793 {
794 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
795
796 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
797 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
798
799 return vec4(position, 0.0, 1.0);
800 }
801
802 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
803 {
804 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
805 }
806
807 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
808 {
809 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
810 }
811
812 fn getSize() -> vec2<f32>
813 {
814 return gfu.uGlobalFrame.zw;
815 }
816
817
818 @vertex
819 fn mainVertex(
820 @location(0) aPosition : vec2<f32>,
821 ) -> VSOutput {
822
823 let filteredCord = filterTextureCoord(aPosition);
824
825 let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
826
827 return VSOutput(
828 filterVertexPosition(aPosition),
829 %blur-vertex-out%
830 );
831 }
832
833 @fragment
834 fn mainFragment(
835 @builtin(position) position: vec4<f32>,
836 %blur-fragment-in%
837 ) -> @location(0) vec4<f32> {
838
839 var finalColor = vec4(0.0);
840
841 %blur-sampling%
842
843 return finalColor;
844 }
845 `;function k_(r,t){const e=Nl[t],i=e.length,n=[],s=[],a=[];for(let h=0;h<t;h++){n[h]=`@location(${h}) offset${h}: vec2<f32>,`,r?s[h]=`filteredCord + vec2(${h-i+1} * pixelStrength, 0.0),`:s[h]=`filteredCord + vec2(0.0, ${h-i+1} * pixelStrength),`;const p=h<i?h:t-h-1,f=e[p].toString();a[h]=`finalColor += textureSample(uTexture, uSampler, offset${h}) * ${f};`}const o=n.join(`
846 `),l=s.join(`
847 `),u=a.join(`
848 `),c=$_.replace("%blur-struct%",o).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",o).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return Xt.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}var DC=Object.defineProperty,L_=Object.getOwnPropertySymbols,UC=Object.prototype.hasOwnProperty,$C=Object.prototype.propertyIsEnumerable,N_=(r,t,e)=>t in r?DC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xl=(r,t)=>{for(var e in t||(t={}))UC.call(t,e)&&N_(r,e,t[e]);if(L_)for(var e of L_(t))$C.call(t,e)&&N_(r,e,t[e]);return r};const X_=class D1 extends Ee{constructor(t){var e;t=Xl(Xl({},D1.defaultOptions),t);const i=U_(t.horizontal,t.kernelSize),n=k_(t.horizontal,t.kernelSize);super(Xl({glProgram:i,gpuProgram:n,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this.legacy=(e=t.legacy)!=null?e:!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,i,n){this.legacy?this._applyLegacy(t,e,i,n):this._applyOptimized(t,e,i,n)}_applyLegacy(t,e,i,n){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,n);else{const s=vt.getSameSizeTexture(e);let a=e,o=s;this._state.blend=!1;const l=t.renderer.type===It.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,a,o,u===0?!0:l);const c=o;o=a,a=c}this._state.blend=!0,t.applyFilter(this,a,i,n),vt.returnTexture(s)}}_applyOptimized(t,e,i,n){if(this._uniforms.uStrength=this._calculateInitialStrength(),this.passes===1)t.applyFilter(this,e,i,n);else{const s=vt.getSameSizeTexture(e);let a=e,o=s;this._state.blend=!1;const l=t.renderer,u=l.type===It.WEBGPU,c=u?l.renderPipes.uniformBatch:null;for(let h=0;h<this.passes-1;h++){c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),t.applyFilter(this,a,o,u);const p=o;o=a,a=p,this._uniforms.uStrength*=.5}c&&this.groups[1].setResource(c.getUboResource(this._blurUniforms),0),this._state.blend=!0,t.applyFilter(this,a,i,n),vt.returnTexture(s)}}_calculateInitialStrength(){let t=1,e=.5;for(let i=1;i<this.passes;i++)t+=e*e,e*=.5;return this.strength/Math.sqrt(t)}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};X_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};let cs=X_;var kC=Object.defineProperty,LC=Object.defineProperties,NC=Object.getOwnPropertyDescriptors,hs=Object.getOwnPropertySymbols,j_=Object.prototype.hasOwnProperty,H_=Object.prototype.propertyIsEnumerable,z_=(r,t,e)=>t in r?kC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ni=(r,t)=>{for(var e in t||(t={}))j_.call(t,e)&&z_(r,e,t[e]);if(hs)for(var e of hs(t))H_.call(t,e)&&z_(r,e,t[e]);return r},XC=(r,t)=>LC(r,NC(t)),jC=(r,t)=>{var e={};for(var i in r)j_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&hs)for(var i of hs(r))t.indexOf(i)<0&&H_.call(r,i)&&(e[i]=r[i]);return e};class W_ extends Ee{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=Ni(Ni({},cs.defaultOptions),i);const n=i,{strength:s,strengthX:a,strengthY:o,quality:l}=n,u=jC(n,["strength","strengthX","strengthY","quality"]);super(XC(Ni({},u),{compatibleRenderers:It.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new cs(Ni({horizontal:!0},i)),this.blurYFilter=new cs(Ni({horizontal:!1},i)),this.quality=l,this.strengthX=a!=null?a:s,this.strengthY=o!=null?o:s,this.repeatEdgePixels=!1}apply(t,e,i,n){const s=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(s&&a){const o=vt.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,o,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,o,i,n),vt.returnTexture(o)}else a?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,n)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,n))}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()}}W_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var V_=`
849 in vec2 vTextureCoord;
850 in vec4 vColor;
851
852 out vec4 finalColor;
853
854 uniform float uColorMatrix[20];
855 uniform float uAlpha;
856
857 uniform sampler2D uTexture;
858
859 float rand(vec2 co)
860 {
861 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
862 }
863
864 void main()
865 {
866 vec4 color = texture(uTexture, vTextureCoord);
867 float randomValue = rand(gl_FragCoord.xy * 0.2);
868 float diff = (randomValue - 0.5) * 0.5;
869
870 if (uAlpha == 0.0) {
871 finalColor = color;
872 return;
873 }
874
875 if (color.a > 0.0) {
876 color.rgb /= color.a;
877 }
878
879 vec4 result;
880
881 result.r = (uColorMatrix[0] * color.r);
882 result.r += (uColorMatrix[1] * color.g);
883 result.r += (uColorMatrix[2] * color.b);
884 result.r += (uColorMatrix[3] * color.a);
885 result.r += uColorMatrix[4];
886
887 result.g = (uColorMatrix[5] * color.r);
888 result.g += (uColorMatrix[6] * color.g);
889 result.g += (uColorMatrix[7] * color.b);
890 result.g += (uColorMatrix[8] * color.a);
891 result.g += uColorMatrix[9];
892
893 result.b = (uColorMatrix[10] * color.r);
894 result.b += (uColorMatrix[11] * color.g);
895 result.b += (uColorMatrix[12] * color.b);
896 result.b += (uColorMatrix[13] * color.a);
897 result.b += uColorMatrix[14];
898
899 result.a = (uColorMatrix[15] * color.r);
900 result.a += (uColorMatrix[16] * color.g);
901 result.a += (uColorMatrix[17] * color.b);
902 result.a += (uColorMatrix[18] * color.a);
903 result.a += uColorMatrix[19];
904
905 vec3 rgb = mix(color.rgb, result.rgb, uAlpha);
906
907 // Premultiply alpha again.
908 rgb *= result.a;
909
910 finalColor = vec4(rgb, result.a);
911 }
912 `,jl=`struct GlobalFilterUniforms {
913 uInputSize:vec4<f32>,
914 uInputPixel:vec4<f32>,
915 uInputClamp:vec4<f32>,
916 uOutputFrame:vec4<f32>,
917 uGlobalFrame:vec4<f32>,
918 uOutputTexture:vec4<f32>,
919 };
920
921 struct ColorMatrixUniforms {
922 uColorMatrix:array<vec4<f32>, 5>,
923 uAlpha:f32,
924 };
925
926
927 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
928 @group(0) @binding(1) var uTexture: texture_2d<f32>;
929 @group(0) @binding(2) var uSampler : sampler;
930 @group(1) @binding(0) var<uniform> colorMatrixUniforms : ColorMatrixUniforms;
931
932
933 struct VSOutput {
934 @builtin(position) position: vec4<f32>,
935 @location(0) uv : vec2<f32>,
936 };
937
938 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
939 {
940 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
941
942 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
943 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
944
945 return vec4(position, 0.0, 1.0);
946 }
947
948 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
949 {
950 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
951 }
952
953 @vertex
954 fn mainVertex(
955 @location(0) aPosition : vec2<f32>,
956 ) -> VSOutput {
957 return VSOutput(
958 filterVertexPosition(aPosition),
959 filterTextureCoord(aPosition),
960 );
961 }
962
963
964 @fragment
965 fn mainFragment(
966 @location(0) uv: vec2<f32>,
967 ) -> @location(0) vec4<f32> {
968
969
970 var c = textureSample(uTexture, uSampler, uv);
971
972 if (colorMatrixUniforms.uAlpha == 0.0) {
973 return c;
974 }
975
976
977 // Un-premultiply alpha before applying the color matrix. See issue #3539.
978 if (c.a > 0.0) {
979 c.r /= c.a;
980 c.g /= c.a;
981 c.b /= c.a;
982 }
983
984 var cm = colorMatrixUniforms.uColorMatrix;
985
986
987 var result = vec4<f32>(0.);
988
989 result.r = (cm[0][0] * c.r);
990 result.r += (cm[0][1] * c.g);
991 result.r += (cm[0][2] * c.b);
992 result.r += (cm[0][3] * c.a);
993 result.r += cm[1][0];
994
995 result.g = (cm[1][1] * c.r);
996 result.g += (cm[1][2] * c.g);
997 result.g += (cm[1][3] * c.b);
998 result.g += (cm[2][0] * c.a);
999 result.g += cm[2][1];
1000
1001 result.b = (cm[2][2] * c.r);
1002 result.b += (cm[2][3] * c.g);
1003 result.b += (cm[3][0] * c.b);
1004 result.b += (cm[3][1] * c.a);
1005 result.b += cm[3][2];
1006
1007 result.a = (cm[3][3] * c.r);
1008 result.a += (cm[4][0] * c.g);
1009 result.a += (cm[4][1] * c.b);
1010 result.a += (cm[4][2] * c.a);
1011 result.a += cm[4][3];
1012
1013 var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha);
1014
1015 rgb.r *= result.a;
1016 rgb.g *= result.a;
1017 rgb.b *= result.a;
1018
1019 return vec4(rgb, result.a);
1020 }`,HC=Object.defineProperty,zC=Object.defineProperties,WC=Object.getOwnPropertyDescriptors,Y_=Object.getOwnPropertySymbols,VC=Object.prototype.hasOwnProperty,YC=Object.prototype.propertyIsEnumerable,K_=(r,t,e)=>t in r?HC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KC=(r,t)=>{for(var e in t||(t={}))VC.call(t,e)&&K_(r,e,t[e]);if(Y_)for(var e of Y_(t))YC.call(t,e)&&K_(r,e,t[e]);return r},qC=(r,t)=>zC(r,WC(t));class ZC extends Ee{constructor(t={}){const e=new At({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),i=Xt.from({vertex:{source:jl,entryPoint:"mainVertex"},fragment:{source:jl,entryPoint:"mainFragment"}}),n=Wt.from({vertex:bi,fragment:V_,name:"color-matrix-filter"});super(qC(KC({},t),{gpuProgram:i,glProgram:n,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){if(e){const i=[...t];this._multiply(i,this.matrix,t),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t;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}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,n,s]=tt.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,n,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(a,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),n=Math.sin(t),s=Math.sqrt,a=1/3,o=s(a),l=i+(1-i)*a,u=a*(1-i)-o*n,c=a*(1-i)+o*n,h=a*(1-i)+o*n,p=i+a*(1-i),f=a*(1-i)-o*n,m=a*(1-i)-o*n,g=a*(1-i)+o*n,_=i+a*(1-i),y=[l,u,c,0,0,h,p,f,0,0,m,g,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=t*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,.046249425232852304,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.2758903984886823,-.231103377548616,-.7501899197440212,1.847597816108189,0,.12137623870388682,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,.24991995145868634,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,.09698983488904393,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,.13972481597886063,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,.1860075629647401,-.037703249837783157,.8609577587992641,.15059552388459913,0,-.14497417640467167,.24113635128153335,-.07441037908422492,.44972182064877153,0,-.029655197167024642,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,.037848179746251466,.02578397704808868,.6441188644374771,.03259127616149294,0,.029265996770472907,.0466055556782719,-.0851232987247891,.5241648018700465,0,.020232119953863904,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,n,s){t||(t=.2),e||(e=.15),i||(i=16770432),n||(n=3375104);const a=tt.shared,[o,l,u]=a.setValue(i).toArray(),[c,h,p]=a.setValue(n).toArray(),f=[.3,.59,.11,0,0,o,l,u,t,0,c,h,p,e,0,o-c,l-h,u-p,0,0];this._loadMatrix(f,s)}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 q_=`
1021 in vec2 vTextureCoord;
1022 in vec2 vFilterUv;
1023
1024 out vec4 finalColor;
1025
1026 uniform sampler2D uTexture;
1027 uniform sampler2D uMapTexture;
1028
1029 uniform vec4 uInputClamp;
1030 uniform highp vec4 uInputSize;
1031 uniform mat2 uRotation;
1032 uniform vec2 uScale;
1033
1034 void main()
1035 {
1036 vec4 map = texture(uMapTexture, vFilterUv);
1037
1038 vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale;
1039
1040 finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw));
1041 }
1042 `,Z_=`in vec2 aPosition;
1043 out vec2 vTextureCoord;
1044 out vec2 vFilterUv;
1045
1046
1047 uniform vec4 uInputSize;
1048 uniform vec4 uOutputFrame;
1049 uniform vec4 uOutputTexture;
1050
1051 uniform mat3 uFilterMatrix;
1052
1053 vec4 filterVertexPosition( void )
1054 {
1055 vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
1056
1057 position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
1058 position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
1059
1060 return vec4(position, 0.0, 1.0);
1061 }
1062
1063 vec2 filterTextureCoord( void )
1064 {
1065 return aPosition * (uOutputFrame.zw * uInputSize.zw);
1066 }
1067
1068 vec2 getFilterCoord( void )
1069 {
1070 return ( uFilterMatrix * vec3( filterTextureCoord(), 1.0) ).xy;
1071 }
1072
1073
1074 void main(void)
1075 {
1076 gl_Position = filterVertexPosition();
1077 vTextureCoord = filterTextureCoord();
1078 vFilterUv = getFilterCoord();
1079 }
1080 `,Hl=`
1081 struct GlobalFilterUniforms {
1082 uInputSize:vec4<f32>,
1083 uInputPixel:vec4<f32>,
1084 uInputClamp:vec4<f32>,
1085 uOutputFrame:vec4<f32>,
1086 uGlobalFrame:vec4<f32>,
1087 uOutputTexture:vec4<f32>,
1088 };
1089
1090 struct DisplacementUniforms {
1091 uFilterMatrix:mat3x3<f32>,
1092 uScale:vec2<f32>,
1093 uRotation:mat2x2<f32>
1094 };
1095
1096
1097
1098 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
1099 @group(0) @binding(1) var uTexture: texture_2d<f32>;
1100 @group(0) @binding(2) var uSampler : sampler;
1101
1102 @group(1) @binding(0) var<uniform> filterUniforms : DisplacementUniforms;
1103 @group(1) @binding(1) var uMapTexture: texture_2d<f32>;
1104 @group(1) @binding(2) var uMapSampler : sampler;
1105
1106 struct VSOutput {
1107 @builtin(position) position: vec4<f32>,
1108 @location(0) uv : vec2<f32>,
1109 @location(1) filterUv : vec2<f32>,
1110 };
1111
1112 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
1113 {
1114 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
1115
1116 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
1117 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
1118
1119 return vec4(position, 0.0, 1.0);
1120 }
1121
1122 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1123 {
1124 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
1125 }
1126
1127 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1128 {
1129 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
1130 }
1131
1132 fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
1133 {
1134 return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
1135 }
1136
1137 fn getSize() -> vec2<f32>
1138 {
1139
1140
1141 return gfu.uGlobalFrame.zw;
1142 }
1143
1144 @vertex
1145 fn mainVertex(
1146 @location(0) aPosition : vec2<f32>,
1147 ) -> VSOutput {
1148 return VSOutput(
1149 filterVertexPosition(aPosition),
1150 filterTextureCoord(aPosition),
1151 getFilterCoord(aPosition)
1152 );
1153 }
1154
1155 @fragment
1156 fn mainFragment(
1157 @location(0) uv: vec2<f32>,
1158 @location(1) filterUv: vec2<f32>,
1159 @builtin(position) position: vec4<f32>
1160 ) -> @location(0) vec4<f32> {
1161
1162 var map = textureSample(uMapTexture, uMapSampler, filterUv);
1163
1164 var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale;
1165
1166 return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw));
1167 }`,QC=Object.defineProperty,JC=Object.defineProperties,tM=Object.getOwnPropertyDescriptors,ds=Object.getOwnPropertySymbols,Q_=Object.prototype.hasOwnProperty,J_=Object.prototype.propertyIsEnumerable,ty=(r,t,e)=>t in r?QC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eM=(r,t)=>{for(var e in t||(t={}))Q_.call(t,e)&&ty(r,e,t[e]);if(ds)for(var e of ds(t))J_.call(t,e)&&ty(r,e,t[e]);return r},rM=(r,t)=>JC(r,tM(t)),iM=(r,t)=>{var e={};for(var i in r)Q_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ds)for(var i of ds(r))t.indexOf(i)<0&&J_.call(r,i)&&(e[i]=r[i]);return e};class nM extends Ee{constructor(...t){let e=t[0];e instanceof pe&&(e={sprite:e,scale:t[1]});const i=e,{sprite:n,scale:s}=i,a=iM(i,["sprite","scale"]);let o=s!=null?s:20;typeof o=="number"&&(o=new lt(o,o));const l=new At({uFilterMatrix:{value:new U,type:"mat3x3<f32>"},uScale:{value:o,type:"vec2<f32>"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2<f32>"}}),u=Wt.from({vertex:Z_,fragment:q_,name:"displacement-filter"}),c=Xt.from({vertex:{source:Hl,entryPoint:"mainVertex"},fragment:{source:Hl,entryPoint:"mainFragment"}}),h=n.texture.source;super(rM(eM({},a),{gpuProgram:c,glProgram:u,resources:{filterUniforms:l,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,n){const s=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(s.uFilterMatrix,this._sprite);const a=this._sprite.worldTransform,o=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d);o!==0&&l!==0&&(s.uRotation[0]=a.a/o,s.uRotation[1]=a.b/o,s.uRotation[2]=a.c/l,s.uRotation[3]=a.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,n)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var ey=`
1168 in vec2 vTextureCoord;
1169 in vec4 vColor;
1170
1171 out vec4 finalColor;
1172
1173 uniform float uNoise;
1174 uniform float uSeed;
1175 uniform sampler2D uTexture;
1176
1177 float rand(vec2 co)
1178 {
1179 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
1180 }
1181
1182 void main()
1183 {
1184 vec4 color = texture(uTexture, vTextureCoord);
1185 float randomValue = rand(gl_FragCoord.xy * uSeed);
1186 float diff = (randomValue - 0.5) * uNoise;
1187
1188 // Un-premultiply alpha before applying the color matrix. See issue #3539.
1189 if (color.a > 0.0) {
1190 color.rgb /= color.a;
1191 }
1192
1193 color.r += diff;
1194 color.g += diff;
1195 color.b += diff;
1196
1197 // Premultiply alpha again.
1198 color.rgb *= color.a;
1199
1200 finalColor = color;
1201 }
1202 `,zl=`
1203
1204 struct GlobalFilterUniforms {
1205 uInputSize:vec4<f32>,
1206 uInputPixel:vec4<f32>,
1207 uInputClamp:vec4<f32>,
1208 uOutputFrame:vec4<f32>,
1209 uGlobalFrame:vec4<f32>,
1210 uOutputTexture:vec4<f32>,
1211 };
1212
1213 struct NoiseUniforms {
1214 uNoise:f32,
1215 uSeed:f32,
1216 };
1217
1218 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
1219 @group(0) @binding(1) var uTexture: texture_2d<f32>;
1220 @group(0) @binding(2) var uSampler : sampler;
1221
1222 @group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;
1223
1224 struct VSOutput {
1225 @builtin(position) position: vec4<f32>,
1226 @location(0) uv : vec2<f32>
1227 };
1228
1229 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
1230 {
1231 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
1232
1233 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
1234 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
1235
1236 return vec4(position, 0.0, 1.0);
1237 }
1238
1239 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1240 {
1241 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
1242 }
1243
1244 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1245 {
1246 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
1247 }
1248
1249 fn getSize() -> vec2<f32>
1250 {
1251 return gfu.uGlobalFrame.zw;
1252 }
1253
1254 @vertex
1255 fn mainVertex(
1256 @location(0) aPosition : vec2<f32>,
1257 ) -> VSOutput {
1258 return VSOutput(
1259 filterVertexPosition(aPosition),
1260 filterTextureCoord(aPosition)
1261 );
1262 }
1263
1264 fn rand(co:vec2<f32>) -> f32
1265 {
1266 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
1267 }
1268
1269
1270
1271 @fragment
1272 fn mainFragment(
1273 @location(0) uv: vec2<f32>,
1274 @builtin(position) position: vec4<f32>
1275 ) -> @location(0) vec4<f32> {
1276
1277 var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy);
1278
1279
1280 var sample = textureSample(uTexture, uSampler, uv);
1281 var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed);
1282 var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
1283
1284 // Un-premultiply alpha before applying the color matrix. See issue #3539.
1285 if (sample.a > 0.0) {
1286 sample.r /= sample.a;
1287 sample.g /= sample.a;
1288 sample.b /= sample.a;
1289 }
1290
1291 sample.r += diff;
1292 sample.g += diff;
1293 sample.b += diff;
1294
1295 // Premultiply alpha again.
1296 sample.r *= sample.a;
1297 sample.g *= sample.a;
1298 sample.b *= sample.a;
1299
1300 return sample;
1301 }`,sM=Object.defineProperty,aM=Object.defineProperties,oM=Object.getOwnPropertyDescriptors,ps=Object.getOwnPropertySymbols,ry=Object.prototype.hasOwnProperty,iy=Object.prototype.propertyIsEnumerable,ny=(r,t,e)=>t in r?sM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wl=(r,t)=>{for(var e in t||(t={}))ry.call(t,e)&&ny(r,e,t[e]);if(ps)for(var e of ps(t))iy.call(t,e)&&ny(r,e,t[e]);return r},lM=(r,t)=>aM(r,oM(t)),uM=(r,t)=>{var e={};for(var i in r)ry.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&&iy.call(r,i)&&(e[i]=r[i]);return e};const sy=class U1 extends Ee{constructor(t={}){t=Wl(Wl({},U1.defaultOptions),t);const e=Xt.from({vertex:{source:zl,entryPoint:"mainVertex"},fragment:{source:zl,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:ey,name:"noise-filter"}),n=t,{noise:s,seed:a}=n,o=uM(n,["noise","seed"]);super(lM(Wl({},o),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new At({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=s,this.seed=a!=null?a: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}};sy.defaultOptions={noise:.5};let cM=sy;var ay=`in vec2 vMaskCoord;
1302 in vec2 vTextureCoord;
1303
1304 uniform sampler2D uTexture;
1305 uniform sampler2D uMaskTexture;
1306
1307 uniform float uAlpha;
1308 uniform vec4 uMaskClamp;
1309 uniform float uInverse;
1310 uniform float uChannel;
1311
1312 out vec4 finalColor;
1313
1314 void main(void)
1315 {
1316 float clip = step(3.5,
1317 step(uMaskClamp.x, vMaskCoord.x) +
1318 step(uMaskClamp.y, vMaskCoord.y) +
1319 step(vMaskCoord.x, uMaskClamp.z) +
1320 step(vMaskCoord.y, uMaskClamp.w));
1321
1322 // TODO look into why this is needed
1323 float npmAlpha = uAlpha;
1324 vec4 original = texture(uTexture, vTextureCoord);
1325 vec4 masky = texture(uMaskTexture, vMaskCoord);
1326
1327 float a;
1328 if (uChannel == 1.0) {
1329 a = masky.a * npmAlpha * clip;
1330 } else {
1331 float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
1332 a = alphaMul * masky.r * npmAlpha * clip;
1333 }
1334
1335 if (uInverse == 1.0) {
1336 a = 1.0 - a;
1337 }
1338
1339 finalColor = original * a;
1340 }
1341 `,oy=`in vec2 aPosition;
1342
1343 out vec2 vTextureCoord;
1344 out vec2 vMaskCoord;
1345
1346
1347 uniform vec4 uInputSize;
1348 uniform vec4 uOutputFrame;
1349 uniform vec4 uOutputTexture;
1350 uniform mat3 uFilterMatrix;
1351
1352 vec4 filterVertexPosition( vec2 aPosition )
1353 {
1354 vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
1355
1356 position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
1357 position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
1358
1359 return vec4(position, 0.0, 1.0);
1360 }
1361
1362 vec2 filterTextureCoord( vec2 aPosition )
1363 {
1364 return aPosition * (uOutputFrame.zw * uInputSize.zw);
1365 }
1366
1367 vec2 getFilterCoord( vec2 aPosition )
1368 {
1369 return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
1370 }
1371
1372 void main(void)
1373 {
1374 gl_Position = filterVertexPosition(aPosition);
1375 vTextureCoord = filterTextureCoord(aPosition);
1376 vMaskCoord = getFilterCoord(aPosition);
1377 }
1378 `,Vl=`struct GlobalFilterUniforms {
1379 uInputSize:vec4<f32>,
1380 uInputPixel:vec4<f32>,
1381 uInputClamp:vec4<f32>,
1382 uOutputFrame:vec4<f32>,
1383 uGlobalFrame:vec4<f32>,
1384 uOutputTexture:vec4<f32>,
1385 };
1386
1387 struct MaskUniforms {
1388 uFilterMatrix:mat3x3<f32>,
1389 uMaskClamp:vec4<f32>,
1390 uAlpha:f32,
1391 uInverse:f32,
1392 uChannel:f32,
1393 };
1394
1395 @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
1396 @group(0) @binding(1) var uTexture: texture_2d<f32>;
1397 @group(0) @binding(2) var uSampler : sampler;
1398
1399 @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
1400 @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
1401
1402 struct VSOutput {
1403 @builtin(position) position: vec4<f32>,
1404 @location(0) uv : vec2<f32>,
1405 @location(1) filterUv : vec2<f32>,
1406 };
1407
1408 fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
1409 {
1410 var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
1411
1412 position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
1413 position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
1414
1415 return vec4(position, 0.0, 1.0);
1416 }
1417
1418 fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1419 {
1420 return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
1421 }
1422
1423 fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
1424 {
1425 return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
1426 }
1427
1428 fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
1429 {
1430 return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
1431 }
1432
1433 fn getSize() -> vec2<f32>
1434 {
1435 return gfu.uGlobalFrame.zw;
1436 }
1437
1438 @vertex
1439 fn mainVertex(
1440 @location(0) aPosition : vec2<f32>,
1441 ) -> VSOutput {
1442 return VSOutput(
1443 filterVertexPosition(aPosition),
1444 filterTextureCoord(aPosition),
1445 getFilterCoord(aPosition)
1446 );
1447 }
1448
1449 @fragment
1450 fn mainFragment(
1451 @location(0) uv: vec2<f32>,
1452 @location(1) filterUv: vec2<f32>,
1453 @builtin(position) position: vec4<f32>
1454 ) -> @location(0) vec4<f32> {
1455
1456 var maskClamp = filterUniforms.uMaskClamp;
1457 var uAlpha = filterUniforms.uAlpha;
1458
1459 var clip = step(3.5,
1460 step(maskClamp.x, filterUv.x) +
1461 step(maskClamp.y, filterUv.y) +
1462 step(filterUv.x, maskClamp.z) +
1463 step(filterUv.y, maskClamp.w));
1464
1465 var mask = textureSample(uMaskTexture, uSampler, filterUv);
1466 var source = textureSample(uTexture, uSampler, uv);
1467
1468 var a: f32;
1469 if (filterUniforms.uChannel == 1.0) {
1470 a = mask.a * uAlpha * clip;
1471 } else {
1472 var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
1473 a = alphaMul * mask.r * uAlpha * clip;
1474 }
1475
1476 if (filterUniforms.uInverse == 1.0) {
1477 a = 1.0 - a;
1478 }
1479
1480 return source * a;
1481 }
1482 `,hM=Object.defineProperty,dM=Object.defineProperties,pM=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,ly=Object.prototype.hasOwnProperty,uy=Object.prototype.propertyIsEnumerable,cy=(r,t,e)=>t in r?hM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fM=(r,t)=>{for(var e in t||(t={}))ly.call(t,e)&&cy(r,e,t[e]);if(fs)for(var e of fs(t))uy.call(t,e)&&cy(r,e,t[e]);return r},mM=(r,t)=>dM(r,pM(t)),gM=(r,t)=>{var e={};for(var i in r)ly.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fs)for(var i of fs(r))t.indexOf(i)<0&&uy.call(r,i)&&(e[i]=r[i]);return e};class hy extends Ee{constructor(t){const e=t,{sprite:i}=e,n=gM(e,["sprite"]),s=new Ua(i.texture),a=new At({uFilterMatrix:{value:new U,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),o=Xt.from({vertex:{source:Vl,entryPoint:"mainVertex"},fragment:{source:Vl,entryPoint:"mainFragment"}}),l=Wt.from({vertex:oy,fragment:ay,name:"mask-filter"});super(mM(fM({},n),{gpuProgram:o,glProgram:l,clipToViewport:!1,resources:{filterUniforms:a,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,i,n){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,n)}}var _M=`fn getLuminosity(c: vec3<f32>) -> f32 {
1483 return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
1484 }
1485
1486 fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32> {
1487 let d: f32 = lum - getLuminosity(c);
1488 let newColor: vec3<f32> = c.rgb + vec3<f32>(d, d, d);
1489
1490 // clip back into legal range
1491 let newLum: f32 = getLuminosity(newColor);
1492 let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b));
1493 let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b));
1494
1495 let t1: f32 = newLum / (newLum - cMin);
1496 let t2: f32 = (1.0 - newLum) / (cMax - newLum);
1497
1498 let finalColor = mix(vec3<f32>(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0));
1499
1500 return finalColor;
1501 }
1502
1503 fn getSaturation(c: vec3<f32>) -> f32 {
1504 return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
1505 }
1506
1507 // Set saturation if color components are sorted in ascending order.
1508 fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32> {
1509 var result: vec3<f32>;
1510 if (cSorted.z > cSorted.x) {
1511 let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x));
1512 result = vec3<f32>(0.0, newY, s);
1513 } else {
1514 result = vec3<f32>(0.0, 0.0, 0.0);
1515 }
1516 return vec3<f32>(result.x, result.y, result.z);
1517 }
1518
1519 fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32> {
1520 var result: vec3<f32> = c;
1521
1522 if (c.r <= c.g && c.r <= c.b) {
1523 if (c.g <= c.b) {
1524 result = setSaturationMinMidMax(result, s);
1525 } else {
1526 var temp: vec3<f32> = vec3<f32>(result.r, result.b, result.g);
1527 temp = setSaturationMinMidMax(temp, s);
1528 result = vec3<f32>(temp.r, temp.b, temp.g);
1529 }
1530 } else if (c.g <= c.r && c.g <= c.b) {
1531 if (c.r <= c.b) {
1532 var temp: vec3<f32> = vec3<f32>(result.g, result.r, result.b);
1533 temp = setSaturationMinMidMax(temp, s);
1534 result = vec3<f32>(temp.g, temp.r, temp.b);
1535 } else {
1536 var temp: vec3<f32> = vec3<f32>(result.g, result.b, result.r);
1537 temp = setSaturationMinMidMax(temp, s);
1538 result = vec3<f32>(temp.g, temp.b, temp.r);
1539 }
1540 } else {
1541 if (c.r <= c.g) {
1542 var temp: vec3<f32> = vec3<f32>(result.b, result.r, result.g);
1543 temp = setSaturationMinMidMax(temp, s);
1544 result = vec3<f32>(temp.b, temp.r, temp.g);
1545 } else {
1546 var temp: vec3<f32> = vec3<f32>(result.b, result.g, result.r);
1547 temp = setSaturationMinMidMax(temp, s);
1548 result = vec3<f32>(temp.b, temp.g, temp.r);
1549 }
1550 }
1551
1552 return result;
1553 }`;const dy=class $1{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let i=0;for(;e.length&&i<$1.uploadsPerFrame;){const n=e.shift();this.uploadQueueItem(n),i++}e.length?Ot.system.addOnce(this._tick,this,Te.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 dt?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(),Ot.system.addOnce(this._tick,this,Te.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i<this.queue.length;i++){const n=this.queue[i];t[n.uid]||(t[n.uid]=!0,this.queue[e++]=n)}this.queue.length=e}destroy(){this._destroyed=!0,clearTimeout(this.timeout)}_resolve(){const{resolves:t}=this,e=t.slice(0);t.length=0;for(const i of e)i()}};dy.uploadsPerFrame=4;let py=dy,yM=class{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}},bM=class{constructor(){this.instructions=new cn}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}};const Yl=class Ah{constructor(t){this._renderer=t,this._managedContexts=new Ut({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Ah.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Ah.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,i=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!i)&&(i&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new bM,i=this.getGpuContext(t);return i.graphicsData=e,e.init(),e}_initContext(t){const e=new yM;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Yl.extension={type:[S.CanvasSystem],name:"graphicsContext"},Yl.defaultOptions={bezierSmoothness:.5};let fy=Yl;class Kl{constructor(t,e){this.state=Vt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ut({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Kl.extension={type:[S.CanvasPipes],name:"graphics"};function vM(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 Yr(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 my{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Et.return(t)}),this.batches.length=0}}class ql{constructor(t,e){this.state=Vt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ut({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!!(n.isBatchable||i!==n.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 n=e[i];n._batcher.updateElement(n)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const n=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const s=n.resources.localUniforms.uniforms;s.uTransformMatrix=t.groupTransform,s.uRound=e._roundPixels|t._roundPixels,Yr(t.groupColorAlpha,s.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,n=this._getGpuDataForRenderable(t).batches;for(let s=0;s<n.length;s++){const a=n[s];i.addToBatch(a,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new my;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const i=t.context,n=this.renderer.graphicsContext.getGpuContext(i),s=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(a=>{const o=Et.get(Vn);return a.copyTo(o),o.renderable=t,o.roundPixels=s,o})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}ql.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"graphics"},X.add(Kl),X.add(ql),X.add(fy),X.add(Zn);var xM=Object.defineProperty,ms=Object.getOwnPropertySymbols,gy=Object.prototype.hasOwnProperty,_y=Object.prototype.propertyIsEnumerable,yy=(r,t,e)=>t in r?xM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TM=(r,t)=>{for(var e in t||(t={}))gy.call(t,e)&&yy(r,e,t[e]);if(ms)for(var e of ms(t))_y.call(t,e)&&yy(r,e,t[e]);return r},SM=(r,t)=>{var e={};for(var i in r)gy.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&&_y.call(r,i)&&(e[i]=r[i]);return e};class hr extends Se{constructor(t){t instanceof kt&&(t={context:t});const e=t||{},{context:i,roundPixels:n}=e,s=SM(e,["context","roundPixels"]);super(TM({label:"Graphics"},s)),this.renderPipeId="graphics",i?this.context=i:(this.context=this._ownedContext=new kt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n!=null?n:!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new hr(this._context.clone()):(this._ownedContext=null,new hr(this._context))}lineStyle(t,e,i){const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,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!==kt.defaultStrokeStyle.width||t.color!==kt.defaultStrokeStyle.color||t.alpha!==kt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}var wM=Object.defineProperty,by=Object.getOwnPropertySymbols,PM=Object.prototype.hasOwnProperty,EM=Object.prototype.propertyIsEnumerable,vy=(r,t,e)=>t in r?wM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xy=(r,t)=>{for(var e in t||(t={}))PM.call(t,e)&&vy(r,e,t[e]);if(by)for(var e of by(t))EM.call(t,e)&&vy(r,e,t[e]);return r};const Ty=class k1 extends nr{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=xy(xy({},k1.defaultOptions),i);const n=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=i.uvs;s||(i.positions?s=new Float32Array(n.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const a=i.indices||new Uint32Array([0,1,2,0,2,3]),o=i.shrinkBuffersToFit,l=new Yt({data:n,label:"attribute-mesh-positions",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),u=new Yt({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),c=new Yt({data:a,label:"index-mesh-buffer",shrinkToFit:o,usage:at.INDEX|at.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:8,offset:0},aUV:{buffer:u,format:"float32x2",stride:8,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}};Ty.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ze=Ty;class gs{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 n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.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 Zl{destroy(){}}class Ql{constructor(t,e){this.localUniforms=new At({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Pe({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,n=t.batched;if(e.batched=n,i!==n)return!0;if(n){const s=t._geometry;if(s.indices.length!==e.indexSize||s.positions.length!==e.vertexSize)return e.indexSize=s.indices.length,e.vertexSize=s.positions.length,!0;const a=this._getBatchableMesh(t);return a.texture.uid!==t._texture.uid&&(a._textureMatrixUpdateId=-1),!a._batcher.checkAndUpdateTexture(a,t._texture)}return!1}addRenderable(t,e){var i,n;const s=this.renderer.renderPipes.batch,a=this._getMeshData(t);if(t.didViewUpdate&&(a.indexSize=(i=t._geometry.indices)==null?void 0:i.length,a.vertexSize=(n=t._geometry.positions)==null?void 0:n.length),a.batched){const o=this._getBatchableMesh(t);o.setTexture(t._texture),o.geometry=t._geometry,s.addToBatch(o,e)}else s.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=Ir(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Yr(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 Zl),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Zl),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new gs;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}}Ql.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"mesh"},X.add(Ql);var AM=Object.defineProperty,_s=Object.getOwnPropertySymbols,Sy=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,Py=(r,t,e)=>t in r?AM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CM=(r,t)=>{for(var e in t||(t={}))Sy.call(t,e)&&Py(r,e,t[e]);if(_s)for(var e of _s(t))wy.call(t,e)&&Py(r,e,t[e]);return r},MM=(r,t)=>{var e={};for(var i in r)Sy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_s)for(var i of _s(r))t.indexOf(i)<0&&wy.call(r,i)&&(e[i]=r[i]);return e};class Kr extends Se{constructor(...t){var e;let i=t[0];i instanceof nr&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const n=i,{geometry:s,shader:a,texture:o,roundPixels:l,state:u}=n,c=MM(n,["geometry","shader","texture","roundPixels","state"]);super(CM({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=a!=null?a:null,this.texture=(e=o!=null?o:a==null?void 0:a.texture)!=null?e:D.WHITE,this.state=u!=null?u:Vt.for2d(),this._geometry=s,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=D.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||(this.state.data&12)!==0?!1:this._geometry instanceof ze?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 n=this.geometry.getBuffer("aPosition").data,s=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const a=this.geometry.getIndex().data,o=a.length;for(let l=0;l+2<o;l+=s){const u=a[l]*2,c=a[l+1]*2,h=a[l+2]*2;if(ao(e,i,n[u],n[u+1],n[c],n[c+1],n[h],n[h+1]))return!0}}else{const a=n.length/2;for(let o=0;o+2<a;o+=s){const l=o*2,u=(o+1)*2,c=(o+2)*2;if(ao(e,i,n[l],n[l+1],n[u],n[u+1],n[c],n[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}}var RM=Object.defineProperty,OM=Object.defineProperties,GM=Object.getOwnPropertyDescriptors,ys=Object.getOwnPropertySymbols,Ey=Object.prototype.hasOwnProperty,Ay=Object.prototype.propertyIsEnumerable,Cy=(r,t,e)=>t in r?RM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IM=(r,t)=>{for(var e in t||(t={}))Ey.call(t,e)&&Cy(r,e,t[e]);if(ys)for(var e of ys(t))Ay.call(t,e)&&Cy(r,e,t[e]);return r},BM=(r,t)=>OM(r,GM(t)),FM=(r,t)=>{var e={};for(var i in r)Ey.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&&Ay.call(r,i)&&(e[i]=r[i]);return e};class Xi extends pe{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:n=1,autoPlay:s=!1,autoUpdate:a=!0,loop:o=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:h,updateAnchor:p=!1}=i,f=FM(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=h;super(BM(IM({},f),{texture:m instanceof D?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=a,this._isConnectedToTicker=!1,this.animationSpeed=n,this.loop=o,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=h,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ot.shared.add(this.update,this,Te.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,n=this.currentFrame;if(this._durations!==null){let s=this._currentTime%1*this._durations[this.currentFrame];for(s+=i/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=s/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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<n||this.animationSpeed<0&&this.currentFrame>n)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(i=>{this.texture!==i&&i.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(D.from(t[i]));return new Xi(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(D.from(t[i]));return new Xi(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof D)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?(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class My{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new U,this.observer=e,this.position=new bt(this,0,0),this.scale=new bt(this,1,1),this.pivot=new bt(this,0,0),this.skew=new bt(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))}}const bs=new U,Be=new U,Ae=[new lt,new lt,new lt,new lt];class Jl{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save(),u.setBlendMode(t.groupBlendMode);const h=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,p=t.groupColorAlpha,f=(h>>>24&255)/255,m=(p>>>24&255)/255,g=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,_=f*m*g;if(_<=0){c.restore();return}c.globalAlpha=_;const y=h&16777215,b=p&16777215,x=xe(Oe(b,y)),v=t.texture,w=Q.getTintedPattern(v,x),T=t.width,P=t.height,E=t.groupTransform,M=(o=(a=v.source._resolution)!=null?a:v.source.resolution)!=null?o:1;Be.copyFrom(t._tileTransform.matrix),t.applyAnchorToTexture||Be.translate(-t.anchor.x*T,-t.anchor.y*P);const C=Be.tx,A=Be.ty;Be.scale(1/M,1/M),Be.tx=C,Be.ty=A,bs.identity(),bs.prepend(Be),bs.prepend(E);const G=l._roundPixels|t._roundPixels;u.setContextTransform(bs,G===1),c.fillStyle=w;const F=t.anchor.x*-T,R=t.anchor.y*-P;Ae[0].set(F,R),Ae[1].set(F+T,R),Ae[2].set(F+T,R+P),Ae[3].set(F,R+P);for(let B=0;B<4;B++)Be.applyInverse(Ae[B],Ae[B]);c.beginPath(),c.moveTo(Ae[0].x,Ae[0].y);for(let B=1;B<4;B++)c.lineTo(Ae[B].x,Ae[B].y);c.closePath(),c.fill(),c.restore()}destroy(){this._renderer=null}}Jl.extension={type:[S.CanvasPipes],name:"tilingSprite"};var DM=Object.defineProperty,UM=Object.defineProperties,$M=Object.getOwnPropertyDescriptors,Ry=Object.getOwnPropertySymbols,kM=Object.prototype.hasOwnProperty,LM=Object.prototype.propertyIsEnumerable,Oy=(r,t,e)=>t in r?DM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gy=(r,t)=>{for(var e in t||(t={}))kM.call(t,e)&&Oy(r,e,t[e]);if(Ry)for(var e of Ry(t))LM.call(t,e)&&Oy(r,e,t[e]);return r},Iy=(r,t)=>UM(r,$M(t));const qr={name:"local-uniform-bit",vertex:{header:`
1554
1555 struct LocalUniforms {
1556 uTransformMatrix:mat3x3<f32>,
1557 uColor:vec4<f32>,
1558 uRound:f32,
1559 }
1560
1561 @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
1562 `,main:`
1563 vColor *= localUniforms.uColor;
1564 modelMatrix *= localUniforms.uTransformMatrix;
1565 `,end:`
1566 if(localUniforms.uRound == 1)
1567 {
1568 vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
1569 }
1570 `}},By=Iy(Gy({},qr),{vertex:Iy(Gy({},qr.vertex),{header:qr.vertex.header.replace("group(1)","group(2)")})}),vs={name:"local-uniform-bit",vertex:{header:`
1571
1572 uniform mat3 uTransformMatrix;
1573 uniform vec4 uColor;
1574 uniform float uRound;
1575 `,main:`
1576 vColor *= uColor;
1577 modelMatrix = uTransformMatrix;
1578 `,end:`
1579 if(uRound == 1.)
1580 {
1581 gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
1582 }
1583 `}},Fy={name:"tiling-bit",vertex:{header:`
1584 struct TilingUniforms {
1585 uMapCoord:mat3x3<f32>,
1586 uClampFrame:vec4<f32>,
1587 uClampOffset:vec2<f32>,
1588 uTextureTransform:mat3x3<f32>,
1589 uSizeAnchor:vec4<f32>
1590 };
1591
1592 @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
1593 @group(2) @binding(1) var uTexture: texture_2d<f32>;
1594 @group(2) @binding(2) var uSampler: sampler;
1595 `,main:`
1596 uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
1597
1598 position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
1599 `},fragment:{header:`
1600 struct TilingUniforms {
1601 uMapCoord:mat3x3<f32>,
1602 uClampFrame:vec4<f32>,
1603 uClampOffset:vec2<f32>,
1604 uTextureTransform:mat3x3<f32>,
1605 uSizeAnchor:vec4<f32>
1606 };
1607
1608 @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
1609 @group(2) @binding(1) var uTexture: texture_2d<f32>;
1610 @group(2) @binding(2) var uSampler: sampler;
1611 `,main:`
1612
1613 var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
1614 coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
1615 var unclamped = coord;
1616 coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
1617
1618 var bias = 0.;
1619
1620 if(unclamped.x == coord.x && unclamped.y == coord.y)
1621 {
1622 bias = -32.;
1623 }
1624
1625 outColor = textureSampleBias(uTexture, uSampler, coord, bias);
1626 `}},Dy={name:"tiling-bit",vertex:{header:`
1627 uniform mat3 uTextureTransform;
1628 uniform vec4 uSizeAnchor;
1629
1630 `,main:`
1631 uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
1632
1633 position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
1634 `},fragment:{header:`
1635 uniform sampler2D uTexture;
1636 uniform mat3 uMapCoord;
1637 uniform vec4 uClampFrame;
1638 uniform vec2 uClampOffset;
1639 `,main:`
1640
1641 vec2 coord = vUV + ceil(uClampOffset - vUV);
1642 coord = (uMapCoord * vec3(coord, 1.0)).xy;
1643 vec2 unclamped = coord;
1644 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1645
1646 outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
1647
1648 `}};let tu,eu;class Uy extends ee{constructor(){tu!=null||(tu=Fr({name:"tiling-sprite-shader",bits:[qr,Fy,Ur]})),eu!=null||(eu=Dr({name:"tiling-sprite-shader",bits:[vs,Dy,$r]}));const t=new At({uMapCoord:{value:new U,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 U,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:eu,gpuProgram:tu,resources:{localUniforms:new At({uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:D.EMPTY.source,uSampler:D.EMPTY.source.style}})}updateUniforms(t,e,i,n,s,a){const o=this.resources.tilingUniforms,l=a.width,u=a.height,c=a.textureMatrix,h=o.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(),o.uniforms.uMapCoord=c.mapCoord,o.uniforms.uClampFrame=c.uClampFrame,o.uniforms.uClampOffset=c.uClampOffset,o.uniforms.uTextureTransform=h,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=s,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class $y extends ze{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 ky(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 Ly(r,t,e,i){let n=0;const s=r.length/(t||2),a=i.a,o=i.b,l=i.c,u=i.d,c=i.tx,h=i.ty;for(e*=t;n<s;){const p=r[e],f=r[e+1];r[e]=a*p+l*f+c,r[e+1]=o*p+u*f+h,e+=t,n++}}function Ny(r,t){const e=r.texture,i=e.frame.width,n=e.frame.height;let s=0,a=0;r.applyAnchorToTexture&&(s=r.anchor.x,a=r.anchor.y),t[0]=t[6]=-s,t[2]=t[4]=1-s,t[1]=t[3]=-a,t[5]=t[7]=1-a;const o=U.shared;o.copyFrom(r._tileTransform.matrix),o.tx/=r.width,o.ty/=r.height,o.invert(),o.scale(r.width/i,r.height/n),Ly(t,2,0,o)}const xs=new $y;class Xy{constructor(){this.canBatch=!0,this.geometry=new ze({indices:xs.indices.slice(),positions:xs.positions.slice(),uvs:xs.uvs.slice()})}destroy(){var t;this.geometry.destroy(),(t=this.shader)==null||t.destroy()}}class ru{constructor(t){this._state=Vt.default2d,this._renderer=t,this._managedTilingSprites=new Ut({renderer:t,type:"renderable",name:"tilingSprite"})}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const n=e.canBatch;if(n&&n===i){const{batchableMesh:s}=e;return!s._batcher.checkAndUpdateTexture(s,t.texture)}return i!==n}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const n=this._getTilingSpriteData(t),{geometry:s,canBatch:a}=n;if(a){n.batchableMesh||(n.batchableMesh=new gs);const o=n.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),o.geometry=s,o.renderable=t,o.transform=t.groupTransform,o.setTexture(t._texture)),o.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(o,e)}else i.break(e),n.shader||(n.shader=new Uy),this.updateRenderable(t),e.add(t)}execute(t){const e=this._renderer,{shader:i}=this._getTilingSpriteData(t);i.groups[0]=e.globalUniforms.bindGroup;const n=i.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,Yr(t.groupColorAlpha,n.uColor,0),this._state.blendMode=Ir(t.groupBlendMode,t.texture._source),e.encoder.draw({geometry:xs,shader:i,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:n}=e;t.didViewUpdate&&this._updateBatchableMesh(t),n._batcher.updateElement(n)}else if(t.didViewUpdate){const{shader:n}=e;n.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 Xy;return e.renderable=t,t._gpuData[this._renderer.uid]=e,this._managedTilingSprites.add(t),e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,n=t.texture.source.style;n.addressMode!=="repeat"&&(n.addressMode="repeat",n.update()),Ny(t,i.uvs),ky(t,i.positions)}destroy(){this._managedTilingSprites.destroy(),this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let n=!0;return this._renderer.type===It.WEBGL&&(n=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(n||i.source.isPowerOfTwo),e.canBatch}}ru.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"tilingSprite"},X.add(Jl),X.add(ru);var NM=Object.defineProperty,Ts=Object.getOwnPropertySymbols,jy=Object.prototype.hasOwnProperty,Hy=Object.prototype.propertyIsEnumerable,zy=(r,t,e)=>t in r?NM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ji=(r,t)=>{for(var e in t||(t={}))jy.call(t,e)&&zy(r,e,t[e]);if(Ts)for(var e of Ts(t))Hy.call(t,e)&&zy(r,e,t[e]);return r},XM=(r,t)=>{var e={};for(var i in r)jy.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&&Hy.call(r,i)&&(e[i]=r[i]);return e};const Wy=class xa extends Se{constructor(...t){let e=t[0]||{};e instanceof D&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=ji(ji({},xa.defaultOptions),e);const i=e!=null?e:{},{texture:n,anchor:s,tilePosition:a,tileScale:o,tileRotation:l,width:u,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=XM(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(ji({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=n,this._width=u!=null?u:n.width,this._height=c!=null?c:n.height,this._tileTransform=new My({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=a,this.tileScale=o,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new xa(ji({texture:it.get(t)},e)):new xa(ji({texture:t},e))}get uvRespectAnchor(){return Mi(zo,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Mi(zo,"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=D.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,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}containsPoint(t){const e=this._width,i=this._height,n=-e*this._anchor._x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this._anchor._y,t.y>=s&&t.y<=s+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}};Wy.defaultOptions={texture:D.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Vy=Wy;var jM=Object.defineProperty,Ss=Object.getOwnPropertySymbols,Yy=Object.prototype.hasOwnProperty,Ky=Object.prototype.propertyIsEnumerable,qy=(r,t,e)=>t in r?jM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HM=(r,t)=>{for(var e in t||(t={}))Yy.call(t,e)&&qy(r,e,t[e]);if(Ss)for(var e of Ss(t))Ky.call(t,e)&&qy(r,e,t[e]);return r},zM=(r,t)=>{var e={};for(var i in r)Yy.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&&Ky.call(r,i)&&(e[i]=r[i]);return e};class ws extends Se{constructor(t,e){const i=t,{text:n,resolution:s,style:a,anchor:o,width:l,height:u,roundPixels:c}=i,h=zM(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(HM({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=n!=null?n:"",this.style=a,this.resolution=s!=null?s:null,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),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,n=-e*this.anchor.x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this.anchor.y,t.y>=s&&t.y<=s+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Ps(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}let dr=null,Fe=null;function WM(r,t){dr||(dr=H.get().createCanvas(256,128),Fe=dr.getContext("2d",{willReadFrequently:!0}),Fe.globalCompositeOperation="copy",Fe.globalAlpha=1),(dr.width<r||dr.height<t)&&(dr.width=Ze(r),dr.height=Ze(t))}function Zy(r,t,e){for(let i=0,n=4*e*t;i<t;++i,n+=4)if(r[n+3]!==0)return!1;return!0}function Qy(r,t,e,i,n){const s=4*t;for(let a=i,o=i*s+4*e;a<=n;++a,o+=s)if(r[o+3]!==0)return!1;return!0}function Jy(...r){var t,e,i;let n=r[0];n.canvas||(n={canvas:r[0],resolution:r[1]});const{canvas:s}=n,a=Math.min((t=n.resolution)!=null?t:1,1),o=(e=n.width)!=null?e:s.width,l=(i=n.height)!=null?i:s.height;let u=n.output;if(WM(o,l),!Fe)throw new TypeError("Failed to get canvas 2D context");Fe.drawImage(s,0,0,o,l,0,0,o*a,l*a);const c=Fe.getImageData(0,0,o,l).data;let h=0,p=0,f=o-1,m=l-1;for(;p<l&&Zy(c,o,p);)++p;if(p===l)return ut.EMPTY;for(;Zy(c,o,m);)--m;for(;Qy(c,o,h,p,m);)++h;for(;Qy(c,o,f,p,m);)--f;return++f,++m,Fe.globalCompositeOperation="source-over",Fe.strokeRect(h,p,f-h,m-p),Fe.globalCompositeOperation="copy",u!=null||(u=new ut),u.set(h/a,p/a,(f-h)/a,(m-p)/a),u}/**
1649 * tiny-lru
1650 *
1651 * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
1652 * @license BSD-3-Clause
1653 * @version 11.4.7
1654 */class VM{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++){const n=t[i];e[i]=[n,this.get(n)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(n=P1({},this.first),this.evict(!0));let s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=s:this.last.next=s,this.last=s}return n}set(t,e,i=!1,n=this.resetTtl){let s=this.items[t];return i||s!==void 0?(s.value=e,i===!1&&n&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(s)):(this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=s:this.last.next=s,this.last=s),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++)e[i]=this.get(t[i]);return e}}function tb(r=1e3,t=0,e=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new VM(r,t,e)}function Es(r){return!!r.tagStyles&&Object.keys(r.tagStyles).length>0}function As(r){return r.includes("<")}function YM(r,t){return r.clone().assign(t)}function iu(r,t){const e=[],i=t.tagStyles;if(!Es(t)||!As(r))return e.push({text:r,style:t}),e;const n=[t],s=[];let a="",o=0;for(;o<r.length;){const l=r[o];if(l==="<"){const u=r.indexOf(">",o);if(u===-1){a+=l,o++;continue}const c=r.indexOf("<",o+1);if(c!==-1&&c<u){a+=l,o++;continue}const h=r.slice(o+1,u);if(h.startsWith("/")){const p=h.slice(1).trim();if(s.length>0&&s[s.length-1]===p){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a=""),n.pop(),s.pop(),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}else{const p=h.trim();if(i[p]){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a="");const f=n[n.length-1],m=YM(f,i[p]);n.push(m),s.push(p),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}}else a+=l,o++}return a.length>0&&e.push({text:a,style:n[n.length-1]}),e}function KM(r,t){return!Es(t)||!As(r)?r:iu(r,t).map(e=>e.text).join("")}const eb=[10,13],rb=new Set(eb),ib=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],nb=new Set(ib),sb=[9,32],ab=new Set(sb),ob=[45,8208,8211,8212,173],lb=new Set(ob),ub=/(\r\n|\r|\n)/,cb=/(?:\r\n|\r|\n)/;function Hi(r){return typeof r!="string"?!1:rb.has(r.charCodeAt(0))}function Qt(r,t){return typeof r!="string"?!1:nb.has(r.charCodeAt(0))}function nu(r){return typeof r!="string"?!1:ab.has(r.charCodeAt(0))}function su(r){return typeof r!="string"?!1:lb.has(r.charCodeAt(0))}function Cs(r){return r==="normal"||r==="pre-line"}function Ms(r){return r==="normal"}function Ce(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Qt(r[t]);)t--;return t<r.length-1?r.slice(0,t+1):r}function au(r){const t=[],e=[];if(typeof r!="string")return t;for(let i=0;i<r.length;i++){const n=r[i],s=r[i+1];if(Qt(n,s)||Hi(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&s===`
1655 `?(t.push(`\r
1656 `),i++):t.push(n);continue}e.push(n),su(n)&&s&&!Qt(s)&&!Hi(s)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function ou(r,t,e,i){const n=e(r),s=[];for(let a=0;a<n.length;a++){let o=n[a],l=o,u=1;for(;n[a+u];){const c=n[a+u];if(!i(l,c,r,a,t))o+=c,l=c,u++;else break}a+=u-1,s.push(o)}return s}const qM=/\r\n|\r|\n/g;function hb(r,t,e,i,n,s,a,o,l){var u,c;const h=iu(r,t);if(Ms(t.whiteSpace))for(let B=0;B<h.length;B++){const O=h[B];h[B]={text:O.text.replace(qM," "),style:O.style}}const p=[];let f=[];for(const B of h){const O=B.text.split(ub);for(let I=0;I<O.length;I++){const L=O[I];L===`\r
1657 `||L==="\r"||L===`
1658 `?(p.push(f),f=[]):L.length>0&&f.push({text:L,style:B.style})}}(f.length>0||p.length===0)&&p.push(f);const m=e?db(p,t,i,s,o,l):p,g=[],_=[],y=[],b=[],x=[];let v=0;const w=t._fontString,T=a(w);T.fontSize===0&&(T.fontSize=t.fontSize,T.ascent=t.fontSize);let P="",E=!!t.dropShadow,M=((u=t._stroke)==null?void 0:u.width)||0;for(const B of m){let O=0,I=T.ascent,L=T.descent,j="";for(const K of B){const N=K.style._fontString,k=a(N);N!==P&&(i.font=N,P=N);const $=n(K.text,K.style.letterSpacing,i);O+=$,I=Math.max(I,k.ascent),L=Math.max(L,k.descent),j+=K.text;const z=((c=K.style._stroke)==null?void 0:c.width)||0;z>M&&(M=z),!E&&K.style.dropShadow&&(E=!0)}B.length===0&&(I=T.ascent,L=T.descent),g.push(O),_.push(I),y.push(L),x.push(j);const J=t.lineHeight||I+L;b.push(J+t.leading),v=Math.max(v,O)}const C=M,A=v+C+(t.dropShadow?t.dropShadow.distance:0);let G=0;for(let B=0;B<b.length;B++)G+=b[B];G=Math.max(G,b[0]+C);const F=G+(t.dropShadow?t.dropShadow.distance:0),R=t.lineHeight||T.fontSize;return{width:A,height:F,lines:x,lineWidths:g,lineHeight:R+t.leading,maxLineWidth:v,fontProperties:T,runsByLine:m,lineAscents:_,lineDescents:y,lineHeights:b,hasDropShadow:E}}function db(r,t,e,i,n,s){var a,o,l;const{letterSpacing:u,whiteSpace:c,wordWrapWidth:h,breakWords:p}=t,f=Cs(c),m=h+u,g={};let _="";const y=(x,v)=>{const w=`${x}|${v.styleKey}`;let T=g[w];if(T===void 0){const P=v._fontString;P!==_&&(e.font=P,_=P),T=i(x,v.letterSpacing,e)+v.letterSpacing,g[w]=T}return T},b=[];for(const x of r){const v=pb(x),w=b.length,T=R=>{let B=0,O=R;do{const{token:I,style:L}=v[O];B+=y(I,L),O++}while(O<v.length&&v[O].continuesFromPrevious);return B},P=R=>{const B=[];let O=R;do B.push({token:v[O].token,style:v[O].style}),O++;while(O<v.length&&v[O].continuesFromPrevious);return B};let E=[],M=0,C=!f,A=null;const G=()=>{A&&A.text.length>0&&E.push(A),A=null},F=()=>{if(G(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}b.push(E),E=[],M=0,C=!1};for(let R=0;R<v.length;R++){const{token:B,style:O,continuesFromPrevious:I}=v[R],L=y(B,O);if(f){const K=Qt(B),N=(l=(o=A==null?void 0:A.text[A.text.length-1])!=null?o:(a=E[E.length-1])==null?void 0:a.text.slice(-1))!=null?l:"",k=N?Qt(N):!1;if(K&&k)continue}const j=!I,J=j?T(R):L;if(J>m&&j)if(M>0&&F(),p){const K=P(R);for(let N=0;N<K.length;N++){const k=K[N].token,$=K[N].style,z=ou(k,p,s,n);for(const rt of z){const _t=y(rt,$);_t+M>m&&F(),!A||A.style!==$?(G(),A={text:rt,style:$}):A.text+=rt,M+=_t}}R+=K.length-1}else{const K=P(R);G(),b.push(K.map(N=>({text:N.token,style:N.style}))),C=!1,R+=K.length-1}else if(J+M>m&&j){if(Qt(B)){C=!1;continue}F(),A={text:B,style:O},M=L}else if(I&&!p)!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L;else{const K=Qt(B);if(M===0&&K&&!C)continue;!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L}}if(G(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}(E.length>0||b.length===w)&&b.push(E)}return b}function pb(r){const t=[];let e=!1;for(const i of r){const n=au(i.text);let s=!0;for(const a of n){const o=Qt(a)||Hi(a),l=s&&e&&!o;t.push({token:a,style:i.style,continuesFromPrevious:l}),e=!o,s=!1}}return t}const ZM={willReadFrequently:!0};function fb(r,t,e,i,n){let s=e[r];return typeof s!="number"&&(s=n(r,t,i)+t,e[r]=s),s}function mb(r,t,e,i,n,s,a){const o=e.getContext("2d",ZM);o.font=t._fontString;let l=0,u="";const c=[],h=Object.create(null),{letterSpacing:p,whiteSpace:f}=t,m=Cs(f),g=Ms(f);let _=!m;const y=t.wordWrapWidth+p,b=au(r);for(let v=0;v<b.length;v++){let w=b[v];if(Hi(w)){if(!g){c.push(Ce(u)),_=!m,u="",l=0;continue}w=" "}if(m){const P=Qt(w),E=Qt(u[u.length-1]);if(P&&E)continue}const T=fb(w,p,h,o,i);if(T>y)if(u!==""&&(c.push(Ce(u)),u="",l=0),n(w,t.breakWords)){const P=ou(w,t.breakWords,a,s);for(const E of P){const M=fb(E,p,h,o,i);M+l>y&&(c.push(Ce(u)),_=!1,u="",l=0),u+=E,l+=M}}else u.length>0&&(c.push(Ce(u)),u="",l=0),c.push(Ce(w)),_=!1,u="",l=0;else T+l>y&&(_=!1,c.push(Ce(u)),u="",l=0),(u.length>0||!Qt(w)||_)&&(u+=w,l+=T)}const x=Ce(u);return x.length>0&&c.push(x),c.join(`
1659 `)}const gb={willReadFrequently:!0},De=class q{static get experimentalLetterSpacingSupported(){let t=q._experimentalLetterSpacingSupported;if(t===void 0){const e=H.get().getCanvasRenderingContext2D().prototype;t=q._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,s,a,o,l,u,c){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=l,this.fontProperties=u,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=q._canvas,n=e.wordWrap){var s,a;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(q._measurementCache.has(o))return q._measurementCache.get(o);if(Es(e)&&As(t)){const v=hb(t,e,n,q._context,q._measureText,q._measureTextAdvance,q.measureFont,q.canBreakChars,q.wordWrapSplit),w=new q(t,e,v.width,v.height,v.lines,v.lineWidths,v.lineHeight,v.maxLineWidth,v.fontProperties,{runsByLine:v.runsByLine,lineAscents:v.lineAscents,lineDescents:v.lineDescents,lineHeights:v.lineHeights,hasDropShadow:v.hasDropShadow});return q._measurementCache.set(o,w),w}const l=e._fontString,u=q.measureFont(l);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize,u.descent=0);const c=q._context;c.font=l;const h=(n?q._wordWrap(t,e,i):t).split(cb),p=new Array(h.length);let f=0;for(let v=0;v<h.length;v++){const w=q._measureText(h[v],e.letterSpacing,c);p[v]=w,f=Math.max(f,w)}const m=(a=(s=e._stroke)==null?void 0:s.width)!=null?a:0,g=e.lineHeight||u.fontSize,_=q._adjustWidthForStyle(f,e),y=Math.max(g,u.fontSize+m)+(h.length-1)*(g+e.leading),b=q._adjustHeightForStyle(y,e),x=new q(t,e,_,b,h,p,g+e.leading,f,u);return q._measurementCache.set(o,x),x}static _adjustWidthForStyle(t,e){var i;const n=((i=e._stroke)==null?void 0:i.width)||0;let s=t+n;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _adjustHeightForStyle(t,e){let i=t;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _measureText(t,e,i){var n,s;const{metricWidth:a,metrics:o,letterSpacingVal:l}=q._measureTextCore(t,e,i),u=-((n=o.actualBoundingBoxLeft)!=null?n:0);let c=((s=o.actualBoundingBoxRight)!=null?s:0)-u;return o.width>0&&(c+=l),Math.max(a,c)}static _measureTextAdvance(t,e,i){return q._measureTextCore(t,e,i).metricWidth}static _measureTextCore(t,e,i){let n=!1;q.experimentalLetterSpacingSupported&&(q.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const s=i.measureText(t);let a=s.width,o=0;return a>0&&(n?o=-e:o=(q.graphemeSegmenter(t).length-1)*e,a+=o),{metricWidth:a,metrics:s,letterSpacingVal:o}}static _wordWrap(t,e,i=q._canvas){return mb(t,e,i,q._measureTextAdvance,q.canBreakWords,q.canBreakChars,q.wordWrapSplit)}static isBreakingSpace(t,e){return Qt(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){return!0}static wordWrapSplit(t){return q.graphemeSegmenter(t)}static measureFont(t){var e,i;if(q._fonts[t])return q._fonts[t];const n=q._context;n.font=t;const s=n.measureText(q.METRICS_STRING+q.BASELINE_SYMBOL),a=(e=s.actualBoundingBoxAscent)!=null?e:0,o=(i=s.actualBoundingBoxDescent)!=null?i:0,l={ascent:a,descent:o,fontSize:a+o};return q._fonts[t]=l,l}static clearMetrics(t=""){t?delete q._fonts[t]:q._fonts={}}static get _canvas(){if(!q.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",gb);if(i!=null&&i.measureText)return q.__canvas=e,e;t=H.get().createCanvas()}catch(e){t=H.get().createCanvas()}t.width=t.height=10,q.__canvas=t}return q.__canvas}static get _context(){return q.__context||(q.__context=q._canvas.getContext("2d",gb)),q.__context}};De.METRICS_STRING="|\xC9q\xC5",De.BASELINE_SYMBOL="M",De.BASELINE_MULTIPLIER=1.4,De.HEIGHT_MULTIPLIER=2,De.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let n=0;for(const s of e)i[n++]=s.segment;return i}}return r=>[...r]})(),De.experimentalLetterSpacing=!1,De._fonts={},De._measurementCache=tb(1e3);let St=De;const QM=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Zr(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 n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!QM.includes(n)&&(n=`"${n}"`),e[i]=n}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const _b=1e5;function pr(r,t,e,i=0,n=0,s=0){var a;if(r.texture===D.WHITE&&!r.fill)return tt.shared.setValue(r.color).setAlpha((a=r.alpha)!=null?a:1).toHexa();if(r.fill){if(r.fill instanceof Xr){const o=r.fill,l=t.createPattern(o.texture.source.resource,"repeat"),u=o.transform.copyTo(U.shared);return u.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),l.setTransform(u),l}else if(r.fill instanceof $t){const o=r.fill,l=o.type==="linear",u=o.textureSpace==="local";let c=1,h=1;u&&e&&(c=e.width+i,h=e.height+i);let p,f=!1;if(l){const{start:m,end:g}=o;p=t.createLinearGradient(m.x*c+n,m.y*h+s,g.x*c+n,g.y*h+s),f=Math.abs(g.x-m.x)<Math.abs((g.y-m.y)*.1)}else{const{center:m,innerRadius:g,outerCenter:_,outerRadius:y}=o;p=t.createRadialGradient(m.x*c+n,m.y*h+s,g*c,_.x*c+n,_.y*h+s,y*c)}if(f&&u&&e){const m=e.lineHeight/h;for(let g=0;g<e.lines.length;g++){const _=(g*e.lineHeight+i/2)/h;o.colorStops.forEach(y=>{let b=_+y.offset*m;b=Math.max(0,Math.min(1,b)),p.addColorStop(Math.floor(b*_b)/_b,tt.shared.setValue(y.color).toHex())})}}else o.colorStops.forEach(m=>{p.addColorStop(m.offset,tt.shared.setValue(m.color).toHex())});return p}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),l=r.matrix.copyTo(U.shared);return l.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(l),o}return"red"}const yb=new ut;function Qr(r){let t=0;for(let e=0;e<r.length;e++)r.charCodeAt(e)===32&&t++;return t}let JM=class{getCanvasAndContext(t){const{text:e,style:i,resolution:n=1}=t,s=i._getFinalPadding(),a=St.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,a.width)+s*2)*n),l=Math.ceil(Math.ceil(Math.max(1,a.height)+s*2)*n),u=me.getOptimalCanvasAndContext(o,l);this._renderTextToCanvas(i,s,n,u,a);const c=i.trim?Jy({canvas:u.canvas,width:o,height:l,resolution:1,output:yb}):yb.set(0,0,o,l);return{canvasAndContext:u,frame:c}}returnCanvasAndContext(t){me.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,n,s){var a,o,l,u,c,h;if(s.runsByLine&&s.runsByLine.length>0){this._renderTaggedTextToCanvas(s,t,e,i,n);return}const{canvas:p,context:f}=n,m=Zr(t),g=s.lines,_=s.lineHeight,y=s.lineWidths,b=s.maxLineWidth,x=s.fontProperties,v=p.height;if(f.resetTransform(),f.scale(i,i),f.textBaseline=t.textBaseline,(a=t._stroke)!=null&&a.width){const C=t._stroke;f.lineWidth=C.width,f.miterLimit=C.miterLimit,f.lineJoin=C.join,f.lineCap=C.cap}f.font=m;let w,T;const P=t.dropShadow?2:1,E=((l=(o=t._stroke)==null?void 0:o.width)!=null?l:0)/2;let M=(_-x.fontSize)/2;_-x.fontSize<0&&(M=0);for(let C=0;C<P;++C){const A=t.dropShadow&&C===0,G=A?Math.ceil(Math.max(1,v)+e*2):0,F=G*i;if(A)this._setupDropShadow(f,t,i,F);else{const R=t._gradientBounds,B=t._gradientOffset;if(R){const O={width:R.width,height:R.height,lineHeight:R.height,lines:s.lines};this._setFillAndStrokeStyles(f,t,O,e,E,(u=B==null?void 0:B.x)!=null?u:0,(c=B==null?void 0:B.y)!=null?c:0)}else B?this._setFillAndStrokeStyles(f,t,s,e,E,B.x,B.y):this._setFillAndStrokeStyles(f,t,s,e,E);f.shadowColor="rgba(0,0,0,0)"}for(let R=0;R<g.length;R++){w=E,T=E+R*_+x.ascent+M,w+=this._getAlignmentOffset(y[R],b,t.align);let B=0;if(t.align==="justify"&&t.wordWrap&&R<g.length-1){const O=Qr(g[R]);O>0&&(B=(b-y[R])/O)}(h=t._stroke)!=null&&h.width&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!0,B),t._fill!==void 0&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!1,B)}}}_renderTaggedTextToCanvas(t,e,i,n,s){var a,o,l,u,c;const{canvas:h,context:p}=s,{runsByLine:f,lineWidths:m,maxLineWidth:g,lineAscents:_,lineHeights:y,hasDropShadow:b}=t,x=h.height;p.resetTransform(),p.scale(n,n),p.textBaseline=e.textBaseline;const v=b?2:1;let w=(o=(a=e._stroke)==null?void 0:a.width)!=null?o:0;for(const E of f)for(const M of E){const C=(u=(l=M.style._stroke)==null?void 0:l.width)!=null?u:0;C>w&&(w=C)}const T=w/2,P=[];for(let E=0;E<f.length;E++){const M=f[E],C=[];for(const A of M){const G=Zr(A.style);p.font=G,C.push({width:St._measureText(A.text,A.style.letterSpacing,p),font:G})}P.push(C)}for(let E=0;E<v;++E){const M=b&&E===0,C=M?Math.ceil(Math.max(1,x)+i*2):0,A=C*n;M||(p.shadowColor="rgba(0,0,0,0)");let G=T;for(let F=0;F<f.length;F++){const R=f[F],B=m[F],O=_[F],I=y[F],L=P[F];let j=T;j+=this._getAlignmentOffset(B,g,e.align);let J=0;if(e.align==="justify"&&e.wordWrap&&F<f.length-1){let k=0;for(const $ of R)k+=Qr($.text);k>0&&(J=(g-B)/k)}const K=G+O;let N=j+i;for(let k=0;k<R.length;k++){const $=R[k],{width:z,font:rt}=L[k];if(p.font=rt,p.textBaseline=$.style.textBaseline,(c=$.style._stroke)!=null&&c.width){const et=$.style._stroke;if(p.lineWidth=et.width,p.miterLimit=et.miterLimit,p.lineJoin=et.join,p.lineCap=et.cap,M)if($.style.dropShadow)this._setupDropShadow(p,$.style,n,A);else{const st=Qr($.text);N+=z+st*J;continue}else{const st=St.measureFont(rt),nt=$.style.lineHeight||st.fontSize,ot={width:z,height:nt,lineHeight:nt,lines:[$.text]};p.strokeStyle=pr(et,p,ot,i*2,N-i,G)}this._drawLetterSpacing($.text,$.style,s,N,K+i-C,!0,J)}const _t=Qr($.text);N+=z+_t*J}N=j+i;for(let k=0;k<R.length;k++){const $=R[k],{width:z,font:rt}=L[k];if(p.font=rt,p.textBaseline=$.style.textBaseline,$.style._fill!==void 0){if(M)if($.style.dropShadow)this._setupDropShadow(p,$.style,n,A);else{const et=Qr($.text);N+=z+et*J;continue}else{const et=St.measureFont(rt),st=$.style.lineHeight||et.fontSize,nt={width:z,height:st,lineHeight:st,lines:[$.text]};p.fillStyle=pr($.style._fill,p,nt,i*2,N-i,G)}this._drawLetterSpacing($.text,$.style,s,N,K+i-C,!1,J)}const _t=Qr($.text);N+=z+_t*J}G+=I}}}_setFillAndStrokeStyles(t,e,i,n,s,a=0,o=0){var l;if(t.fillStyle=e._fill?pr(e._fill,t,i,n*2,a,o):null,(l=e._stroke)!=null&&l.width){const u=s+n*2;t.strokeStyle=pr(e._stroke,t,i,u,a,o)}}_setupDropShadow(t,e,i,n){t.fillStyle="black",t.strokeStyle="black";const s=e.dropShadow,a=s.color,o=s.alpha;t.shadowColor=tt.shared.setValue(a).setAlpha(o).toRgbaString();const l=s.blur*i,u=s.distance*i;t.shadowBlur=l,t.shadowOffsetX=Math.cos(s.angle)*u,t.shadowOffsetY=Math.sin(s.angle)*u+n}_getAlignmentOffset(t,e,i){return i==="right"?e-t:i==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,i,n,s,a=!1,o=0){const{context:l}=i,u=e.letterSpacing;let c=!1;if(St.experimentalLetterSpacingSupported&&(St.experimentalLetterSpacing?(l.letterSpacing=`${u}px`,l.textLetterSpacing=`${u}px`,c=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(u===0||c)&&o===0){a?l.strokeText(t,n,s):l.fillText(t,n,s);return}if(o!==0&&(u===0||c)){const g=t.split(" ");let _=n;const y=l.measureText(" ").width;for(let b=0;b<g.length;b++)a?l.strokeText(g[b],_,s):l.fillText(g[b],_,s),_+=l.measureText(g[b]).width+y+o;return}let h=n;const p=St.graphemeSegmenter(t);let f=l.measureText(t).width,m=0;for(let g=0;g<p.length;++g){const _=p[g];a?l.strokeText(_,h,s):l.fillText(_,h,s);let y="";for(let b=g+1;b<p.length;++b)y+=p[b];m=l.measureText(y).width,h+=f-m+u,_===" "&&(h+=o),f=m}}};const ye=new JM;var tR=Object.defineProperty,eR=Object.defineProperties,rR=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,iR=Object.prototype.hasOwnProperty,nR=Object.prototype.propertyIsEnumerable,vb=(r,t,e)=>t in r?tR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lt=(r,t)=>{for(var e in t||(t={}))iR.call(t,e)&&vb(r,e,t[e]);if(bb)for(var e of bb(t))nR.call(t,e)&&vb(r,e,t[e]);return r},sR=(r,t)=>eR(r,rR(t));const lu=class yr extends Nt{constructor(t={}){var e;super(),this.uid=ht("textStyle"),this._tick=0,this._cachedFontString=null,aR(t),t instanceof yr&&(t=t._toObject());const i=Lt(Lt({},yr.defaultTextStyle),t);for(const n in i){const s=n;this[s]=i[n]}this._tagStyles=(e=t.tagStyles)!=null?e:void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Lt(Lt({},yr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Lt({},yr.defaultDropShadow)):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(Lt(Lt({},kt.defaultFillStyle),t),()=>{this._fill=Xe(Lt({},this._originalFill),kt.defaultFillStyle)})),this._fill=Xe(t===0?"black":t,kt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Lt(Lt({},kt.defaultStrokeStyle),t),()=>{this._stroke=Bi(Lt({},this._originalStroke),kt.defaultStrokeStyle)})),this._stroke=Bi(t,kt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=yr.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Zr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Lt({},this._dropShadow):null,fill:this._fill?Lt({},this._fill):void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?Lt({},this._stroke):void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?Lt({},this._tagStyles):void 0}}clone(){return new yr(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,n,s;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(a),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(s=this._originalStroke)!=null&&s.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,n,s)=>(i[n]===s||(i[n]=s,e==null||e(n,s),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(tt.isColorLike(t)||t instanceof $t||t instanceof Xr)}};lu.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},lu.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 jt=lu;function aR(r){var t,e,i,n,s;const a=r;if(typeof a.dropShadow=="boolean"&&a.dropShadow){const o=jt.defaultDropShadow;r.dropShadow={alpha:(t=a.dropShadowAlpha)!=null?t:o.alpha,angle:(e=a.dropShadowAngle)!=null?e:o.angle,blur:(i=a.dropShadowBlur)!=null?i:o.blur,color:(n=a.dropShadowColor)!=null?n:o.color,distance:(s=a.dropShadowDistance)!=null?s:o.distance}}if(a.strokeThickness!==void 0){const o=a.stroke;let l={};if(tt.isColorLike(o))l.color=o;else if(o instanceof $t||o instanceof Xr)l.fill=o;else if(Object.hasOwnProperty.call(o,"color")||Object.hasOwnProperty.call(o,"fill"))l=o;else throw new Error("Invalid stroke value.");r.stroke=sR(Lt({},l),{width:a.strokeThickness})}if(Array.isArray(a.fillGradientStops)){if(!Array.isArray(a.fill)||a.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");a.fill.length,a.fillGradientStops.length;const o=new $t({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=a.fillGradientStops.slice(),u=a.fill.map(c=>tt.shared.setValue(c).toNumber());l.forEach((c,h)=>{o.addColorStop(c,u[h])}),r.fill={fill:o}}}function Rs(r,t){const{texture:e,bounds:i}=r,n=t._style._getFinalPadding();qa(i,t._anchor,e);const s=t._anchor._x*n*2,a=t._anchor._y*n*2;i.minX-=n-s,i.minY-=n-a,i.maxX-=n-s,i.maxY-=n-a}class zi{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class xb extends zi{}class uu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,Rs(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new xb;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}uu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};class cu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,n){var s;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof jt||(t.style=new jt(t.style)),t.textureStyle instanceof Jt||(t.textureStyle=new Jt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:a,style:o,textureStyle:l,autoGenerateMipmaps:u}=t,c=(s=t.resolution)!=null?s:this._renderer.resolution,{frame:h,canvasAndContext:p}=ye.getCanvasAndContext({text:a,style:o,resolution:c}),f=Cn(p.canvas,h.width,h.height,c,u);if(l&&(f.source.style=l),o.trim&&(h.pad(o.padding),f.frame.copyFrom(h),f.frame.scale(1/c),f.updateUvs()),o.filters){const m=this._applyFilters(f,o.filters);return this.returnTexture(f),ye.returnCanvasAndContext(p),m}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||ye.returnCanvasAndContext(p),f}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&i!=null&&i.getContext){const n=i.getContext("2d");n&&ye.returnCanvasAndContext({canvas:i,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",vt.returnTexture(t,!0)}renderTextToCanvas(){}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class hu extends cu{constructor(t){super(t,!0)}}hu.extension={type:[S.CanvasSystem],name:"canvasText"};class du extends cu{constructor(t){super(t,!1)}}du.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"},X.add(hu),X.add(du),X.add(uu);class Wi extends ws{constructor(...t){var e;const i=Ps(t,"Text");super(i,jt),this.renderPipeId="text",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:s,canvasAndContext:a}=ye.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ye.returnCanvasAndContext(a),i=s.width,n=s.height}else{const s=St.measureText(this._text,this._style);i=s.width,n=s.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}class Tb extends py{resolveQueueItem(t,e){return t instanceof dt?this.resolveContainerQueueItem(t,e):t instanceof ft||t instanceof D?e.push(t.source):t instanceof kt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof pe||t instanceof Vy||t instanceof Kr?e.push(t.texture.source):t instanceof Wi?e.push(t):t instanceof hr?e.push(t.context):t instanceof Xi&&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:n}=i.data;return n.source}else if(i.action==="fill"){const{texture:n}=i.data.style;return n.source}return null}}class pu extends Nt{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 oR=Object.defineProperty,Sb=Object.getOwnPropertySymbols,lR=Object.prototype.hasOwnProperty,uR=Object.prototype.propertyIsEnumerable,wb=(r,t,e)=>t in r?oR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pb=(r,t)=>{for(var e in t||(t={}))lR.call(t,e)&&wb(r,e,t[e]);if(Sb)for(var e of Sb(t))uR.call(t,e)&&wb(r,e,t[e]);return r};const Eb=class L1 extends pu{constructor(t){var e,i,n;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 s=Pb(Pb({},L1.defaultOptions),t);this._textureSize=s.textureSize,this._mipmap=s.mipmap;const a=s.style.clone();s.overrideFill&&(a._fill.color=16777215,a._fill.alpha=1,a._fill.texture=D.WHITE,a._fill.fill=null),this.applyFillAsTint=s.overrideFill;const o=a.fontSize;a.fontSize=this.baseMeasurementFontSize;const l=Zr(a);s.overrideSize?(a._stroke&&(a._stroke.width*=this.baseRenderedFontSize/o),a.dropShadow&&(a.dropShadow.blur*=this.baseRenderedFontSize/o,a.dropShadow.distance*=this.baseRenderedFontSize/o)):a.fontSize=this.baseRenderedFontSize=o,this._style=a,this._skipKerning=(e=s.skipKerning)!=null?e:!1,this.resolution=(i=s.resolution)!=null?i:1,this._padding=(n=s.padding)!=null?n:4,s.textureStyle&&(this._textureStyle=s.textureStyle instanceof Jt?s.textureStyle:new Jt(s.textureStyle)),this.fontMetrics=St.measureFont(l),this.lineHeight=a.lineHeight||this.fontMetrics.fontSize||a.fontSize}ensureCharacters(t){var e,i,n,s;const a=St.graphemeSegmenter(t).filter(w=>!this._currentChars.includes(w)).filter((w,T,P)=>P.indexOf(w)===T);if(!a.length)return;this._currentChars=[...this._currentChars,...a];let o;this._currentPageIndex===-1?o=this._nextPage():o=this.pages[this._currentPageIndex];let{canvas:l,context:u}=o.canvasAndContext,c=o.texture.source;const h=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const g=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)+((s=(n=h._stroke)==null?void 0:n.width)!=null?s:0),y=this._padding+_;let b=!1;const x=l.width/this.resolution,v=l.height/this.resolution;for(let w=0;w<a.length;w++){const T=a[w],P=St.measureText(T,h,l,!1);P.lineHeight=P.height;const E=P.width*g,M=Math.ceil((h.fontStyle==="italic"?2:1)*E),C=P.height*g,A=M+y*2,G=C+y*2;if(b=!1,T!==`
1660 `&&T!=="\r"&&T!==" "&&T!==" "&&(b=!0,m=Math.ceil(Math.max(G,m))),p+A>x&&(f+=m,m=G,p=0,f+m>v)){c.update();const R=this._nextPage();l=R.canvasAndContext.canvas,u=R.canvasAndContext.context,c=R.texture.source,p=0,f=0,m=0}const F=u.measureText(T).width/g;if(this.chars[T]={id:T.codePointAt(0),xOffset:-(y/g),yOffset:-(y/g),xAdvance:F,kerning:{}},b){this._drawGlyph(u,P,p+y,f+y,g,h);const R=c.width*g,B=c.height*g,O=new ut(p/R*c.width,f/B*c.height,A/R*c.width,G/B*c.height);this.chars[T].texture=new D({source:c,frame:O}),p+=Math.ceil(A)}}c.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning||this._applyKerning(a,u,g)}get pageTextures(){return this.pages}_applyKerning(t,e,i){const n=this._measureCache;for(let s=0;s<t.length;s++){const a=t[s];for(let o=0;o<this._currentChars.length;o++){const l=this._currentChars[o];let u=n[a];u||(u=n[a]=e.measureText(a).width);let c=n[l];c||(c=n[l]=e.measureText(l).width);let h=e.measureText(a+l).width,p=h-(u+c);p&&this.chars[a]&&(this.chars[a].kerning[l]=p/i),h=e.measureText(a+l).width,p=h-(u+c),p&&this.chars[l]&&(this.chars[l].kerning[a]=p/i)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=me.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new D({source:new ke({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(n.source.style=this._textureStyle);const s={canvasAndContext:e,texture:n};return this.pages[this._currentPageIndex]=s,s}_setupContext(t,e,i){var n;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Zr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const s=e._stroke,a=(n=s==null?void 0:s.width)!=null?n:0;if(s&&(t.lineWidth=a,t.lineJoin=s.join,t.miterLimit=s.miterLimit,t.strokeStyle=pr(s,t)),e._fill&&(t.fillStyle=pr(e._fill,t)),e.dropShadow){const o=e.dropShadow,l=tt.shared.setValue(o.color).toArray(),u=o.blur*i,c=o.distance*i;t.shadowColor=`rgba(${l[0]*255},${l[1]*255},${l[2]*255},${o.alpha})`,t.shadowBlur=u,t.shadowOffsetX=Math.cos(o.angle)*c,t.shadowOffsetY=Math.sin(o.angle)*c}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,n,s,a){var o;const l=e.text,u=e.fontProperties,c=a._stroke,h=((o=c==null?void 0:c.width)!=null?o:0)*s,p=i+h/2,f=n-h/2,m=u.descent*s,g=e.lineHeight*s;let _=!1;a.stroke&&h&&(_=!0,t.strokeText(l,p,f+g-m));const{shadowBlur:y,shadowOffsetX:b,shadowOffsetY:x}=t;a._fill&&(_&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(l,p,f+g-m)),_&&(t.shadowBlur=y,t.shadowOffsetX=b,t.shadowOffsetY=x)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];me.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Eb.defaultOptions={textureSize:512,style:new jt,mipmap:!0};let fu=Eb;function Os(r,t,e,i){var n,s;const a={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};a.offsetY=e.baseLineOffset;let o=a.lines[0],l=null,u=!0;const c={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=e.baseMeasurementFontSize/t.fontSize,p=t.letterSpacing*h,f=t.wordWrapWidth*h,m=t.lineHeight?t.lineHeight*h:e.lineHeight,g=t.wordWrap&&t.breakWords,_=Cs(t.whiteSpace),y=Ms(t.whiteSpace);if(_||y){const w=[];let T=_;for(let P=0;P<r.length;P++){let E=r[P];if(E==="\r"||E===`
1661 `)if(y)E==="\r"&&r[P+1]===`
1662 `&&P++,E=" ";else{_&&(T=!0),w.push(E);continue}if(Qt(E))if(_&&nu(E)){if(T)continue;T=!0,w.push(" ")}else T=!1,w.push(E);else T=!1,w.push(E)}r=w}const b=w=>{const T=o.width;for(let P=0;P<c.index;P++){const E=w.positions[P];o.chars.push(w.chars[P]),o.charPositions.push(E+T)}o.width+=w.width,(c.index>0||!_)&&(u=!1),c.width=0,c.index=0,c.chars.length=0},x=()=>{let w=o.chars.length-1;if(i){let T=o.chars[w];for(;nu(T);)o.width-=e.chars[T].xAdvance,o.spacesIndex.pop(),T=o.chars[--w]}a.width=Math.max(a.width,o.width),o={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},u=!0,a.lines.push(o),a.height+=m},v=w=>w-p>f;for(let w=0;w<r.length+1;w++){let T;const P=w===r.length;P||(T=r[w]);const E=e.chars[T];if(/(?:\s)/.test(T)||T==="\r"||T===`
1663 `||P){if(!u&&t.wordWrap&&v(o.width+c.width)?(x(),b(c),P||o.charPositions.push(0)):(c.start=o.width,b(c),P||o.charPositions.push(0)),T==="\r"||T===`
1664 `)x();else if(!P&&E){const M=E.xAdvance+(((n=E.kerning)==null?void 0:n[l])||0)+p;o.width+=M,o.spaceWidth=M,o.spacesIndex.push(o.charPositions.length),o.chars.push(T)}}else if(E){const M=((s=E.kerning)==null?void 0:s[l])||0,C=E.xAdvance+M+p;g&&v(c.width+C)&&(u||x(),b(c),x()),c.positions[c.index++]=c.width+M,c.chars.push(T),c.width+=C,su(T)&&(!u&&t.wordWrap&&v(o.width+c.width)&&x(),b(c))}l=T}return x(),t.align==="center"?cR(a):t.align==="right"?hR(a):t.align==="justify"&&dR(a),a}function cR(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width/2-e.width/2;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=i}}function hR(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width-e.width;for(let n=0;n<e.charPositions.length;n++)e.charPositions[n]+=i}}function dR(r){const t=r.width;for(let e=0;e<r.lines.length-2;e++){const i=r.lines[e];let n=0,s=i.spacesIndex[n++],a=0;const o=i.spacesIndex.length,l=(t-i.width)/o;for(let u=0;u<i.charPositions.length;u++)u===s&&(s=i.spacesIndex[n++],a+=l),i.charPositions[u]+=a}}function Ab(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const n=r[e];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const s=n[0].charCodeAt(0),a=n[1].charCodeAt(0);if(a<s)throw new Error("[BitmapFont]: Invalid character range.");for(let o=s,l=a;o<=l;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var pR=Object.defineProperty,Cb=Object.getOwnPropertySymbols,fR=Object.prototype.hasOwnProperty,mR=Object.prototype.propertyIsEnumerable,Mb=(r,t,e)=>t in r?pR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mu=(r,t)=>{for(var e in t||(t={}))fR.call(t,e)&&Mb(r,e,t[e]);if(Cb)for(var e of Cb(t))mR.call(t,e)&&Mb(r,e,t[e]);return r};let Gs=0,gR=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=tb(1e3)}getFont(t,e){var i,n;let s=`${e.fontFamily}-bitmap`,a=!0;if(it.has(s)){const l=it.get(s);return(i=l.ensureCharacters)==null||i.call(l,t),l}if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,a=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,a=!1),s+=`-${e.fontStyle}`,s+=`-${e.fontVariant}`,s+=`-${e.fontWeight}`,!it.has(s)){const l=Object.create(e);l._lineHeight=0;const u=new fu(mu({style:l,overrideFill:a,overrideSize:!0},this.defaultOptions));Gs++,Gs>50&&ue("BitmapText",`You have dynamically created ${Gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Gs--,it.remove(s)}),it.set(s,u)}const o=it.get(s);return(n=o.ensureCharacters)==null||n.call(o,t),o}getLayout(t,e,i=!0){const n=this.getFont(t,e),s=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(s))return this.measureCache.get(s);const a=St.graphemeSegmenter(t),o=Os(a,e,n,i);return this.measureCache.set(s,o),o}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,n,s,a;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:(n=t[2])==null?void 0:n.padding,skipKerning:(s=t[2])==null?void 0:s.skipKerning});const l=o==null?void 0:o.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");o=mu(mu({},this.defaultOptions),o);const u=o.style,c=u instanceof jt?u:new jt(u),h=(a=o.dynamicFill)!=null?a:this._canUseTintForStyle(c),p=new fu({style:c,overrideFill:h,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),f=Ab(o.chars);return p.ensureCharacters(f.join("")),it.set(`${l}-bitmap`,p),p.once("destroy",()=>it.remove(`${l}-bitmap`)),p}uninstall(t){const e=`${t}-bitmap`,i=it.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const Jr=new gR;class Rb extends hr{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class gu{constructor(t){this._renderer=t,this._managedBitmapTexts=new Ut({renderer:t,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Ob(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);Ob(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=Jr.getFont(t.text,t._style);if(i.clear(),n.distanceField.type!=="none"){const y=this.getSdfShader();y&&(i.customShader||(i.customShader=y))}const s=St.graphemeSegmenter(t.text),a=t._style;let o=n.baseLineOffset;const l=Os(s,a,n,!0),u=a.padding,c=l.scale;let h=l.width,p=l.height+l.offsetY;a._stroke&&(h+=a._stroke.width/c,p+=a._stroke.width/c),i.translate(-t._anchor._x*h-u,-t._anchor._y*p-u).scale(c,c);const f=n.applyFillAsTint?a._fill.color:16777215;let m=n.fontMetrics.fontSize,g=n.lineHeight;a.lineHeight&&(m=a.fontSize/c,g=a.lineHeight/c);let _=(g-m)/2;_-n.baseLineOffset<0&&(_=0);for(let y=0;y<l.lines.length;y++){const b=l.lines[y];for(let x=0;x<b.charPositions.length;x++){const v=b.chars[x],w=n.chars[v];if(w!=null&&w.texture){const T=w.texture;i.texture(T,f,Math.round(b.charPositions[x]+w.xOffset),Math.round(o+w.yOffset+_),T.orig.width,T.orig.height)}}o+=g}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Rb;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),this._managedBitmapTexts.add(t),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,n=it.get(`${i}-bitmap`),{a:s,b:a,c:o,d:l}=t.groupTransform,u=Math.sqrt(s*s+a*a),c=Math.sqrt(o*o+l*l),h=(Math.abs(u)+Math.abs(c))/2,p=n.baseRenderedFontSize/t._style.fontSize,f=h*n.distanceField.range*(1/p);e.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){this._managedBitmapTexts.destroy(),this._renderer=null,this._managedBitmapTexts=null}}function Ob(r,t){t.groupTransform=r.groupTransform,t.groupColorAlpha=r.groupColorAlpha,t.groupColor=r.groupColor,t.groupBlendMode=r.groupBlendMode,t.globalDisplayStatus=r.globalDisplayStatus,t.groupTransform=r.groupTransform,t.localDisplayStatus=r.localDisplayStatus,t.groupAlpha=r.groupAlpha,t._roundPixels=r._roundPixels}class _u extends gu{getSdfShader(){return null}}_u.extension={type:[S.CanvasPipes],name:"bitmapText"};const Gb={name:"local-uniform-msdf-bit",vertex:{header:`
1665 struct LocalUniforms {
1666 uColor:vec4<f32>,
1667 uTransformMatrix:mat3x3<f32>,
1668 uDistance: f32,
1669 uRound:f32,
1670 }
1671
1672 @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
1673 `,main:`
1674 vColor *= localUniforms.uColor;
1675 modelMatrix *= localUniforms.uTransformMatrix;
1676 `,end:`
1677 if(localUniforms.uRound == 1)
1678 {
1679 vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
1680 }
1681 `},fragment:{header:`
1682 struct LocalUniforms {
1683 uColor:vec4<f32>,
1684 uTransformMatrix:mat3x3<f32>,
1685 uDistance: f32
1686 }
1687
1688 @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
1689 `,main:`
1690 outColor = vec4<f32>(calculateMSDFAlpha(outColor, vColor, localUniforms.uDistance));
1691 `}},Ib={name:"local-uniform-msdf-bit",vertex:{header:`
1692 uniform mat3 uTransformMatrix;
1693 uniform vec4 uColor;
1694 uniform float uRound;
1695 `,main:`
1696 vColor *= uColor;
1697 modelMatrix *= uTransformMatrix;
1698 `,end:`
1699 if(uRound == 1.)
1700 {
1701 gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
1702 }
1703 `},fragment:{header:`
1704 uniform float uDistance;
1705 `,main:`
1706 outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
1707 `}},Bb={name:"msdf-bit",fragment:{header:`
1708 fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
1709
1710 // MSDF
1711 var median = msdfColor.r + msdfColor.g + msdfColor.b -
1712 min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
1713 max(msdfColor.r, max(msdfColor.g, msdfColor.b));
1714
1715 // SDF
1716 median = min(median, msdfColor.a);
1717
1718 var screenPxDistance = distance * (median - 0.5);
1719 var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
1720 if (median < 0.01) {
1721 alpha = 0.0;
1722 } else if (median > 0.99) {
1723 alpha = 1.0;
1724 }
1725
1726 // Gamma correction for coverage-like alpha
1727 var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
1728 var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
1729 var coverage: f32 = pow(shapeColor.a * alpha, gamma);
1730
1731 return coverage;
1732
1733 }
1734 `}},Fb={name:"msdf-bit",fragment:{header:`
1735 float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
1736
1737 // MSDF
1738 float median = msdfColor.r + msdfColor.g + msdfColor.b -
1739 min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
1740 max(msdfColor.r, max(msdfColor.g, msdfColor.b));
1741
1742 // SDF
1743 median = min(median, msdfColor.a);
1744
1745 float screenPxDistance = distance * (median - 0.5);
1746 float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
1747
1748 if (median < 0.01) {
1749 alpha = 0.0;
1750 } else if (median > 0.99) {
1751 alpha = 1.0;
1752 }
1753
1754 // Gamma correction for coverage-like alpha
1755 float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
1756 float gamma = mix(1.0, 1.0 / 2.2, luma);
1757 float coverage = pow(shapeColor.a * alpha, gamma);
1758
1759 return coverage;
1760 }
1761 `}};let yu,bu;class Db extends ee{constructor(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});yu!=null||(yu=Fr({name:"sdf-shader",bits:[Ln,Xn(t),Gb,Bb,Ur]})),bu!=null||(bu=Dr({name:"sdf-shader",bits:[Nn,jn(t),Ib,Fb,$r]})),super({glProgram:bu,gpuProgram:yu,resources:{localUniforms:e,batchSamplers:Hn(t)}})}}class vu extends gu{getSdfShader(){return new Db(this._renderer.limits.maxBatchableTextures)}}vu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"bitmapText"},X.add(_u),X.add(vu);class xu extends ws{constructor(...t){var e,i,n;const s=Ps(t,"BitmapText");(e=s.style)!=null||(s.style=s.style||{}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s,jt),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const i in this._gpuData)(e=this._gpuData[i])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,i=Jr.measureText(this.text,this._style),n=i.scale,s=i.offsetY*n;let a=i.width*n,o=i.height*n;const l=this._style._stroke;l&&(a+=l.width,o+=l.width),t.minX=-e._x*a,t.maxX=t.minX+a,t.minY=-e._y*(o+s),t.maxY=t.minY+o}set resolution(t){}get resolution(){return this._resolution}}var _R=Object.defineProperty,Ub=Object.getOwnPropertySymbols,yR=Object.prototype.hasOwnProperty,bR=Object.prototype.propertyIsEnumerable,$b=(r,t,e)=>t in r?_R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tu=(r,t)=>{for(var e in t||(t={}))yR.call(t,e)&&$b(r,e,t[e]);if(Ub)for(var e of Ub(t))bR.call(t,e)&&$b(r,e,t[e]);return r};function kb(r){var t;const e=r._stroke,i=r._fill,n=[`div { ${[`color: ${tt.shared.setValue(i.color).setAlpha((t=i.alpha)!=null?t:1).toHexa()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-break: ${r.breakWords?"break-word":"normal"}`,`max-width: ${r.wordWrapWidth}px`]:[],...e?[Lb(e)]:[],...r.dropShadow?[Su(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return vR(r.tagStyles,n),n.join(" ")}function Su(r){var t;const e=Tu({},r),i=tt.shared.setValue(e.color).setAlpha((t=e.alpha)!=null?t:1).toHexa(),n=Math.round(Math.cos(e.angle)*e.distance),s=Math.round(Math.sin(e.angle)*e.distance),a=`${n}px ${s}px`;return e.blur>0?`text-shadow: ${a} ${e.blur}px ${i}`:`text-shadow: ${a} ${i}`}function Lb(r){var t;const e=tt.shared.setValue(r.color).setAlpha((t=r.alpha)!=null?t:1).toHexa();return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${e}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${e}`,"paint-order: stroke"].join(";")}const Nb={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"},Xb={fill:r=>`color: ${tt.shared.setValue(r).toHexa()}`,breakWords:r=>`word-break: ${r?"break-all":"normal"}`,stroke:Lb,dropShadow:r=>r===!0?Su(jt.defaultDropShadow):r&&typeof r=="object"?Su(Tu(Tu({},jt.defaultDropShadow),r)):""};function vR(r,t){for(const e in r){const i=r[e],n=[];for(const s in i)Xb[s]?n.push(Xb[s](i[s])):Nb[s]&&n.push(Nb[s].replace("{{VALUE}}",i[s]));t.push(`${e} { ${n.join(";")} }`)}}var xR=Object.defineProperty,jb=Object.getOwnPropertySymbols,TR=Object.prototype.hasOwnProperty,SR=Object.prototype.propertyIsEnumerable,Hb=(r,t,e)=>t in r?xR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zb=(r,t)=>{for(var e in t||(t={}))TR.call(t,e)&&Hb(r,e,t[e]);if(jb)for(var e of jb(t))SR.call(t,e)&&Hb(r,e,t[e]);return r};class Is extends jt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:{},this.update())}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new Is({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?zb({},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:zb({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=kb(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}}const Wb="http://www.w3.org/2000/svg",Vb="http://www.w3.org/1999/xhtml";class wu{constructor(){this.svgRoot=document.createElementNS(Wb,"svg"),this.foreignObject=document.createElementNS(Wb,"foreignObject"),this.domElement=document.createElementNS(Vb,"div"),this.styleElement=document.createElementNS(Vb,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:n}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(n),this.image=H.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}let Yb;function Pu(r,t,e,i){i||(i=Yb||(Yb=new wu));const{domElement:n,styleElement:s,svgRoot:a}=i;n.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${r}</div>`,n.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(s.textContent=e),document.body.appendChild(a);let o=n.scrollWidth,l=n.scrollHeight;if(a.remove(),t.dropShadow){const{distance:c,angle:h,blur:p}=t.dropShadow,f=Math.abs(Math.round(Math.cos(h)*c)),m=Math.abs(Math.round(Math.sin(h)*c));o+=f+p,l+=m+p}const u=t.padding*2;return{width:o-u,height:l-u}}class Kb extends zi{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class Eu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"htmlText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==n)&&this._updateGpuText(t).catch(s=>{console.error(s)}),t._didTextUpdate=!1,Rs(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;const i=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let n=this._renderer.htmlText.getTexturePromise(t);i&&(n=n.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=n,e.currentKey=t.styleKey,e.texture=await n;const s=t.renderGroup||t.parentRenderGroup;s&&(s.structureDidChange=!0),e.generatingTexture=!1,Rs(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Kb;return e.renderable=t,e.transform=t.groupTransform,e.texture=D.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{htmlText:i}=this._renderer;i.getReferenceCount(e.currentKey)===null?i.returnTexturePromise(e.texturePromise):i.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Eu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"htmlText"};function Au(){const{userAgent:r}=H.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}function qb(r,t){const e=t.fontFamily,i=[],n={},s=/font-family:([^;"\s]+)/g,a=r.match(s);function o(l){n[l]||(i.push(l),n[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)o(e[l]);else o(e);a&&a.forEach(l=>{const u=l.split(":")[1].trim();o(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;o(u)}return i}async function Zb(r){const t=await(await H.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,n)=>{e.onloadend=()=>i(e.result),e.onerror=n,e.readAsDataURL(t)})}async function Qb(r,t){const e=await Zb(t);return`@font-face {
1762 font-family: "${r.fontFamily}";
1763 font-weight: ${r.fontWeight};
1764 font-style: ${r.fontStyle};
1765 src: url('${e}');
1766 }`}const Bs=new Map;async function Jb(r){const t=r.filter(e=>it.has(`${e}-and-url`)).map(e=>{if(!Bs.has(e)){const{entries:i}=it.get(`${e}-and-url`),n=[];i.forEach(s=>{const a=s.url,o=s.faces.map(l=>({weight:l.weight,style:l.style}));n.push(...o.map(l=>Qb({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},a)))}),Bs.set(e,Promise.all(n).then(s=>s.join(`
1767 `)))}return Bs.get(e)});return(await Promise.all(t)).join(`
1768 `)}function tv(r,t,e,i,n){const{domElement:s,styleElement:a,svgRoot:o}=n;s.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${r}</div>`,s.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:l,height:u}=n.image;return o.setAttribute("width",l.toString()),o.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(o)}function ev(r,t){const e=me.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 rv(r,t,e){return new Promise(async i=>{e&&await new Promise(n=>setTimeout(n,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}class Cu{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===It.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const i=this._buildTexturePromise(t).then(n=>(this._activeTextures[e].texture=n,n));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(i=>{e.texture=i,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:n,textureStyle:s,autoGenerateMipmaps:a}=t,o=Et.get(wu),l=qb(e,i),u=await Jb(l),c=Pu(e,i,u,o),h=Math.ceil(Math.ceil(Math.max(1,c.width)+i.padding*2)*n),p=Math.ceil(Math.ceil(Math.max(1,c.height)+i.padding*2)*n),f=o.image,m=2;f.width=(h|0)+m,f.height=(p|0)+m;const g=tv(e,i,n,u,o);await rv(f,g,Au()&&l.length>0);const _=f;let y;this._createCanvas&&(y=ev(f,n));const b=Cn(y?y.canvas:_,f.width-m,f.height-m,n,a);return s&&(b.source.style=s),this._createCanvas&&(this._renderer.texture.initSource(b.source),me.returnCanvasAndContext(y)),Et.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){vt.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Cu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"htmlText"},X.add(Cu),X.add(Eu);class iv extends ws{constructor(...t){var e;const i=Ps(t,"HtmlText");super(i,Is),this.renderPipeId="htmlText",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor,i=Pu(this.text,this._style),{width:n,height:s}=i;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*s,t.maxY=t.minY+s}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;"))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class nv extends Tb{uploadQueueItem(t){t instanceof ft?this.uploadTextureSource(t):t instanceof Wi?this.uploadText(t):t instanceof iv?this.uploadHTMLText(t):t instanceof xu?this.uploadBitmapText(t):t instanceof kt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:n}=i.data;this.uploadTextureSource(n.source)}else if(i.action==="fill"){const{texture:n}=i.data.style;this.uploadTextureSource(n.source)}return null}}class sv extends nv{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}sv.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"prepare"};const Mu=class br{static _getPatternRepeat(t,e){const i=t&&t!=="clamp-to-edge",n=e&&e!=="clamp-to-edge";return i&&n?"repeat":i?"repeat-x":n?"repeat-y":"no-repeat"}start(t,e,i){}execute(t,e){var i,n,s,a,o,l,u,c,h,p;const f=e.elements;if(!f||!f.length)return;const m=t.renderer,g=m.canvasContext,_=g.activeContext;for(let y=0;y<f.length;y++){const b=f[y];if(!b.packAsQuad)continue;const x=b,v=x.texture,w=v?Q.getCanvasSource(v):null;if(!w)continue;const T=v.source.style,P=g.smoothProperty,E=T.scaleMode!=="nearest";_[P]!==E&&(_[P]=E),g.setBlendMode(e.blendMode);const M=(n=(i=m.globalUniforms.globalUniformData)==null?void 0:i.worldColor)!=null?n:4294967295,C=x.color,A=(M>>>24&255)/255,G=(C>>>24&255)/255,F=(a=(s=m.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,R=A*G*F;if(R<=0)continue;_.globalAlpha=R;const B=M&16777215,O=C&16777215,I=xe(Oe(O,B)),L=v.frame,j=(o=T.addressModeU)!=null?o:T.addressMode,J=(l=T.addressModeV)!=null?l:T.addressMode,K=br._getPatternRepeat(j,J),N=(c=(u=v.source._resolution)!=null?u:v.source.resolution)!=null?c:1,k=(p=(h=x.renderable)==null?void 0:h.renderGroup)==null?void 0:p.isCachedAsTexture,$=L.x*N,z=L.y*N,rt=L.width*N,_t=L.height*N,et=x.bounds,st=m.renderTarget.renderTarget.isRoot,nt=et.minX,ot=et.minY,gt=et.maxX-et.minX,yt=et.maxY-et.minY,pt=v.rotate,Y=v.uvs,Rt=Math.min(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),Ct=Math.max(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),ce=K!=="no-repeat"&&(Rt<0||Ct>1),mh=pt&&!(!ce&&(I!==16777215||pt));mh?(br._tempPatternMatrix.copyFrom(x.transform),W.matrixAppendRotationInv(br._tempPatternMatrix,pt,nt,ot,gt,yt),g.setContextTransform(br._tempPatternMatrix,x.roundPixels===1,void 0,k&&st)):g.setContextTransform(x.transform,x.roundPixels===1,void 0,k&&st);const ya=mh?0:nt,ba=mh?0:ot,gh=gt,_h=yt;if(ce){let _r=w;const ii=I!==16777215&&!pt,PB=L.width<=v.source.width&&L.height<=v.source.height;ii&&PB&&(_r=Q.getTintedCanvas({texture:v},I));const yh=_.createPattern(_r,K);if(!yh)continue;const m1=gh,g1=_h;if(m1===0||g1===0)continue;const _1=1/m1,y1=1/g1,b1=(Y.x1-Y.x0)*_1,v1=(Y.y1-Y.y0)*_1,x1=(Y.x3-Y.x0)*y1,T1=(Y.y3-Y.y0)*y1,EB=Y.x0-b1*ya-x1*ba,AB=Y.y0-v1*ya-T1*ba,bh=v.source.pixelWidth,vh=v.source.pixelHeight;br._tempPatternMatrix.set(b1*bh,v1*vh,x1*bh,T1*vh,EB*bh,AB*vh),Q.applyPatternTransform(yh,br._tempPatternMatrix),_.fillStyle=yh,_.fillRect(ya,ba,gh,_h)}else{const _r=I!==16777215||pt?Q.getTintedCanvas({texture:v},I):w,ii=_r!==w;_.drawImage(_r,ii?0:$,ii?0:z,ii?_r.width:rt,ii?_r.height:_t,ya,ba,gh,_h)}}}};Mu._tempPatternMatrix=new U,Mu.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let av=Mu;class Ru{constructor(){this._tempState=Vt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,s=this._didUploadHash[i.uid];n.shader.bind(i,s),s||(this._didUploadHash[i.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const n=e.textures.textures;for(let s=0;s<e.textures.count;s++)i.texture.bind(n[s],s);i.geometry.draw(e.topology,e.size,e.start)}}Ru.extension={type:[S.WebGLPipesAdaptor],name:"batch"};function wR(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 PR(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 Fs=Vt.for2d();class Ou{start(t,e,i){const n=t.renderer,s=n.encoder,a=i.gpuProgram;this._shader=i,this._geometry=e,s.setGeometry(e,a),Fs.blendMode="normal",n.pipeline.getPipeline(e,a,Fs);const o=n.globalUniforms.bindGroup;s.resetBindGroup(1),s.setBindGroup(0,o,a)}execute(t,e){const i=this._shader.gpuProgram,n=t.renderer,s=n.encoder;if(!e.bindGroup){const l=e.textures;e.bindGroup=Un(l.textures,l.count,n.limits.maxBatchableTextures)}Fs.blendMode=e.blendMode;const a=n.bindGroup.getBindGroup(e.bindGroup,i,1),o=n.pipeline.getPipeline(this._geometry,i,Fs,e.topology);e.bindGroup._touch(n.gc.now,n.tick),s.setPipeline(o),s.renderPassEncoder.setBindGroup(1,a),s.renderPassEncoder.drawIndexed(e.size,1,e.start)}}Ou.extension={type:[S.WebGPUPipesAdaptor],name:"batch"};const Gu=class N1{constructor(t,e){this.state=Vt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null);var i,n;this.renderer=t,this._adaptor=e,(n=(i=this._adaptor).init)==null||n.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 zn({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]=N1.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 n=e[i],s=n.geometry;s.indexBuffer.setDataWithSize(n.indexBuffer,n.indexSize,!0),s.buffers[0].setDataWithSize(n.attributeBuffer.float32View,n.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const n=e[i],s=n.geometry;n.dirty&&(n.dirty=!1,s.buffers[0].update(n.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=e.geometry,n=e.shader;this._adaptor.start(this,i,n)}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}};Gu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"batch"},Gu._availableBatchers=Object.create(null);let Ds=Gu;X.handleByMap(S.Batcher,Ds._availableBatchers),X.add(zn);function ER(r){const t=r.split(/([\n{}])/g).map(i=>i.trim()).filter(i=>i.length);let e="";return t.map(i=>{let n=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),n=e+i),n}).join(`
1769 `)}const ov={name:"texture-bit",vertex:{header:`
1770
1771 struct TextureUniforms {
1772 uTextureMatrix:mat3x3<f32>,
1773 }
1774
1775 @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
1776 `,main:`
1777 uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
1778 `},fragment:{header:`
1779 @group(2) @binding(0) var uTexture: texture_2d<f32>;
1780 @group(2) @binding(1) var uSampler: sampler;
1781
1782
1783 `,main:`
1784 outColor = textureSample(uTexture, uSampler, vUV);
1785 `}},lv={name:"texture-bit",vertex:{header:`
1786 uniform mat3 uTextureMatrix;
1787 `,main:`
1788 uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
1789 `},fragment:{header:`
1790 uniform sampler2D uTexture;
1791
1792
1793 `,main:`
1794 outColor = texture(uTexture, vUV);
1795 `}},AR=new Mt;let CR=class extends oi{constructor(){super(),this.filters=[new hy({sprite:new pe(D.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}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}};class Us{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){var n;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.channel=(n=e._maskOptions.channel)!=null?n:"red",t.renderMaskToTexture){const a=t.mask;a.includeInBuild=!0,a.collectRenderables(i,s,null),a.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 n=Et.get(CR);if(n.inverse=t.inverse,n.channel=t.mask.channel,i){t.mask.mask.measurable=!0;const s=li(t.mask.mask,!0,AR);t.mask.mask.measurable=!1,s.ceil();const a=e.renderTarget.renderTarget.colorTexture.source,o=vt.getOptimalTexture(s.width,s.height,a._resolution,a.antialias);e.renderTarget.push(o,!0),e.globalUniforms.push({offset:s,worldColor:4294967295});const l=n.sprite;l.texture=o,l.worldTransform.tx=s.minX,l.worldTransform.ty=s.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:o})}else n.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const n=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===It.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:n.maskedContainer,filterEffect:n.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const n=this._activeMaskStage.pop();i&&vt.returnTexture(n.filterTexture),Et.return(n.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Us.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class Iu{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 n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Iu.extension={type:[S.CanvasPipes],name:"colorMask"};class Bu{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 n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Bu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};class MR{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){xn(this.mask,t,e)}addLocalBounds(t,e){Tn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}function RR(r,t,e,i,n,s){s=Math.max(0,Math.min(s,Math.min(i,n)/2)),r.moveTo(t+s,e),r.lineTo(t+i-s,e),r.quadraticCurveTo(t+i,e,t+i,e+s),r.lineTo(t+i,e+n-s),r.quadraticCurveTo(t+i,e+n,t+i-s,e+n),r.lineTo(t+s,e+n),r.quadraticCurveTo(t,e+n,t,e+n-s),r.lineTo(t,e+s),r.quadraticCurveTo(t,e,t+s,e)}function uv(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;RR(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.moveTo(e.x+e.radius,e.y),r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?(r.moveTo(e.x+e.halfWidth,e.y),r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,i=e.points;if(!(i!=null&&i.length))break;r.moveTo(i[0],i[1]);for(let n=2;n<i.length;n+=2)r.lineTo(i[n],i[n+1]);e.closePath&&r.closePath();break}}}function OR(r,t,e){var i;const n=[],s=[],a=[],o=Ne[t.type];if(!(o!=null&&o.build(t,n)))return!1;const l=(i=t.closePath)!=null?i:!0;qn(n,e,!1,l,s,a);for(let u=0;u<a.length;u+=3){const c=a[u]*2,h=a[u+1]*2,p=a[u+2]*2;r.moveTo(s[c],s[c+1]),r.lineTo(s[h],s[h+1]),r.lineTo(s[p],s[p+1]),r.closePath()}return!0}function GR(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const i=t[e];if(!(i!=null&&i.shape))continue;const n=i.transform,s=n&&!n.isIdentity();s&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),uv(r,i.shape),s&&r.restore()}return!0}class Fu{constructor(t){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){var e,i,n;if(t.action!=="pushMaskBegin"&&t.action!=="popMaskEnd")return;const s=this._renderer,a=s.canvasContext,o=a==null?void 0:a.activeContext;if(!o)return;if(t.action==="popMaskEnd"){this._canvasMaskStack.pop()&&o.restore();return}t.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const l=t.mask.mask;if(!(l instanceof hr)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const u=l,c=(e=u.context)==null?void 0:e.instructions;if(!(c!=null&&c.length)){this._canvasMaskStack.push(!1);return}o.save(),a.setContextTransform(u.groupTransform,(s._roundPixels|u._roundPixels)===1),o.beginPath();let h=!1,p=!1;for(let f=0;f<c.length;f++){const m=c[f],g=m.action;if(g!=="fill"&&g!=="stroke")continue;const _=m.data,y=(i=_==null?void 0:_.path)==null?void 0:i.shapePath;if(!((n=y==null?void 0:y.shapePrimitives)!=null&&n.length))continue;const b=g==="stroke",x=y.shapePrimitives;for(let v=0;v<x.length;v++){const w=x[v];if(!(w!=null&&w.shape))continue;const T=w.transform,P=T&&!T.isIdentity();P&&(o.save(),o.transform(T.a,T.b,T.c,T.d,T.tx,T.ty)),b&&_.style?h=OR(o,w.shape,_.style)||h:(uv(o,w.shape),p=GR(o,w.holes)||p,h=!0),P&&o.restore()}}if(!h){o.restore(),this._canvasMaskStack.push(!1);return}p?o.clip("evenodd"):o.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(t,e){this._warnedMaskTypes.has(t)||(this._warnedMaskTypes.add(t),ue(e))}}Fu.extension={type:[S.CanvasPipes],name:"stencilMask"};class Du{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var n,s;const a=t,o=this._renderer;o.renderPipes.batch.break(i),o.renderPipes.blendMode.setBlendMode(a.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=a.mask;l.includeInBuild=!0,this._maskHash.has(a)||this._maskHash.set(a,{instructionsStart:0,instructionsLength:0});const u=this._maskHash.get(a);u.instructionsStart=i.instructionSize,l.collectRenderables(i,o,null),l.includeInBuild=!1,o.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=o.renderTarget.renderTarget.uid;(s=(n=this._maskStackHash)[h])!=null||(n[h]=0)}pop(t,e,i){const n=t,s=this._renderer;s.renderPipes.batch.break(i),s.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const a=this._maskHash.get(t);for(let o=0;o<a.instructionsLength;o++)i.instructions[i.instructionSize++]=i.instructions[a.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i;const n=this._renderer,s=n,a=n.renderTarget.renderTarget.uid;let o=(i=(e=this._maskStackHash)[a])!=null?i:e[a]=0;t.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(wt.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?s.stencil.setStencilMode(wt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(wt.MASK_ACTIVE,o),s.colorMask.setMask(15)):t.action==="popMaskBegin"?(s.colorMask.setMask(0),o!==0?s.stencil.setStencilMode(wt.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,Kt.STENCIL),s.stencil.setStencilMode(wt.DISABLED,o)),o--):t.action==="popMaskEnd"&&(t.inverse?s.stencil.setStencilMode(wt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(wt.MASK_ACTIVE,o),s.colorMask.setMask(15)),this._maskStackHash[a]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Du.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"stencilMask"};const mt="source-over";function cv(){const r=so(),t=Object.create(null);return t.inherit=mt,t.none=mt,t.normal="source-over",t.add="lighter",t.multiply=r?"multiply":mt,t.screen=r?"screen":mt,t.overlay=r?"overlay":mt,t.darken=r?"darken":mt,t.lighten=r?"lighten":mt,t["color-dodge"]=r?"color-dodge":mt,t["color-burn"]=r?"color-burn":mt,t["hard-light"]=r?"hard-light":mt,t["soft-light"]=r?"soft-light":mt,t.difference=r?"difference":mt,t.exclusion=r?"exclusion":mt,t.saturation=r?"saturation":mt,t.color=r?"color":mt,t.luminosity=r?"luminosity":mt,t["linear-burn"]=r?"color-burn":mt,t["linear-dodge"]=r?"color-dodge":mt,t["linear-light"]=r?"hard-light":mt,t["pin-light"]=r?"hard-light":mt,t["vivid-light"]=r?"hard-light":mt,t["hard-mix"]=mt,t.negation=r?"difference":mt,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=mt,t.divide=mt,t.min=mt,t.max=mt,t}const IR=new U;class Uu{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=cv(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=t}resolutionChange(t){this.activeResolution=t}init(){const t=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,i,n){var s;const a=n?U.IDENTITY:((s=this._renderer.globalUniforms.globalUniformData)==null?void 0:s.worldTransformMatrix)||U.IDENTITY;let o=IR;o.copyFrom(a),o.append(t);const l=this._projTransform,u=this.activeResolution;if(i=i||u,l){const c=U.shared;c.copyFrom(o),c.prepend(l),o=c}e?this.activeContext.setTransform(o.a*i,o.b*i,o.c*i,o.d*i,o.tx*u|0,o.ty*u|0):this.activeContext.setTransform(o.a*i,o.b*i,o.c*i,o.d*i,o.tx*u,o.ty*u)}clear(t,e){const i=this.activeContext,n=this._renderer;if(i.clearRect(0,0,n.width,n.height),t){const s=tt.shared.setValue(t);i.globalAlpha=e!=null?e:s.alpha,i.fillStyle=s.toHex(),i.fillRect(0,0,n.width,n.height),i.globalAlpha=1}}setBlendMode(t){if(this._activeBlendMode===t)return;this._activeBlendMode=t,this._outerBlend=!1;const e=this.blendModes[t];if(!e){this._warnedBlendModes.has(t)||(console.warn(`CanvasRenderer: blend mode "${t}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(t)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=e}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Uu.extension={type:[S.CanvasSystem],name:"canvasContext"};class $u{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}$u.extension={type:[S.CanvasSystem],name:"limits"};class $s{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}}$s.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"customRender"};function ks(r,t){const e=r.instructionSet,i=e.instructions;for(let n=0;n<e.instructionSize;n++){const s=i[n];t[s.renderPipeId].execute(s)}}class Ls{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(Et.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const n=(i=t._batchableRenderGroup)!=null?i:t._batchableRenderGroup=Et.get(zi);n.renderable=t.root,n.transform=t.root.relativeGroupTransform,n.texture=t.texture,n.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(n,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=new U().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),ks(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}),ks(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}Ls.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"renderGroup"};const BR="#808080",Ns=new U,FR=new U,DR=new U,ku=new U;function UR(r,t,e){r.beginPath();for(let i=0;i<e.length;i+=3){const n=e[i]*2,s=e[i+1]*2,a=e[i+2]*2;r.moveTo(t[n],t[n+1]),r.lineTo(t[s],t[s+1]),r.lineTo(t[a],t[a+1]),r.closePath()}r.fill()}function $R(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function kR(r,t,e,i,n,s){s=Math.max(0,Math.min(s,Math.min(i,n)/2)),r.moveTo(t+s,e),r.lineTo(t+i-s,e),r.quadraticCurveTo(t+i,e,t+i,e+s),r.lineTo(t+i,e+n-s),r.quadraticCurveTo(t+i,e+n,t+i-s,e+n),r.lineTo(t+s,e+n),r.quadraticCurveTo(t,e+n,t,e+n-s),r.lineTo(t,e+s),r.quadraticCurveTo(t,e,t+s,e)}function Xs(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;kR(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,i=e.points;if(!(i!=null&&i.length))break;r.moveTo(i[0],i[1]);for(let n=2;n<i.length;n+=2)r.lineTo(i[n],i[n+1]);e.closePath&&r.closePath();break}}}function LR(r,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const i=t[e];if(!(i!=null&&i.shape))continue;const n=i.transform,s=n&&!n.isIdentity();s&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Xs(r,i.shape),s&&r.restore()}return!0}function NR(r,t,e,i){const n=r.fill;if(n instanceof $t){n.buildGradient();const a=n.texture;if(a){const o=Q.getTintedPattern(a,t),l=e?ku.copyFrom(e).scale(a.source.pixelWidth,a.source.pixelHeight):ku.copyFrom(n.transform);return i&&!r.textureSpace&&l.append(i),Q.applyPatternTransform(o,l),o}}if(n instanceof Xr){const a=Q.getTintedPattern(n.texture,t);return Q.applyPatternTransform(a,n.transform),a}const s=r.texture;if(s&&s!==D.WHITE){if(!s.source.resource)return BR;const a=Q.getTintedPattern(s,t),o=e?ku.copyFrom(e).scale(s.source.pixelWidth,s.source.pixelHeight):r.matrix;return Q.applyPatternTransform(a,o),a}return $R(t)}class Lu{constructor(){this.shader=null}contextChange(t){}execute(t,e){var i,n,s,a,o,l,u,c,h,p,f,m;const g=t.renderer,_=g.canvasContext,y=_.activeContext,b=e.groupTransform,x=(n=(i=g.globalUniforms.globalUniformData)==null?void 0:i.worldColor)!=null?n:4294967295,v=e.groupColorAlpha,w=(x>>>24&255)/255,T=(v>>>24&255)/255,P=(a=(s=g.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,E=w*T*P;if(E<=0)return;const M=x&16777215,C=v&16777215,A=xe(Oe(C,M)),G=g._roundPixels|e._roundPixels;y.save(),_.setContextTransform(b,G===1),_.setBlendMode(e.groupBlendMode);const F=e.context.instructions;for(let R=0;R<F.length;R++){const B=F[R];if(B.action==="texture"){const k=B.data,$=k.image,z=$?Q.getCanvasSource($):null;if(!z)continue;const rt=k.alpha*E;if(rt<=0)continue;const _t=Oe(k.style,A);y.globalAlpha=rt;let et=z;_t!==16777215&&(et=Q.getTintedCanvas({texture:$},_t));const st=$.frame,nt=(l=(o=$.source._resolution)!=null?o:$.source.resolution)!=null?l:1;let ot=st.x*nt,gt=st.y*nt;const yt=st.width*nt,pt=st.height*nt;et!==z&&(ot=0,gt=0);const Y=k.transform,Rt=Y&&!Y.isIdentity(),Ct=$.rotate;Rt||Ct?(Ns.copyFrom(b),Rt&&Ns.append(Y),Ct&&W.matrixAppendRotationInv(Ns,Ct,k.dx,k.dy,k.dw,k.dh),_.setContextTransform(Ns,G===1)):_.setContextTransform(b,G===1),y.drawImage(et,ot,gt,et===z?yt:et.width,et===z?pt:et.height,Ct?0:k.dx,Ct?0:k.dy,k.dw,k.dh),(Rt||Ct)&&_.setContextTransform(b,G===1);continue}const O=B.data,I=(u=O==null?void 0:O.path)==null?void 0:u.shapePath;if(!((c=I==null?void 0:I.shapePrimitives)!=null&&c.length))continue;const L=O.style,j=Oe(L.color,A),J=L.alpha*E;if(J<=0)continue;const K=B.action==="stroke";if(y.globalAlpha=J,K){const k=L;y.lineWidth=k.width,y.lineCap=k.cap,y.lineJoin=k.join,y.miterLimit=k.miterLimit}const N=I.shapePrimitives;if(!K&&(f=(p=(h=O.hole)==null?void 0:h.shapePath)==null?void 0:p.shapePrimitives)!=null&&f.length){const k=N[N.length-1];k.holes=O.hole.shapePath.shapePrimitives}for(let k=0;k<N.length;k++){const $=N[k];if(!($!=null&&$.shape))continue;const z=$.transform,rt=z&&!z.isIdentity(),_t=L.texture&&L.texture!==D.WHITE,et=L.textureSpace==="global"?z:null,st=_t?ol(FR,L,$.shape,et):null,nt=rt?DR.copyFrom(b).append(z):b,ot=NR(L,j,st,nt);if(rt&&(y.save(),y.transform(z.a,z.b,z.c,z.d,z.tx,z.ty)),K){const gt=L;if(gt.alignment!==.5&&!gt.pixelLine){const yt=[],pt=[],Y=[],Rt=Ne[$.shape.type];if(Rt!=null&&Rt.build($.shape,yt)){const Ct=(m=$.shape.closePath)!=null?m:!0;qn(yt,gt,!1,Ct,pt,Y),y.fillStyle=ot,UR(y,pt,Y)}else y.strokeStyle=ot,y.beginPath(),Xs(y,$.shape),y.stroke()}else y.strokeStyle=ot,y.beginPath(),Xs(y,$.shape),y.stroke()}else y.fillStyle=ot,y.beginPath(),Xs(y,$.shape),LR(y,$.holes)?y.fill("evenodd"):y.fill();rt&&y.restore()}}y.restore()}destroy(){this.shader=null}}Lu.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class js{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 zi;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}}js.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"sprite"};const Vi={};X.handle(S.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Vi[r.name]=r.ref},r=>{delete Vi[r.name]});class Hs{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,i){this._blendModeStack.push(e),this.setBlendMode(t,e,i)}popBlendMode(t){var e;this._blendModeStack.pop();const i=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,i,t)}setBlendMode(t,e,i){var n;const s=t instanceof pn;if(this._activeBlendMode===e){this._isAdvanced&&t&&!s&&((n=this._renderableList)==null||n.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!Vi[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!Vi[i])return;const n=this._ensureFilterEffect(i),s=t instanceof pn,a={renderPipeId:"filter",action:"pushFilter",filterEffect:n,renderables:s?null:[t],container:s?t.root:null,canBundle:!1};this._renderableList=a.renderables,e.add(a)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new oi,e.filters=[new Vi[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Hs.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function zs(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const XR=new dt,hv=xr|ci|mn;function Nu(r,t=!1){dv(r);const e=r.childrenToUpdate,i=r.updateTick++;for(const n in e){const s=Number(n),a=e[n],o=a.list,l=a.index;for(let u=0;u<l;u++){const c=o[u];c.parentRenderGroup===r&&c.relativeRenderGroupDepth===s&&Xu(c,i,0)}zs(o,l),a.index=0}if(t)for(let n=0;n<r.renderGroupChildren.length;n++)Nu(r.renderGroupChildren[n],t)}function dv(r){const t=r.root;let e;if(r.renderGroupParent){const i=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),r.worldColor=ui(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 Xu(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const n=r.parent;if(n&&!n.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,n.relativeGroupTransform),e&hv&&pv(r,n,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&hv&&pv(r,XR,e)),!r.renderGroup){const s=r.children,a=s.length;for(let u=0;u<a;u++)Xu(s[u],t,e);const o=r.parentRenderGroup,l=r;l.renderPipeId&&!o.structureDidChange&&o.updateRenderable(l)}}function pv(r,t,e){if(e&ci){r.groupColor=ui(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&mn&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&xr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function fv(r,t){const{list:e}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n<r.childrenRenderablesToUpdate.index;n++){const s=e[n];if(i=t[s.renderPipeId].validateRenderable(s),i)break}return r.structureDidChange=i,i}const jR=new U;class ju{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,n=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const s=this._renderer,a=jR;e&&(a.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=s.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),s.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),ks(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(a),t.parent=i,t.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var i,n;if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}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(),a=this._renderer,o=t.textureOptions.resolution||a.view.resolution,l=(i=t.textureOptions.antialias)!=null?i:a.view.antialias,u=(n=t.textureOptions.scaleMode)!=null?n:"linear",c=t.texture;s.ceil(),t.texture&&vt.returnTexture(t.texture,!0);const h=vt.getOptimalTexture(s.width,s.height,o,l);h._source.style=new Jt({scaleMode:u}),t.texture=h,t._textureBounds||(t._textureBounds=new Mt),t._textureBounds.copyFrom(s),c!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(vt.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?zs(t.childrenRenderablesToUpdate.list,0):fv(t,i),Nu(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 n=0;n<t.renderGroupChildren.length;n++)this._updateRenderGroups(t.renderGroupChildren[n])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let n=0;n<i;n++){const s=e[n];s.didViewUpdate&&t.updateRenderable(s)}zs(e,i)}_buildInstructions(t,e){const i=t.root,n=t.instructionSet;n.reset();const s=e.renderPipes?e:e.batch.renderer,a=s.renderPipes;a.batch.buildStart(n),a.blendMode.buildStart(),a.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(n,s,null),a.batch.buildEnd(n),a.blendMode.buildEnd(n)}}ju.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderGroup"};var HR=Object.defineProperty,mv=Object.getOwnPropertySymbols,zR=Object.prototype.hasOwnProperty,WR=Object.prototype.propertyIsEnumerable,gv=(r,t,e)=>t in r?HR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_v=(r,t)=>{for(var e in t||(t={}))zR.call(t,e)&&gv(r,e,t[e]);if(mv)for(var e of mv(t))WR.call(t,e)&&gv(r,e,t[e]);return r};const Hu=class X1{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new tt(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=_v(_v({},X1.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(){}};Hu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0},Hu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let yv=Hu;var VR=Object.defineProperty,bv=Object.getOwnPropertySymbols,YR=Object.prototype.hasOwnProperty,KR=Object.prototype.propertyIsEnumerable,vv=(r,t,e)=>t in r?VR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zu=(r,t)=>{for(var e in t||(t={}))YR.call(t,e)&&vv(r,e,t[e]);if(bv)for(var e of bv(t))KR.call(t,e)&&vv(r,e,t[e]);return r};const Wu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Vu=class j1{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof dt||t instanceof D?zu({target:t},e):zu(zu({},e),t)}async image(t){const e=H.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,j1.defaultImageOptions);const{format:e,quality:i}=t,n=this.canvas(t);if(n.toBlob!==void 0)return new Promise((s,a)=>{n.toBlob(o=>{if(!o){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>s(l.result),l.onerror=a,l.readAsDataURL(o)},Wu[e],i)});if(n.toDataURL!==void 0)return n.toDataURL(Wu[e],i);if(n.convertToBlob!==void 0){const s=await n.convertToBlob({type:Wu[e],quality:i});return new Promise((a,o)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(s)})}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 D)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),s=i.texture.generateCanvas(n);return n.destroy(!0),s}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,n=e instanceof D?e:i.textureGenerator.generateTexture(t),s=i.texture.getPixels(n);return e instanceof dt&&n.destroy(!0),s}texture(t){return t=this._normalizeOptions(t),t.target instanceof D?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),n=document.createElement("a");n.download=(e=t.filename)!=null?e:"image.png",n.href=i.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const n=this.canvas(t),s=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const a=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",a)}destroy(){this._renderer=null}};Vu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"},Vu.defaultImageOptions={format:"png",quality:1};let xv=Vu;var qR=Object.defineProperty,ZR=Object.defineProperties,QR=Object.getOwnPropertyDescriptors,Ws=Object.getOwnPropertySymbols,Tv=Object.prototype.hasOwnProperty,Sv=Object.prototype.propertyIsEnumerable,wv=(r,t,e)=>t in r?qR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JR=(r,t)=>{for(var e in t||(t={}))Tv.call(t,e)&&wv(r,e,t[e]);if(Ws)for(var e of Ws(t))Sv.call(t,e)&&wv(r,e,t[e]);return r},tO=(r,t)=>ZR(r,QR(t)),eO=(r,t)=>{var e={};for(var i in r)Tv.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};class Vs extends D{static create(t){const e=t,{dynamic:i,textureOptions:n}=e,s=eO(e,["dynamic","textureOptions"]);return new Vs(tO(JR({},n),{source:new ft(s),dynamic:i!=null?i:!1}))}resize(t,e,i){return this.source.resize(t,e,i),this}}var rO=Object.defineProperty,iO=Object.defineProperties,nO=Object.getOwnPropertyDescriptors,Pv=Object.getOwnPropertySymbols,sO=Object.prototype.hasOwnProperty,aO=Object.prototype.propertyIsEnumerable,Ev=(r,t,e)=>t in r?rO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oO=(r,t)=>{for(var e in t||(t={}))sO.call(t,e)&&Ev(r,e,t[e]);if(Pv)for(var e of Pv(t))aO.call(t,e)&&Ev(r,e,t[e]);return r},lO=(r,t)=>iO(r,nO(t));const uO=new ut,cO=new Mt,hO=[0,0,0,0];class Yu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof dt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,n=t.antialias||this._renderer.view.antialias,s=t.target;let a=t.clearColor;a?a=Array.isArray(a)&&a.length===4?a:tt.shared.setValue(a).toArray():a=hO;const o=((e=t.frame)==null?void 0:e.copyTo(uO))||un(s,cO).rectangle,l=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};o.width=Math.max(o.width,1/i)|0,o.height=Math.max(o.height,1/i)|0;const u=Vs.create(lO(oO({},t.textureSourceOptions),{width:o.width,height:o.height,resolution:i,antialias:n,textureOptions:l})),c=U.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:c,target:u,clearColor:a}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Yu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function Av(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 n=r[i];n&&(e[i]=n)}return e}function Cv(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 dO=Object.defineProperty,Mv=Object.getOwnPropertySymbols,pO=Object.prototype.hasOwnProperty,fO=Object.prototype.propertyIsEnumerable,Rv=(r,t,e)=>t in r?dO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ov=(r,t)=>{for(var e in t||(t={}))pO.call(t,e)&&Rv(r,e,t[e]);if(Mv)for(var e of Mv(t))fO.call(t,e)&&Rv(r,e,t[e]);return r};const Ku=class H1{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t=Ov(Ov({},H1.defaultOptions),t),this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:i,collection:n,type:s}=e;s==="hash"?i[n]=Av(i[n]):i[n]=Cv(i[n])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}addCollection(t,e,i){this._managedCollections.push({context:t,collection:e,type:i})}addResource(t,e){var i,n;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now);return}const s=this._managedResources.length;t._gcData={index:s,type:e},t._gcLastUsed=this.now,(n=t._onTouch)==null||n.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const i=e.index,n=this._managedResources.length-1;if(i!==n){const s=this._managedResources[n];this._managedResources[i]=s,s._gcData.index=i}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,i,n=0){this._managedResourceHashes.push({context:t,hash:e,type:i,priority:n}),this._managedResourceHashes.sort((s,a)=>s.priority-a.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const n of e)this.runOnHash(n,t);let i=0;for(let n=0;n<this._managedResources.length;n++){const s=this._managedResources[n];i=this.runOnResource(s,t,i)}this._managedResources.length=i}updateRenderableGCTick(t,e){var i,n,s,a,o;const l=(i=t.renderGroup)!=null?i:t.parentRenderGroup,u=(s=(n=l==null?void 0:l.instructionSet)==null?void 0:n.gcTick)!=null?s:-1;((a=l==null?void 0:l.gcTick)!=null?a:0)===u&&(t._gcLastUsed=e,(o=t._onTouch)==null||o.call(t,e))}runOnResource(t,e,i){const n=t._gcData;return n.type==="renderable"&&this.updateRenderableGCTick(t,e),e-t._gcLastUsed<this.maxUnusedTime||!t.autoGarbageCollect?(this._managedResources[i]=t,n.index=i,i++):(t.unload(),t._gcData=null,t._gcLastUsed=-1,t.off("unload",this.removeResource,this)),i}_createHashClone(t,e){const i=Object.create(null);for(const n in t){if(n===e)break;t[n]!==null&&(i[n]=t[n])}return i}runOnHash(t,e){var i,n;const{context:s,hash:a,type:o}=t,l=s[a];let u=null,c=0;for(const h in l){const p=l[h];if(p===null){c++,c===1e4&&!u&&(u=this._createHashClone(l,h));continue}if(p._gcLastUsed===-1){p._gcLastUsed=e,(i=p._onTouch)==null||i.call(p,e),u&&(u[h]=p);continue}if(o==="renderable"&&this.updateRenderableGCTick(p,e),!(e-p._gcLastUsed<this.maxUnusedTime)&&p.autoGarbageCollect){if(u||(c+1!==1e4?(l[h]=null,c++):u=this._createHashClone(l,h)),o==="renderable"){const f=p,m=(n=f.renderGroup)!=null?n:f.parentRenderGroup;m&&(m.structureDidChange=!0)}p.unload(),p._gcData=null,p._gcLastUsed=-1}else u&&(u[h]=p)}u&&(s[a]=u)}destroy(){this.enabled=!1,this._managedResources.forEach(t=>{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Ku.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0},Ku.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Gv=Ku;class qu{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:n,offset:s}){const a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new U,worldColor:4294967295,offset:new lt},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||a.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:s||o.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,Yr(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 Pe,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===It.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new At({uProjectionMatrix:{value:new U,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new U,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let mO=1;class Zu{constructor(){this._tasks=[],this._offset=0}init(){Ot.system.add(this._update,this)}repeat(t,e,i=!0){const n=mO++;let s=0;return i&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:s,last:performance.now(),repeat:!0,id:n}),n}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 n=t-i.start;i.func(n),i.last=t}}}destroy(){Ot.system.remove(this._update,this),this._tasks.length=0}}Zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let Iv=!1;function Bv(r){if(!Iv){if(H.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Ai} (${r}) http://www.pixijs.com/
1796
1797 `,"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 ${Ai} - ${r} - http://www.pixijs.com/`);Iv=!0}}class Ys{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===It.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Bv(e)}}}Ys.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"hello",priority:-2},Ys.defaultOptions={hello:!1};var gO=Object.defineProperty,Fv=Object.getOwnPropertySymbols,_O=Object.prototype.hasOwnProperty,yO=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?gO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uv=(r,t)=>{for(var e in t||(t={}))_O.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))yO.call(t,e)&&Dv(r,e,t[e]);return r};const Qu=class z1{constructor(t){this._renderer=t}init(t){t=Uv(Uv({},z1.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return this._renderer.gc.enabled}set enabled(t){this._renderer.gc.enabled=t}addManagedHash(t,e){this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){this._renderer.gc.addResource(t,"renderable")}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderableGC",priority:0},Qu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let $v=Qu;const Ju=class Ta{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){}get active(){return this._renderer.gc.enabled}set active(t){this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==Ta.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Ta.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Ta.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Ju.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"textureGC"},Ju.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let kv=Ju;var bO=Object.defineProperty,Lv=Object.getOwnPropertySymbols,vO=Object.prototype.hasOwnProperty,xO=Object.prototype.propertyIsEnumerable,Nv=(r,t,e)=>t in r?bO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xv=(r,t)=>{for(var e in t||(t={}))vO.call(t,e)&&Nv(r,e,t[e]);if(Lv)for(var e of Lv(t))xO.call(t,e)&&Nv(r,e,t[e]);return r};const jv=class W1{constructor(t={}){if(this.uid=ht("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Xv(Xv({},W1.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new ft({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(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 D||t.depthStencilTexture instanceof ft?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ft({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach((s,a)=>{n&&a===0||s.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)}};jv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Ks=jv;var TO=Object.defineProperty,Hv=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,wO=Object.prototype.propertyIsEnumerable,zv=(r,t,e)=>t in r?TO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PO=(r,t)=>{for(var e in t||(t={}))SO.call(t,e)&&zv(r,e,t[e]);if(Hv)for(var e of Hv(t))wO.call(t,e)&&zv(r,e,t[e]);return r};const fr=new Map;qe.register(fr);function tc(r,t){if(!fr.has(r)){const e=new D({source:new fe(PO({resource:r},t))}),i=()=>{fr.get(r)===e&&fr.delete(r)};e.once("destroy",i),e.source.once("destroy",i),fr.set(r,e)}return fr.get(r)}function EO(r){return fr.has(r)}var AO=Object.defineProperty,Wv=Object.getOwnPropertySymbols,CO=Object.prototype.hasOwnProperty,MO=Object.prototype.propertyIsEnumerable,Vv=(r,t,e)=>t in r?AO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yv=(r,t)=>{for(var e in t||(t={}))CO.call(t,e)&&Vv(r,e,t[e]);if(Wv)for(var e of Wv(t))MO.call(t,e)&&Vv(r,e,t[e]);return r};const ec=class V1{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=Yv(Yv({},V1.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new ut(0,0,t.width,t.height),this.canvas=t.canvas||H.get().createCanvas(),this.antialias=!!t.antialias,this.texture=tc(this.canvas,t),this.renderTarget=new Ks({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),this.texture.destroy()}};ec.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"view",priority:0},ec.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Kv=ec;const qs=[yv,qu,Ys,Kv,ju,Gv,kv,Yu,xv,$o,$v,Zu],rc=[Hs,Ds,js,Ls,Us,Du,Bu,$s];function qv(r,t,e,i,n,s){const a=s?1:-1;return r.identity(),r.a=1/i*2,r.d=a*(1/n*2),r.tx=-1-t*r.a,r.ty=-a-e*r.d,r}function Zv(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class Zs{constructor(t){this.rootViewPort=new ut,this.viewport=new ut,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Bo("onRenderTargetChange"),this.projectionMatrix=new U,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:n,mipLevel:s,layer:a}){var o,l;this._renderTargetStack.length=0,this.push(t,e,i,n,s!=null?s:0,a!=null?a:0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Zv(this.rootRenderTarget),(l=(o=this.adaptor).prerender)==null||l.call(o,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,n,s=0,a=0){const o=this.getRenderTarget(t),l=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=t;const u=this.getGpuRenderTarget(o);(o.pixelWidth!==u.width||o.pixelHeight!==u.height)&&(this.adaptor.resizeGpuRenderTarget(o),u.width=o.pixelWidth,u.height=o.pixelHeight);const c=o.colorTexture,h=this.viewport,p=c.arrayLayerCount||1;if((a|0)!==a&&(a|=0),a<0||a>=p)throw new Error(`[RenderTargetSystem] layer ${a} is out of bounds (arrayLayerCount=${p}).`);this.mipLevel=s|0,this.layer=a|0;const f=Math.max(c.pixelWidth>>s,1),m=Math.max(c.pixelHeight>>s,1);if(!n&&t instanceof D&&(n=t.frame),n){const g=c._resolution,_=1<<Math.max(s|0,0),y=n.x*g+.5|0,b=n.y*g+.5|0,x=n.width*g+.5|0,v=n.height*g+.5|0;let w=Math.floor(y/_),T=Math.floor(b/_),P=Math.ceil(x/_),E=Math.ceil(v/_);w=Math.min(Math.max(w,0),f-1),T=Math.min(Math.max(T,0),m-1),P=Math.min(Math.max(P,1),f-w),E=Math.min(Math.max(E,1),m-T),h.x=w,h.y=T,h.width=P,h.height=E}else h.x=0,h.y=0,h.width=f,h.height=m;return qv(this.projectionMatrix,0,0,h.width/c.resolution,h.height/c.resolution,!o.isRoot),this.adaptor.startRenderPass(o,e,i,h,s,a),l&&this.onRenderTargetChange.emit(o),o}clear(t,e=Kt.ALL,i,n=this.mipLevel,s=this.layer){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport,n,s))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Kt.ALL,i,n,s=0,a=0){const o=this.bind(t,e,i,n,s,a);return this._renderTargetStack.push({renderTarget:o,frame:n,mipLevel:s,layer:a}),o}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame,t.mipLevel,t.layer)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,i,n,s){i.x<0&&(n.width+=i.x,s.x-=i.x,i.x=0),i.y<0&&(n.height+=i.y,s.y-=i.y,i.y=0);const{pixelWidth:a,pixelHeight:o}=t;return n.width=Math.min(n.width,a-i.x),n.height=Math.min(n.height,o-i.y),this.adaptor.copyToTexture(t,e,i,n,s)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return fe.test(t)&&(t=tc(t).source),t instanceof Ks?e=t:t instanceof ft&&(e=new Ks({colorTextures:[t]}),t.source instanceof fe&&(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 Qv{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:i,context:n}=this._ensureCanvas(e);return{canvas:i,context:n,width:i.width,height:i.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:i}=this._ensureCanvas(e);i.width=t.pixelWidth,i.height=t.pixelHeight}startRenderPass(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,i,n)}clear(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t).context,a=n||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(s.setTransform(1,0,0,1,0,0),s.clearRect(a.x,a.y,a.width,a.height),i){const o=tt.shared.setValue(i);o.alpha>0&&(s.globalAlpha=o.alpha,s.fillStyle=o.toHex(),s.fillRect(a.x,a.y,a.width,a.height),s.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,i,n,s){var a,o;const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,u=e.source,{context:c}=this._ensureCanvas(u),h=(a=s==null?void 0:s.x)!=null?a:0,p=(o=s==null?void 0:s.y)!=null?o:0;return c.drawImage(l,i.x,i.y,n.width,n.height,h,p,n.width,n.height),u.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!fe.test(e))&&(e=H.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const i=e.getContext("2d");return{canvas:e,context:i}}}class ic extends Zs{constructor(t){super(t),this.adaptor=new Qv,this.adaptor.init(t,this)}}ic.extension={type:[S.CanvasSystem],name:"renderTarget"};class nc{constructor(t){}init(){}initSource(t){}generateCanvas(t){var e,i;const n=H.get().createCanvas(),s=n.getContext("2d"),a=Q.getCanvasSource(t);if(!a)return n;const o=t.frame,l=(i=(e=t.source._resolution)!=null?e:t.source.resolution)!=null?i:1,u=o.x*l,c=o.y*l,h=o.width*l,p=o.height*l;return n.width=Math.ceil(h),n.height=Math.ceil(p),s.drawImage(a,u,c,h,p,0,0,h,p),n}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}nc.extension={type:[S.CanvasSystem],name:"texture"};const RO=[...qs,Uu,$u,nc,ic],OO=[Hs,Ds,js,Ls,Us,Fu,Iu,$s],GO=[av,Lu],Jv=[],tx=[],ex=[];X.handleByNamedList(S.CanvasSystem,Jv),X.handleByNamedList(S.CanvasPipes,tx),X.handleByNamedList(S.CanvasPipesAdaptor,ex),X.add(...RO,...OO,...GO);class rx extends Mr{constructor(){const t={name:"canvas",type:It.CANVAS,systems:Jv,renderPipes:tx,renderPipeAdaptors:ex};super(t)}}var IO={__proto__:null,CanvasRenderer:rx},Yi=(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))(Yi||{});class ix{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class sc{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,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,n=this._nextBindBaseIndex;for(;i<2;){n>=this._maxBindings&&(n=this._minBaseLocation,i++);const s=this._boundBufferBases[n];if(s&&s._lastBindCallId===this._bindCallId){n++;continue}break}return e=n,this._nextBindBaseIndex=n+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,n){const{_gl:s}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,s.bindBufferRange(s.UNIFORM_BUFFER,e||0,t.buffer,i*256,n||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 n=t.data,s=t.descriptor.usage&at.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return n?i.byteLength>=n.byteLength?e.bufferSubData(i.type,0,n,0,t._updateSize/n.BYTES_PER_ELEMENT):(i.byteLength=n.byteLength,e.bufferData(i.type,n,s)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,s)),i}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||this._gl.deleteBuffer(i.buffer))}createGLBuffer(t){const{_gl:e}=this;let i=Yi.ARRAY_BUFFER;t.descriptor.usage&at.INDEX?i=Yi.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&at.UNIFORM&&(i=Yi.UNIFORM_BUFFER);const n=new ix(e.createBuffer(),i);return t._gpuData[this._renderer.uid]=n,this._managedBuffers.add(t),n}resetState(){this._boundBufferBases=Object.create(null)}}sc.extension={type:[S.WebGLSystem],name:"buffer"};var BO=Object.defineProperty,FO=Object.defineProperties,DO=Object.getOwnPropertyDescriptors,nx=Object.getOwnPropertySymbols,UO=Object.prototype.hasOwnProperty,$O=Object.prototype.propertyIsEnumerable,sx=(r,t,e)=>t in r?BO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qs=(r,t)=>{for(var e in t||(t={}))UO.call(t,e)&&sx(r,e,t[e]);if(nx)for(var e of nx(t))$O.call(t,e)&&sx(r,e,t[e]);return r},ax=(r,t)=>FO(r,DO(t));const ac=class Y1{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=Qs(Qs({},Y1.defaultOptions),t);let n=this.multiView=t.multiView;if(t.context&&n&&(ue("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),n=!1),n?this.canvas=H.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const s=this._renderer.background.alpha<1,a=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:a,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&ue("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof H.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const n=this.canvas;if(t===2&&(i=n.getContext("webgl2",e)),!i&&(i=n.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=ax(Qs({},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=ax(Qs({},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,n=this.webGLVersion===2,s=this.extensions;i.uint32Indices=n||!!s.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!s.vertexArrayObject,i.srgbTextures=n||!!s.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices}};ac.extension={type:[S.WebGLSystem],name:"context"},ac.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let ox=ac;function oc(r,t){var e,i,n;for(const s in r.attributes){const a=r.attributes[s],o=t[s];o?((e=a.format)!=null||(a.format=o.format),(i=a.offset)!=null||(a.offset=o.offset),(n=a.instance)!=null||(a.instance=o.instance)):ue(`Attribute ${s} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}kO(r)}function kO(r){var t,e;const{buffers:i,attributes:n}=r,s={},a={};for(const o in i){const l=i[o];s[l.uid]=0,a[l.uid]=0}for(const o in n){const l=n[o];s[l.buffer.uid]+=Ie(l.format).stride}for(const o in n){const l=n[o];(t=l.stride)!=null||(l.stride=s[l.buffer.uid]),(e=l.start)!=null||(l.start=a[l.buffer.uid]),a[l.buffer.uid]+=Ie(l.format).stride}}var Js=(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))(Js||{}),ta=(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))(ta||{}),lx=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(lx||{}),ct=(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))(ct||{});const ux={uint8x2:ct.UNSIGNED_BYTE,uint8x4:ct.UNSIGNED_BYTE,sint8x2:ct.BYTE,sint8x4:ct.BYTE,unorm8x2:ct.UNSIGNED_BYTE,unorm8x4:ct.UNSIGNED_BYTE,snorm8x2:ct.BYTE,snorm8x4:ct.BYTE,uint16x2:ct.UNSIGNED_SHORT,uint16x4:ct.UNSIGNED_SHORT,sint16x2:ct.SHORT,sint16x4:ct.SHORT,unorm16x2:ct.UNSIGNED_SHORT,unorm16x4:ct.UNSIGNED_SHORT,snorm16x2:ct.SHORT,snorm16x4:ct.SHORT,float16x2:ct.HALF_FLOAT,float16x4:ct.HALF_FLOAT,float32:ct.FLOAT,float32x2:ct.FLOAT,float32x3:ct.FLOAT,float32x4:ct.FLOAT,uint32:ct.UNSIGNED_INT,uint32x2:ct.UNSIGNED_INT,uint32x3:ct.UNSIGNED_INT,uint32x4:ct.UNSIGNED_INT,sint32:ct.INT,sint32x2:ct.INT,sint32x3:ct.INT,sint32x4:ct.INT};function cx(r){var t;return(t=ux[r])!=null?t:ux.float32}const LO={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class hx{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class lc{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new Ut({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=n=>e.bindVertexArrayOES(n),t.deleteVertexArray=n=>e.deleteVertexArrayOES(n));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(n,s,a,o)=>{i.drawArraysInstancedANGLE(n,s,a,o)},t.drawElementsInstanced=(n,s,a,o,l)=>{i.drawElementsInstancedANGLE(n,s,a,o,l)},t.vertexAttribDivisor=(n,s)=>i.vertexAttribDivisorANGLE(n,s)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const i=this.gl;this._activeGeometry=t;const n=this.getVao(t,e);this._activeVao!==n&&(this._activeVao=n,i.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const n=t.buffers[i];e.updateBuffer(n)}t._gcLastUsed=this._renderer.gc.now}checkCompatibility(t,e){const i=t.attributes,n=e._attributeData;for(const s in n)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(t,e){const i=t.attributes,n=e._attributeData,s=["g",t.uid];for(const a in i)n[a]&&s.push(a,n[a].location);return s.join("-")}getVao(t,e){var i;return((i=t._gpuData[this._renderer.uid])==null?void 0:i.vaoCache[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const n=this._renderer.gl,s=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const a=this.getSignature(t,e);let o=t._gpuData[this._renderer.uid];o||(o=new hx,t._gpuData[this._renderer.uid]=o,this._managedGeometries.add(t));const l=o.vaoCache;let u=l[a];if(u)return l[e._key]=u,u;oc(t,e._attributeData);const c=t.buffers;u=n.createVertexArray(),n.bindVertexArray(u);for(let h=0;h<c.length;h++){const p=c[h];s.bind(p)}return this.activateVao(t,e),l[e._key]=u,l[a]=u,n.bindVertexArray(null),u}onGeometryUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];if(!i)return;const n=i.vaoCache;if(!e)for(const s in n)this._activeVao!==n[s]&&this.resetState(),this.gl.deleteVertexArray(n[s])}destroyAll(t=!1){this._managedGeometries.removeAll(t)}activateVao(t,e){var i,n;const s=this._renderer.gl,a=this._renderer.buffer,o=t.attributes;t.indexBuffer&&a.bind(t.indexBuffer);let l=null;for(const u in o){const c=o[u],h=c.buffer,p=a.getGlBuffer(h),f=e._attributeData[u];if(f){l!==p&&(a.bind(h),l=p);const m=f.location;s.enableVertexAttribArray(m);const g=Ie(c.format),_=cx(c.format);if(((i=f.format)==null?void 0:i.substring(1,4))==="int"?s.vertexAttribIPointer(m,g.size,_,c.stride,c.offset):s.vertexAttribPointer(m,g.size,_,g.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const y=(n=c.divisor)!=null?n:1;s.vertexAttribDivisor(m,y)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,n){const{gl:s}=this._renderer,a=this._activeGeometry,o=LO[t||a.topology];if(n!=null||(n=a.instanceCount),a.indexBuffer){const l=a.indexBuffer.data.BYTES_PER_ELEMENT,u=l===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;n!==1?s.drawElementsInstanced(o,e||a.indexBuffer.data.length,u,(i||0)*l,n):s.drawElements(o,e||a.indexBuffer.data.length,u,(i||0)*l)}else n!==1?s.drawArraysInstanced(o,i||0,e||a.getSize(),n):s.drawArrays(o,i||0,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}lc.extension={type:[S.WebGLSystem],name:"geometry"};var NO=Object.defineProperty,dx=Object.getOwnPropertySymbols,XO=Object.prototype.hasOwnProperty,jO=Object.prototype.propertyIsEnumerable,px=(r,t,e)=>t in r?NO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fx=(r,t)=>{for(var e in t||(t={}))XO.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))jO.call(t,e)&&px(r,e,t[e]);return r};const HO=new nr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),uc=class K1{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=fx(fx({},K1.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(ue("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Vt.for2d();const n=new Wt({vertex:`
1798 attribute vec2 aPosition;
1799 out vec2 vUv;
1800
1801 void main() {
1802 gl_Position = vec4(aPosition, 0.0, 1.0);
1803
1804 vUv = (aPosition + 1.0) / 2.0;
1805
1806 // flip dem UVs
1807 vUv.y = 1.0 - vUv.y;
1808 }`,fragment:`
1809 in vec2 vUv;
1810 out vec4 finalColor;
1811
1812 uniform sampler2D uTexture;
1813
1814 void main() {
1815 finalColor = texture(uTexture, vUv);
1816 }`,name:"big-triangle"});this._bigTriangleShader=new ee({glProgram:n,resources:{uTexture:D.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:HO,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new D({source:new ft({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};uc.extension={type:[S.WebGLSystem],name:"backBuffer",priority:1},uc.defaultOptions={useBackBuffer:!1};let mx=uc;class cc{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)))}}cc.extension={type:[S.WebGLSystem],name:"colorMask"};class hc{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:n,state:s,skipSync:a,topology:o,size:l,start:u,instanceCount:c}=t;e.shader.bind(n,a),e.geometry.bind(i,e.shader._activeProgram),s&&e.state.set(s),e.geometry.draw(o,l,u,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}hc.extension={type:[S.WebGLSystem],name:"encoder"};class dc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Wo(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}dc.extension={type:[S.WebGLSystem],name:"limits"};class gx{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const Ue=[];Ue[wt.NONE]=void 0,Ue[wt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ue[wt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ue[wt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ue[wt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ue[wt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class pc{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:wt.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:wt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=wt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=Ue[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===wt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))}}pc.extension={type:[S.WebGLSystem],name:"stencil"};class fc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ro())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 Yt({data:new Float32Array(e.layout.size/4),usage:at.UNIFORM|at.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 n=Object.keys(t.uniformStructures).map(o=>t.uniformStructures[o]),s=this._adaptor.createUboElements(n),a=this._generateUboSync(s.uboElements);i=this._syncFunctionHash[e]={layout:s,syncFunction:a}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const n=this.getUniformGroupData(t);t.buffer||(t.buffer=new Yt({data:new Float32Array(n.layout.size/4),usage:at.UNIFORM|at.COPY_DST}));let s=null;return e||(e=t.buffer.data,s=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,s,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 mc={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 _x(r){const t=r.map(s=>({data:s,offset:0,size:0})),e=16;let i=0,n=0;for(let s=0;s<t.length;s++){const a=t[s];if(i=mc[a.data.type],!i)throw new Error(`Unknown type ${a.data.type}`);a.data.size>1&&(i=Math.max(i,e)*a.data.size);const o=i===12?16:i;a.size=i;const l=n%e;l>0&&e-l<o?n+=(e-l)%16:n+=(i-l%i)%i,a.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}const We=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
1817 var matrix = uv[name].toArray(true);
1818 data[offset] = matrix[0];
1819 data[offset + 1] = matrix[1];
1820 data[offset + 2] = matrix[2];
1821 data[offset + 4] = matrix[3];
1822 data[offset + 5] = matrix[4];
1823 data[offset + 6] = matrix[5];
1824 data[offset + 8] = matrix[6];
1825 data[offset + 9] = matrix[7];
1826 data[offset + 10] = matrix[8];
1827 `,uniform:`
1828 gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
1829 `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
1830 v = uv[name];
1831 data[offset] = v.x;
1832 data[offset + 1] = v.y;
1833 data[offset + 2] = v.width;
1834 data[offset + 3] = v.height;
1835 `,uniform:`
1836 cv = ud[name].value;
1837 v = uv[name];
1838 if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
1839 cv[0] = v.x;
1840 cv[1] = v.y;
1841 cv[2] = v.width;
1842 cv[3] = v.height;
1843 gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
1844 }
1845 `},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
1846 v = uv[name];
1847 data[offset] = v.x;
1848 data[offset + 1] = v.y;
1849 `,uniform:`
1850 cv = ud[name].value;
1851 v = uv[name];
1852 if (cv[0] !== v.x || cv[1] !== v.y) {
1853 cv[0] = v.x;
1854 cv[1] = v.y;
1855 gl.uniform2f(ud[name].location, v.x, v.y);
1856 }
1857 `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
1858 v = uv[name];
1859 data[offset] = v.red;
1860 data[offset + 1] = v.green;
1861 data[offset + 2] = v.blue;
1862 data[offset + 3] = v.alpha;
1863 `,uniform:`
1864 cv = ud[name].value;
1865 v = uv[name];
1866 if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
1867 cv[0] = v.red;
1868 cv[1] = v.green;
1869 cv[2] = v.blue;
1870 cv[3] = v.alpha;
1871 gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
1872 }
1873 `},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
1874 v = uv[name];
1875 data[offset] = v.red;
1876 data[offset + 1] = v.green;
1877 data[offset + 2] = v.blue;
1878 `,uniform:`
1879 cv = ud[name].value;
1880 v = uv[name];
1881 if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
1882 cv[0] = v.red;
1883 cv[1] = v.green;
1884 cv[2] = v.blue;
1885 gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
1886 }
1887 `}];function gc(r,t,e,i){const n=[`
1888 var v = null;
1889 var v2 = null;
1890 var t = 0;
1891 var index = 0;
1892 var name = null;
1893 var arrayOffset = null;
1894 `];let s=0;for(let o=0;o<r.length;o++){const l=r[o],u=l.data.name;let c=!1,h=0;for(let p=0;p<We.length;p++)if(We[p].test(l.data)){h=l.offset/4,n.push(`name = "${u}";`,`offset += ${h-s};`,We[p][t]||We[p].ubo),c=!0;break}if(!c)if(l.data.size>1)h=l.offset/4,n.push(e(l,h-s));else{const p=i[l.data.type];h=l.offset/4,n.push(`
1895 v = uv.${u};
1896 offset += ${h-s};
1897 ${p};
1898 `)}s=h}const a=n.join(`
1899 `);return new Function("uv","data","dataInt32","offset",a)}var zO=Object.defineProperty,WO=Object.defineProperties,VO=Object.getOwnPropertyDescriptors,yx=Object.getOwnPropertySymbols,YO=Object.prototype.hasOwnProperty,KO=Object.prototype.propertyIsEnumerable,bx=(r,t,e)=>t in r?zO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qO=(r,t)=>{for(var e in t||(t={}))YO.call(t,e)&&bx(r,e,t[e]);if(yx)for(var e of yx(t))KO.call(t,e)&&bx(r,e,t[e]);return r},ZO=(r,t)=>WO(r,VO(t));function ti(r,t){return`
1900 for (let i = 0; i < ${r*t}; i++) {
1901 data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
1902 }
1903 `}const _c={f32:`
1904 data[offset] = v;`,i32:`
1905 dataInt32[offset] = v;`,"vec2<f32>":`
1906 data[offset] = v[0];
1907 data[offset + 1] = v[1];`,"vec3<f32>":`
1908 data[offset] = v[0];
1909 data[offset + 1] = v[1];
1910 data[offset + 2] = v[2];`,"vec4<f32>":`
1911 data[offset] = v[0];
1912 data[offset + 1] = v[1];
1913 data[offset + 2] = v[2];
1914 data[offset + 3] = v[3];`,"vec2<i32>":`
1915 dataInt32[offset] = v[0];
1916 dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
1917 dataInt32[offset] = v[0];
1918 dataInt32[offset + 1] = v[1];
1919 dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
1920 dataInt32[offset] = v[0];
1921 dataInt32[offset + 1] = v[1];
1922 dataInt32[offset + 2] = v[2];
1923 dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
1924 data[offset] = v[0];
1925 data[offset + 1] = v[1];
1926 data[offset + 4] = v[2];
1927 data[offset + 5] = v[3];`,"mat3x3<f32>":`
1928 data[offset] = v[0];
1929 data[offset + 1] = v[1];
1930 data[offset + 2] = v[2];
1931 data[offset + 4] = v[3];
1932 data[offset + 5] = v[4];
1933 data[offset + 6] = v[5];
1934 data[offset + 8] = v[6];
1935 data[offset + 9] = v[7];
1936 data[offset + 10] = v[8];`,"mat4x4<f32>":`
1937 for (let i = 0; i < 16; i++) {
1938 data[offset + i] = v[i];
1939 }`,"mat3x2<f32>":ti(3,2),"mat4x2<f32>":ti(4,2),"mat2x3<f32>":ti(2,3),"mat4x3<f32>":ti(4,3),"mat2x4<f32>":ti(2,4),"mat3x4<f32>":ti(3,4)},vx=ZO(qO({},_c),{"mat2x2<f32>":`
1940 data[offset] = v[0];
1941 data[offset + 1] = v[1];
1942 data[offset + 2] = v[2];
1943 data[offset + 3] = v[3];
1944 `});function xx(r,t){const e=Math.max(mc[r.data.type]/16,1),i=r.data.value.length/r.data.size,n=(4-i%4)%4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
1945 v = uv.${r.data.name};
1946 offset += ${t};
1947
1948 arrayOffset = offset;
1949
1950 t = 0;
1951
1952 for(var i=0; i < ${r.data.size*e}; i++)
1953 {
1954 for(var j = 0; j < ${i}; j++)
1955 {
1956 ${s}[arrayOffset++] = v[t++];
1957 }
1958 ${n!==0?`arrayOffset += ${n};`:""}
1959 }
1960 `}function Tx(r){return gc(r,"uboStd40",xx,_c)}class yc extends fc{constructor(){super({createUboElements:_x,generateUboSync:Tx})}}yc.extension={type:[S.WebGLSystem],name:"ubo"};class Sx{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(i,n)=>t.COLOR_ATTACHMENT0+n)}copyToTexture(t,e,i,n,s){const a=this._renderTargetSystem,o=this._renderer,l=a.getGpuRenderTarget(t),u=o.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),o.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,s.x,s.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n,s=0,a=0){const o=this._renderTargetSystem,l=t.colorTexture,u=o.getGpuRenderTarget(t);if(a!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(s>0){if(u.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let c=n.y;t.isRoot&&(c=l.pixelHeight-n.height-n.y),t.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,u.framebuffer),!t.isRoot&&(u._attachedMipLevel!==s||u._attachedLayer!==a)&&(t.colorTextures.forEach((f,m)=>{const g=this._renderer.texture.getGlSource(f);if(g.target===h.TEXTURE_2D){if(a!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_2D,g.texture,s)}else if(g.target===h.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,g.texture,s,a)}else if(g.target===h.TEXTURE_CUBE_MAP){if(a<0||a>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_CUBE_MAP_POSITIVE_X+a,g.texture,s)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),u._attachedMipLevel=s,u._attachedLayer=a),t.colorTextures.length>1&&this._setDrawBuffers(t,h);const p=this._viewPortCache;(p.x!==n.x||p.y!==c||p.width!==n.width||p.height!==n.height)&&(p.x=n.x,p.y=c,p.width=n.width,p.height=n.height,h.viewport(n.x,c,n.width,n.height)),!u.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(u),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 gx;return i._attachedMipLevel=0,i._attachedLayer=0,t.colorTexture instanceof fe?(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,n,s=0,a=0){if(!e)return;if(a!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const o=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const l=this._renderer.gl;if(e&Kt.COLOR){i!=null||(i=o.defaultClearColor);const u=this._clearColorCache,c=i;(u[0]!==c[0]||u[1]!==c[1]||u[2]!==c[2]||u[3]!==c[3])&&(u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],l.clearColor(c[0],c[1],c[2],c[3]))}l.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,n=i.gl,s=n.createFramebuffer();if(e.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,o)=>{const l=a.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:ue("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l),c=u.texture;if(u.target===n.TEXTURE_2D)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_2D,c,0);else if(u.target===n.TEXTURE_2D_ARRAY){if(i.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");n.framebufferTextureLayer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,c,0,0)}else if(u.target===n.TEXTURE_CUBE_MAP)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const a=n.createFramebuffer();e.framebuffer=a,n.bindFramebuffer(n.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=n.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=s;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((n,s)=>{s!==0&&n.source.resize(i.width,i.height,i._resolution)}),e.msaa){const n=this._renderer,s=n.gl,a=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=o.source;n.texture.bindSource(u,0);const c=n.texture.getGlSource(u).internalFormat,h=e.msaaRenderBuffer[l];s.bindRenderbuffer(s.RENDERBUFFER,h),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,c,u.pixelWidth,u.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,s.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&&fe.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&fe.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}_setDrawBuffers(t,e){const i=t.colorTextures.length,n=this._drawBuffersCache[i];if(this._renderer.context.webGLVersion===1){const s=this._renderer.context.extensions.drawBuffers;s?s.drawBuffersWEBGL(n):ue("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(n)}}class bc extends Zs{constructor(t){super(t),this.adaptor=new Sx,this.adaptor.init(t,this)}}bc.extension={type:[S.WebGLSystem],name:"renderTarget"};class ea extends Nt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=ht("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ht("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=ht("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function wx(r,t){const e=[],i=[`
1961 var g = s.groups;
1962 var sS = r.shader;
1963 var p = s.glProgram;
1964 var ugS = r.uniformGroup;
1965 var resources;
1966 `];let n=!1,s=0;const a=t._getProgramData(r.glProgram);for(const l in r.groups){const u=r.groups[l];e.push(`
1967 resources = g[${l}].resources;
1968 `);for(const c in u.resources){const h=u.resources[c];if(h instanceof At)if(h.ubo){const p=r._uniformBindMap[l][Number(c)];e.push(`
1969 sS.bindUniformBlock(
1970 resources[${c}],
1971 '${p}',
1972 ${r.glProgram._uniformBlockData[p].index}
1973 );
1974 `)}else e.push(`
1975 ugS.updateUniformGroup(resources[${c}], p, sD);
1976 `);else if(h instanceof ea){const p=r._uniformBindMap[l][Number(c)];e.push(`
1977 sS.bindUniformBlock(
1978 resources[${c}],
1979 '${p}',
1980 ${r.glProgram._uniformBlockData[p].index}
1981 );
1982 `)}else if(h instanceof ft){const p=r._uniformBindMap[l][c],f=a.uniformData[p];f&&(n||(n=!0,i.push(`
1983 var tS = r.texture;
1984 `)),t._gl.uniform1i(f.location,s),e.push(`
1985 tS.bind(resources[${c}], ${s});
1986 `),s++)}}}const o=[...i,...e].join(`
1987 `);return new Function("r","s","sD",o)}class QO{}class Px{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 vc(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function xc(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Tc(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 xc(2*t);case"bvec3":return xc(3*t);case"bvec4":return xc(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 ra=null;const Ex={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"},JO={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 Sc(r,t){if(!ra){const e=Object.keys(Ex);ra={};for(let i=0;i<e.length;++i){const n=e[i];ra[r[n]]=Ex[n]}}return ra[t]}function Ax(r,t){const e=Sc(r,t);return JO[e]||"float32"}function Cx(r,t,e=!1){const i={},n=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let a=0;a<n;a++){const o=t.getActiveAttrib(r,a);if(o.name.startsWith("gl_"))continue;const l=Ax(t,o.type);i[o.name]={location:0,format:l,stride:Ie(l).stride,offset:0,instance:!1,start:0}}const s=Object.keys(i);if(e){s.sort((a,o)=>a>o?1:-1);for(let a=0;a<s.length;a++)i[s[a]].location=a,t.bindAttribLocation(r,a,s[a]);t.linkProgram(r)}else for(let a=0;a<s.length;a++)i[s[a]].location=t.getAttribLocation(r,s[a]);return i}function Mx(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let n=0;n<i;n++){const s=t.getActiveUniformBlockName(r,n),a=t.getUniformBlockIndex(r,s),o=t.getActiveUniformBlockParameter(r,n,t.UNIFORM_BLOCK_DATA_SIZE);e[s]={name:s,index:a,size:o}}return e}function Rx(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const s=t.getActiveUniform(r,n),a=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),l=Sc(t,s.type);e[a]={name:a,index:n,type:l,size:s.size,isArray:o,value:Tc(l,s.size)}}return e}function Ox(r,t){const e=r.getShaderSource(t).split(`
1988 `).map((u,c)=>`${c}: ${u}`),i=r.getShaderInfoLog(t),n=i.split(`
1989 `),s={},a=n.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!s[u]?(s[u]=!0,!0):!1),o=[""];a.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
1990 `);o[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Gx(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Ox(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Ox(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function Ix(r,t){const e=vc(r,r.VERTEX_SHADER,t.vertex),i=vc(r,r.FRAGMENT_SHADER,t.fragment),n=r.createProgram();r.attachShader(n,e),r.attachShader(n,i);const s=t.transformFeedbackVaryings;s&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS)||Gx(r,n,e,i),t._attributeData=Cx(n,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Rx(n,r),t._uniformBlockData=Mx(n,r),r.deleteShader(e),r.deleteShader(i);const a={};for(const o in t._uniformData){const l=t._uniformData[o];a[o]={location:r.getUniformLocation(n,o),value:Tc(l.type,l.size)}}return new Px(n,a)}const ia={textureCount:0,blockIndex:0};class wc{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;ia.textureCount=0,ia.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,ia)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ia)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),a=t._bufferResource;a||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,l=n.updateBuffer(o),u=n.freeLocationForBufferBase(l);if(a){const{offset:h,size:p}=t;h===0&&p===o.data.byteLength?n.bindBufferBase(l,u):n.bindBufferRange(l,u,h)}else n.getLastBindBaseLocation(l)!==u&&n.bindBufferBase(l,u);const c=this._activeProgram._uniformBlockData[e].index;s.uniformBlockBindings[i]!==u&&(s.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(s.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]=Ix(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return wx(t,e)}resetState(){this._activeProgram=null}}wc.extension={type:[S.WebGLSystem],name:"shader"};const Bx={f32:`if (cv !== v) {
1991 cu.value = v;
1992 gl.uniform1f(location, v);
1993 }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
1994 cv[0] = v[0];
1995 cv[1] = v[1];
1996 gl.uniform2f(location, v[0], v[1]);
1997 }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1998 cv[0] = v[0];
1999 cv[1] = v[1];
2000 cv[2] = v[2];
2001 gl.uniform3f(location, v[0], v[1], v[2]);
2002 }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
2003 cv[0] = v[0];
2004 cv[1] = v[1];
2005 cv[2] = v[2];
2006 cv[3] = v[3];
2007 gl.uniform4f(location, v[0], v[1], v[2], v[3]);
2008 }`,i32:`if (cv !== v) {
2009 cu.value = v;
2010 gl.uniform1i(location, v);
2011 }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
2012 cv[0] = v[0];
2013 cv[1] = v[1];
2014 gl.uniform2i(location, v[0], v[1]);
2015 }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
2016 cv[0] = v[0];
2017 cv[1] = v[1];
2018 cv[2] = v[2];
2019 gl.uniform3i(location, v[0], v[1], v[2]);
2020 }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
2021 cv[0] = v[0];
2022 cv[1] = v[1];
2023 cv[2] = v[2];
2024 cv[3] = v[3];
2025 gl.uniform4i(location, v[0], v[1], v[2], v[3]);
2026 }`,u32:`if (cv !== v) {
2027 cu.value = v;
2028 gl.uniform1ui(location, v);
2029 }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
2030 cv[0] = v[0];
2031 cv[1] = v[1];
2032 gl.uniform2ui(location, v[0], v[1]);
2033 }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
2034 cv[0] = v[0];
2035 cv[1] = v[1];
2036 cv[2] = v[2];
2037 gl.uniform3ui(location, v[0], v[1], v[2]);
2038 }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
2039 cv[0] = v[0];
2040 cv[1] = v[1];
2041 cv[2] = v[2];
2042 cv[3] = v[3];
2043 gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
2044 }`,bool:`if (cv !== v) {
2045 cu.value = v;
2046 gl.uniform1i(location, v);
2047 }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
2048 cv[0] = v[0];
2049 cv[1] = v[1];
2050 gl.uniform2i(location, v[0], v[1]);
2051 }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
2052 cv[0] = v[0];
2053 cv[1] = v[1];
2054 cv[2] = v[2];
2055 gl.uniform3i(location, v[0], v[1], v[2]);
2056 }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
2057 cv[0] = v[0];
2058 cv[1] = v[1];
2059 cv[2] = v[2];
2060 cv[3] = v[3];
2061 gl.uniform4i(location, v[0], v[1], v[2], v[3]);
2062 }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Fx={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 Dx(r,t){const e=[`
2063 var v = null;
2064 var cv = null;
2065 var cu = null;
2066 var t = 0;
2067 var gl = renderer.gl;
2068 var name = null;
2069 `];for(const i in r.uniforms){if(!t[i]){r.uniforms[i]instanceof At?r.uniforms[i].ubo?e.push(`
2070 renderer.shader.bindUniformBlock(uv.${i}, "${i}");
2071 `):e.push(`
2072 renderer.shader.updateUniformGroup(uv.${i});
2073 `):r.uniforms[i]instanceof ea&&e.push(`
2074 renderer.shader.bindBufferResource(uv.${i}, "${i}");
2075 `);continue}const n=r.uniformStructures[i];let s=!1;for(let a=0;a<We.length;a++){const o=We[a];if(n.type===o.type&&o.test(n)){e.push(`name = "${i}";`,We[a].uniform),s=!0;break}}if(!s){const a=(n.size===1?Bx:Fx)[n.type].replace("location",`ud["${i}"].location`);e.push(`
2076 cu = ud["${i}"];
2077 cv = cu.value;
2078 v = uv["${i}"];
2079 ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
2080 `))}class Pc{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const n=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==n.uniformDirtyGroups[t.uid])&&(n.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(n.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]={}),n=this._getSignature(t,e._uniformData,"u");return this._cache[n]||(this._cache[n]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[n],i[e._key]}_generateUniformsSync(t,e){return Dx(t,e)}_getSignature(t,e,i){const n=t.uniforms,s=[`${i}-`];for(const a in n)s.push(a),e[a]&&s.push(e[a].type);return s.join("-")}destroy(){this._renderer=null,this._cache=null}}Pc.extension={type:[S.WebGLSystem],name:"uniformGroup"};function t3(r){return r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in"),r=`
2081 out vec4 finalColor;
2082 ${r}
2083 `,r}const e3={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 r3(r){return e3[r]}function Ux(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof H.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const i3=0,n3=1,s3=2,a3=3,o3=4,l3=5,$x=class Ch{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[i3]=this.setBlend,this.map[n3]=this.setOffset,this.map[s3]=this.setCullFace,this.map[a3]=this.setDepthTest,this.map[o3]=this.setFrontFace,this.map[l3]=this.setDepthMask,this.checks=[],this.defaultState=Vt.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=Ux(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(Ch._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Ch._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}};$x.extension={type:[S.WebGLSystem],name:"state"};let kx=$x;class Ec{constructor(t){this.target=ta.TEXTURE_2D,this._layerInitMask=0,this.texture=t,this.width=-1,this.height=-1,this.type=ct.UNSIGNED_BYTE,this.internalFormat=Js.RGBA,this.format=Js.RGBA,this.samplerType=0}destroy(){}}const Lx={id:"buffer",upload(r,t,e,i,n,s=!1){const a=n||t.target;!s&&t.width===r.width&&t.height===r.height?e.texSubImage2D(a,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(a,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},u3={"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},Nx={id:"compressed",upload(r,t,e,i,n,s){const a=n!=null?n:t.target;e.pixelStorei(e.UNPACK_ALIGNMENT,4);let o=r.pixelWidth,l=r.pixelHeight;const u=!!u3[r.format];for(let c=0;c<r.resource.length;c++){const h=r.resource[c];u?e.compressedTexImage2D(a,c,t.internalFormat,o,l,0,h):e.texImage2D(a,c,t.internalFormat,o,l,0,t.format,t.type,h),o=Math.max(o>>1,1),l=Math.max(l>>1,1)}}},Xx=["right","left","top","bottom","front","back"];function jx(r){return{id:"cube",upload(t,e,i,n){const s=t.faces;for(let a=0;a<Xx.length;a++){const o=Xx[a],l=s[o];(r[l.uploadMethodId]||r.image).upload(l,e,i,n,ta.TEXTURE_CUBE_MAP_POSITIVE_X+a,(e._layerInitMask&1<<a)===0),e._layerInitMask|=1<<a}e.width=t.pixelWidth,e.height=t.pixelHeight}}}const Ac={id:"image",upload(r,t,e,i,n,s=!1){const a=n||t.target,o=r.pixelWidth,l=r.pixelHeight,u=r.resourceWidth,c=r.resourceHeight,h=i===2,p=s||t.width!==o||t.height!==l,f=u>=o&&c>=l,m=r.resource;(h?c3:h3)(e,a,t,o,l,u,c,m,p,f),t.width=o,t.height=l}};function c3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,s,a,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,o)}function h3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,o)}const d3=Au(),Hx={id:"video",upload(r,t,e,i,n,s=d3){if(!r.isValid){const a=n!=null?n:t.target;e.texImage2D(a,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Ac.upload(r,t,e,i,n,s)}},Cc={linear:9729,nearest:9728},zx={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},na={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Wx={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Mc(r,t,e,i,n,s,a,o){const l=s;if(!o||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=na[a?"clamp-to-edge":r.addressModeU],c=na[a?"clamp-to-edge":r.addressModeV],h=na[a?"clamp-to-edge":r.addressModeW];t[n](l,t.TEXTURE_WRAP_S,u),t[n](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[n](l,t.TEXTURE_WRAP_R,h)}if((!o||r.magFilter!=="linear")&&t[n](l,t.TEXTURE_MAG_FILTER,Cc[r.magFilter]),e){if(!o||r.mipmapFilter!=="linear"){const u=zx[r.minFilter][r.mipmapFilter];t[n](l,t.TEXTURE_MIN_FILTER,u)}}else t[n](l,t.TEXTURE_MIN_FILTER,Cc[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[n](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[n](l,t.TEXTURE_COMPARE_FUNC,Wx[r.compare])}function Vx(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 p3=Object.defineProperty,f3=Object.defineProperties,m3=Object.getOwnPropertyDescriptors,Yx=Object.getOwnPropertySymbols,g3=Object.prototype.hasOwnProperty,_3=Object.prototype.propertyIsEnumerable,Kx=(r,t,e)=>t in r?p3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mr=(r,t)=>{for(var e in t||(t={}))g3.call(t,e)&&Kx(r,e,t[e]);if(Yx)for(var e of Yx(t))_3.call(t,e)&&Kx(r,e,t[e]);return r},y3=(r,t)=>f3(r,m3(t));function qx(r,t){let e={},i=r.RGBA;return r instanceof H.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},i=r.RGBA8),mr(mr(mr(mr(mr(mr(y3(mr({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 Zx(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 Qx(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}function b3(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 n=255.001/i;r[e]=r[e]*n+.5,r[e+1]=r[e+1]*n+.5,r[e+2]=r[e+2]*n+.5}}}var v3=Object.defineProperty,x3=Object.defineProperties,T3=Object.getOwnPropertyDescriptors,Jx=Object.getOwnPropertySymbols,S3=Object.prototype.hasOwnProperty,w3=Object.prototype.propertyIsEnumerable,t0=(r,t,e)=>t in r?v3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P3=(r,t)=>{for(var e in t||(t={}))S3.call(t,e)&&t0(r,e,t[e]);if(Jx)for(var e of Jx(t))w3.call(t,e)&&t0(r,e,t[e]);return r},E3=(r,t)=>x3(r,T3(t));const A3=4;class Rc{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e={image:Ac,buffer:Lx,video:Hx,compressed:Nx};this._uploads=E3(P3({},e),{cube:jx(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=qx(t,this._renderer.context.extensions),this._mapFormatToType=Zx(t),this._mapFormatToFormat=Vx(t),this._mapViewDimensionToGlTarget=Qx(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(D.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._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=D.EMPTY.source);const n=this.getGlSource(t);i.bindTexture(n.target,n.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const n=this._getGlSampler(t);this._boundSamplers[e]!==n&&(this._boundSamplers[e]=n,i.bindSampler(e,n))}unbind(t){const e=t.source,i=this._boundTextures,n=this._gl;for(let s=0;s<i.length;s++)if(i[s]===e){this._activateLocation(s);const a=this.getGlSource(e);n.bindTexture(a.target,null),i[s]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new Ec(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],i.target=this._mapViewDimensionToGlTarget[t.viewDimension],i.target===null)throw new Error(`Unsupported view dimension: ${t.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(t.uploadMethodId==="cube"&&(i.target=e.TEXTURE_CUBE_MAP),t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const n=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(n))+1}return t._gpuData[this._renderer.uid]=i,this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,n=this.getGlSource(t);i.bindTexture(n.target,n.texture),this._boundTextures[this._activeTextureLocation]=t,Mc(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",n.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||(this.unbind(t),this._gl.deleteTexture(i.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t;const n=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion);else if(i.target===e.TEXTURE_2D)this._initEmptyTexture2D(i,t);else if(i.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(i,t);else if(i.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(i,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(i,t),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)}_initEmptyTexture2D(t,e){const i=this._gl;i.texImage2D(i.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),s=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++)i.texImage2D(i.TEXTURE_2D,a,t.internalFormat,n,s,0,t.format,t.type,null),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const i=this._gl,n=Math.max(e.arrayLayerCount|0,1);i.texImage3D(i.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,n,0,t.format,t.type,null);let s=Math.max(e.pixelWidth>>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o<e.mipLevelCount;o++)i.texImage3D(i.TEXTURE_2D_ARRAY,o,t.internalFormat,s,a,n,0,t.format,t.type,null),s=Math.max(s>>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(t,e){const i=this._gl,n=6;for(let o=0;o<n;o++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let s=Math.max(e.pixelWidth>>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o<e.mipLevelCount;o++){for(let l=0;l<n;l++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+l,o,t.internalFormat,s,a,0,t.format,t.type,null);s=Math.max(s>>1,1),a=Math.max(a>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;const i=this._gl,n=Math.max((e.mipLevelCount|0)-1,0);i.texParameteri(t.target,i.TEXTURE_BASE_LEVEL,0),i.texParameteri(t.target,i.TEXTURE_MAX_LEVEL,n)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Mc(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 t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:n}=this.getPixels(t),s=H.get().createCanvas();s.width=i,s.height=n;const a=s.getContext("2d");if(a){const o=a.createImageData(i,n);o.data.set(e),a.putImageData(o,0,0)}return s}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),s=Math.max(Math.round(i.height*e),1),a=new Uint8Array(A3*n*s),o=this._renderer,l=o.renderTarget.getRenderTarget(t),u=o.renderTarget.getGpuRenderTarget(l),c=o.gl;return c.bindFramebuffer(c.FRAMEBUFFER,u.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,s,c.RGBA,c.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:n,height:s}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(D.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Rc.extension={type:[S.WebGLSystem],name:"texture"};class Oc{contextChange(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new U,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=Dr({name:"graphics",bits:[Nn,jn(i),vs,$r]});this.shader=new ee({glProgram:n,resources:{localUniforms:e,batchSamplers:Hn(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(t.state),s.shader.bind(n),s.geometry.bind(o.geometry,n.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++)s.texture.bind(h.textures.textures[p],p);s.geometry.draw(h.topology,h.size,h.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Oc.extension={type:[S.WebGLPipesAdaptor],name:"graphics"};class Gc{init(){const t=Dr({name:"mesh",bits:[vs,lv,$r]});this._shader=new ee({glProgram:t,resources:{uTexture:D.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return}else{n=this._shader;const s=e.texture,a=s.source;n.resources.uTexture=a,n.resources.uSampler=a.style,n.resources.textureUniforms.uniforms.uTextureMatrix=s.textureMatrix.mapCoord}n.groups[100]=i.globalUniforms.bindGroup,n.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Gc.extension={type:[S.WebGLPipesAdaptor],name:"mesh"};const C3=[...qs,yc,mx,ox,dc,sc,Rc,bc,lc,Pc,wc,hc,kx,pc,cc],M3=[...rc],R3=[Ru,Gc,Oc],e0=[],r0=[],i0=[];X.handleByNamedList(S.WebGLSystem,e0),X.handleByNamedList(S.WebGLPipes,r0),X.handleByNamedList(S.WebGLPipesAdaptor,i0),X.add(...C3,...M3,...R3);class n0 extends Mr{constructor(){const t={name:"webgl",type:It.WEBGL,systems:e0,renderPipes:r0,renderPipeAdaptors:i0};super(t)}}var O3={__proto__:null,WebGLRenderer:n0};class Ic{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n;const s=this._gpu.device,a=e.layout[i],o=[],l=this._renderer;for(const h in a){const p=(n=t.resources[h])!=null?n:t.resources[a[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const g=m.buffer;f={buffer:l.buffer.getGPUBuffer(g),offset:0,size:g.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.getTextureView(m)}o.push({binding:a[h],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],c=s.createBindGroup({layout:u,entries:o});return this._hash[t._key]=c,c}destroy(){this._hash=null,this._renderer=null}}Ic.extension={type:[S.WebGPUSystem],name:"bindGroup"};class s0{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Bc{constructor(t){this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(t),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(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=ht("resource"),t.data&&($n(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new s0(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Bc.extension={type:[S.WebGPUSystem],name:"buffer"};class a0{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 Fc{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}}Fc.extension={type:[S.WebGPUSystem],name:"colorMask"};class sa{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await H.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(s=>e.features.has(s)),n=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}}destroy(){this.gpu=null,this._renderer=null}}sa.extension={type:[S.WebGPUSystem],name:"device"},sa.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var G3=Object.defineProperty,o0=Object.getOwnPropertySymbols,I3=Object.prototype.hasOwnProperty,B3=Object.prototype.propertyIsEnumerable,l0=(r,t,e)=>t in r?G3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,u0=(r,t)=>{for(var e in t||(t={}))I3.call(t,e)&&l0(r,e,t[e]);if(o0)for(var e of o0(t))B3.call(t,e)&&l0(r,e,t[e]);return r};class Dc{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,n){const s=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(s)}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.gc.now,this._renderer.tick);const n=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,n)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const n in i)this._setVertexBuffer(parseInt(n,10),t.attributes[i[n]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const n=t.groups[i];e||this._syncBindGroup(n),this.setBindGroup(i,n,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:n,topology:s,size:a,start:o,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,s),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(a||e.indexBuffer.data.length,l!=null?l:e.instanceCount,o||0):this.renderPassEncoder.draw(a||e.getSize(),l!=null?l:e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=u0({},this._boundVertexBuffer),n=this._boundIndexBuffer,s=u0({},this._boundBindGroup);this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in s)this.setBindGroup(o,s[o],null);this._setIndexBuffer(n)}_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}}Dc.extension={type:[S.WebGPUSystem],name:"encoder",priority:1};class Uc{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Uc.extension={type:[S.WebGPUSystem],name:"limits"};class $c{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:wt.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 n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}$c.extension={type:[S.WebGPUSystem],name:"stencil"};const Ki={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 c0(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const n=t[i];let s=Ki[n.data.type].size;const a=Ki[n.data.type].align;if(!Ki[n.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${n.data.type}`);n.data.size>1&&(s=Math.max(s,a)*n.data.size),e=Math.ceil(e/a)*a,n.size=s,n.offset=e,e+=s}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function h0(r,t){const{size:e,align:i}=Ki[r.data.type],n=(i-e)/4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
2084 v = uv.${r.data.name};
2085 ${t!==0?`offset += ${t};`:""}
2086
2087 arrayOffset = offset;
2088
2089 t = 0;
2090
2091 for(var i=0; i < ${r.data.size*(e/4)}; i++)
2092 {
2093 for(var j = 0; j < ${e/4}; j++)
2094 {
2095 ${s}[arrayOffset++] = v[t++];
2096 }
2097 ${n!==0?`arrayOffset += ${n};`:""}
2098 }
2099 `}function d0(r){return gc(r,"uboWgsl",h0,vx)}class kc extends fc{constructor(){super({createUboElements:c0,generateUboSync:d0})}}kc.extension={type:[S.WebGPUSystem],name:"ubo"};const Ve=128;class Lc{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new a0({minUniformOffsetAlignment:Ve});const e=256/Ve;for(let i=0;i<e;i++){let n=at.UNIFORM|at.COPY_DST;i===0&&(n|=at.COPY_SRC),this._buffers.push(new Yt({data:this._batchBuffer.data,usage:n}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,n=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,n/4),this._bindGroupHash[t.uid]=this._getBindGroup(n/Ve),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/Ve)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/Ve)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/Ve;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new ea({buffer:e,offset:(t/2|0)*256,size:Ve})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Pe({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 n=1;n<this._buffers.length;n++){const s=this._buffers[n];i.copyBufferToBuffer(t.getGPUBuffer(e),Ve,t.getGPUBuffer(s),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){var t;for(let e=0;e<this._bindGroups.length;e++)(t=this._bindGroups[e])==null||t.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}Lc.extension={type:[S.WebGPUPipes],name:"uniformBatch"};var F3=Object.defineProperty,D3=Object.defineProperties,U3=Object.getOwnPropertyDescriptors,p0=Object.getOwnPropertySymbols,$3=Object.prototype.hasOwnProperty,k3=Object.prototype.propertyIsEnumerable,f0=(r,t,e)=>t in r?F3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L3=(r,t)=>{for(var e in t||(t={}))$3.call(t,e)&&f0(r,e,t[e]);if(p0)for(var e of p0(t))k3.call(t,e)&&f0(r,e,t[e]);return r},N3=(r,t)=>D3(r,U3(t));const X3={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function j3(r,t,e,i,n){return r<<24|t<<16|e<<10|i<<5|n}function H3(r,t,e,i,n){return e<<8|r<<5|i<<3|n<<1|t}class Nc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(wt.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Ue[t],this._updatePipeHash())}setPipeline(t,e,i,n){const s=this.getPipeline(t,e,i);n.setPipeline(s)}getPipeline(t,e,i,n){t._layoutKey||(oc(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const s=j3(t._layoutKey,e._layoutKey,i.data,i._blendModeId,X3[n]);return this._pipeCache[s]?this._pipeCache[s]:(this._pipeCache[s]=this._createPipeline(t,e,i,n),this._pipeCache[s])}_createPipeline(t,e,i,n){const s=this._gpu.device,a=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i,this._colorTargetCount),l=this._stencilMode===wt.RENDERING_MASK_ADD?0:this._colorMask;for(let h=0;h<o.length;h++)o[h].writeMask=l;const u=this._renderer.shader.getProgramData(e).pipeline,c={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:n,cullMode:i.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(c.depthStencil=N3(L3({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),s.createRenderPipeline(c)}_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 n=Object.keys(t.attributes).sort();for(let a=0;a<n.length;a++){const o=t.attributes[n[a]];e[i++]=o.offset,e[i++]=o.format,e[i++]=o.stride,e[i++]=o.instance}const s=e.join("|");return t._layoutKey=Ar(s,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const n=Object.keys(t.attributeData).sort();for(let a=0;a<n.length;a++){const o=t.attributeData[n[a]];e[i++]=o.location}const s=e.join("|");return t._attributeLocationsKey=Ar(s,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const n=this._createVertexBufferLayouts(t,e),s=Object.create(null),a=e.attributeData;for(let o=0;o<n.length;o++){const l=Object.values(n[o].attributes)[0].shaderLocation;for(const u in a)if(a[u].location===l){s[o]=u;break}}return this._bindingNamesCache[i]=s,s}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const n=[];return t.buffers.forEach(s=>{var a;const o={arrayStride:0,stepMode:"vertex",attributes:[]},l=o.attributes;for(const u in e.attributeData){const c=t.attributes[u];((a=c.divisor)!=null?a:1)!==1&&ue(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===s&&(o.arrayStride=c.stride,o.stepMode=c.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:c.offset,format:c.format}))}l.length&&n.push(o)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=H3(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Nc.extension={type:[S.WebGPUSystem],name:"pipeline"};class m0{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class g0{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,s){const a=this._renderer,o=this._getGpuColorTexture(t),l=a.texture.getGpuSource(e.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:l,origin:s},n),e}startRenderPass(t,e=!0,i,n,s=0,a=0){var o,l;const u=this._renderTargetSystem.getGpuRenderTarget(t);if(a!==0&&(o=u.msaaTextures)!=null&&o.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(s>0&&(l=u.msaaTextures)!=null&&l.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const c=this.getDescriptor(t,e,i,s,a);u.descriptor=c,this._renderer.pipeline.setRenderTarget(u),this._renderer.encoder.beginRenderPass(u),this._renderer.encoder.setViewport(n)}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,n=0,s=0){typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const a=this._renderTargetSystem,o=a.getGpuRenderTarget(t),l=t.colorTextures.map((c,h)=>{const p=o.contexts[h];let f,m;if(p){if(s!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");f=p.getCurrentTexture().createView()}else f=this._renderer.texture.getGpuSource(c).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1});o.msaaTextures[h]&&(m=f,f=this._renderer.texture.getTextureView(o.msaaTextures[h]));const g=e&Kt.COLOR?"clear":"load";return i!=null||(i=a.defaultClearColor),{view:f,resolveTarget:m,clearValue:i,storeOp:"store",loadOp:g}});let u;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=o.msaa?4:1),t.depthStencilTexture){const c=e&Kt.STENCIL?"clear":"load",h=e&Kt.DEPTH?"clear":"load";u={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:c,depthClearValue:1,depthLoadOp:h,depthStoreOp:"store"}}return{colorAttachments:l,depthStencilAttachment:u}}clear(t,e=!0,i,n,s=0,a=0){if(!e)return;const{gpu:o,encoder:l}=this._renderer,u=o.device;if(l.commandEncoder===null){const c=u.createCommandEncoder(),h=this.getDescriptor(t,e,i,s,a),p=c.beginRenderPass(h);p.setViewport(n.x,n.y,n.width,n.height,0,1),p.end();const f=c.finish();u.queue.submit([f])}else this.startRenderPass(t,e,i,n,s,a)}initGpuRenderTarget(t){t.isRoot=!0;const e=new m0;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((i,n)=>{if(i instanceof fe){const s=i.resource.getContext("webgpu"),a=i.transparent?"premultiplied":"opaque";try{s.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:a})}catch(o){console.error(o)}e.contexts[n]=s}if(e.msaa=i.source.antialias,i.source.antialias){const s=new ft({width:0,height:0,sampleCount:4,arrayLayerCount:i.source.arrayLayerCount});e.msaaTextures[n]=s}}),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,n)=>{const s=e.msaaTextures[n];s==null||s.resize(i.source.width,i.source.height,i.source._resolution)})}}class Xc extends Zs{constructor(t){super(t),this.adaptor=new g0,this.adaptor.init(t,this)}}Xc.extension={type:[S.WebGPUSystem],name:"renderTarget"};class jc{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(s=>e.createBindGroupLayout({entries:s})),n={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(n)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}jc.extension={type:[S.WebGPUSystem],name:"shader"};const Ht={};Ht.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ht.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ht["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ht["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ht.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Ht.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Ht.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Hc{constructor(){this.defaultState=new Vt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const i=Ht[t.blendMode]||Ht.normal,n=[],s={format:"bgra8unorm",writeMask:0,blend:i};for(let a=0;a<e;a++)n[a]=s;return n}destroy(){this.gpu=null}}Hc.extension={type:[S.WebGPUSystem],name:"state"};const _0={type:"image",upload(r,t,e,i=0){const n=r.resource,s=(r.pixelWidth|0)*(r.pixelHeight|0),a=n.byteLength/s;e.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:i}},n,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*a},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},zc={"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}},z3={blockBytes:4,blockWidth:1,blockHeight:1},y0={type:"compressed",upload(r,t,e,i=0){let n=r.pixelWidth,s=r.pixelHeight;const a=zc[r.format]||z3;for(let o=0;o<r.resource.length;o++){const l=r.resource[o],u=Math.ceil(n/a.blockWidth)*a.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:o,origin:{x:0,y:0,z:i}},l,{offset:0,bytesPerRow:u},{width:Math.ceil(n/a.blockWidth)*a.blockWidth,height:Math.ceil(s/a.blockHeight)*a.blockHeight,depthOrArrayLayers:1}),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}},b0=["right","left","top","bottom","front","back"];function v0(r){return{type:"cube",upload(t,e,i){const n=t.faces;for(let s=0;s<b0.length;s++){const a=b0[s],o=n[a];(r[o.uploadMethodId]||r.image).upload(o,e,i,s)}}}}const Wc={type:"image",upload(r,t,e,i=0){const n=r.resource;if(!n)return;if(globalThis.HTMLImageElement&&n instanceof HTMLImageElement){const l=H.get().createCanvas(n.width,n.height);l.getContext("2d").drawImage(n,0,0,n.width,n.height),r.resource=l}const s=Math.min(t.width,r.resourceWidth||r.pixelWidth),a=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:n},{texture:t,origin:{x:0,y:0,z:i},premultipliedAlpha:o},{width:s,height:a})}},x0={type:"video",upload(r,t,e,i){Wc.upload(r,t,e,i)}};class T0{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:`
2100 var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
2101 vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
2102
2103 struct VertexOutput {
2104 @builtin(position) position : vec4<f32>,
2105 @location(0) texCoord : vec2<f32>,
2106 };
2107
2108 @vertex
2109 fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
2110 var output : VertexOutput;
2111 output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
2112 output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
2113 return output;
2114 }
2115
2116 @group(0) @binding(0) var imgSampler : sampler;
2117 @group(0) @binding(1) var img : texture_2d<f32>;
2118
2119 @fragment
2120 fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
2121 return textureSample(img, imgSampler, texCoord);
2122 }
2123 `})),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 n=t.depthOrArrayLayers||1,s=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!s){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(l)}const a=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let l=0;l<n;++l){let u=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),c=s?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=a.beginRenderPass({colorAttachments:[{view:p,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),m=this.device.createBindGroup({layout:o,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(!s){const l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n};for(let u=1;u<t.mipLevelCount;++u)a.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([a.finish()]),s||i.destroy(),t}}var W3=Object.defineProperty,V3=Object.defineProperties,Y3=Object.getOwnPropertyDescriptors,S0=Object.getOwnPropertySymbols,K3=Object.prototype.hasOwnProperty,q3=Object.prototype.propertyIsEnumerable,w0=(r,t,e)=>t in r?W3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Z3=(r,t)=>{for(var e in t||(t={}))K3.call(t,e)&&w0(r,e,t[e]);if(S0)for(var e of S0(t))q3.call(t,e)&&w0(r,e,t[e]);return r},Q3=(r,t)=>V3(r,Y3(t));class Vc{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Yc{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e={image:Wc,buffer:_0,video:x0,compressed:y0};this._uploads=Q3(Z3({},e),{cube:v0(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=zc[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,s=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,a={label:t.label,size:{width:n,height:s,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpu.device.createTexture(a);return t._gpuData[this._renderer.uid]=new Vc(o),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new T0(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],i=e==null?void 0:e.gpuTexture;i?(i.width!==t.pixelWidth||i.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]||this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Pe({0:e,1:e.style,2:new At({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let i=e._gpuData[this._renderer.uid];return i||(this.initSource(e),i=e._gpuData[this._renderer.uid]),i.textureView||(i.textureView=i.gpuTexture.createView({dimension:e.viewDimension})),i.textureView}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),n=H.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:H.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=me.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:s,height:a}=e,o=n.getImageData(0,0,s,a),l=new Uint8ClampedArray(o.data.buffer);return me.returnCanvasAndContext(i),{pixels:l,width:s,height:a}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Yc.extension={type:[S.WebGPUSystem],name:"texture"};class Kc{constructor(){this._maxTextures=0}contextChange(t){const e=new At({uTransformMatrix:{value:new U,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=Fr({name:"graphics",bits:[Ln,Xn(this._maxTextures),By,Ur]});this.shader=new ee({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i),u=s.encoder;u.setGeometry(o.geometry,n.gpuProgram);const c=s.globalUniforms.bindGroup;u.setBindGroup(0,c,n.gpuProgram);const h=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);u.setBindGroup(2,h,n.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m<l.instructionSize;m++){const g=p[m];if(g.topology!==f&&(f=g.topology,u.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,t.state,g.topology)),n.groups[1]=g.bindGroup,!g.gpuBindGroup){const _=g.textures;g.bindGroup=Un(_.textures,_.count,this._maxTextures),g.gpuBindGroup=s.bindGroup.getBindGroup(g.bindGroup,n.gpuProgram,1)}u.setBindGroup(1,g.bindGroup,n.gpuProgram),u.renderPassEncoder.drawIndexed(g.size,1,g.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Kc.extension={type:[S.WebGPUPipesAdaptor],name:"graphics"};class qc{init(){const t=Fr({name:"mesh",bits:[qr,ov,Ur]});this._shader=new ee({gpuProgram:t,resources:{uTexture:D.EMPTY._source,uSampler:D.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(!n)n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!n.gpuProgram)return;const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),s.autoAssignLocalUniforms){const a=t.localUniforms;n.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(a,!0)}i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}qc.extension={type:[S.WebGPUPipesAdaptor],name:"mesh"};const J3=[...qs,kc,Dc,sa,Uc,Bc,Yc,Xc,jc,Hc,Nc,Fc,$c,Ic],tG=[...rc,Lc],eG=[Ou,qc,Kc],P0=[],E0=[],A0=[];X.handleByNamedList(S.WebGPUSystem,P0),X.handleByNamedList(S.WebGPUPipes,E0),X.handleByNamedList(S.WebGPUPipesAdaptor,A0),X.add(...J3,...tG,...eG);class C0 extends Mr{constructor(){const t={name:"webgpu",type:It.WEBGPU,systems:P0,renderPipes:E0,renderPipeAdaptors:A0};super(t)}}var rG={__proto__:null,WebGPURenderer:C0};const iG={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},nG=new Proxy(iG,{get(r,t){return r[t]}});var Zc=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Zc||{});const sG=new Proxy(Zc,{get(r,t){return r[t]}});var Qc=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Qc||{});const aG=new Proxy(Qc,{get(r,t){return r[t]}});var oG=Object.defineProperty,lG=Object.defineProperties,uG=Object.getOwnPropertyDescriptors,aa=Object.getOwnPropertySymbols,M0=Object.prototype.hasOwnProperty,R0=Object.prototype.propertyIsEnumerable,O0=(r,t,e)=>t in r?oG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cG=(r,t)=>{for(var e in t||(t={}))M0.call(t,e)&&O0(r,e,t[e]);if(aa)for(var e of aa(t))R0.call(t,e)&&O0(r,e,t[e]);return r},hG=(r,t)=>lG(r,uG(t)),dG=(r,t)=>{var e={};for(var i in r)M0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&aa)for(var i of aa(r))t.indexOf(i)<0&&R0.call(r,i)&&(e[i]=r[i]);return e};class ei extends ft{constructor(t){const e=t,{faces:i}=e,n=dG(e,["faces"]);ei._validateFaces(i);const s=i.right,a=s.resolution,o=s.format,l=s.alphaMode;super(hG(cG({},n),{resource:i,width:s.width,height:s.height,dimensions:"2d",viewDimension:"cube",arrayLayerCount:6,resolution:a,format:o,alphaMode:l})),this.uploadMethodId="cube",this.faces=i;for(const u of Object.keys(i)){const c=i[u];c.on("update",this._onFaceUpdate,this),c.on("resize",this._onFaceResize,this),c.on("unload",this._onFaceUpdate,this)}}destroy(){const t=this.faces;if(t)for(const e of Object.keys(t)){const i=t[e];i.off("update",this._onFaceUpdate,this),i.off("resize",this._onFaceResize,this),i.off("unload",this._onFaceUpdate,this)}super.destroy()}_onFaceUpdate(){this.emit("update",this)}_onFaceResize(t){ei._validateFaces(this.faces),this.resize(t.width,t.height,t.resolution)}static _validateFaces(t){if(!t.right||!t.left||!t.top||!t.bottom||!t.front||!t.back)throw new Error("[CubeTextureSource] Requires { left, right, top, bottom, front, back } faces.");const e=t.right,i=e.pixelWidth,n=e.pixelHeight,s=e.format,a=e.alphaMode,o=e.resolution;for(const l of Object.keys(t)){const u=t[l];if(u.pixelWidth!==i||u.pixelHeight!==n)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different size. All faces must match.`);if(u.format!==s)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different format. All faces must match.`);if(u.alphaMode!==a)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different alphaMode. All faces must match.`);if(u.resolution!==o)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different resolution. All faces must match.`)}}}var pG=Object.defineProperty,fG=Object.defineProperties,mG=Object.getOwnPropertyDescriptors,oa=Object.getOwnPropertySymbols,G0=Object.prototype.hasOwnProperty,I0=Object.prototype.propertyIsEnumerable,B0=(r,t,e)=>t in r?pG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,F0=(r,t)=>{for(var e in t||(t={}))G0.call(t,e)&&B0(r,e,t[e]);if(oa)for(var e of oa(t))I0.call(t,e)&&B0(r,e,t[e]);return r},gG=(r,t)=>fG(r,mG(t)),_G=(r,t)=>{var e={};for(var i in r)G0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&oa)for(var i of oa(r))t.indexOf(i)<0&&I0.call(r,i)&&(e[i]=r[i]);return e};const Jc=["left","right","top","bottom","front","back"];function yG(r,t){const e=t?F0({},t):{};delete e.label;const i=Object.keys(e).sort(),n=i.length?`|${i.map(s=>`${s}=${String(e[s])}`).join("&")}`:"";return`cube:${Jc.map(s=>r[s]).join(",")}${n}`}class la extends Nt{constructor(t){var e;super(),this.uid=ht("cubeTexture"),this.destroyed=!1;const{label:i,source:n}=t;this.label=i,this.source=n,this.source.label=(e=this.label)!=null?e:this.source.label}static from(t,e=!1){if(t instanceof ei)return new la({source:t});const i=t,{faces:n}=i,s=_G(i,["faces"]);let a=null;const o=Jc.every(h=>typeof n[h]=="string");if(!e&&o&&(a=yG(n,s),it.has(a)))return it.get(a);const l=h=>h.isTexture?h:D.from(h),u={};for(const h of Jc)u[h]=l(n[h]).source;const c=new la({source:new ei(gG(F0({},s),{faces:u})),label:s.label});return a&&(it.set(a,c),c.once("destroy",()=>{it.has(a)&&it.remove(a)})),c}destroy(t=!1){this.destroyed||(this.destroyed=!0,t&&this.source.destroy(),this.emit("destroy",this),this.removeAllListeners())}}const th=Object.create(null),eh=Object.create(null);function bG(r){var t;if(r.type===It.WEBGPU)return eh[t=r.uid]||(eh[t]=r.gpu.device.createTexture({label:"ExternalSource placeholder",size:{width:1,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST})),eh[r.uid];if(!th[r.uid]){const e=r.gl,i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null),th[r.uid]=i}return th[r.uid]}class vG extends ft{constructor({resource:t,renderer:e,label:i,width:n,height:s}){var a,o;t||(t=bG(e)),n||(n=(a=n!=null?n:t==null?void 0:t.width)!=null?a:1),s||(s=(o=s!=null?s:t==null?void 0:t.height)!=null?o:1),super({resource:t,width:n,height:s,label:i,autoGarbageCollect:!1}),this._renderer=e,this._initGpuData(t)}static test(t){return globalThis.GPUTexture&&t instanceof GPUTexture||globalThis.WebGLTexture&&t instanceof WebGLTexture}_validateTexture(t){const e=this._renderer,i=!!e.gpu,n=globalThis.GPUTexture&&t instanceof GPUTexture,s=globalThis.WebGLTexture&&t instanceof WebGLTexture;if(i&&s)throw new Error("Cannot use WebGLTexture with a WebGPU renderer");if(!i&&n)throw new Error("Cannot use GPUTexture with a WebGL renderer");if(!i){const a=e.gl;if(a&&!a.isTexture(t))throw new Error("WebGLTexture does not belong to this renderer's WebGL context")}}_initGpuData(t){const e=this._renderer;this._validateTexture(t),e.gpu?this._gpuData[e.uid]=new Vc(t):this._gpuData[e.uid]=new Ec(t)}updateGPUTexture(t,e,i){const n=this._renderer,s=this._gpuData[n.uid];if(this.resource=t,n.gpu){this._validateTexture(t);const a=s;if(a.gpuTexture!==t){a.gpuTexture=t,a.textureView=null;const u=n.texture;u!=null&&u._bindGroupHash&&(u._bindGroupHash[this.uid]=null)}const o=e!=null?e:t.width,l=i!=null?i:t.height;this.resize(o,l)}else{this._validateTexture(t);const a=s;a.texture=t,e!==void 0&&i!==void 0&&this.resize(e,i)}this.emit("update",this)}destroy(){const t=this._renderer;delete this._gpuData[t.uid],super.destroy()}}class xG{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 n=e.width,s=e.height;if(i){const a=t.width/2/n,o=t.height/2/s,l=t.x/n+a,u=t.y/s+o;i=W.add(i,W.NW),this.x0=l+a*W.uX(i),this.y0=u+o*W.uY(i),i=W.add(i,2),this.x1=l+a*W.uX(i),this.y1=u+o*W.uY(i),i=W.add(i,2),this.x2=l+a*W.uX(i),this.y2=u+o*W.uY(i),i=W.add(i,2),this.x3=l+a*W.uX(i),this.y3=u+o*W.uY(i)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;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 TG(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 SG(r,t){return r.getFastGlobalBounds(!0,t)}var wG=Object.defineProperty,ua=Object.getOwnPropertySymbols,D0=Object.prototype.hasOwnProperty,U0=Object.prototype.propertyIsEnumerable,$0=(r,t,e)=>t in r?wG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PG=(r,t)=>{for(var e in t||(t={}))D0.call(t,e)&&$0(r,e,t[e]);if(ua)for(var e of ua(t))U0.call(t,e)&&$0(r,e,t[e]);return r},EG=(r,t)=>{var e={};for(var i in r)D0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ua)for(var i of ua(r))t.indexOf(i)<0&&U0.call(r,i)&&(e[i]=r[i]);return e};class AG extends Se{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const n=t,{render:s}=n,a=EG(n,["render"]);super(PG({label:"RenderContainer"},a)),this.renderPipeId="customRender",this.batched=!1,s&&(this.render=s),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 CG(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function MG(r,t){const e=t._scale,i=t._pivot,n=t._position,s=e._x,a=e._y,o=i._x,l=i._y;r.a=t._cx*s,r.b=t._sx*s,r.c=t._cy*a,r.d=t._sy*a,r.tx=n._x-(o*r.a+l*r.c),r.ty=n._y-(o*r.b+l*r.d)}function RG(r,t,e){const i=r.a,n=r.b,s=r.c,a=r.d,o=r.tx,l=r.ty,u=t.a,c=t.b,h=t.c,p=t.d;e.a=i*u+n*h,e.b=i*c+n*p,e.c=s*u+a*h,e.d=s*c+a*p,e.tx=o*u+l*h+t.tx,e.ty=o*c+l*p+t.ty}class k0{constructor(){this._gradients=[],this._nextId=0}addStyle(t){var e;if(!(t.fill instanceof $t))return null;const i=`pixi-grad-${this._nextId++}`;return this._gradients.push({id:i,gradient:t.fill,textureSpace:(e=t.textureSpace)!=null?e:"local"}),`url(#${i})`}build(){var t,e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y;if(this._gradients.length===0)return"";const b=["<defs>"];for(const{id:x,gradient:v,textureSpace:w}of this._gradients){const T=w==="global"?"userSpaceOnUse":"objectBoundingBox",P=OG(v.colorStops);if(v.type==="radial"){const E=(e=(t=v.outerCenter)==null?void 0:t.x)!=null?e:.5,M=(n=(i=v.outerCenter)==null?void 0:i.y)!=null?n:.5,C=(s=v.outerRadius)!=null?s:.5,A=(o=(a=v.center)==null?void 0:a.x)!=null?o:E,G=(u=(l=v.center)==null?void 0:l.y)!=null?u:M;b.push(`<radialGradient id="${x}" gradientUnits="${T}" cx="${E}" cy="${M}" r="${C}" fx="${A}" fy="${G}">`,P,"</radialGradient>")}else{const E=(h=(c=v.start)==null?void 0:c.x)!=null?h:0,M=(f=(p=v.start)==null?void 0:p.y)!=null?f:0,C=(g=(m=v.end)==null?void 0:m.x)!=null?g:1,A=(y=(_=v.end)==null?void 0:_.y)!=null?y:0;b.push(`<linearGradient id="${x}" gradientUnits="${T}" x1="${E}" y1="${M}" x2="${C}" y2="${A}">`,P,"</linearGradient>")}}return b.push("</defs>"),b.join("")}}function OG(r){return r.map(t=>{const e=tt.shared.setValue(t.color).toHex();return`<stop offset="${t.offset}" stop-color="${e}"/>`}).join("")}const gr=Math.PI*2,GG=new Set(["regularPoly","roundPoly","roundShape","filletRect","chamferRect","arcTo"]);function Ye(r,t=2,e=!1){var i,n,s;if(r.instructions.some(l=>GG.has(l.action)))return DG(r,t,e);const a=[];let o=!1;for(let l=0;l<r.instructions.length;l++){const u=r.instructions[l],c=u.data;switch(u.action){case"moveTo":a.push(`M${Ft(c[0],c[1],null,t)}`),o=!0;break;case"lineTo":a.push(`L${Ft(c[0],c[1],null,t)}`),o=!0;break;case"quadraticCurveTo":a.push(`Q${Ft(c[0],c[1],null,t)} ${Ft(c[2],c[3],null,t)}`),o=!0;break;case"bezierCurveTo":a.push(`C${Ft(c[0],c[1],null,t)} ${Ft(c[2],c[3],null,t)} ${Ft(c[4],c[5],null,t)}`),o=!0;break;case"arcToSvg":a.push(`A${V(c[0],t)} ${V(c[1],t)} ${V(c[2],t)} ${c[3]} ${c[4]} ${Ft(c[5],c[6],null,t)}`),o=!0;break;case"closePath":a.push("Z"),o=!1;break;case"arc":a.push(BG(c[0],c[1],c[2],c[3],c[4],!!c[5],o,t,e)),o=!IG(c[3],c[4],!!c[5]);break;case"rect":a.push(rh(c[0],c[1],c[2],c[3],c[4],t)),o=!1;break;case"circle":a.push(qi(c[0],c[1],c[2],c[2],c[3],t,e)),o=!1;break;case"ellipse":a.push(qi(c[0],c[1],c[2],c[3],c[4],t,e)),o=!1;break;case"roundRect":a.push(L0(c[0],c[1],c[2],c[3],(i=c[4])!=null?i:0,c[5],t,e)),o=!1;break;case"poly":a.push(N0(c[0],(n=c[1])!=null?n:!0,c[2],t)),o=!((s=c[1])==null||s);break;case"addPath":a.push(FG(c[0],c[1],t,e)),o=!0;break}}return a.join("")}function IG(r,t,e){let i=t-r;return e?i>0&&(i-=gr):i<0&&(i+=gr),Math.abs(i)>=gr-1e-6}function V(r,t){return parseFloat(r.toFixed(t)).toString()}function Ft(r,t,e,i){if(e&&!e.isIdentity()){const n=e.a*r+e.c*t+e.tx,s=e.b*r+e.d*t+e.ty;return`${V(n,i)} ${V(s,i)}`}return`${V(r,i)} ${V(t,i)}`}function BG(r,t,e,i,n,s,a,o,l=!1){let u=n-i;if(s?u>0&&(u-=gr):u<0&&(u+=gr),Math.abs(u)>=gr-1e-6)return qi(r,t,e,e,null,o,l);if(l){const _=[];for(let y=0;y<=32;y++){const b=i+y/32*u,x=r+e*Math.cos(b),v=t+e*Math.sin(b),w=y===0?a?"L":"M":"L";_.push(`${w}${V(x,o)} ${V(v,o)}`)}return _.join("")}const c=r+e*Math.cos(i),h=t+e*Math.sin(i),p=r+e*Math.cos(n),f=t+e*Math.sin(n),m=Math.abs(u)>Math.PI?1:0,g=s?0:1;return`${a?"L":"M"}${V(c,o)} ${V(h,o)}A${V(e,o)} ${V(e,o)} 0 ${m} ${g} ${V(p,o)} ${V(f,o)}`}function qi(r,t,e,i,n,s,a=!1){const o=n&&!n.isIdentity()?n:null;if(!o&&!a)return`M${V(r-e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r+e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r-e,s)} ${V(t,s)}Z`;const l=64,u=[];for(let c=0;c<l;c++){const h=c/l*gr,p=r+e*Math.cos(h),f=t+i*Math.sin(h);u.push(`${c===0?"M":"L"}${Ft(p,f,o,s)}`)}return u.push("Z"),u.join("")}function rh(r,t,e,i,n,s){return`M${Ft(r,t,n,s)}L${Ft(r+e,t,n,s)}L${Ft(r+e,t+i,n,s)}L${Ft(r,t+i,n,s)}Z`}function L0(r,t,e,i,n,s,a,o=!1){const l=s&&!s.isIdentity()?s:null;if(n<=0)return rh(r,t,e,i,l,a);if(n=Math.min(n,Math.min(e,i)/2),l||o){const u=[],c=[[r+e-n,t+n,-Math.PI/2],[r+e-n,t+i-n,0],[r+n,t+i-n,Math.PI/2],[r+n,t+n,Math.PI]];let h=!0;for(let p=0;p<c.length;p++){const[f,m,g]=c[p];for(let _=0;_<=8;_++){const y=g+_/8*(Math.PI/2),b=f+n*Math.cos(y),x=m+n*Math.sin(y);u.push(`${h?"M":"L"}${Ft(b,x,l,a)}`),h=!1}}return u.push("Z"),u.join("")}return`M${V(r+n,a)} ${V(t,a)}L${V(r+e-n,a)} ${V(t,a)}A${V(n,a)} ${V(n,a)} 0 0 1 ${V(r+e,a)} ${V(t+n,a)}L${V(r+e,a)} ${V(t+i-n,a)}A${V(n,a)} ${V(n,a)} 0 0 1 ${V(r+e-n,a)} ${V(t+i,a)}L${V(r+n,a)} ${V(t+i,a)}A${V(n,a)} ${V(n,a)} 0 0 1 ${V(r,a)} ${V(t+i-n,a)}L${V(r,a)} ${V(t+n,a)}A${V(n,a)} ${V(n,a)} 0 0 1 ${V(r+n,a)} ${V(t,a)}Z`}function N0(r,t,e,i){if(r.length===0)return"";const n=[];if(typeof r[0]=="number"){const s=r;n.push(`M${Ft(s[0],s[1],e,i)}`);for(let a=2;a<s.length;a+=2)n.push(`L${Ft(s[a],s[a+1],e,i)}`)}else{const s=r;n.push(`M${Ft(s[0].x,s[0].y,e,i)}`);for(let a=1;a<s.length;a++)n.push(`L${Ft(s[a].x,s[a].y,e,i)}`)}return t&&n.push("Z"),n.join("")}function FG(r,t,e,i){return!t||t.isIdentity()?Ye(r,e,i):Ye(r.clone(!0).transform(t),e,i)}function DG(r,t,e){const i=r.shapePath.shapePrimitives,n=[];for(const s of i){const a=s.shape,o=s.transform;switch(a.type){case"polygon":{const l=a;n.push(N0(l.points,l.closePath,o,t));break}case"circle":{const l=a;n.push(qi(l.x,l.y,l.radius,l.radius,o,t,e));break}case"ellipse":{const l=a;n.push(qi(l.x,l.y,l.halfWidth,l.halfHeight,o,t,e));break}case"rectangle":{const l=a;n.push(rh(l.x,l.y,l.width,l.height,o,t));break}case"roundedRectangle":{const l=a;n.push(L0(l.x,l.y,l.width,l.height,l.radius,o,t,e));break}}}return n.join("")}function X0(r,t){const e=t.addStyle(r),i=[];return e?i.push(`fill="${e}"`):i.push(`fill="${tt.shared.setValue(r.color).toHex()}"`),r.alpha<1&&i.push(`fill-opacity="${r.alpha}"`),i.join(" ")}function j0(r,t){const e=t.addStyle(r),i=[];return i.push('fill="none"'),e?i.push(`stroke="${e}"`):i.push(`stroke="${tt.shared.setValue(r.color).toHex()}"`),i.push(`stroke-width="${r.width}"`),r.cap!=="butt"&&i.push(`stroke-linecap="${r.cap}"`),r.join!=="miter"?i.push(`stroke-linejoin="${r.join}"`):r.miterLimit!==10&&i.push(`stroke-miterlimit="${r.miterLimit}"`),r.alpha<1&&i.push(`stroke-opacity="${r.alpha}"`),i.join(" ")}function UG(r,t=2){const e=r instanceof kt?r:r.context,i=new k0,n=[],s=e.instructions;let a=0;for(;a<s.length;){const m=s[a];switch(m.action){case"fill":{const g=m,_=!!g.data.hole,y=_?Ye(g.data.path,t)+Ye(g.data.hole,t,!0):Ye(g.data.path,t),b=X0(g.data.style,i),x=_?' fill-rule="evenodd"':"";n.push(`<path d="${y}" ${b}${x}/>`);break}case"stroke":{const g=m;let _=Ye(g.data.path,t);g.data.hole&&(_+=Ye(g.data.hole,t,!0));const y=j0(g.data.style,i);n.push(`<path d="${_}" ${y}/>`);break}case"texture":break}a++}const o=e.bounds,l=parseFloat(o.minX.toFixed(t)),u=parseFloat(o.minY.toFixed(t)),c=parseFloat((o.maxX-o.minX).toFixed(t)),h=parseFloat((o.maxY-o.minY).toFixed(t)),p=i.build(),f=n.join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${h}" viewBox="${l} ${u} ${c} ${h}">${p}${f}</svg>`}function $G(r){r instanceof ge&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],n=r.path.shapePath,s=r.textureMatrix;n.shapePrimitives.forEach(({shape:o,transform:l})=>{const u=i.length,c=t.length/2,h=[],p=Ne[o.type];p.build(o,h),l&&Wn(h,l),p.triangulate(h,t,2,c,i,u);const f=e.length/2;s?(l&&s.append(l.clone().invert()),el(t,2,c,e,f,2,t.length/2-c,s)):rl(e,f,2,t.length/2-c)});const a=r.out;return a?(a.positions=new Float32Array(t),a.uvs=new Float32Array(e),a.indices=new Uint32Array(i),a):new ze({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var kG=Object.defineProperty,H0=Object.getOwnPropertySymbols,LG=Object.prototype.hasOwnProperty,NG=Object.prototype.propertyIsEnumerable,z0=(r,t,e)=>t in r?kG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W0=(r,t)=>{for(var e in t||(t={}))LG.call(t,e)&&z0(r,e,t[e]);if(H0)for(var e of H0(t))NG.call(t,e)&&z0(r,e,t[e]);return r};const V0=class q1 extends dt{constructor(t={}){t=W0(W0({},q1.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 n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){const i=t[e],n=this.renderLayerChildren.indexOf(i);n!==-1&&this.renderLayerChildren.splice(n,1),i.parentRenderLayer=null;const s=this.renderGroup||this.parentRenderGroup;s&&(s.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 n=this.renderLayerChildren,s=n.length;this.sortableChildren&&this.sortRenderLayerChildren();for(let a=0;a<s;a++)n[a].parent||ue("Container must be added to both layer and scene graph. Layers only handle render order - the scene graph is required for transforms (addChild)",n[a]),n[a].collectRenderables(t,e,this)}sortRenderLayerChildren(){this.renderLayerChildren.sort(this.sortFunction)}_getGlobalBoundsRecursive(t,e,i){if(!t)return;const n=this.renderLayerChildren;for(let s=0;s<n.length;s++)n[s]._getGlobalBoundsRecursive(!0,e,this)}getFastGlobalBounds(t,e){return super.getFastGlobalBounds(t,e)}addChild(...t){throw new Error("RenderLayer.addChild() is not available. Please use RenderLayer.attach()")}removeChild(...t){throw new Error("RenderLayer.removeChild() is not available. Please use RenderLayer.detach()")}removeChildren(t,e){throw new Error("RenderLayer.removeChildren() is not available. Please use RenderLayer.detach()")}removeChildAt(t){throw new Error("RenderLayer.removeChildAt() is not available")}getChildAt(t){throw new Error("RenderLayer.getChildAt() is not available")}setChildIndex(t,e){throw new Error("RenderLayer.setChildIndex() is not available")}getChildIndex(t){throw new Error("RenderLayer.getChildIndex() is not available")}addChildAt(t,e){throw new Error("RenderLayer.addChildAt() is not available")}swapChildren(t,e){throw new Error("RenderLayer.swapChildren() is not available")}reparentChild(...t){throw new Error("RenderLayer.reparentChild() is not available with the render layer")}reparentChildAt(t,e){throw new Error("RenderLayer.reparentChildAt() is not available with the render layer")}};V0.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex};let XG=V0;var jG=Object.defineProperty,Y0=Object.getOwnPropertySymbols,HG=Object.prototype.hasOwnProperty,zG=Object.prototype.propertyIsEnumerable,K0=(r,t,e)=>t in r?jG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,q0=(r,t)=>{for(var e in t||(t={}))HG.call(t,e)&&K0(r,e,t[e]);if(Y0)for(var e of Y0(t))zG.call(t,e)&&K0(r,e,t[e]);return r};const Z0=class Z1 extends ze{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,n,s;t=q0(q0({},Z1.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(n=this.width)!=null?n:t.width,this.height=(s=this.height)!=null?s:t.height;const a=this.verticesX*this.verticesY,o=[],l=[],u=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let g=0;g<a;g++){const _=g%this.verticesX,y=g/this.verticesX|0;o.push(_*p,y*f),l.push(_/c,y/h)}const m=c*h;for(let g=0;g<m;g++){const _=g%c,y=g/c|0,b=y*this.verticesX+_,x=y*this.verticesX+_+1,v=(y+1)*this.verticesX+_,w=(y+1)*this.verticesX+_+1;u.push(b,x,v,x,w,v)}this.buffers[0].data=new Float32Array(o),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(u),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Z0.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let ca=Z0;function Q0(r,t,e,i){const n=e.buffers[0],s=n.data,{verticesX:a,verticesY:o}=e,l=r/(a-1),u=t/(o-1);let c=0;const h=i[0],p=i[1],f=i[2],m=i[3],g=i[4],_=i[5],y=i[6],b=i[7],x=i[8];for(let v=0;v<s.length;v+=2){const w=c%a*l,T=(c/a|0)*u,P=h*w+p*T+f,E=m*w+g*T+_,M=y*w+b*T+x;s[v]=P/M,s[v+1]=E/M,c++}n.update()}function J0(r,t){const e=t[0],i=t[1],n=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8];return r[0]=a*c-o*u,r[1]=n*u-i*c,r[2]=i*o-n*a,r[3]=o*l-s*c,r[4]=e*c-n*l,r[5]=n*s-e*o,r[6]=s*u-a*l,r[7]=i*l-e*u,r[8]=e*a-i*s,r}function tT(r,t,e){const i=t[0],n=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=e[0],f=e[1],m=e[2],g=e[3],_=e[4],y=e[5],b=e[6],x=e[7],v=e[8];return r[0]=p*i+f*a+m*u,r[1]=p*n+f*o+m*c,r[2]=p*s+f*l+m*h,r[3]=g*i+_*a+y*u,r[4]=g*n+_*o+y*c,r[5]=g*s+_*l+y*h,r[6]=b*i+x*a+v*u,r[7]=b*n+x*o+v*c,r[8]=b*s+x*l+v*h,r}function WG(r,t,e){const i=e[0],n=e[1],s=e[2];return r[0]=t[0]*i+t[1]*n+t[2]*s,r[1]=t[3]*i+t[4]*n+t[5]*s,r[2]=t[6]*i+t[7]*n+t[8]*s,r}const VG=[0,0,0,0,0,0,0,0,0],YG=[0,0,0],ha=[0,0,0];function eT(r,t,e,i,n,s,a,o,l){const u=VG;u[0]=t,u[1]=i,u[2]=s,u[3]=e,u[4]=n,u[5]=a,u[6]=1,u[7]=1,u[8]=1;const c=J0(r,u);ha[0]=o,ha[1]=l,ha[2]=1;const h=WG(YG,c,ha),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],tT(r,p,u)}const KG=[0,0,0,0,0,0,0,0,0],qG=[0,0,0,0,0,0,0,0,0];function rT(r,t,e,i,n,s,a,o,l,u,c,h,p,f,m,g,_){const y=eT(KG,t,e,s,a,u,c,f,m),b=eT(qG,i,n,o,l,h,p,g,_);return tT(r,J0(y,y),b)}class iT extends ca{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,n,s,a,o,l){const u=this.corners;u[0]=t,u[1]=e,u[2]=i,u[3]=n,u[4]=s,u[5]=a,u[6]=o,u[7]=l,this.updateProjection()}updateProjection(){const{width:t,height:e}=this,i=this.corners,n=rT(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]);Q0(t,e,this,n)}}var ZG=Object.defineProperty,QG=Object.defineProperties,JG=Object.getOwnPropertyDescriptors,da=Object.getOwnPropertySymbols,nT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable,aT=(r,t,e)=>t in r?ZG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ih=(r,t)=>{for(var e in t||(t={}))nT.call(t,e)&&aT(r,e,t[e]);if(da)for(var e of da(t))sT.call(t,e)&&aT(r,e,t[e]);return r},tI=(r,t)=>QG(r,JG(t)),eI=(r,t)=>{var e={};for(var i in r)nT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&da)for(var i of da(r))t.indexOf(i)<0&&sT.call(r,i)&&(e[i]=r[i]);return e};const oT=class Q1 extends Kr{constructor(t){t=ih(ih({},Q1.defaultOptions),t);const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=eI(e,["texture","verticesX","verticesY"]),o=new iT(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(tI(ih({},a),{geometry:o}))),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,n,s,a,o,l){this.geometry.setCorners(t,e,i,n,s,a,o,l)}};oT.defaultOptions={texture:D.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let rI=oT;var iI=Object.defineProperty,nI=Object.defineProperties,sI=Object.getOwnPropertyDescriptors,pa=Object.getOwnPropertySymbols,lT=Object.prototype.hasOwnProperty,uT=Object.prototype.propertyIsEnumerable,cT=(r,t,e)=>t in r?iI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aI=(r,t)=>{for(var e in t||(t={}))lT.call(t,e)&&cT(r,e,t[e]);if(pa)for(var e of pa(t))uT.call(t,e)&&cT(r,e,t[e]);return r},oI=(r,t)=>nI(r,sI(t)),lI=(r,t)=>{var e={};for(var i in r)lT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&pa)for(var i of pa(r))t.indexOf(i)<0&&uT.call(r,i)&&(e[i]=r[i]);return e};class uI extends Kr{constructor(t){const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=lI(e,["texture","verticesX","verticesY"]),o=new ca(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(oI(aI({},a),{geometry:o,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 cI=Object.defineProperty,hT=Object.getOwnPropertySymbols,hI=Object.prototype.hasOwnProperty,dI=Object.prototype.propertyIsEnumerable,dT=(r,t,e)=>t in r?cI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pT=(r,t)=>{for(var e in t||(t={}))hI.call(t,e)&&dT(r,e,t[e]);if(hT)for(var e of hT(t))dI.call(t,e)&&dT(r,e,t[e]);return r};const fT=class J1 extends ze{constructor(t){const{width:e,points:i,textureScale:n}=pT(pT({},J1.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=n,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),n=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),n.data=new Uint16Array((t.length-1)*6));const s=i.data,a=n.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let o=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,g=l.y-t[p].y,_=Math.sqrt(m*m+g*g);l=t[p],o+=_/u}else o=p/(c-1);s[f]=o,s[f+1]=0,s[f+2]=o,s[f+3]=1}let h=0;for(let p=0;p<c-1;p++){const f=p*2;a[h++]=f,a[h++]=f+1,a[h++]=f+2,a[h++]=f+2,a[h++]=f+1,a[h++]=f+3}i.update(),n.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,n=0,s=0;const a=this.buffers[0].data,o=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let u=0;u<o;u++){const c=t[u],h=u*4;u<t.length-1?i=t[u+1]:i=c,s=-(i.x-e.x),n=i.y-e.y;let p=(1-u/(o-1))*10;p>1&&(p=1);const f=Math.sqrt(n*n+s*s);f<1e-6?(n=0,s=0):(n/=f,s/=f,n*=l,s*=l),a[h]=c.x+n,a[h+1]=c.y+s,a[h+2]=c.x-n,a[h+3]=c.y-s,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};fT.defaultOptions={width:200,points:[],textureScale:0};let mT=fT;var pI=Object.defineProperty,fI=Object.defineProperties,mI=Object.getOwnPropertyDescriptors,fa=Object.getOwnPropertySymbols,gT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable,yT=(r,t,e)=>t in r?pI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nh=(r,t)=>{for(var e in t||(t={}))gT.call(t,e)&&yT(r,e,t[e]);if(fa)for(var e of fa(t))_T.call(t,e)&&yT(r,e,t[e]);return r},gI=(r,t)=>fI(r,mI(t)),_I=(r,t)=>{var e={};for(var i in r)gT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fa)for(var i of fa(r))t.indexOf(i)<0&&_T.call(r,i)&&(e[i]=r[i]);return e};const bT=class tS extends Kr{constructor(t){const e=nh(nh({},tS.defaultOptions),t),{width:i,texture:n,points:s,textureScale:a}=e,o=_I(e,["width","texture","points","textureScale"]),l=new mT(he({width:i!=null?i:n.height,points:s,textureScale:a}));a>0&&(n.source.style.addressMode="repeat"),super(he(gI(nh({},o),{texture:n,geometry:l}))),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())}};bT.defaultOptions={textureScale:0};let yI=bT;var bI=Object.defineProperty,vI=Object.defineProperties,xI=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,vT=Object.prototype.hasOwnProperty,xT=Object.prototype.propertyIsEnumerable,TT=(r,t,e)=>t in r?bI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TI=(r,t)=>{for(var e in t||(t={}))vT.call(t,e)&&TT(r,e,t[e]);if(ma)for(var e of ma(t))xT.call(t,e)&&TT(r,e,t[e]);return r},SI=(r,t)=>vI(r,xI(t)),wI=(r,t)=>{var e={};for(var i in r)vT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ma)for(var i of ma(r))t.indexOf(i)<0&&xT.call(r,i)&&(e[i]=r[i]);return e};class PI extends Kr{constructor(t){const e=t,{texture:i,vertices:n,uvs:s,indices:a,topology:o}=e,l=wI(e,["texture","vertices","uvs","indices","topology"]),u=new ze(he({positions:n,uvs:s,indices:a,topology:o}));super(he(SI(TI({},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 EI(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}class ST{execute(t,e){var i,n,s;const a=t.renderer,o=a.canvasContext.activeContext,l=e.particleChildren,u=e.texture;o.save(),a.canvasContext.setContextTransform(e.worldTransform,e.roundPixels),a.canvasContext.setBlendMode(e.groupBlendMode);const c=e.groupColorAlpha,h=(n=(i=a.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,p=(c>>>24&255)/255*h;for(let f=0;f<l.length;f++){const m=l[f],g=m.texture||u;if(!((s=g==null?void 0:g.source)!=null&&s.resource))continue;const _=m.color,y=(_>>>24&255)/255*p;if(y<=0)continue;const b=_&16777215,x=((b&255)<<16)+(b&65280)+(b>>16&255);let v=g.source.resource;x!==16777215&&(v=Q.getTintedCanvas({texture:g},x));const w=g.frame,T=g.source.resolution,P=w.x*T,E=w.y*T,M=w.width*T,C=w.height*T;o.globalAlpha=y;const A=-m.anchorX*w.width,G=-m.anchorY*w.height;m.rotation!==0||m.scaleX!==1||m.scaleY!==1?(o.save(),o.translate(m.x,m.y),o.rotate(m.rotation),o.scale(m.scaleX,m.scaleY),o.drawImage(v,P,E,M,C,A,G,w.width,w.height),o.restore()):o.drawImage(v,P,E,M,C,m.x+A,m.y+G,w.width,w.height)}o.restore()}}function sh(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,n=0;i<e;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function wT(r){return{dynamicUpdate:PT(r,!0),staticUpdate:PT(r,!1)}}function PT(r,t){const e=[];e.push(`
2124
2125 var index = 0;
2126
2127 for (let i = 0; i < ps.length; ++i)
2128 {
2129 const p = ps[i];
2130
2131 `);let i=0;for(const s in r){const a=r[s];if(t!==a.dynamic)continue;e.push(`offset = index + ${i}`),e.push(a.code);const o=Ie(a.format);i+=o.stride/4}e.push(`
2132 index += stride * 4;
2133 }
2134 `),e.unshift(`
2135 var stride = ${i};
2136 `);const n=e.join(`
2137 `);return new Function("ps","f32v","u32v",n)}class ET{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,n=t.properties;let s=0,a=0;for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?a+=f.stride:s+=f.stride}this._dynamicStride=a/4,this._staticStride=s/4,this.staticAttributeBuffer=new or(i*4*s),this.dynamicAttributeBuffer=new or(i*4*a),this.indexBuffer=sh(i);const o=new nr;let l=0,u=0;this._staticBuffer=new Yt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST}),this._dynamicBuffer=new Yt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST});for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?(o.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(o.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}o.addIndex(this.indexBuffer);const c=this.getParticleUpdate(n);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=o}getParticleUpdate(t){const e=AI(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return wT(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new or(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new or(this._size*this._dynamicStride*4*4),this.indexBuffer=sh(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 n=this.staticAttributeBuffer;this._staticUpload(t,n.float32View,n.uint32View),this._staticBuffer.setDataWithSize(n.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function AI(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 AT=`varying vec2 vUV;
2138 varying vec4 vColor;
2139
2140 uniform sampler2D uTexture;
2141
2142 void main(void){
2143 vec4 color = texture2D(uTexture, vUV) * vColor;
2144 gl_FragColor = color;
2145 }`,CT=`attribute vec2 aVertex;
2146 attribute vec2 aUV;
2147 attribute vec4 aColor;
2148
2149 attribute vec2 aPosition;
2150 attribute float aRotation;
2151
2152 uniform mat3 uTranslationMatrix;
2153 uniform float uRound;
2154 uniform vec2 uResolution;
2155 uniform vec4 uColor;
2156
2157 varying vec2 vUV;
2158 varying vec4 vColor;
2159
2160 vec2 roundPixels(vec2 position, vec2 targetSize)
2161 {
2162 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
2163 }
2164
2165 void main(void){
2166 float cosRotation = cos(aRotation);
2167 float sinRotation = sin(aRotation);
2168 float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
2169 float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
2170
2171 vec2 v = vec2(x, y);
2172 v = v + aPosition;
2173
2174 gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
2175
2176 if(uRound == 1.0)
2177 {
2178 gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
2179 }
2180
2181 vUV = aUV;
2182 vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
2183 }
2184 `,ah=`
2185 struct ParticleUniforms {
2186 uTranslationMatrix:mat3x3<f32>,
2187 uColor:vec4<f32>,
2188 uRound:f32,
2189 uResolution:vec2<f32>,
2190 };
2191
2192 fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
2193 {
2194 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
2195 }
2196
2197 @group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
2198
2199 @group(1) @binding(0) var uTexture: texture_2d<f32>;
2200 @group(1) @binding(1) var uSampler : sampler;
2201
2202 struct VSOutput {
2203 @builtin(position) position: vec4<f32>,
2204 @location(0) uv : vec2<f32>,
2205 @location(1) color : vec4<f32>,
2206 };
2207 @vertex
2208 fn mainVertex(
2209 @location(0) aVertex: vec2<f32>,
2210 @location(1) aPosition: vec2<f32>,
2211 @location(2) aUV: vec2<f32>,
2212 @location(3) aColor: vec4<f32>,
2213 @location(4) aRotation: f32,
2214 ) -> VSOutput {
2215
2216 let v = vec2(
2217 aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
2218 aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
2219 ) + aPosition;
2220
2221 var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
2222
2223 if(uniforms.uRound == 1.0) {
2224 position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
2225 }
2226
2227 let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
2228
2229 return VSOutput(
2230 position,
2231 aUV,
2232 vColor,
2233 );
2234 }
2235
2236 @fragment
2237 fn mainFragment(
2238 @location(0) uv: vec2<f32>,
2239 @location(1) color: vec4<f32>,
2240 @builtin(position) position: vec4<f32>,
2241 ) -> @location(0) vec4<f32> {
2242
2243 var sample = textureSample(uTexture, uSampler, uv) * color;
2244
2245 return sample;
2246 }`;class MT extends ee{constructor(){const t=Wt.from({vertex:CT,fragment:AT}),e=Xt.from({fragment:{source:ah,entryPoint:"mainFragment"},vertex:{source:ah,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:D.WHITE.source,uSampler:new Jt({}),uniforms:{uTranslationMatrix:{value:new U,type:"mat3x3<f32>"},uColor:{value:new tt(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class Zi{constructor(t,e){this.state=Vt.for2d(),this.localUniforms=new At({uTranslationMatrix:{value:new U,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 MT,this.state=Vt.for2d(),this._managedContainers=new Ut({renderer:t,type:"renderable",name:"particleContainer"})}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new ET({size:t.particleChildren.length,properties:t._properties}),this._managedContainers.add(t),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,n=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const s=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,s.blendMode=Ir(t.blendMode,t.texture._source);const a=this.localUniforms.uniforms,o=a.uTranslationMatrix;t.worldTransform.copyTo(o);const l=i.globalUniforms.globalUniformData;o.tx-=l.offset.x,o.ty-=l.offset.y,o.prepend(l.projectionMatrix),a.uResolution=l.resolution,a.uRound=i._roundPixels|t._roundPixels,Yr(t.groupColorAlpha,a.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}Zi.extension={type:[S.CanvasPipes],name:"particle"};class oh extends Zi{constructor(t){super(t,new ST)}}oh.extension={type:[S.CanvasPipes],name:"particle"};class RT{execute(t,e){const i=t.state,n=t.renderer,s=e.shader||t.defaultShader;s.resources.uTexture=e.texture._source,s.resources.uniforms=t.localUniforms;const a=n.gl,o=t.getBuffers(e);n.shader.bind(s),n.state.set(i),n.geometry.bind(o.geometry,s.glProgram);const l=o.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;a.drawElements(a.TRIANGLES,e.particleChildren.length*6,l,0)}}class lh extends Zi{constructor(t){super(t,new RT)}}lh.extension={type:[S.WebGLPipes],name:"particle"};class OT{execute(t,e){const i=t.renderer,n=e.shader||t.defaultShader;n.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),n.groups[1]=i.texture.getTextureBindGroup(e.texture);const s=t.state,a=t.getBuffers(e);i.encoder.draw({geometry:a.geometry,shader:e.shader||t.defaultShader,state:s,size:e.particleChildren.length*6})}}class uh extends Zi{constructor(t){super(t,new OT)}}uh.extension={type:[S.WebGPUPipes],name:"particle"};var CI=Object.defineProperty,GT=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,RI=Object.prototype.propertyIsEnumerable,IT=(r,t,e)=>t in r?CI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BT=(r,t)=>{for(var e in t||(t={}))MI.call(t,e)&&IT(r,e,t[e]);if(GT)for(var e of GT(t))RI.call(t,e)&&IT(r,e,t[e]);return r};const FT=class Mh{constructor(t){if(t instanceof D)this.texture=t,fn(this,Mh.defaultOptions,{});else{const e=BT(BT({},Mh.defaultOptions),t);fn(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return xe(this._tint)}set tint(t){this._tint=tt.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};FT.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let OI=FT;const ch={vertex:{attributeName:"aVertex",format:"float32x2",code:`
2247 const texture = p.texture;
2248 const sx = p.scaleX;
2249 const sy = p.scaleY;
2250 const ax = p.anchorX;
2251 const ay = p.anchorY;
2252 const trim = texture.trim;
2253 const orig = texture.orig;
2254
2255 if (trim)
2256 {
2257 w1 = trim.x - (ax * orig.width);
2258 w0 = w1 + trim.width;
2259
2260 h1 = trim.y - (ay * orig.height);
2261 h0 = h1 + trim.height;
2262 }
2263 else
2264 {
2265 w1 = -ax * (orig.width);
2266 w0 = w1 + orig.width;
2267
2268 h1 = -ay * (orig.height);
2269 h0 = h1 + orig.height;
2270 }
2271
2272 f32v[offset] = w1 * sx;
2273 f32v[offset + 1] = h1 * sy;
2274
2275 f32v[offset + stride] = w0 * sx;
2276 f32v[offset + stride + 1] = h1 * sy;
2277
2278 f32v[offset + (stride * 2)] = w0 * sx;
2279 f32v[offset + (stride * 2) + 1] = h0 * sy;
2280
2281 f32v[offset + (stride * 3)] = w1 * sx;
2282 f32v[offset + (stride * 3) + 1] = h0 * sy;
2283 `,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:`
2284 var x = p.x;
2285 var y = p.y;
2286
2287 f32v[offset] = x;
2288 f32v[offset + 1] = y;
2289
2290 f32v[offset + stride] = x;
2291 f32v[offset + stride + 1] = y;
2292
2293 f32v[offset + (stride * 2)] = x;
2294 f32v[offset + (stride * 2) + 1] = y;
2295
2296 f32v[offset + (stride * 3)] = x;
2297 f32v[offset + (stride * 3) + 1] = y;
2298 `,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:`
2299 var rotation = p.rotation;
2300
2301 f32v[offset] = rotation;
2302 f32v[offset + stride] = rotation;
2303 f32v[offset + (stride * 2)] = rotation;
2304 f32v[offset + (stride * 3)] = rotation;
2305 `,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:`
2306 var uvs = p.texture.uvs;
2307
2308 f32v[offset] = uvs.x0;
2309 f32v[offset + 1] = uvs.y0;
2310
2311 f32v[offset + stride] = uvs.x1;
2312 f32v[offset + stride + 1] = uvs.y1;
2313
2314 f32v[offset + (stride * 2)] = uvs.x2;
2315 f32v[offset + (stride * 2) + 1] = uvs.y2;
2316
2317 f32v[offset + (stride * 3)] = uvs.x3;
2318 f32v[offset + (stride * 3) + 1] = uvs.y3;
2319 `,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:`
2320 const c = p.color;
2321
2322 u32v[offset] = c;
2323 u32v[offset + stride] = c;
2324 u32v[offset + (stride * 2)] = c;
2325 u32v[offset + (stride * 3)] = c;
2326 `,dynamic:!1}};X.add(lh),X.add(uh),X.add(oh);var GI=Object.defineProperty,II=Object.defineProperties,BI=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,DT=Object.prototype.hasOwnProperty,UT=Object.prototype.propertyIsEnumerable,$T=(r,t,e)=>t in r?GI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ri=(r,t)=>{for(var e in t||(t={}))DT.call(t,e)&&$T(r,e,t[e]);if(ga)for(var e of ga(t))UT.call(t,e)&&$T(r,e,t[e]);return r},kT=(r,t)=>II(r,BI(t)),FI=(r,t)=>{var e={};for(var i in r)DT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ga)for(var i of ga(r))t.indexOf(i)<0&&UT.call(r,i)&&(e[i]=r[i]);return e};const DI=new Mt(0,0,0,0),LT=class Rh extends Se{constructor(t={}){t=kT(ri(ri({},Rh.defaultOptions),t),{dynamicProperties:ri(ri({},Rh.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:n,roundPixels:s,texture:a,particles:o}=e,l=FI(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(ri({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=a||null,this.shader=n,this._properties={};for(const u in ch){const c=ch[u],h=i[u];this._properties[u]=kT(ri({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=s!=null?s:!1,this.particleChildren=o!=null?o:[]}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 n=this.particleChildren.indexOf(t[i]);n>-1&&(this.particleChildren.splice(n,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return DI}updateBounds(){}destroy(t=!1){var e,i,n;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource,a=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;a&&a.destroy(s)}this.texture=null,(n=this.shader)==null||n.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")}};LT.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let UI=LT;class hh{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save();const h=t.groupTransform,p=l._roundPixels|t._roundPixels;u.setContextTransform(h,p===1),u.setBlendMode(t.groupBlendMode);const f=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,m=t.groupColorAlpha,g=(f>>>24&255)/255,_=(m>>>24&255)/255,y=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,b=g*_*y;if(b<=0){c.restore();return}c.globalAlpha=b;const x=f&16777215,v=m&16777215,w=xe(Oe(v,x)),T=t.texture,P=Q.getCanvasSource(T);if(!P){c.restore();return}const E=u.smoothProperty,M=T.source.style.scaleMode!=="nearest";c[E]!==M&&(c[E]=M);const C=w!==16777215||T.rotate!==0,A=C?Q.getTintedCanvas({texture:T},w):P,{leftWidth:G,topHeight:F,rightWidth:R,bottomHeight:B,width:O,height:I}=t,L=G+R,j=F+B,J=Math.min(L>O?O/L:1,j>I?I/j:1,1),K=G*J,N=R*J,k=F*J,$=B*J,z=Math.max(0,O-K-N),rt=Math.max(0,I-k-$),_t=t.anchor,et=(o=(a=T.source._resolution)!=null?a:T.source.resolution)!=null?o:1;let st=T.frame.x*et,nt=T.frame.y*et;const ot=-_t.x*O,gt=-_t.y*I,yt=G*et,pt=F*et,Y=R*et,Rt=B*et;let Ct=T.frame.width*et,ce=T.frame.height*et;C&&(st=0,nt=0,Ct=A.width,ce=A.height),c.drawImage(A,st,nt,yt,pt,ot,gt,K,k),c.drawImage(A,st+yt,nt,Ct-yt-Y,pt,ot+K,gt,z,k),c.drawImage(A,st+Ct-Y,nt,Y,pt,ot+O-N,gt,N,k),c.drawImage(A,st,nt+pt,yt,ce-pt-Rt,ot,gt+k,K,rt),c.drawImage(A,st+yt,nt+pt,Ct-yt-Y,ce-pt-Rt,ot+K,gt+k,z,rt),c.drawImage(A,st+Ct-Y,nt+pt,Y,ce-pt-Rt,ot+O-N,gt+k,N,rt),c.drawImage(A,st,nt+ce-Rt,yt,Rt,ot,gt+I-$,K,$),c.drawImage(A,st+yt,nt+ce-Rt,Ct-yt-Y,Rt,ot+K,gt+I-$,z,$),c.drawImage(A,st+Ct-Y,nt+ce-Rt,Y,Rt,ot+O-N,gt+I-$,N,$),c.restore()}destroy(){this._renderer=null}}hh.extension={type:[S.CanvasPipes],name:"nineSliceSprite"};var $I=Object.defineProperty,NT=Object.getOwnPropertySymbols,kI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,XT=(r,t,e)=>t in r?$I(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jT=(r,t)=>{for(var e in t||(t={}))kI.call(t,e)&&XT(r,e,t[e]);if(NT)for(var e of NT(t))LI.call(t,e)&&XT(r,e,t[e]);return r};const HT=class Sa extends ca{constructor(t={}){var e,i;t=jT(jT({},Sa.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this._trimX=0,this._trimY=0,this._trimWidth=(e=t.originalWidth)!=null?e:Sa.defaultOptions.originalWidth,this._trimHeight=(i=t.originalHeight)!=null?i:Sa.defaultOptions.originalHeight,this.update(t)}update(t){var e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y,b,x;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(n=t.originalWidth)!=null?n:this._originalWidth,this._originalHeight=(s=t.originalHeight)!=null?s:this._originalHeight,this._leftWidth=(a=t.leftWidth)!=null?a:this._leftWidth,this._rightWidth=(o=t.rightWidth)!=null?o: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,t.trim!==void 0?(this._trimX=(f=(p=t.trim)==null?void 0:p.x)!=null?f:0,this._trimY=(g=(m=t.trim)==null?void 0:m.y)!=null?g:0,this._trimWidth=(y=(_=t.trim)==null?void 0:_.width)!=null?y:this._originalWidth,this._trimHeight=(x=(b=t.trim)==null?void 0:b.height)!=null?x:this._originalHeight):(this._trimWidth=this._originalWidth,this._trimHeight=this._originalHeight),this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:s,_topHeight:a,_bottomHeight:o,_anchorX:l,_anchorY:u}=this,c=n+s,h=e>c?1:e/c,p=a+o,f=i>p?1:i/p,m=Math.min(h,f),g=l*e,_=u*i;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=n*m-g,t[4]=t[12]=t[20]=t[28]=e-s*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-_,t[9]=t[11]=t[13]=t[15]=a*m-_,t[17]=t[19]=t[21]=t[23]=i-o*m-_,t[25]=t[27]=t[29]=t[31]=i-_,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs,e=this._originalWidth,i=this._originalHeight,n=this._trimX/e,s=this._trimY/i,a=(this._trimX+this._trimWidth)/e,o=(this._trimY+this._trimHeight)/i;t[0]=t[8]=t[16]=t[24]=n,t[1]=t[3]=t[5]=t[7]=s,t[6]=t[14]=t[22]=t[30]=a,t[25]=t[27]=t[29]=t[31]=o;const l=1/e,u=1/i;t[2]=t[10]=t[18]=t[26]=n+l*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s+u*this._topHeight,t[4]=t[12]=t[20]=t[28]=a-l*this._rightWidth,t[17]=t[19]=t[21]=t[23]=o-u*this._bottomHeight,this.getBuffer("aUV").update()}};HT.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Ke=HT;class zT extends gs{constructor(){super(),this.geometry=new Ke}destroy(){this.geometry.destroy()}}class dh{constructor(t){this._renderer=t,this._managedSprites=new Ut({renderer:t,type:"renderable",name:"nineSliceSprite"})}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 zT,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}dh.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"nineSliceSprite"},X.add(hh),X.add(dh);var NI=Object.defineProperty,_a=Object.getOwnPropertySymbols,WT=Object.prototype.hasOwnProperty,VT=Object.prototype.propertyIsEnumerable,YT=(r,t,e)=>t in r?NI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,XI=(r,t)=>{for(var e in t||(t={}))WT.call(t,e)&&YT(r,e,t[e]);if(_a)for(var e of _a(t))VT.call(t,e)&&YT(r,e,t[e]);return r},jI=(r,t)=>{var e={};for(var i in r)WT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_a)for(var i of _a(r))t.indexOf(i)<0&&VT.call(r,i)&&(e[i]=r[i]);return e};const KT=class eS extends Se{constructor(t){var e,i,n,s,a,o,l,u,c,h;t instanceof D&&(t={texture:t});const p=t,{width:f,height:m,anchor:g,leftWidth:_,rightWidth:y,topHeight:b,bottomHeight:x,texture:v,roundPixels:w}=p,T=jI(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(XI({label:"NineSliceSprite"},T)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=_!=null?_:(e=v==null?void 0:v.defaultBorders)==null?void 0:e.left)!=null?i:Ke.defaultOptions.leftWidth,this._topHeight=(s=b!=null?b:(n=v==null?void 0:v.defaultBorders)==null?void 0:n.top)!=null?s:Ke.defaultOptions.topHeight,this._rightWidth=(o=y!=null?y:(a=v==null?void 0:v.defaultBorders)==null?void 0:a.right)!=null?o:Ke.defaultOptions.rightWidth,this._bottomHeight=(u=x!=null?x:(l=v==null?void 0:v.defaultBorders)==null?void 0:l.bottom)!=null?u:Ke.defaultOptions.bottomHeight,this._width=(c=f!=null?f:v.width)!=null?c:Ke.defaultOptions.width,this._height=(h=m!=null?m:v.height)!=null?h:Ke.defaultOptions.height,this.allowChildren=!1,this.texture=v!=null?v:eS.defaultOptions.texture,this.roundPixels=w!=null?w:!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),g?this.anchor=g: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=D.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}get trim(){var t;return(t=this._texture.trim)!=null?t:null}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}};KT.defaultOptions={texture:D.EMPTY};let qT=KT;class HI extends qT{constructor(...t){let e=t[0];e instanceof D&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}class ZT extends pu{constructor(t,e){var i;super();const{textures:n,data:s}=t;Object.keys(s.pages).forEach(a=>{const o=s.pages[parseInt(a,10)],l=n[o.id];this.pages.push({texture:l})}),Object.keys(s.chars).forEach(a=>{var o;const l=s.chars[a],{frame:u,source:c,rotate:h}=n[l.page],p=W.transformRectCoords(l,u,h,new ut),f=new D({frame:p,orig:new ut(0,0,l.width,l.height),source:c,rotate:h});this.chars[a]={id:a.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(o=l.kerning)!=null?o:{},texture:f}}),this.baseRenderedFontSize=s.fontSize,this.baseMeasurementFontSize=s.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:s.fontSize},this.baseLineOffset=s.baseLineOffset,this.lineHeight=s.lineHeight,this.fontFamily=s.fontFamily,this.distanceField=(i=s.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){Jr.install(t)}static uninstall(t){Jr.uninstall(t)}}var zI={__proto__:null,BitmapFont:ZT};function QT(r){const{text:t,style:e,chars:i}=r,n=e,s=Jr.getFont(t,n),a=St.graphemeSegmenter(t),o=Os(a,n,s,!0),l=o.scale,u=[],c=[],h=[],p=e.lineHeight?e.lineHeight:s.lineHeight*l;let f=0;for(const m of o.lines){if(m.chars.length===0)continue;const g=new dt({label:"line"});g.y=f,h.push(g);let _=new dt({label:"word"}),y=0;for(let b=0;b<m.chars.length;b++){const x=m.chars[b];if(!x||!s.chars[x])continue;const v=x===" ",w=b===m.chars.length-1;let T;i.length>0?(T=i.shift(),T.text=x,T.style=n,T.label=`char-${x}`,T.x=m.charPositions[b]*l-m.charPositions[y]*l):T=new xu({text:x,style:n,label:`char-${x}`,x:m.charPositions[b]*l-m.charPositions[y]*l}),v||(u.push(T),_.addChild(T)),(v||w)&&_.children.length>0&&(_.x=m.charPositions[y]*l,c.push(_),g.addChild(_),_=new dt({label:"word"}),y=b+1)}f+=p}return{chars:u,lines:h,words:c}}var JT=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,VI=Object.prototype.propertyIsEnumerable,YI=(r,t)=>{var e={};for(var i in r)WI.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&JT)for(var i of JT(r))t.indexOf(i)<0&&VI.call(r,i)&&(e[i]=r[i]);return e};class ph extends dt{constructor(t){const e=t,{text:i,style:n,autoSplit:s,lineAnchor:a,wordAnchor:o,charAnchor:l}=e,u=YI(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=i,this._autoSplit=s,this._lineAnchor=a,this._wordAnchor=o,this._charAnchor=l,this.style=n}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,i){let n;typeof t=="number"?n={x:t,y:t}:n={x:t.x,y:t.y},e.forEach(s=>{const a=s.getLocalBounds(),o=a.minX+a.width*n.x,l=a.minY+a.height*n.y;s.origin.set(o,l)}),this[i]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new jt(t),this.styleChanged()}styleChanged(){this.words.forEach(t=>t.destroy()),this.words.length=0,this.lines.forEach(t=>t.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var KI=Object.defineProperty,qI=Object.defineProperties,ZI=Object.getOwnPropertyDescriptors,t1=Object.getOwnPropertySymbols,QI=Object.prototype.hasOwnProperty,JI=Object.prototype.propertyIsEnumerable,e1=(r,t,e)=>t in r?KI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qi=(r,t)=>{for(var e in t||(t={}))QI.call(t,e)&&e1(r,e,t[e]);if(t1)for(var e of t1(t))JI.call(t,e)&&e1(r,e,t[e]);return r},tB=(r,t)=>qI(r,ZI(t));const r1=class wa extends ph{constructor(t){var e,i,n;const s=Qi(Qi({},wa.defaultOptions),t);(e=s.style)!=null||(s.style={}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s)}static from(t,e){const i=tB(Qi(Qi({},wa.defaultOptions),e),{text:t.text,style:new jt(t.style)});t.style.tagStyles&&(t.style._tagStyles=void 0);const n=new wa(Qi({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return QT({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};r1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let eB=r1;function i1(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;default:return 0}}function fh(r){return r==="\r"||r===`
2327 `||r===`\r
2328 `}const rB=/^\s*$/;function iB(r,t){const e=[];let i=t.lines[0],n="",s=[],a=0;return r.forEach(o=>{const l=rB.test(o),u=fh(o),c=n.length===0&&l;l&&!u&&c||(u||(n+=o),s.push(o),n.length>=i.length&&(e.push({line:n,chars:s}),s=[],n="",a++,i=t.lines[a]))}),e}function n1(r){var t,e;const{text:i,style:n,chars:s}=r,a=n,o=St.measureText(i,a);if(o.runsByLine&&o.runsByLine.length>0)return nB(o,a,s,i);const l=St.graphemeSegmenter(i),u=iB(l,o),c=a.align,h=o.lineWidths.reduce((F,R)=>Math.max(F,R),0),p=(t=a._fill)==null?void 0:t.fill,f=(e=a._stroke)==null?void 0:e.fill,m=p instanceof $t,g=f instanceof $t,_=m||g,y=m&&p.textureSpace==="local"||g&&f.textureSpace==="local",b=o.width,x=o.height,v=a.clone();v.align="left";let w=0,T=0;if(v.trim){const{frame:F,canvasAndContext:R}=ye.getCanvasAndContext({text:i,style:a,resolution:1});ye.returnCanvasAndContext(R),w=-F.x,T=-F.y,v.trim=!1}const P=[],E=[],M=[];let C=0,A=0;const G=y?{width:b,height:x}:null;return u.forEach((F,R)=>{const B=new dt({label:`line-${R}`});B.y=C+T,E.push(B);const O=o.lineWidths[R];let I=i1(c,O,h),L=new dt({label:"word"});L.x=I+w;const j=St._context;j.font=v._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=F.line,K=j.measureText(J).width;if(F.chars.forEach(N=>{if(fh(N))return;J=J.slice(N.length);const k=J.length>0?j.measureText(J).width:0,$=K-k;if(K=k,$!==0)if(N===" ")L.children.length>0&&(M.push(L),B.addChild(L)),I+=$+a.letterSpacing,L=new dt({label:"word"}),L.x=I+w;else{let z=v;_&&(z=v.clone(),z._gradientOffset={x:-I,y:-C},G&&(z._gradientBounds=G));let rt;A<s.length?(rt=s[A++],rt.text=N,rt.style=z,rt.setFromMatrix(U.IDENTITY),rt.x=I-L.x+w):rt=new Wi({text:N,style:z,x:I-L.x+w}),P.push(rt),L.addChild(rt),I+=$+a.letterSpacing}}),L.children.length>0&&(M.push(L),B.addChild(L)),c==="justify"&&a.wordWrap&&R<u.length-1){const N=B.children,k=N.length-1;if(k>0){const $=(h-O)/k;for(let z=1;z<N.length;z++)N[z].x+=z*$}}C+=o.lineHeight}),{chars:P,lines:E,words:M}}function nB(r,t,e,i){const{runsByLine:n}=r,s=t.align,a=r.lineWidths.reduce((m,g)=>Math.max(m,g),0);let o=0,l=0;if(t.trim){const{frame:m,canvasAndContext:g}=ye.getCanvasAndContext({text:i,style:t,resolution:1});ye.returnCanvasAndContext(g),o=-m.x,l=-m.y}const u=[],c=[],h=[];let p=0,f=0;return n.forEach((m,g)=>{var _,y,b,x;const v=new dt({label:`line-${g}`});v.y=p+l,c.push(v);const w=r.lineWidths[g];let T=i1(s,w,a),P=new dt({label:"word"});P.x=T+o;for(const M of m){const C=M.style,A=(_=C._fill)==null?void 0:_.fill,G=(y=C._stroke)==null?void 0:y.fill,F=A instanceof $t,R=G instanceof $t,B=F||R,O=F&&A.textureSpace==="local"||R&&G.textureSpace==="local",I=St.graphemeSegmenter(M.text),L=C.clone();L.align="left",L.wordWrap=!1,L.trim&&(L.trim=!1),L.tagStyles=void 0,L._lineHeight=0;const j=St._context;j.font=L._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=M.text,K=j.measureText(J).width;const N=T,k=K,$=St.measureFont(L._fontString),z=C.lineHeight||$.fontSize,rt=O?{width:k,height:z}:null;for(const _t of I){J=J.slice(_t.length);const et=J.length>0?j.measureText(J).width:0,st=K-et;if(K=et,!fh(_t)&&st!==0)if(_t===" ")P.children.length>0&&(h.push(P),v.addChild(P)),T+=st+C.letterSpacing,P=new dt({label:"word"}),P.x=T+o;else{let nt=L;B&&(nt=L.clone(),O?(nt._gradientOffset={x:-(T-N),y:0},nt._gradientBounds=rt):nt._gradientOffset={x:-(T-N),y:0});let ot;f<e.length?(ot=e[f++],ot.text=_t,ot.style=nt,ot.setFromMatrix(U.IDENTITY),ot.x=T-P.x+o):ot=new Wi({text:_t,style:nt,x:T-P.x+o}),u.push(ot),P.addChild(ot),T+=st+C.letterSpacing}}}if(P.children.length>0&&(h.push(P),v.addChild(P)),s==="justify"&&t.wordWrap&&g<n.length-1){const M=v.children,C=M.length-1;if(C>0){const A=(a-w)/C;for(let G=1;G<M.length;G++)M[G].x+=G*A}}const E=(x=(b=r.lineHeights)==null?void 0:b[g])!=null?x:r.lineHeight;p+=E}),{chars:u,lines:c,words:h}}var sB=Object.defineProperty,aB=Object.defineProperties,oB=Object.getOwnPropertyDescriptors,s1=Object.getOwnPropertySymbols,lB=Object.prototype.hasOwnProperty,uB=Object.prototype.propertyIsEnumerable,a1=(r,t,e)=>t in r?sB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t||(t={}))lB.call(t,e)&&a1(r,e,t[e]);if(s1)for(var e of s1(t))uB.call(t,e)&&a1(r,e,t[e]);return r},cB=(r,t)=>aB(r,oB(t));const o1=class Pa extends ph{constructor(t){const e=Ji(Ji({},Pa.defaultOptions),t);super(e)}static from(t,e){const i=cB(Ji(Ji({},Pa.defaultOptions),e),{text:t.text,style:new jt(t.style)}),n=new Pa(Ji({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return n1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};o1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let hB=o1;const l1=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function dB(r){const t=[];let e=0;for(let i=0;i<l1.length;i++){const n=`_${l1[i]}`;t[e++]=r[n]}return e=u1(r._fill,t,e),e=fB(r._stroke,t,e),e=mB(r.dropShadow,t,e),e=pB(r.filters,t,e),t.join("-")}function pB(r,t,e){if(!r)return e;for(const i of r)t[e++]=i.uid;return e}function u1(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 fB(r,t,e){return r&&(e=u1(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 mB(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=tt.shared.setValue(r.color).toNumber()),e}async function gB(r,t,e=200){const i=await t.extract.base64(r);t.type!==It.CANVAS&&await t.encoder.commandFinished;const n=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const s=["font-size: 1px;",`padding: ${n}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",s)}var _B=Object.defineProperty,yB=Object.defineProperties,bB=Object.getOwnPropertyDescriptors,c1=Object.getOwnPropertySymbols,vB=Object.prototype.hasOwnProperty,xB=Object.prototype.propertyIsEnumerable,h1=(r,t,e)=>t in r?_B(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d1=(r,t)=>{for(var e in t||(t={}))vB.call(t,e)&&h1(r,e,t[e]);if(c1)for(var e of c1(t))xB.call(t,e)&&h1(r,e,t[e]);return r},TB=(r,t)=>yB(r,bB(t));const SB=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let wB=0;function p1(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=SB[wB++]);let i="";for(let a=0;a<t;a++)i+=" ";let n=r.label;!n&&r instanceof pe&&(n=`sprite:${r.texture.label}`);let s=`%c ${i}|- ${n} (worldX:${r.worldTransform.tx}, relativeRenderX:${r.relativeGroupTransform.tx}, renderX:${r.groupTransform.tx}, localX:${r.x})`;r.renderGroup&&(s+=" (RenderGroup)"),r.filters&&(s+="(*filters)"),console.log(s,`color:${e.color}; font-weight:bold;`),t++;for(let a=0;a<r.children.length;a++){const o=r.children[a];p1(o,t,d1({},e))}}function f1(r,t=0,e={index:0,color:"#000000"}){let i="";for(let s=0;s<t;s++)i+=" ";const n=`%c ${i}- ${e.index}: ${r.root.label} worldX:${r.worldTransform.tx}`;console.log(n,`color:${e.color}; font-weight:bold;`),t++;for(let s=0;s<r.renderGroupChildren.length;s++){const a=r.renderGroupChildren[s];f1(a,t,TB(d1({},e),{index:s}))}}return d.AbstractBitmapFont=pu,d.AbstractBitmapTextPipe=gu,d.AbstractRenderer=Mr,d.AbstractSplitText=ph,d.AbstractText=ws,d.AbstractTextSystem=cu,d.AccessibilitySystem=ip,d.AlphaFilter=IC,d.AlphaMask=Za,d.AlphaMaskPipe=Us,d.AnimatedSprite=Xi,d.Application=Of,d.ApplicationInitHook=Uo,d.Assets=Fi,d.AssetsClass=Yg,d.BLEND_TO_NPM=im,d.BREAKING_SPACES=ib,d.BREAKING_SPACES_SET=nb,d.BREAK_AFTER_CHARS=ob,d.BREAK_AFTER_CHARS_SET=lb,d.BUFFER_TYPE=Yi,d.BackgroundLoader=Bf,d.BackgroundSystem=yv,d.Batch=um,d.BatchGeometry=fm,d.BatchTextureArray=sm,d.BatchableGraphics=Vn,d.BatchableHTMLText=Kb,d.BatchableMesh=gs,d.BatchableSprite=zi,d.BatchableText=xb,d.Batcher=pm,d.BatcherPipe=Ds,d.BigPool=Et,d.BindGroup=Pe,d.BindGroupSystem=Ic,d.BitmapFont=ZT,d.BitmapFontManager=Jr,d.BitmapText=xu,d.BitmapTextGraphics=Rb,d.BitmapTextPipe=vu,d.BlendModeFilter=PC,d.BlendModePipe=Hs,d.BlurFilter=W_,d.BlurFilterPass=cs,d.Bounds=Mt,d.BrowserAdapter=dp,d.Buffer=Yt,d.BufferImageSource=dn,d.BufferResource=ea,d.BufferUsage=at,d.CLEAR=Kt,d.COLLAPSIBLE_SPACES=sb,d.COLLAPSIBLE_SPACES_SET=ab,d.Cache=it,d.CanvasBatchAdaptor=av,d.CanvasBitmapTextPipe=_u,d.CanvasColorMaskPipe=Iu,d.CanvasContextSystem=Uu,d.CanvasFilterSystem=co,d.CanvasGraphicsAdaptor=Lu,d.CanvasGraphicsContextSystem=fy,d.CanvasGraphicsPipe=Kl,d.CanvasLimitsSystem=$u,d.CanvasNineSliceSpritePipe=hh,d.CanvasObserver=Xa,d.CanvasParticleContainerAdaptor=ST,d.CanvasParticleContainerPipe=oh,d.CanvasPool=me,d.CanvasPoolClass=Op,d.CanvasRenderTargetAdaptor=Qv,d.CanvasRenderTargetSystem=ic,d.CanvasRenderer=rx,d.CanvasRendererTextSystem=hu,d.CanvasSource=fe,d.CanvasStencilMaskPipe=Fu,d.CanvasTextGenerator=ye,d.CanvasTextMetrics=St,d.CanvasTextPipe=uu,d.CanvasTextSystem=du,d.CanvasTextureSystem=nc,d.CanvasTilingSpritePipe=Jl,d.Circle=wn,d.Color=tt,d.ColorMask=Qa,d.ColorMaskPipe=Bu,d.ColorMatrixFilter=ZC,d.CompressedSource=Di,d.Container=dt,d.CubeTexture=la,d.CubeTextureSource=ei,d.Culler=x_,d.CullerPlugin=T_,d.CustomRenderPipe=$s,d.D3D10_RESOURCE_DIMENSION=Fl,d.D3DFMT=qt,d.DATA_URI=$w,d.DDS=Z,d.DEG_TO_RAD=Qh,d.DEPRECATED_SCALE_MODES=Qc,d.DEPRECATED_WRAP_MODES=Zc,d.DOMAdapter=H,d.DOMContainer=p2,d.DOMPipe=Wa,d.DRAW_MODES=nG,d.DXGI_FORMAT=Bl,d.DXGI_TO_TEXTURE_FORMAT=Zt,d.DefaultBatcher=zn,d.DefaultShader=tl,d.DisplacementFilter=nM,d.DynamicBitmapFont=fu,d.Ellipse=Pn,d.EventBoundary=lp,d.EventEmitter=Nt,d.EventSystem=Ya,d.EventsTicker=we,d.ExtensionType=S,d.ExternalSource=vG,d.ExtractSystem=xv,d.FOURCC_TO_TEXTURE_FORMAT=Dl,d.FederatedContainer=hp,d.FederatedEvent=Tr,d.FederatedMouseEvent=hi,d.FederatedPointerEvent=ae,d.FederatedWheelEvent=rr,d.FillGradient=$t,d.FillPattern=Xr,d.Filter=Ee,d.FilterEffect=oi,d.FilterPipe=ho,d.FilterSystem=Ao,d.FontStylePromiseCache=Bs,d.GAUSSIAN_VALUES=Nl,d.GCManagedHash=Ut,d.GCSystem=Gv,d.GL_FORMATS=Js,d.GL_INTERNAL_FORMAT=l_,d.GL_TARGETS=ta,d.GL_TYPES=ct,d.GL_WRAP_MODES=lx,d.GPUTextureGpuData=Vc,d.GenerateTextureSystem=Yu,d.Geometry=nr,d.GlBackBufferSystem=mx,d.GlBatchAdaptor=Ru,d.GlBuffer=ix,d.GlBufferSystem=sc,d.GlColorMaskSystem=cc,d.GlContextSystem=ox,d.GlEncoderSystem=hc,d.GlGeometryGpuData=hx,d.GlGeometrySystem=lc,d.GlGraphicsAdaptor=Oc,d.GlLimitsSystem=dc,d.GlMeshAdaptor=Gc,d.GlParticleContainerAdaptor=RT,d.GlParticleContainerPipe=lh,d.GlProgram=Wt,d.GlProgramData=Px,d.GlRenderTarget=gx,d.GlRenderTargetAdaptor=Sx,d.GlRenderTargetSystem=bc,d.GlShaderSystem=wc,d.GlStateSystem=kx,d.GlStencilSystem=pc,d.GlTexture=Ec,d.GlTextureSystem=Rc,d.GlUboSystem=yc,d.GlUniformGroupSystem=Pc,d.GlobalResourceRegistry=qe,d.GlobalUniformSystem=qu,d.GpuBatchAdaptor=Ou,d.GpuBlendModesToPixi=Ht,d.GpuBufferData=s0,d.GpuBufferSystem=Bc,d.GpuColorMaskSystem=Fc,d.GpuDeviceSystem=sa,d.GpuEncoderSystem=Dc,d.GpuGraphicsAdaptor=Kc,d.GpuGraphicsContext=qm,d.GpuLimitsSystem=Uc,d.GpuMeshAdapter=qc,d.GpuMipmapGenerator=T0,d.GpuParticleContainerAdaptor=OT,d.GpuParticleContainerPipe=uh,d.GpuProgram=Xt,d.GpuRenderTarget=m0,d.GpuRenderTargetAdaptor=g0,d.GpuRenderTargetSystem=Xc,d.GpuShaderSystem=jc,d.GpuStateSystem=Hc,d.GpuStencilModesToPixi=Ue,d.GpuStencilSystem=$c,d.GpuTextureSystem=Yc,d.GpuUboSystem=kc,d.GpuUniformBatchPipe=Lc,d.Graphics=hr,d.GraphicsContext=kt,d.GraphicsContextRenderData=Zm,d.GraphicsContextSystem=Zn,d.GraphicsGpuData=my,d.GraphicsPath=ge,d.GraphicsPipe=ql,d.HTMLText=iv,d.HTMLTextPipe=Eu,d.HTMLTextRenderData=wu,d.HTMLTextStyle=Is,d.HTMLTextSystem=Cu,d.HelloSystem=Ys,d.IGLUniformData=QO,d.ImageSource=ke,d.InstructionSet=cn,d.KTX=Pt,d.Loader=Wf,d.LoaderParserPriority=te,d.MaskEffectManager=an,d.MaskEffectManagerClass=nd,d.MaskFilter=hy,d.Matrix=U,d.Mesh=Kr,d.MeshGeometry=ze,d.MeshGpuData=Zl,d.MeshPipe=Ql,d.MeshPlane=uI,d.MeshRope=yI,d.MeshSimple=PI,d.NEWLINES=eb,d.NEWLINES_SET=rb,d.NEWLINE_MATCH_REGEX=cb,d.NEWLINE_SPLIT_REGEX=ub,d.NOOP=Da,d.NineSliceGeometry=Ke,d.NineSlicePlane=HI,d.NineSliceSprite=qT,d.NineSliceSpriteGpuData=zT,d.NineSliceSpritePipe=dh,d.NoiseFilter=cM,d.ObservablePoint=bt,d.PI_2=qh,d.Particle=OI,d.ParticleBuffer=ET,d.ParticleContainer=UI,d.ParticleContainerPipe=Zi,d.ParticleShader=MT,d.PassthroughFilter=df,d.PerspectiveMesh=rI,d.PerspectivePlaneGeometry=iT,d.PipelineSystem=Nc,d.PlaneGeometry=ca,d.Point=lt,d.Polygon=Er,d.Pool=Jh,d.PoolGroupClass=td,d.PrepareBase=py,d.PrepareQueue=Tb,d.PrepareSystem=sv,d.PrepareUpload=nv,d.QuadGeometry=$y,d.RAD_TO_DEG=Zh,d.Rectangle=ut,d.RenderContainer=AG,d.RenderGroup=pn,d.RenderGroupPipe=Ls,d.RenderGroupSystem=ju,d.RenderLayer=XG,d.RenderTarget=Ks,d.RenderTargetSystem=Zs,d.RenderTexture=Vs,d.RenderableGCSystem=$v,d.RendererInitHook=$o,d.RendererType=It,d.ResizePlugin=ko,d.Resolver=$e,d.RopeGeometry=mT,d.RoundedRectangle=An,d.SCALE_MODES=aG,d.STENCIL_MODES=wt,d.SVGDefsCollector=k0,d.SVGParser=fg,d.SchedulerSystem=Zu,d.ScissorMask=MR,d.SdfShader=Db,d.Shader=ee,d.ShaderStage=Le,d.ShapePath=sg,d.SharedRenderPipes=rc,d.SharedSystems=qs,d.SplitBitmapText=eB,d.SplitText=hB,d.Sprite=pe,d.SpritePipe=js,d.Spritesheet=Ka,d.State=Vt,d.StencilMask=Ja,d.StencilMaskPipe=Du,d.SystemRunner=Bo,d.TEXTURE_FORMAT_BLOCK_SIZE=n_,d.Text=Wi,d.TextStyle=jt,d.Texture=D,d.TextureGCSystem=kv,d.TextureMatrix=Ua,d.TexturePool=vt,d.TexturePoolClass=Fd,d.TextureSource=ft,d.TextureStyle=Jt,d.TextureUvs=xG,d.Ticker=Ot,d.TickerListener=gn,d.TickerPlugin=Lo,d.TilingSprite=Vy,d.TilingSpriteGpuData=Xy,d.TilingSpritePipe=ru,d.TilingSpriteShader=Uy,d.Transform=My,d.Triangle=oo,d.UNIFORM_TO_ARRAY_SETTERS=Fx,d.UNIFORM_TO_SINGLE_SETTERS=Bx,d.UNIFORM_TYPES_MAP=Zp,d.UNIFORM_TYPES_VALUES=go,d.UPDATE_BLEND=mn,d.UPDATE_COLOR=ci,d.UPDATE_PRIORITY=Te,d.UPDATE_TRANSFORM=JS,d.UPDATE_VISIBLE=xr,d.UboBatch=a0,d.UboSystem=fc,d.UniformGroup=At,d.VERSION=Ai,d.VideoSource=wr,d.ViewContainer=Se,d.ViewSystem=Kv,d.ViewableBuffer=or,d.WGSL_ALIGN_SIZE_DATA=Ki,d.WGSL_TO_STD40_SIZE=mc,d.WRAP_MODES=sG,d.WebGLRenderer=n0,d.WebGPURenderer=C0,d.WorkerManager=wl,d.accessibilityTarget=np,d.addBits=Vo,d.addMaskBounds=xn,d.addMaskLocalBounds=Tn,d.addProgramDefines=Fp,d.alphaFrag=R_,d.alphaWgsl=kl,d.appendSVGPath=vl,d.applyMatrix=Ly,d.applyProjectiveTransformationToPlane=Q0,d.applyStyleParams=Mc,d.assignWithIgnore=fn,d.autoDetectEnvironment=mw,d.autoDetectRenderer=Af,d.autoDetectSource=H2,d.basisTranscoderUrls=ss,d.bgr2rgb=xe,d.bitmapFontCachePlugin=Gf,d.bitmapFontTextParser=Dn,d.bitmapFontXMLParser=No,d.bitmapFontXMLStringParser=Xo,d.bitmapTextSplit=QT,d.blendTemplateFrag=S_,d.blendTemplateVert=w_,d.blendTemplateWgsl=P_,d.blockDataMap=zc,d.blurTemplateWgsl=$_,d.boundsPool=ve,d.browserExt=xC,d.buildAdaptiveBezier=cl,d.buildAdaptiveQuadratic=Jm,d.buildArc=pl,d.buildArcTo=tg,d.buildArcToSvg=rg,d.buildCircle=kr,d.buildContextBatches=Ym,d.buildEllipse=Bm,d.buildGeometryFromPath=$G,d.buildLine=qn,d.buildPixelLine=$m,d.buildPolygon=km,d.buildRectangle=Lm,d.buildRoundedRectangle=Fm,d.buildSVGFillAttributes=X0,d.buildSVGPath=Ye,d.buildSVGStrokeAttributes=j0,d.buildSimpleUvs=rl,d.buildTriangle=Nm,d.buildUvs=el,d.cacheAsTextureMixin=ed,d.cacheTextureArray=Ff,d.calculatePathArea=hg,d.calculateProjection=qv,d.canUseNewCanvasBlendModes=so,d.canvasTextSplit=n1,d.canvasUtils=Q,d.checkChildrenDidChange=Ia,d.checkDataUrl=ar,d.checkExtension=le,d.checkForNestedPattern=ug,d.checkMaxIfStatementsInShader=Wo,d.childrenHelperMixin=rd,d.cleanArray=Cv,d.cleanHash=Av,d.clearList=zs,d.closePointEps=il,d.collapseNewlines=Ms,d.collapseSpaces=Cs,d.collectAllRenderables=CG,d.collectRenderablesMixin=id,d.color32BitToUniform=Yr,d.colorBit=Ln,d.colorBitGl=Nn,d.colorMatrixFilterFrag=V_,d.colorMatrixFilterWgsl=jl,d.colorToUniform=vM,d.compareModeToGlCompare=Wx,d.compileHighShader=ym,d.compileHighShaderGl=bm,d.compileHighShaderGlProgram=Dr,d.compileHighShaderGpuProgram=Fr,d.compileHooks=Yo,d.compileInputs=Ko,d.compileOutputs=_m,d.compileShader=vc,d.compute2DProjection=rT,d.convertFormatIfRequired=uC,d.convertToList=oe,d.copySearchParams=bn,d.createGlUploadCubeTextureResource=jx,d.createGpuUploadCubeTextureResource=v0,d.createIdFromString=Ar,d.createIndicesForQuads=sh,d.createLevelBuffers=xA,d.createLevelBuffersFromKTX=cC,d.createStringVariations=mp,d.createTexture=He,d.createUboElementsSTD40=_x,d.createUboElementsWGSL=c0,d.createUboSyncFunction=gc,d.createUboSyncFunctionSTD40=Tx,d.createUboSyncFunctionWGSL=d0,d.crossOrigin=Lg,d.cullingMixin=Kh,d.curveEps=nl,d.defaultFilterVert=bi,d.defaultValue=Tc,d.definedProps=he,d.deprecation=Mi,d.detectAvif=Df,d.detectBasis=rA,d.detectCompressed=_C,d.detectDefaults=$f,d.detectMp4=kf,d.detectOgv=Lf,d.detectVideoAlphaMode=eo,d.detectWebm=Nf,d.detectWebp=Xf,d.determineCrossOrigin=Xg,d.displacementFrag=q_,d.displacementVert=Z_,d.displacementWgsl=Hl,d.earcut=vf,d.effectsMixin=ld,d.ensureAttributes=oc,d.ensureIsBuffer=Eo,d.ensurePrecision=Dp,d.ensureTextOptions=Ps,d.executeInstructions=ks,d.extensions=X,d.extractAttributesFromGlProgram=Cx,d.extractAttributesFromGpuProgram=Vp,d.extractFontFamilies=qb,d.extractStructAndGroups=Rn,d.extractSubpaths=cg,d.extractSvgUrlId=_l,d.fastCopy=$n,d.findMixin=ud,d.fontStringFromTextStyle=Zr,d.formatShader=ER,d.fragmentGPUTemplate=Sm,d.fragmentGlTemplate=Pm,d.generateArraySyncSTD40=xx,d.generateArraySyncWGSL=h0,d.generateBlurFragSource=F_,d.generateBlurGlProgram=U_,d.generateBlurProgram=k_,d.generateBlurVertSource=D_,d.generateGPULayout=wR,d.generateGpuLayoutGroups=Yp,d.generateLayout=PR,d.generateLayoutHash=Kp,d.generateParticleUpdateFunction=wT,d.generateProgram=Ix,d.generateShaderSyncCode=wx,d.generateTextStyleKey=dB,d.generateTextureBatchBit=Xn,d.generateTextureBatchBitGl=jn,d.generateTextureMatrix=ol,d.generateUniformsSync=Dx,d.getAdjustedBlendModeBlend=Ir,d.getAttributeInfoFromFormat=Ie,d.getBatchSamplersUniformGroup=Hn,d.getBitmapTextLayout=Os,d.getCanvasBoundingBox=Jy,d.getCanvasFillStyle=pr,d.getCanvasTexture=tc,d.getCharacterGroups=ou,d.getDefaultUniformValue=Qp,d.getFastGlobalBounds=SG,d.getFastGlobalBoundsMixin=hd,d.getFillInstructionData=mE,d.getFontCss=Jb,d.getFontFamilyName=Zf,d.getGeometryBounds=pf,d.getGlTypeFromFormat=cx,d.getGlobalBounds=li,d.getGlobalMixin=fd,d.getGlobalRenderableBounds=lo,d.getLocalBounds=un,d.getMaxFragmentPrecision=Bp,d.getMaxMiterRatio=wg,d.getMaxTexturesPerBatch=nm,d.getOrientationOfPoints=Dm,d.getPlainText=KM,d.getPo2TextureFromSource=Cn,d.getResolutionOfUrl=je,d.getSVGUrl=tv,d.getSupportedCompressedTextureFormats=Il,d.getSupportedGPUCompressedTextureFormats=Ol,d.getSupportedGlCompressedTextureFormats=Rl,d.getSupportedTextureFormats=Ui,d.getTemporaryCanvasFromImage=ev,d.getTestContext=fo,d.getTextureBatchBindGroup=Un,d.getTextureDefaultMatrix=EI,d.getTextureFormatFromKTXTexture=pC,d.getUboData=Mx,d.getUniformData=Rx,d.getUrlExtension=yp,d.glFormatToGPUFormat=b_,d.glUploadBufferImageResource=Lx,d.glUploadCompressedTextureResource=Nx,d.glUploadImageResource=Ac,d.glUploadVideoResource=Hx,d.globalUniformsBit=Em,d.globalUniformsBitGl=Am,d.globalUniformsUBOBitGl=OP,d.gpuFormatToBasisTranscoderFormat=SA,d.gpuFormatToKTXBasisTranscoderFormat=mC,d.gpuUploadBufferImageResource=_0,d.gpuUploadCompressedTextureResource=y0,d.gpuUploadImageResource=Wc,d.gpuUploadVideoResource=x0,d.graphicsContextToSvg=UG,d.groupD8=W,d.hasCachedCanvasTexture=EO,d.hasTagMarkup=As,d.hasTagStyles=Es,d.hslWgsl=_M,d.hslgl=EC,d.hslgpu=AC,d.injectBits=qo,d.insertVersion=Up,d.isBreakAfterChar=su,d.isBreakingSpace=Qt,d.isCanvasFilterCapable=uo,d.isCollapsibleSpace=nu,d.isMobile=qd,d.isNewline=Hi,d.isPow2=Ba,d.isRenderingToScreen=Zv,d.isSafari=Au,d.isSingleItem=fi,d.isWebGLSupported=Pi,d.isWebGPUSupported=Ei,d.ktxTranscoderUrls=as,d.loadBasis=vA,d.loadBasisOnWorker=e_,d.loadBitmapFont=If,d.loadDDS=UA,d.loadEnvironmentExtensions=Mo,d.loadFontAsBase64=Zb,d.loadFontCSS=Qb,d.loadImageBitmap=Dg,d.loadJson=Vf,d.loadKTX=ZA,d.loadKTX2=lC,d.loadKTX2onWorker=m_,d.loadSVGImage=rv,d.loadSvg=Og,d.loadTextures=Pl,d.loadTxt=Yf,d.loadVideoTextures=jg,d.loadWebFont=Qf,d.localUniformBit=qr,d.localUniformBitGl=vs,d.localUniformBitGroup2=By,d.localUniformMSDFBit=Gb,d.localUniformMSDFBitGl=Ib,d.log2=MS,d.logDebugTexture=gB,d.logProgramError=Gx,d.logRenderGroupScene=f1,d.logScene=p1,d.mSDFBit=Bb,d.mSDFBitGl=Fb,d.mapCanvasBlendModesToPixi=cv,d.mapFormatToGlFormat=Vx,d.mapFormatToGlInternalFormat=qx,d.mapFormatToGlType=Zx,d.mapGlToVertexFormat=Ax,d.mapSize=r3,d.mapType=Sc,d.mapViewDimensionToGlTarget=Qx,d.mapWebGLBlendModesToPixi=Ux,d.maskFrag=ay,d.maskVert=oy,d.maskWgsl=Vl,d.matrixPool=Dt,d.measureHtmlText=Pu,d.measureMixin=gd,d.measureTaggedText=hb,d.migrateFragmentFromV7toV8=t3,d.mipmapScaleModeToGlFilter=zx,d.multiplyColors=ui,d.multiplyHexColors=Oe,d.nextPow2=Ze,d.noiseFrag=ey,d.noiseWgsl=zl,d.nonCompressedFormats=Qg,d.normalizeExtensionPriority=ni,d.onRenderMixin=_d,d.parseDDS=s_,d.parseFunctionBody=TG,d.parseKTX=u_,d.parseSVGDefinitions=og,d.parseSVGFloatAttribute=Tt,d.parseSVGPath=tm,d.parseSVGStyle=bl,d.parseTaggedText=iu,d.particleData=ch,d.particlesFrag=AT,d.particlesVert=CT,d.particlesWgsl=ah,d.passthroughFrag=hf,d.passthroughWgsl=Po,d.path=zt,d.pointInTriangle=ao,d.preloadVideo=Ng,d.removeItems=Ga,d.removeStructAndGroupDuplicates=qp,d.resetUids=TS,d.resolveCharacters=Ab,d.resolveCompressedTextureUrl=gC,d.resolveJsonUrl=Hg,d.resolveTextureUrl=Ml,d.resourceToTexture=Cp,d.roundPixelsBit=Ur,d.roundPixelsBitGl=$r,d.roundedShapeArc=ig,d.roundedShapeQuadraticCurve=ng,d.sayHello=Bv,d.scaleModeToGlFilter=Cc,d.setBasisTranscoderPath=hA,d.setKTXTranscoderPath=JA,d.setPositions=ky,d.setProgramName=$p,d.setUvs=Ny,d.shapeBuilders=Ne,d.sortMixin=yd,d.spritesheetAsset=xp,d.squaredDistanceToLineSegment=mi,d.stripVersion=kp,d.styleAttributes=yl,d.testImageFormat=jo,d.testVideoFormat=Ci,d.textStyleToCSS=kb,d.textureBit=ov,d.textureBitGl=lv,d.textureFrom=Mp,d.tilingBit=Fy,d.tilingBitGl=Dy,d.toFillStyle=Xe,d.toLocalGlobalMixin=bd,d.toStrokeStyle=Bi,d.tokenize=au,d.tokenizeTaggedRuns=pb,d.transformVertices=Wn,d.triangulateWithHoles=sl,d.trimRight=Ce,d.uboSyncFunctionsSTD40=_c,d.uboSyncFunctionsWGSL=vx,d.uid=ht,d.uniformParsers=We,d.unpremultiplyAlpha=b3,d.unsafeEvalSupported=Ro,d.updateLocalTransform=MG,d.updateQuadBounds=qa,d.updateRenderGroupTransform=dv,d.updateRenderGroupTransforms=Nu,d.updateTextBounds=Rs,d.updateTransformAndChildren=Xu,d.updateTransformBackwards=ln,d.updateWorldTransform=RG,d.v8_0_0=zo,d.v8_3_4=yP,d.validFormats=os,d.validateRenderables=fv,d.vertexGPUTemplate=Tm,d.vertexGlTemplate=wm,d.vkFormatToGPUFormat=v_,d.warn=ue,d.wordWrap=mb,d.wordWrapTaggedLines=db,d.wrapModeToGlAddress=na,d})({});
2329 //# sourceMappingURL=pixi.min.js.map
2330