/*! * PixiJS - v8.1.4 * Compiled Fri, 17 May 2024 12:41:01 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */var PIXI=function(d){"use strict";"use strict";var Kb=Object.defineProperty,qb=Object.defineProperties,Zb=Object.getOwnPropertyDescriptors,rl=Object.getOwnPropertySymbols,Qb=Object.prototype.hasOwnProperty,Jb=Object.prototype.propertyIsEnumerable,il=(r,t,e)=>t in r?Kb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sl=(r,t)=>{for(var e in t||(t={}))Qb.call(t,e)&&il(r,e,t[e]);if(rl)for(var e of rl(t))Jb.call(t,e)&&il(r,e,t[e]);return r},tv=(r,t)=>qb(r,Zb(t)),x=(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))(x||{});const Ds=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=tv(sl({},t),{ref:r})}if(typeof r=="object")r=sl({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Qe=(r,t)=>{var e;return(e=Ds(r).priority)!=null?e:t},U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ds).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Ds).forEach(t=>{t.type.forEach(e=>{var i,s;const n=this._addHandlers,o=this._queue;n[e]?(s=n[e])==null||s.call(n,t):(o[e]=o[e]||[],(i=o[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const s=this._addHandlers,n=this._removeHandlers;s[r]=t,n[r]=e;const o=this._queue;return o[r]&&((i=o[r])==null||i.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,n)=>Qe(n.value,e)-Qe(s.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Qe(n,e)-Qe(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};var BA=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Us(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function IA(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function FA(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function DA(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var ks={exports:{}},UA=ks.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(u,l,c){this.fn=u,this.context=l,this.once=c||!1}function n(u,l,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,h||u,p),m=e?e+l:l;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],f]:u._events[m].push(f):(u._events[m]=f,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new i:delete u._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,h;if(this._eventsCount===0)return l;for(h in c=this._events)t.call(c,h)&&l.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,m=new Array(f);p0:typeof r=="number"},ot=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Pt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},nl=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ol=function(r){return{r:Pt(r.r,0,255),g:Pt(r.g,0,255),b:Pt(r.b,0,255),a:Pt(r.a)}},Ls=function(r){return{r:ot(r.r),g:ot(r.g),b:ot(r.b),a:ot(r.a,3)}},iv=/^#([0-9a-f]{3,8})$/i,qr=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},al=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},ul=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),u=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,u,i][l],g:255*[u,i,i,a,o,o][l],b:255*[o,o,u,i,i,a][l],a:s}},ll=function(r){return{h:nl(r.h),s:Pt(r.s,0,100),l:Pt(r.l,0,100),a:Pt(r.a)}},cl=function(r){return{h:ot(r.h),s:ot(r.s),l:ot(r.l),a:ot(r.a,3)}},hl=function(r){return ul((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},Je=function(r){return{h:(t=al(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},sv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ov=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,av=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$s={string:[[function(r){var t=iv.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?ot(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?ot(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=ov.exec(r)||av.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:ol({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=sv.exec(r)||nv.exec(r);if(!t)return null;var e,i,s=ll({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(rv[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return hl(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return zt(t)&&zt(e)&&zt(i)?ol({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!zt(t)||!zt(e)||!zt(i))return null;var o=ll({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return hl(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!zt(t)||!zt(e)||!zt(i))return null;var o=function(a){return{h:nl(a.h),s:Pt(a.s,0,100),v:Pt(a.v,0,100),a:Pt(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return ul(o)},"hsv"]]},dl=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Ls(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?qr(ot(255*n)):"","#"+qr(e)+qr(i)+qr(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Ls(this.rgba)},r.prototype.toRgbString=function(){return t=Ls(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return cl(Je(this.rgba))},r.prototype.toHslString=function(){return t=cl(Je(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=al(this.rgba),{h:ot(t.h),s:ot(t.s),v:ot(t.v),a:ot(t.a,3)};var t},r.prototype.invert=function(){return kt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),kt(Ns(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),kt(Ns(this.rgba,-t))},r.prototype.grayscale=function(){return kt(Ns(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),kt(fl(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),kt(fl(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"?kt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ot(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Je(this.rgba);return typeof t=="number"?kt({h:t,s:e.s,l:e.l,a:e.a}):ot(e.h)},r.prototype.isEqual=function(t){return this.toHex()===kt(t).toHex()},r}(),kt=function(r){return r instanceof Zr?r:new Zr(r)},ml=[],uv=function(r){r.forEach(function(t){ml.indexOf(t)<0&&(t(Zr,$s),ml.push(t))})},LA=function(){return new Zr({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function lv(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,u,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),h=1/0,p="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var m in e){var _=(a=c,u=n[m],Math.pow(a.r-u.r,2)+Math.pow(a.g-u.g,2)+Math.pow(a.b-u.b,2));_t in r?cv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pv=(r,t)=>{for(var e in t||(t={}))hv.call(t,e)&&_l(r,e,t[e]);if(gl)for(var e of gl(t))dv.call(t,e)&&_l(r,e,t[e]);return r};uv([lv]);const we=class Yr{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 Yr)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._normalize(t),this._value=this._cloneSource(t))}}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?pv({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Yr._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Yr.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=kt(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Yr||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}};we.shared=new we,we._temp=new we,we.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let K=we;const bl={cullArea:null,cullable:!1,cullableChildren:!0},vl=Math.PI*2,yl=180/Math.PI,xl=Math.PI/180;class V{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new V(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}static get shared(){return Xs.x=0,Xs.y=0,Xs}}const Xs=new V;class G{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new V;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new V;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,u=this.ty,l=1/(i*o+n*-s),c=t.x,h=t.y;return e.x=o*l*c+-n*l*h+(u*n-a*o)*l,e.y=i*l*h+-s*l*c+(-u*i+a*s)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,u=t.ty,l=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*l+s*h,this.b=i*c+s*p,this.c=n*l+o*h,this.d=n*c+o*p,this.tx=a*l+u*h+e.tx,this.ty=a*c+u*p+e.ty,this}setTransform(t,e,i,s,n,o,a,u,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-u)*o,this.d=Math.cos(a-u)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),u=Math.atan2(i,e),l=Math.abs(a+u);return l<1e-5||Math.abs(vl-l)<1e-5?(t.rotation=u,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=u),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new G;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 mv.identity()}static get shared(){return fv.identity()}}const fv=new G,mv=new G;class it{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new it(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 tr={default:-1};function J(r="default"){return tr[r]===void 0&&(tr[r]=-1),++tr[r]}function gv(){for(const r in tr)delete tr[r]}function zs(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s0&&i<=e){for(let o=e-1;o>=r;o--){const a=this.children[o];a&&(s.push(a),a.parent=null)}zs(this.children,r,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(s);for(let o=0;o=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r.didViewUpdate=!1,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)}};class er{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t0?i=this._pool[--this._index]:i=new this._classType,(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}}class Sl{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 Qr(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const W=new Sl;class El{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;ee.priority-i.priority);const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0),this._updateIsSimple()},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),Jr.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Jr.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new er);r=r;const i=(r==null?void 0:r.length)>0,s=((t=e.filters)==null?void 0:t.length)>0,n=i!==s;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new er),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Pl={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=this.x&&t=this.y&&e=u&&t<=l&&e>=c&&e<=h&&!(t>p&&tm&&e<_)}intersects(t,e){if(!e){const M=this.xt.right?t.right:this.right)<=M)return!1;const S=this.yt.bottom?t.bottom:this.bottom)>S}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=ti[0].set(t.left,t.top),u=ti[1].set(t.left,t.bottom),l=ti[2].set(t.right,t.top),c=ti[3].set(t.right,t.bottom);if(l.x<=a.x||u.y<=a.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(a,a),e.apply(u,u),e.apply(l,l),e.apply(c,c),Math.max(a.x,u.x,l.x,c.x)<=i||Math.min(a.x,u.x,l.x,c.x)>=s||Math.max(a.y,u.y,l.y,c.y)<=n||Math.min(a.y,u.y,l.y,c.y)>=o))return!1;const p=h*(u.y-a.y),f=h*(a.x-u.x),m=p*i+f*n,_=p*s+f*n,g=p*i+f*o,b=p*s+f*o;if(Math.max(m,_,g,b)<=p*a.x+f*a.y||Math.min(m,_,g,b)>=p*c.x+f*c.y)return!1;const v=h*(a.y-l.y),y=h*(l.x-a.x),T=v*i+y*n,E=v*s+y*n,R=v*i+y*o,w=v*s+y*o;return!(Math.max(T,E,R,w)<=v*a.x+y*a.y||Math.min(T,E,R,w)>=v*c.x+y*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t=t||new j,t.copyFrom(this),t}}const wl=new G;class lt{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=wl,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new j);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=wl,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,u=n.c,l=n.d,c=n.tx,h=n.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY,g=o*t+u*e+c,b=a*t+l*e+h;gm&&(m=g),b>_&&(_=b),g=o*i+u*e+c,b=a*i+l*e+h,gm&&(m=g),b>_&&(_=b),g=o*t+u*s+c,b=a*t+l*s+h,gm&&(m=g),b>_&&(_=b),g=o*i+u*s+c,b=a*i+l*s+h,gm&&(m=g),b>_&&(_=b),this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*e+u*n+c,f=a*e+l*n+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*s+u*n+c,f=a*s+l*n+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,s){return this.minXe&&(this.maxX=e),this.minYs&&(this.maxY=s),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new lt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,s){let n=this.minX,o=this.minY,a=this.maxX,u=this.maxY;s||(s=this.matrix);const l=s.a,c=s.b,h=s.c,p=s.d,f=s.tx,m=s.ty;for(let _=e;_a?v:a,u=y>u?y:u}this.minX=n,this.minY=o,this.maxX=a,this.maxY=u}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}]`}}const Lt=new Qr(G),$t=new Qr(lt);function rr(r,t,e){e.clear();let i,s;return r.parent?t?i=r.parent.worldTransform:(s=Lt.get().identity(),i=ir(r,s)):i=G.IDENTITY,js(r,e,i,t),s&&Lt.return(s),e.isValid||e.set(0,0,0,0),e}function js(r,t,e,i){var s,n;if(!r.visible||!r.measurable)return;let o;i?o=r.worldTransform:(r.updateLocalTransform(),o=Lt.get(),o.appendFrom(r.localTransform,e));const a=t,u=!!r.effects.length;if(u&&(t=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.addBounds&&(t.matrix=o,r.addBounds(t));for(let l=0;l>12&&(r.didChange=!0,r.data[0]=this._didChangeId>>12),Vs(this,r),r.didChange&&ei(this,r.localBounds,_v),r.localBounds},getBounds(r,t){return rr(this,r,t||new lt)}},Ol={_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}},Gl={_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(bv))}};function bv(r,t){return r._zIndex-t._zIndex}const Bl={getGlobalPosition(r=new V,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){if(!e){this.updateLocalTransform();const i=ir(this,new G);return i.append(this.localTransform),i.apply(r,t)}return this.worldTransform.apply(r,t)},toLocal(r,t,e,i){if(t&&(r=t.toGlobal(r,e,i)),!i){this.updateLocalTransform();const s=ir(this,new G);return s.append(this.localTransform),s.applyInverse(r,e)}return this.worldTransform.applyInverse(r,e)}};class Ws{constructor(){this.uid=J("instructionSet"),this.instructions=[],this.instructionSize=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class Il{constructor(t){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new G,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Ws,this._onRenderContainers=[],this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i-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;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(s)),this.effects=[],(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(Y.prototype,Object.getOwnPropertyDescriptors(t))}addChild(...t){if(t.length>1){for(let s=0;s1){for(let s=0;s-1&&(this._didChangeId+=4096,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didChangeId++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){if(this.renderGroup&&t===!1)throw new Error("[Pixi] cannot undo a render group just yet");t&&this.enableRenderGroup()}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t&&t.removeChild(this),this.renderGroup=new Il(this),t&&t.addChild(this),this._updateIsSimple(),this.groupTransform=G.IDENTITY}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new G),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*yl}set angle(t){this.rotation=t*xl}get pivot(){return this._pivot===Ks&&(this._pivot=new it(this,0,0)),this._pivot}set pivot(t){this._pivot===Ks&&(this._pivot=new it(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ys&&(this._skew=new it(this,0,0)),this._skew}set skew(t){this._skew===Ys&&(this._skew=new it(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===qs&&(this._scale=new it(this,1,1)),this._scale}set scale(t){this._scale===qs&&(this._scale=new it(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const s=this.getLocalBounds();let n,o;typeof t!="object"?(n=t,o=e!=null?e:t):(n=t.width,o=(i=t.height)!=null?i:t.width),n!==void 0&&this._setWidth(n,s.width),o!==void 0&&this._setHeight(o,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){if((this._didLocalTransformChangeId&15)===this._didChangeId)return;this._didLocalTransformChangeId=this._didChangeId;const t=this.localTransform,e=this._scale,i=this._pivot,s=this._position,n=e._x,o=e._y,a=i._x,u=i._y;t.a=this._cx*n,t.b=this._sx*n,t.c=this._cy*o,t.d=this._sy*o,t.tx=s._x-(a*t.a+u*t.c),t.ty=s._y-(a*t.b+u*t.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=ri,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=K.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=ri,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Zs,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?1:0;(this.localDisplayStatus&2)>>1!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=sr,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?1:0;(this.localDisplayStatus&4)>>2!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=sr,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|=sr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let i=0;i1&&typeof MSStream=="undefined"};function yv(r){return function(t){return t.test(r)}}function Wl(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var s=yv(e),n={apple:{phone:s(Qs)&&!s(jt),ipod:s(Dl),tablet:!s(Qs)&&(s(Ul)||Vl(t))&&!s(jt),universal:s(kl),device:(s(Qs)||s(Dl)||s(Ul)||s(kl)||Vl(t))&&!s(jt)},amazon:{phone:s(Me),tablet:!s(Me)&&s(ii),device:s(Me)||s(ii)},android:{phone:!s(jt)&&s(Me)||!s(jt)&&s(Js),tablet:!s(jt)&&!s(Me)&&!s(Js)&&(s(ii)||s(Ll)),device:!s(jt)&&(s(Me)||s(ii)||s(Js)||s(Ll))||s(/\bokhttp\b/i)},windows:{phone:s(jt),tablet:s($l),device:s(jt)||s($l)},other:{blackberry:s(Nl),blackberry10:s(Hl),opera:s(Xl),firefox:s(jl),chrome:s(zl),device:s(Nl)||s(Hl)||s(Xl)||s(jl)||s(zl)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var Yl;const Kl=((Yl=Wl.default)!=null?Yl:Wl)(globalThis.navigator),xv=9,si=100,Tv=0,Sv=0,ql=2,Zl=1,Ev=-1e3,Av=-1e3,Pv=2;class tn{constructor(t,e=Kl){this._mobileInfo=e,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook();const i=document.createElement("div");i.style.width=`${si}px`,i.style.height=`${si}px`,i.style.position="absolute",i.style.top=`${Tv}px`,i.style.left=`${Sv}px`,i.style.zIndex=ql.toString(),this._div=i,this._renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width=`${Zl}px`,t.style.height=`${Zl}px`,t.style.position="absolute",t.style.top=`${Ev}px`,t.style.left=`${Av}px`,t.style.zIndex=Pv.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(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(t=this._renderer.view.canvas.parentNode)==null||t.appendChild(this._div))}_deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(t=this._div.parentNode)==null||t.removeChild(this._div))}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i title : ${t.title}
tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._pool.pop();e||(e=document.createElement("button"),e.style.width=`${si}px`,e.style.height=`${si}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=ql.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{container:i}=t.target,s=this._renderer.events.rootBoundary,n=Object.assign(new Re(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===xv&&this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}tn.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"accessibility"};const Ql={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};U.add(tn),Y.mixin(Ql);class en{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}en.extension=x.Application;var Vt=(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))(Vt||{});class ni{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=s}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Jl=class At{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 ni(null,null,1/0),this.deltaMS=1/At.targetFPMS,this.elapsedMS=1/At.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=Vt.NORMAL){return this._addListener(new ni(t,e,i))}addOnce(t,e,i=Vt.NORMAL){return this._addListener(new ni(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ht.shared:new ht,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}rn.extension=x.Application,U.add(en),U.add(rn);let wv=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||(ht.system.add(this._tickerUpdate,this,Vt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ht.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(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTimei.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i=0;h--){const p=c[h],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const u=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:u&&!n(t,i)&&s(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Wt.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children,l=i;for(let c=u.length-1;c>=0;c--){const h=u[c],p=this.hitTestRecursive(h,this._isInteractive(e)?e:h.eventMode,l,s,n);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,or),!t.hitArea.contains(or.x,or.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i0&&u!==n.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,u);if(this.dispatchEvent(p,"pointerout"),o&&this.dispatchEvent(p,"mouseout"),!n.composedPath().includes(u)){const f=this.createPointerEvent(t,"pointerleave",u);for(f.eventPhase=f.AT_TARGET;f.target&&!n.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(u!==n.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(n,h);this.dispatchEvent(p,"pointerover"),o&&this.dispatchEvent(p,"mouseover");let f=u==null?void 0:u.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(n,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==u&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),o&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(p)}const l=[],c=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(n,"pointermove"),c&&l.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(s=n.target)==null?void 0:s.cursor),l.length>0&&this.all(n,l),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof wt))return;const i=this.trackingData(t.pointerId),s=this.createPointerEvent(t),n=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(e=s.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(s,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;i.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof wt))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof wt))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const u=i.button===2;this.notifyTarget(i,u?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const u=s.clicksByButton[t.button];if(u.target===a.target&&e-u.timeStamp<200?++u.clickCount:u.clickCount=1,u.target=a.target,u.timeStamp=e,a.detail=u.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof wt))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof oe))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;it in r?Cv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bv=(r,t)=>{for(var e in t||(t={}))Ov.call(t,e)&&rc(r,e,t[e]);if(ec)for(var e of ec(t))Gv.call(t,e)&&rc(r,e,t[e]);return r};const Iv=1,Fv={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},sn=class Ku{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new tc(null),Wt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new wt(null),this._rootWheelEvent=new oe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(Bv({},Ku.defaultEventFeatures),{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,i;const{canvas:s,resolution:n}=this.renderer;this.setTargetElement(s),this.resolution=n,Ku._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let n=0,o=s.length;n{u.off(r,a,o)}),n?u.once(r,a,o):u.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Re))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}};U.add(nn),Y.mixin(ic);var _t=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(_t||{});const sc={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let nc=sc;const z={get(){return nc},set(r){nc=r}};function Ot(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ar(r){return r.split("?")[0].split("#")[0]}function Dv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Uv(r,t,e){return r.replace(new RegExp(Dv(t),"g"),e)}function kv(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){const u=e.lastIndexOf("/");if(u!==e.length-1){u===-1?(e="",i=0):(e=e.slice(0,u),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const ft={toPosix(r){return Uv(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){Ot(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(Ot(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=ar(this.toPosix(t!=null?t:z.get().getBaseUrl())),s=ar(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ft.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Ot(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=kv(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Ot(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;i0)if(e===void 0)e=s;else{const n=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Ot(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){Ot(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){Ot(r),t&&Ot(t),r=ar(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const u=r.charCodeAt(n);if(u===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(u===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){Ot(r),r=ar(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Ot(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=ar(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;const n="";t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let o=-1,a=0,u=-1,l=!0,c=r.length-1,h=0;for(;c>=s;--c){if(e=r.charCodeAt(c),e===47){if(!l){a=c+1;break}continue}u===-1&&(l=!1,u=c+1),e===46?o===-1?o=c:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||u===-1||h===0||h===1&&o===u-1&&o===a+1?u!==-1&&(a===0&&i?t.base=t.name=r.slice(1,u):t.base=t.name=r.slice(a,u)):(a===0&&i?(t.name=r.slice(1,o),t.base=r.slice(1,u)):(t.name=r.slice(a,o),t.base=r.slice(a,u)),t.ext=r.slice(o,u)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Rt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function oc(r,t,e,i,s){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");s.push(o)}),oc(r,s,0,e,i)}else i.push(r);return i}const ur=r=>!Array.isArray(r);var Lv=Object.defineProperty,$v=Object.defineProperties,Nv=Object.getOwnPropertyDescriptors,uc=Object.getOwnPropertySymbols,Hv=Object.prototype.hasOwnProperty,Xv=Object.prototype.propertyIsEnumerable,lc=(r,t,e)=>t in r?Lv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ce=(r,t)=>{for(var e in t||(t={}))Hv.call(t,e)&&lc(r,e,t[e]);if(uc)for(var e of uc(t))Xv.call(t,e)&&lc(r,e,t[e]);return r},zv=(r,t)=>$v(r,Nv(t));class qt{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,s;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(s=t.extractAssetIdFromBundle)!=null?s:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Rt(e||i,s=>typeof s=="string"?s:Array.isArray(s)?s.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):s!=null&&s.src?s.src:s,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Ce({alias:n},o))),s.forEach(n=>{const o=n.src,a=n.alias;let u;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),u=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),u=[...a,...l]}this.add(zv(Ce({},n),{alias:u,src:o}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;Rt(e).forEach(s=>{const{src:n}=s;let{data:o,format:a,loadParser:u}=s;const l=Rt(n).map(p=>typeof p=="string"?ac(p):Array.isArray(p)?p:[p]),c=this.getAlias(s),h=[];l.forEach(p=>{p.forEach(f=>{var m,_,g;let b={};if(typeof f!="object"){b.src=f;for(let v=0;v{this._assetMap[p]=h})})}resolveBundle(t){const e=ur(t);t=Rt(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const u in o){const l=o[u];a[this._extractAssetIdFromBundle(s,u)]=l}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=ur(t);t=Rt(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(u=>{const l=n.filter(c=>c[a]?c[a]===u:!1);l.length&&(n=l)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,s;const{aliases:n,data:o,loadParser:a,format:u}=e;return(this._basePath||this._rootPath)&&(t.src=ft.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=n!=null?n:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Ce(Ce({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=(s=u!=null?u:t.format)!=null?s:cc(t.src),t}}qt.RETINA_PREFIX=/@([0-9\.]+)x/;function cc(r){return r.split(".").pop().split("?").shift().split("#").shift()}const oi=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},ae=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ue=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],le=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ce=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],on=[],hc=[],ai=Math.sign;function jv(){for(let r=0;r<16;r++){const t=[];on.push(t);for(let e=0;e<16;e++){const i=ai(ae[r]*ae[e]+le[r]*ue[e]),s=ai(ue[r]*ae[e]+ce[r]*ue[e]),n=ai(ae[r]*le[e]+le[r]*ce[e]),o=ai(ue[r]*le[e]+ce[r]*ce[e]);for(let a=0;a<16;a++)if(ae[a]===i&&ue[a]===s&&le[a]===n&&ce[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new G;t.set(ae[r],ue[r],le[r],ce[r],0,0),hc.push(t)}}jv();const k={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=>ae[r],uY:r=>ue[r],vX:r=>le[r],vY:r=>ce[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>on[r][t],sub:(r,t)=>on[r][k.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?k.S:k.N:Math.abs(t)*2<=Math.abs(r)?r>0?k.E:k.W:t>0?r>0?k.SE:k.SW:r>0?k.NE:k.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=hc[k.inv(t)];s.tx=e,s.ty=i,r.append(s)}},an=()=>{};function he(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function un(r){return!(r&r-1)&&!!r}function Vv(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 Zt(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var Wv=Object.defineProperty,dc=Object.getOwnPropertySymbols,Yv=Object.prototype.hasOwnProperty,Kv=Object.prototype.propertyIsEnumerable,pc=(r,t,e)=>t in r?Wv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fc=(r,t)=>{for(var e in t||(t={}))Yv.call(t,e)&&pc(r,e,t[e]);if(dc)for(var e of dc(t))Kv.call(t,e)&&pc(r,e,t[e]);return r};const mc=Object.create(null);function qv(r){const t=mc[r];return t===void 0&&(mc[r]=J("resource")),t}const gc=class Ab extends pt{constructor(t={}){var e,i,s,n,o,a,u;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=fc(fc({},Ab.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(s=t.addressModeW)!=null?s:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(u=t.maxAnisotropy)!=null?u:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=qv(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};gc.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let _c=gc;var Zv=Object.defineProperty,bc=Object.getOwnPropertySymbols,Qv=Object.prototype.hasOwnProperty,Jv=Object.prototype.propertyIsEnumerable,vc=(r,t,e)=>t in r?Zv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yc=(r,t)=>{for(var e in t||(t={}))Qv.call(t,e)&&vc(r,e,t[e]);if(bc)for(var e of bc(t))Jv.call(t,e)&&vc(r,e,t[e]);return r};const xc=class Pb extends pt{constructor(t={}){var e,i,s;super(),this.options=t,this.uid=J("textureSource"),this._resourceType="textureSource",this._resourceId=J("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=yc(yc({},Pb.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(s=this.resourceHeight)!=null?s:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new _c(Zt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=J("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const s=Math.round(t*i),n=Math.round(e*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=J("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=un(this.pixelWidth)&&un(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};xc.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let rt=xc;var ty=Object.defineProperty,ey=Object.defineProperties,ry=Object.getOwnPropertyDescriptors,Tc=Object.getOwnPropertySymbols,iy=Object.prototype.hasOwnProperty,sy=Object.prototype.propertyIsEnumerable,Sc=(r,t,e)=>t in r?ty(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ny=(r,t)=>{for(var e in t||(t={}))iy.call(t,e)&&Sc(r,e,t[e]);if(Tc)for(var e of Tc(t))sy.call(t,e)&&Sc(r,e,t[e]);return r},oy=(r,t)=>ey(r,ry(t));class ui extends rt{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(oy(ny({},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}}ui.extension=x.TextureSource;const Ec=new G;class ln{constructor(t,e){this.mapCoord=new G,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Kr.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Kr.BATCH_SIZE;for(;e-t{this._batchIndex*Kr.BATCH_SIZE{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[s]=t.textures[s]}),!e){const s=ft.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Pc([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const wc={extension:x.Asset,cache:{test:r=>r instanceof cn,getCacheableAssets:(r,t)=>Pc(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&ay.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=qt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:x.LoadParser,priority:_t.Normal},async testParse(r,t){return ft.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,s,n;const{texture:o,imageFilename:a}=(i=t==null?void 0:t.data)!=null?i:{};let u=ft.dirname(t.src);u&&u.lastIndexOf("/")!==u.length-1&&(u+="/");let l;if(o instanceof P)l=o;else{const p=oi(u+(a!=null?a:r.meta.image),t.src);l=(await e.load([p]))[p]}const c=new cn(l.source,r);await c.parse();const h=(s=r==null?void 0:r.meta)==null?void 0:s.related_multi_packs;if(Array.isArray(h)){const p=[];for(const m of h){if(typeof m!="string")continue;let _=u+m;(n=t.data)!=null&&n.ignoreMultiPack||(_=oi(_,t.src),p.push(e.load({src:_,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(p);c.linkedSheets=f,f.forEach(m=>{m.linkedSheets=[c].concat(c.linkedSheets.filter(_=>_!==m))})}return c},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};U.add(wc);function lr(r,t,e,i){const{width:s,height:n}=e.orig,o=e.trim;if(o){const a=o.width,u=o.height;r.minX=o.x-t._x*s-i,r.maxX=r.minX+a,r.minY=o.y-t._y*n-i,r.maxY=r.minY+u}else r.minX=-t._x*s-i,r.maxX=r.minX+s,r.minY=-t._y*n-i,r.maxY=r.minY+n}var uy=Object.defineProperty,li=Object.getOwnPropertySymbols,Rc=Object.prototype.hasOwnProperty,Mc=Object.prototype.propertyIsEnumerable,Cc=(r,t,e)=>t in r?uy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ly=(r,t)=>{for(var e in t||(t={}))Rc.call(t,e)&&Cc(r,e,t[e]);if(li)for(var e of li(t))Mc.call(t,e)&&Cc(r,e,t[e]);return r},cy=(r,t)=>{var e={};for(var i in r)Rc.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&li)for(var i of li(r))t.indexOf(i)<0&&Mc.call(r,i)&&(e[i]=r[i]);return e};class Gt extends Y{constructor(t=P.EMPTY){t instanceof P&&(t={texture:t});const e=t,{texture:i=P.EMPTY,anchor:s,roundPixels:n,width:o,height:a}=e,u=cy(e,["texture","anchor","roundPixels","width","height"]);super(ly({label:"Sprite"},u)),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this._sourceBoundsDirty=!0,this._roundPixels=0,this._anchor=new it({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o&&(this.width=o),a&&(this.height=a)}static from(t,e=!1){return t instanceof P?new Gt(t):new Gt(P.from(t,e))}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didChangeId+=4096,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){lr(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:s,height:n}=e.orig;i.maxX=-t._x*s,i.minX=i.maxX+s,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width)}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height)}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;let s,n;typeof t!="object"?(s=t,n=e!=null?e:t):(s=t.width,n=(i=t.height)!=null?i:t.width),s!==void 0&&this._setWidth(s,this._texture.orig.width),n!==void 0&&this._setHeight(n,this._texture.orig.height)}}const hy=new lt;function ci(r,t,e){const i=hy;r.measurable=!0,rr(r,e,i),t.addBoundsMask(i),r.measurable=!1}function hi(r,t,e){const i=$t.get();r.measurable=!0;const s=Lt.get().identity(),n=hn(r,e,s);ei(r,i,n),r.measurable=!1,t.addBoundsMask(i),Lt.return(s),$t.return(i)}function hn(r,t,e){return r&&r!==t&&(hn(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class dn{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Gt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){ci(this.mask,t,e)}addLocalBounds(t,e){hi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Gt}}dn.extension=x.MaskEffect;class pn{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"}}pn.extension=x.MaskEffect;class fn{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){ci(this.mask,t,e)}addLocalBounds(t,e){hi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof Y}}fn.extension=x.MaskEffect;class de extends rt{constructor(t){t.resource||(t.resource=z.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;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}}de.extension=x.TextureSource;class pe extends rt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=z.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0),t.resource=e}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap}}pe.extension=x.TextureSource;let mn;async function gn(){return mn!=null||(mn=(async()=>{var r;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(s),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),mn}var dy=Object.defineProperty,py=Object.defineProperties,fy=Object.getOwnPropertyDescriptors,Oc=Object.getOwnPropertySymbols,my=Object.prototype.hasOwnProperty,gy=Object.prototype.propertyIsEnumerable,Gc=(r,t,e)=>t in r?dy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_n=(r,t)=>{for(var e in t||(t={}))my.call(t,e)&&Gc(r,e,t[e]);if(Oc)for(var e of Oc(t))gy.call(t,e)&&Gc(r,e,t[e]);return r},_y=(r,t)=>py(r,fy(t));const di=class wb extends rt{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=_n(_n({},wb.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ht.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await gn(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ht.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||(ht.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ht.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||globalThis.VideoFrame&&t instanceof VideoFrame}};di.extension=x.TextureSource,di.defaultOptions=_y(_n({},rt.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),di.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let cr=di,by=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=Rt(t);let s;for(let u=0;u{n.set(u,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(u=>{this._cacheMap.set(u,a)}),o.forEach(u=>{const l=s?s[u]:e;this._cache.has(u)&&this._cache.get(u),this._cache.set(u,n.get(u))})}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 q=new by,bn=[];U.handleByList(x.TextureSource,bn);function Bc(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s{q.has(i)&&q.remove(i)}),t||q.set(i,n),n}function Fc(r,t=!1){return typeof r=="string"?q.get(r):r instanceof rt?new P({source:r}):Ic(r,t)}P.from=Fc,U.add(dn,pn,fn,cr,pe,de,ui);var H=(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))(H||{});class bt extends pt{constructor(t){let{data:e,size:i}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this.uid=J("buffer"),this._resourceType="buffer",this._resourceId=J("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i!=null?i:e==null?void 0:e.byteLength;const a=!!e;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&H.STATIC)}set static(t){t?this.descriptor.usage|=H.STATIC:this.descriptor.usage&=~H.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const s=this._data;if(this._data=t,s.length!==t.length){!this.shrinkToFit&&t.byteLengtha&&(a=f),m>u&&(u=m),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const yy=new Float32Array(1),xy=new Uint32Array(1);class yn extends Oe{constructor(){const t=new bt({data:yy,label:"attribute-batch-buffer",usage:H.VERTEX|H.COPY_DST,shrinkToFit:!1}),e=new bt({data:xy,label:"index-batch-buffer",usage:H.INDEX|H.COPY_DST,shrinkToFit:!1}),i=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:i,offset:0,location:1},aUV:{buffer:t,format:"float32x2",stride:i,offset:8,location:3},aColor:{buffer:t,format:"unorm8x4",stride:i,offset:16,location:0},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:i,offset:20,location:2}},indexBuffer:e})}}class Nt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,s;const n=this.resources[e];t!==n&&(n&&((i=t.off)==null||i.call(t,"change",this.onResourceChange,this)),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}let hr;function xn(){return(!hr||hr!=null&&hr.isContextLost())&&(hr=z.get().createCanvas().getContext("webgl",{})),hr}function Uc(){const r=xn();return r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)}const dt=Uc(),kc={};function pi(r,t){let e=0;for(let i=0;i>>0;return kc[e]||Ty(r,e)}function Ty(r,t){const e={};let i=0;for(let n=0;n0){const n=new Uint8Array(r,e*8,s);new Uint8Array(t,e*8,s).set(n)}}const Lc={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var st=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",r[r.NONE=4]="NONE",r))(st||{});function Sn(r,t){return t.alphaMode==="no-premultiply-alpha"&&Lc[r]||r}class En{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;tt in r?Sy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hc=(r,t)=>{for(var e in t||(t={}))Ey.call(t,e)&&Nc(r,e,t[e]);if($c)for(var e of $c(t))Ay.call(t,e)&&Nc(r,e,t[e]);return r};class An{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}let dr=0;const Xc=class Rb{constructor(t={}){this.uid=J("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],this._batchPool=[],this._batchPoolIndex=0,this._textureBatchPool=[],this._textureBatchPoolIndex=0,t=Hc(Hc({},Rb.defaultOptions),t);const{vertexSize:e,indexSize:i}=t;this.attributeBuffer=new Tn(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(i)}begin(){this.batchIndex=0,this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0,this._batchPoolIndex=0,this._textureBatchPoolIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t.indexStart=this.indexSize,t.location=this.attributeSize,t.batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.vertexSize*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,t.packAttributes(this.attributeBuffer.float32View,this.attributeBuffer.uint32View,t.location,t.textureId)}break(t){const e=this._elements;let i=this._textureBatchPool[this._textureBatchPoolIndex++]||new En;if(i.clear(),!e[this.elementStart])return;const s=e[this.elementStart];let n=Sn(s.blendMode,s.texture._source);this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,a=this.attributeBuffer.uint32View,u=this.indexBuffer;let l=this._batchIndexSize,c=this._batchIndexStart,h="startBatch",p=this._batchPool[this._batchPoolIndex++]||new An;for(let f=this.elementStart;f=dt||b)&&(this._finishBatch(p,c,l-c,i,n,t,h),h="renderBatch",c=l,n=g,i=this._textureBatchPool[this._textureBatchPoolIndex++]||new En,i.clear(),p=this._batchPool[this._batchPoolIndex++]||new An,++dr),m.textureId=_._textureBindLocation=i.count,i.ids[_.uid]=i.count,i.textures[i.count++]=_,m.batch=p,l+=m.indexSize,m.packAttributes(o,a,m.location,m.textureId),m.packIndex(u,m.indexStart,m.location/this._vertexSize)}i.count>0&&(this._finishBatch(p,c,l-c,i,n,t,h),c=l,++dr),this.elementStart=this.elementSize,this._batchIndexStart=c,this._batchIndexSize=l}_finishBatch(t,e,i,s,n,o,a){t.gpuBindGroup=null,t.action=a,t.batcher=this,t.textures=s,t.blendMode=n,t.start=e,t.size=i,++dr,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 Tn(e);fi(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n>16&255,i=r>>8&255,s=r&255,n=t>>16&255,o=t>>8&255,a=t&255,u=e*n/255,l=i*o/255,c=s*a/255;return(u<<16)+(l<<8)+c}class gi{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}packIndex(t,e,i){const s=this.geometryData.indices;for(let n=0;n>16|h&65280|(h&255)<<16;if(this.applyTransform){const f=zc(p,o.groupColor)+(this.alpha*o.groupAlpha*255<<24),m=o.groupTransform,_=s<<16|this.roundPixels&65535,g=m.a,b=m.b,v=m.c,y=m.d,T=m.tx,E=m.ty;for(let R=l;R=0&&a>=0&&s>=0&&n>=0))return t;const u=Math.ceil(2.3*Math.sqrt(o+a)),l=u*8+(s?4:0)+(n?4:0);if(l===0)return t;if(u===0)return t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n,t;let c=0,h=u*4+(s?2:0)+2,p=h,f=l,m=s+o,_=n,g=e+m,b=e-m,v=i+_;if(t[c++]=g,t[c++]=v,t[--h]=v,t[--h]=b,n){const T=i-_;t[p++]=b,t[p++]=T,t[--f]=T,t[--f]=g}for(let T=1;T0&&(s[n++]=u,s[n++]=l,s[n++]=u-1),u++;s[n++]=l+1,s[n++]=l,s[n++]=u-1}},jc=1e-4,Mn=1e-4;function Vc(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,s=r[t-2],n=r[t-1];ih&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),_=Math.sqrt(u*u+l*l),g=(15*m*Math.sqrt(_)/Math.PI>>0)+1,b=f/g;if(p+=b,a){o.push(r,t),o.push(e,i);for(let v=1,y=p;v=0&&(c.join==="round"?v+=me(S,A,S-O*I,A-B*I,S-Z*I,A-$*I,g,!1)+4:v+=2,g.push(S-Z*D,A-$*D),g.push(S+Z*I,A+$*I));continue}const Tb=(-O+w)*(-B+A)-(-O+S)*(-B+M),Sb=(-Z+N)*(-$+A)-(-Z+S)*(-$+L),Bs=(ne*Sb-jr*Tb)/Gs,Is=(Vr*Tb-zr*Sb)/Gs,Yu=(Bs-S)*(Bs-S)+(Is-A)*(Is-A),Se=S+(Bs-S)*I,Ee=A+(Is-A)*I,Ae=S-(Bs-S)*D,Pe=A-(Is-A)*D,OA=Math.min(ne*ne+zr*zr,jr*jr+Vr*Vr),Eb=Wr?I:D,GA=OA+Eb*Eb*E;Yu<=GA?c.join==="bevel"||Yu/E>R?(Wr?(g.push(Se,Ee),g.push(S+O*D,A+B*D),g.push(Se,Ee),g.push(S+Z*D,A+$*D)):(g.push(S-O*I,A-B*I),g.push(Ae,Pe),g.push(S-Z*I,A-$*I),g.push(Ae,Pe)),v+=2):c.join==="round"?Wr?(g.push(Se,Ee),g.push(S+O*D,A+B*D),v+=me(S,A,S+O*D,A+B*D,S+Z*D,A+$*D,g,!0)+4,g.push(Se,Ee),g.push(S+Z*D,A+$*D)):(g.push(S-O*I,A-B*I),g.push(Ae,Pe),v+=me(S,A,S-O*I,A-B*I,S-Z*I,A-$*I,g,!1)+4,g.push(S-Z*I,A-$*I),g.push(Ae,Pe)):(g.push(Se,Ee),g.push(Ae,Pe)):(g.push(S-O*I,A-B*I),g.push(S+O*D,A+B*D),c.join==="round"?Wr?v+=me(S,A,S+O*D,A+B*D,S+Z*D,A+$*D,g,!0)+2:v+=me(S,A,S-O*I,A-B*I,S-Z*I,A-$*I,g,!1)+2:c.join==="miter"&&Yu/E<=R&&(Wr?(g.push(Ae,Pe),g.push(Ae,Pe)):(g.push(Se,Ee),g.push(Se,Ee)),v+=2),g.push(S-Z*I,A-$*I),g.push(S+Z*D,A+$*D),v+=2)}w=r[(b-2)*2],M=r[(b-2)*2+1],S=r[(b-1)*2],A=r[(b-1)*2+1],O=-(M-A),B=w-S,Et=Math.sqrt(O*O+B*B),O/=Et,B/=Et,O*=T,B*=T,g.push(S-O*I,A-B*I),g.push(S+O*D,A+B*D),m||(c.cap==="round"?v+=me(S-O*(I-D)*.5,A-B*(I-D)*.5,S-O*I,A-B*I,S+O*D,A+B*D,g,!1)+2:c.cap==="square"&&(v+=Wc(S,A,O,B,I,D,!1,g)));const CA=Mn*Mn;for(let Q=y;Q80*e){a=l=r[0],u=c=r[1];for(var m=e;ml&&(l=h),p>c&&(c=p);f=Math.max(l-a,c-u),f=f!==0?32767/f:0}return pr(n,o,e,a,u,f,0),o}function Kc(r,t,e,i,s){var n,o;if(s===Gn(r,t,e,i)>0)for(n=t;n=t;n-=i)o=Qc(n,r[n],r[n+1],o);return o&&vi(o,o.next)&&(mr(o),o=o.next),o}function ge(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(vi(e,e.next)||tt(e.prev,e,e.next)===0)){if(mr(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function pr(r,t,e,i,s,n,o){if(r){!o&&n&&Fy(r,i,s,n);for(var a=r,u,l;r.prev!==r.next;){if(u=r.prev,l=r.next,n?wy(r,i,s,n):Py(r)){t.push(u.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),mr(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Ry(ge(r),t,e),pr(r,t,e,i,s,n,2)):o===2&&My(r,t,e,i,s,n):pr(ge(r),t,e,i,s,n,1);break}}}}function Py(r){var t=r.prev,e=r,i=r.next;if(tt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,u=e.y,l=i.y,c=sn?s>o?s:o:n>o?n:o,f=a>u?a>l?a:l:u>l?u:l,m=i.next;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&Ge(s,a,n,u,o,l,m.x,m.y)&&tt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function wy(r,t,e,i){var s=r.prev,n=r,o=r.next;if(tt(s,n,o)>=0)return!1;for(var a=s.x,u=n.x,l=o.x,c=s.y,h=n.y,p=o.y,f=au?a>l?a:l:u>l?u:l,g=c>h?c>p?c:p:h>p?h:p,b=Cn(f,m,t,e,i),v=Cn(_,g,t,e,i),y=r.prevZ,T=r.nextZ;y&&y.z>=b&&T&&T.z<=v;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==s&&y!==o&&Ge(a,c,u,h,l,p,y.x,y.y)&&tt(y.prev,y,y.next)>=0||(y=y.prevZ,T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ge(a,c,u,h,l,p,T.x,T.y)&&tt(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;y&&y.z>=b;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==s&&y!==o&&Ge(a,c,u,h,l,p,y.x,y.y)&&tt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;T&&T.z<=v;){if(T.x>=f&&T.x<=_&&T.y>=m&&T.y<=g&&T!==s&&T!==o&&Ge(a,c,u,h,l,p,T.x,T.y)&&tt(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Ry(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!vi(s,n)&&qc(s,i,i.next,n)&&fr(s,n)&&fr(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),mr(i),mr(i.next),i=r=n),i=i.next}while(i!==r);return ge(i)}function My(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&ky(o,a)){var u=Zc(o,a);o=ge(o,o.next),u=ge(u,u.next),pr(o,t,e,i,s,n,0),pr(u,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Cy(r,t,e,i){var s=[],n,o,a,u,l;for(n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x=e.x&&e.x>=l&&i!==e.x&&Ge(so.x||e.x===o.x&&Iy(o,e)))&&(o=e,h=p)),e=e.next;while(e!==u);return o}function Iy(r,t){return tt(r.prev,r,t.prev)<0&&tt(t.next,r,r.next)<0}function Fy(r,t,e,i){var s=r;do s.z===0&&(s.z=Cn(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Dy(s)}function Dy(r){var t,e,i,s,n,o,a,u,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t0||u>0&&i;)a!==0&&(u===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,u--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,l*=2}while(o>1);return r}function Cn(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Uy(r){var t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function ky(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ly(r,t)&&(fr(r,t)&&fr(t,r)&&$y(r,t)&&(tt(r.prev,r,t.prev)||tt(r,t.prev,t))||vi(r,t)&&tt(r.prev,r,r.next)>0&&tt(t.prev,t,t.next)>0)}function tt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function vi(r,t){return r.x===t.x&&r.y===t.y}function qc(r,t,e,i){var s=xi(tt(r,t,e)),n=xi(tt(r,t,i)),o=xi(tt(e,i,r)),a=xi(tt(e,i,t));return!!(s!==n&&o!==a||s===0&&yi(r,e,t)||n===0&&yi(r,i,t)||o===0&&yi(e,r,i)||a===0&&yi(e,t,i))}function yi(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function xi(r){return r>0?1:r<0?-1:0}function Ly(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&qc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function fr(r,t){return tt(r.prev,r,r.next)<0?tt(r,t,r.next)>=0&&tt(r,r.prev,t)>=0:tt(r,t,r.prev)<0||tt(r,r.next,t)<0}function $y(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function Zc(r,t){var e=new On(r.i,r.x,r.y),i=new On(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Qc(r,t,e,i){var s=new On(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function mr(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 On(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}bi.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Gn(r,0,n,e));if(s)for(var a=0,u=t.length;a0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Ny=_i.exports,Jc=Us(Ny);function Bn(r,t,e,i,s,n,o){const a=Jc(r,t,2);if(!a)return;for(let l=0;l=0&&o>=0&&(t[0]=i,t[1]=s,t[2]=i+n,t[3]=s,t[4]=i+n,t[5]=s+o,t[6]=i,t[7]=s+o),t},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[6],t[i+o+1]=r[7],o+=e,t[i+o]=r[4],t[i+o+1]=r[5],o+=e;const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},Dn={build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,t},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[4],t[i+o+1]=r[5];const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2}},Un={rectangle:Fn,polygon:In,triangle:Dn,circle:fe,ellipse:fe,roundedRectangle:fe},Xy=new j;function th(r,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let s=0;s{var f;const m=u.length,_=o.length/2,g=[],b=Un[c.type];if(b.build(c,g),h&&mi(g,h),i){const E=(f=c.closePath)!=null?f:!0;Yc(g,t,!1,E,o,2,_,u,m)}else if(e&&l===p){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const E=[],R=g.slice();jy(e.shapePath).forEach(w=>{E.push(R.length/2),R.push(...w)}),Bn(R,E,o,2,_,u,m)}else b.triangulate(g,o,2,_,u,m);const v=a.length/2,y=t.texture;if(y!==P.WHITE){const E=t.matrix;h&&E.append(h.clone().invert()),wn(o,2,_,a,v,2,o.length/2-_,E)}else Rn(a,v,2,o.length/2-_);const T=W.get(gi);T.indexOffset=m,T.indexSize=u.length-m,T.vertexOffset=_,T.vertexSize=o.length/2-_,T.color=t.color,T.alpha=t.alpha,T.texture=y,T.geometryData=n,s.push(T)})}function jy(r){if(!r)return[];const t=r.shapePrimitives,e=[];for(let i=0;i{W.return(i)})}destroy(){for(const t of this._needsContextNeedsRebuild)this._gpuContextHash[t.uid]&&this.onGraphicsContextDestroy(t);this._needsContextNeedsRebuild.length=0}};kn.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"graphicsContext"},kn.defaultOptions={bezierSmoothness:.5};let Ti=kn;const Vy={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8},Ln=0,$n=1,Nn=2,Hn=3,Xn=4,zn=5,jn=class Mb{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function gr(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 Vn{constructor(t,e){this.state=Bt.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,i=!!this._graphicsBatchesHash[t.uid],s=this.renderer.graphicsContext.updateGpuContext(e);return!!(s.isBatchable||i!==s.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let i=0;i{const a=W.get(gi);return o.copyTo(a),a.renderable=t,a.roundPixels=s,a});return this._graphicsBatchesHash[t.uid]=n,t.on("destroyed",()=>{this.destroyRenderable(t)}),n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{W.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}Vn.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"graphics"},U.add(Vn),U.add(Ti);const Wn=Object.create(null),sh=Object.create(null);function _r(r,t){let e=sh[r];return e===void 0&&(Wn[t]===void 0&&(Wn[t]=1),sh[r]=e=Wn[t]++),e}function nh(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Yy=Object.defineProperty,oh=Object.getOwnPropertySymbols,Ky=Object.prototype.hasOwnProperty,qy=Object.prototype.propertyIsEnumerable,ah=(r,t,e)=>t in r?Yy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uh=(r,t)=>{for(var e in t||(t={}))Ky.call(t,e)&&ah(r,e,t[e]);if(oh)for(var e of oh(t))qy.call(t,e)&&ah(r,e,t[e]);return r};const lh=class Cb{constructor(t,e){this._touched=0,this.uid=J("uniform"),this._resourceType="uniformGroup",this._resourceId=J("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,s;e=uh(uh({},Cb.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];a.name=o,a.size=(i=a.size)!=null?i:1,(s=a.value)!=null||(a.value=nh(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=_r(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};lh.defaultOptions={ubo:!1,isStatic:!1};let nt=lh;class Si{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null}packIndex(t,e,i){const s=this.geometry.indices;for(let n=0;n"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Nt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t),a=t.texture;if(o.texture._source!==a._source&&o.texture._source!==a._source)return!o.batcher.checkAndUpdateTexture(o,a)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,{batched:s}=this._getMeshData(t);if(s){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,i.addToBatch(n)}else i.break(e),e.add({renderPipeId:"mesh",mesh:t})}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e.batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&(W.return(e),this._gpuBatchableMeshHash[t.uid]=null)}execute({mesh:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),gr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,i;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(i=t._geometry.positions)==null?void 0:i.length},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=W.get(Si);return e.mesh=t,e.texture=t._texture,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e.mesh=t,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&W.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Yn.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"mesh"},U.add(Yn);class Ei{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(t,e,i,s){const n=this.renderable,o=this.texture,a=n.groupTransform,u=a.a,l=a.b,c=a.c,h=a.d,p=a.tx,f=a.ty,m=this.bounds,_=m.maxX,g=m.minX,b=m.maxY,v=m.minY,y=o.uvs,T=n.groupColorAlpha,E=s<<16|this.roundPixels&65535;t[i+0]=u*g+c*v+p,t[i+1]=h*v+l*g+f,t[i+2]=y.x0,t[i+3]=y.y0,e[i+4]=T,e[i+5]=E,t[i+6]=u*_+c*v+p,t[i+7]=h*v+l*_+f,t[i+8]=y.x1,t[i+9]=y.y1,e[i+10]=T,e[i+11]=E,t[i+12]=u*_+c*b+p,t[i+13]=h*b+l*_+f,t[i+14]=y.x2,t[i+15]=y.y2,e[i+16]=T,e[i+17]=E,t[i+18]=u*g+c*b+p,t[i+19]=h*b+l*g+f,t[i+20]=y.x3,t[i+21]=y.y3,e[i+22]=T,e[i+23]=E}packIndex(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}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class Kn{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){var e;const i=this._getGpuText(t),s=t._getKey();if(i.currentKey!==s){const n=(e=t.resolution)!=null?e:this._renderer.resolution,{width:o,height:a}=this._renderer.canvasText.getTextureSize(t.text,n,t._style);return!(this._renderer.canvasText.getReferenceCount(i.currentKey)===1&&o===i.texture._source.width&&a===i.texture._source.height)}return!1}addRenderable(t,e){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),W.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),s=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;lr(s.bounds,t._anchor,s.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),i=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=i.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),i.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:W.get(Ei)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,this._updateText(t),t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Kn.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"text"};class ch{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=z.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=he(t),e=he(e);const s=(t<<17)+(e<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const{width:e,height:i}=t.canvas,s=(e<<17)+(i<<1);this._canvasPool[s].push(t)}clear(){this._canvasPool={}}}const Ht=new ch;var Zy=Object.defineProperty,Qy=Object.defineProperties,Jy=Object.getOwnPropertyDescriptors,hh=Object.getOwnPropertySymbols,tx=Object.prototype.hasOwnProperty,ex=Object.prototype.propertyIsEnumerable,dh=(r,t,e)=>t in r?Zy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rx=(r,t)=>{for(var e in t||(t={}))tx.call(t,e)&&dh(r,e,t[e]);if(hh)for(var e of hh(t))ex.call(t,e)&&dh(r,e,t[e]);return r},ix=(r,t)=>Qy(r,Jy(t));let sx=0;class ph{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,i){const s=new rt(ix(rx({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!0}));return new P({source:s,label:`texturePool_${sx++}`})}getOptimalTexture(t,e,i=1,s){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=he(n),o=he(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let u=this._texturePool[a].pop();return u||(u=this.createTexture(n,o,s)),u.source._resolution=i,u.source.width=n/i,u.source.height=o/i,u.source.pixelWidth=n,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=a,u}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t){const e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let s=0;s2&&(t.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==qn[n])return s.unshift(i),t.push(s);if(s.length0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:}l!=="Z"&&l!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return t}class Pi{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Pi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const s=this.x-t,n=this.y-e,o=this.radius,a=i/2,u=Math.sqrt(s*s+n*n);return uo-a}getBounds(t){return t=t||new j,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 wi{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new wi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i){const{halfWidth:s,halfHeight:n}=this;if(s<=0||n<=0)return!1;const o=i/2,a=s-o,u=n-o,l=s+o,c=n+o,h=t-this.x,p=e-this.y,f=h*h/(a*a)+p*p/(u*u),m=h*h/(l*l)+p*p/(c*c);return f>1&&m<=1}getBounds(){return new j(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function br(r,t,e,i,s,n){const o=r-e,a=t-i,u=s-e,l=n-i,c=o*u+a*l,h=u*u+l*l;let p=-1;h!==0&&(p=c/h);let f,m;p<0?(f=e,m=i):p>1?(f=s,m=n):(f=e+p*u,m=i+p*l);const _=r-f,g=t-m;return _*_+g*g}class Be{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;se!=c>e&&t<(l-a)*((e-u)/(c-u))+a&&(i=!i)}return i}strokeContains(t,e,i){const s=i/2,n=s*s,{points:o}=this,a=o.length-(this.closePath?0:2);for(let u=0;us?l:s,n=co?c:o}return t.x=i,t.width=s-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const Ri=(r,t,e,i,s,n)=>{const o=r-e,a=t-i,u=Math.sqrt(o*o+a*a);return u>=s-n&&u<=s+n};class Mi{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t=t||new j,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Mi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(t,e,i){const{x:s,y:n,width:o,height:a,radius:u}=this,l=i/2,c=s+u,h=n+u,p=o-u*2,f=a-u*2,m=s+o,_=n+a;return(t>=s-l&&t<=s+l||t>=m-l&&t<=m+l)&&e>=h&&e<=h+f||(e>=n-l&&e<=n+l||e>=_-l&&e<=_+l)&&t>=c&&t<=c+p?!0:tm-u&&em-u&&e>_-u&&Ri(t,e,m-u,_-u,u,l)||t_-u&&Ri(t,e,c,_-u,u,l)}}const dx=8,Ci=11920929e-14,px=1,Zn=.01,Ie=0,_e=0;function Qn(r,t,e,i,s,n,o,a,u,l){const c=Math.min(.99,Math.max(0,l!=null?l:Ti.defaultOptions.bezierSmoothness));let h=(px-c)/1;return h*=h,fx(t,e,i,s,n,o,a,u,r,h),r}function fx(r,t,e,i,s,n,o,a,u,l){Jn(r,t,e,i,s,n,o,a,u,l,0),u.push(o,a)}function Jn(r,t,e,i,s,n,o,a,u,l,c){if(c>dx)return;const h=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+s)/2,_=(i+n)/2,g=(s+o)/2,b=(n+a)/2,v=(p+m)/2,y=(f+_)/2,T=(m+g)/2,E=(_+b)/2,R=(v+T)/2,w=(y+E)/2;if(c>0){let M=o-r,S=a-t;const A=Math.abs((e-o)*S-(i-a)*M),N=Math.abs((s-o)*S-(n-a)*M);let L,O;if(A>Ci&&N>Ci){if((A+N)*(A+N)<=l*(M*M+S*S)){if(Ie=h&&(L=2*h-L),O>=h&&(O=2*h-O),L+O_e){u.push(e,i);return}if(O>_e){u.push(s,n);return}}}}else if(A>Ci){if(A*A<=l*(M*M+S*S)){if(Ie=h&&(L=2*h-L),L_e){u.push(e,i);return}}}else if(N>Ci){if(N*N<=l*(M*M+S*S)){if(Ie=h&&(L=2*h-L),L_e){u.push(s,n);return}}}else if(M=R-(r+o)/2,S=w-(t+a)/2,M*M+S*S<=l){u.push(R,w);return}}Jn(r,t,p,f,v,y,R,w,u,l,c+1),Jn(R,w,T,E,g,b,o,a,u,l,c+1)}const mx=8,gx=11920929e-14,_x=1,bx=.01,xh=0;function Th(r,t,e,i,s,n,o,a){const u=Math.min(.99,Math.max(0,a!=null?a:Ti.defaultOptions.bezierSmoothness));let l=(_x-u)/1;return l*=l,vx(t,e,i,s,n,o,r,l),r}function vx(r,t,e,i,s,n,o,a){to(o,r,t,e,i,s,n,a,0),o.push(s,n)}function to(r,t,e,i,s,n,o,a,u){if(u>mx)return;const l=Math.PI,c=(t+i)/2,h=(e+s)/2,p=(i+n)/2,f=(s+o)/2,m=(c+p)/2,_=(h+f)/2;let g=n-t,b=o-e;const v=Math.abs((i-n)*b-(s-o)*g);if(v>gx){if(v*v<=a*(g*g+b*b)){if(xh=l&&(y=2*l-y),yn||o&&n>s)&&(u=2*Math.PI-u),a=a||Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(u/Math.PI))),a=Math.max(a,3);let l=u/a,c=s;l*=o?-1:1;for(let h=0;hc*a)}const vr=Math.PI*2,ro={centerX:0,centerY:0,ang1:0,ang2:0},io=({x:r,y:t},e,i,s,n,o,a,u)=>{r*=e,t*=i;const l=s*r-n*t,c=n*r+s*t;return u.x=l+o,u.y=c+a,u};function yx(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Eh=(r,t,e,i)=>{const s=r*i-t*e<0?-1:1;let n=r*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},xx=(r,t,e,i,s,n,o,a,u,l,c,h,p)=>{const f=Math.pow(s,2),m=Math.pow(n,2),_=Math.pow(c,2),g=Math.pow(h,2);let b=f*m-f*g-m*_;b<0&&(b=0),b/=f*g+m*_,b=Math.sqrt(b)*(o===a?-1:1);const v=b*s/n*h,y=b*-n/s*c,T=l*v-u*y+(r+e)/2,E=u*v+l*y+(t+i)/2,R=(c-v)/s,w=(h-y)/n,M=(-c-v)/s,S=(-h-y)/n,A=Eh(1,0,R,w);let N=Eh(R,w,M,S);a===0&&N>0&&(N-=vr),a===1&&N<0&&(N+=vr),p.centerX=T,p.centerY=E,p.ang1=A,p.ang2=N};function Ah(r,t,e,i,s,n,o,a=0,u=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*vr/360),h=Math.cos(a*vr/360),p=h*(t-i)/2+c*(e-s)/2,f=-c*(t-i)/2+h*(e-s)/2;if(p===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),xx(t,e,i,s,n,o,u,l,c,h,p,f,ro);let{ang1:_,ang2:g}=ro;const{centerX:b,centerY:v}=ro;let y=Math.abs(g)/(vr/4);Math.abs(1-y)<1e-7&&(y=1);const T=Math.max(Math.ceil(y),1);g/=T;let E=r[r.length-2],R=r[r.length-1];const w={x:0,y:0};for(let M=0;M{const l=u.x-a.x,c=u.y-a.y,h=Math.sqrt(l*l+c*c),p=l/h,f=c/h;return{len:h,nx:p,ny:f}},n=(a,u)=>{a===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y)};let o=t[t.length-1];for(let a=0;a0&&(m=-1,_=!0);const g=f/2;let b,v=Math.abs(Math.cos(g)*l/Math.sin(g));v>Math.min(h.len/2,p.len/2)?(v=Math.min(h.len/2,p.len/2),b=Math.abs(v*Math.sin(g)/Math.cos(g))):b=l;const y=u.x+p.nx*v+-p.ny*b*m,T=u.y+p.ny*v+p.nx*b*m,E=Math.atan2(h.ny,h.nx)+Math.PI/2*m,R=Math.atan2(p.ny,p.nx)-Math.PI/2*m;a===0&&r.moveTo(y+Math.cos(E)*b,T+Math.sin(E)*b),r.arc(y,T,b,E,R,_),o=u}}function wh(r,t,e,i){var s;const n=(u,l)=>Math.sqrt((u.x-l.x)**2+(u.y-l.y)**2),o=(u,l,c)=>({x:u.x+(l.x-u.x)*c,y:u.y+(l.y-u.y)*c}),a=t.length;for(let u=0;u=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,s,n){return this.drawShape(new wi(t,e,i,s),n),this}roundRect(t,e,i,s,n,o){return this.drawShape(new Mi(t,e,i,s,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Be,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 Be,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,s=e.shape.y;if(!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;et in r?Sx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oi=(r,t)=>{for(var e in t||(t={}))Ex.call(t,e)&&Ch(r,e,t[e]);if(Mh)for(var e of Mh(t))Ax.call(t,e)&&Ch(r,e,t[e]);return r};function Oh(r,t){if(typeof r=="string"){const i=document.createElement("div");i.innerHTML=r.trim(),r=i.querySelector("svg")}const e={context:t,path:new Qt};return Gh(r,e,null,null),t}function Gh(r,t,e,i){const s=r.children,{fillStyle:n,strokeStyle:o}=Px(r);n&&e?e=Oi(Oi({},e),n):n&&(e=n),o&&i?i=Oi(Oi({},i),o):o&&(i=o),t.context.fillStyle=e,t.context.strokeStyle=i;let a,u,l,c,h,p,f,m,_,g,b,v,y,T,E,R,w;switch(r.nodeName.toLowerCase()){case"path":T=r.getAttribute("d"),E=new Qt(T),t.context.path(E),e&&t.context.fill(),i&&t.context.stroke();break;case"circle":f=at(r,"cx",0),m=at(r,"cy",0),_=at(r,"r",0),t.context.ellipse(f,m,_,_),e&&t.context.fill(),i&&t.context.stroke();break;case"rect":a=at(r,"x",0),u=at(r,"y",0),R=at(r,"width",0),w=at(r,"height",0),g=at(r,"rx",0),b=at(r,"ry",0),g||b?t.context.roundRect(a,u,R,w,g||b):t.context.rect(a,u,R,w),e&&t.context.fill(),i&&t.context.stroke();break;case"ellipse":f=at(r,"cx",0),m=at(r,"cy",0),g=at(r,"rx",0),b=at(r,"ry",0),t.context.beginPath(),t.context.ellipse(f,m,g,b),e&&t.context.fill(),i&&t.context.stroke();break;case"line":l=at(r,"x1",0),c=at(r,"y1",0),h=at(r,"x2",0),p=at(r,"y2",0),t.context.beginPath(),t.context.moveTo(l,c),t.context.lineTo(h,p),i&&t.context.stroke();break;case"polygon":y=r.getAttribute("points"),v=y.match(/\d+/g).map(M=>parseInt(M,10)),t.context.poly(v,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":y=r.getAttribute("points"),v=y.match(/\d+/g).map(M=>parseInt(M,10)),t.context.poly(v,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}for(let M=0;Mt in r?wx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,be=(r,t)=>{for(var e in t||(t={}))Cx.call(t,e)&&Fh(r,e,t[e]);if(Ih)for(var e of Ih(t))Ox.call(t,e)&&Fh(r,e,t[e]);return r},no=(r,t)=>Rx(r,Mx(t));function Yt(r,t){var e,i;if(r==null)return null;let s,n;if(r!=null&&r.fill?(n=r.fill,s=be(be({},t),r)):(n=r,s=t),K.isColorLike(n)){const u=K.shared.setValue(n!=null?n:0);return no(be({},s),{color:u.toNumber(),alpha:u.alpha===1?s.alpha:u.alpha,texture:P.WHITE})}else if(n instanceof so){const u=n;return no(be({},s),{color:16777215,texture:u.texture,matrix:u.transform,fill:(e=s.fill)!=null?e:null})}else if(n instanceof Ai){const u=n;return u.buildLinearGradient(),no(be({},s),{color:16777215,texture:u.texture,matrix:u.transform})}const o=be(be({},t),r);if(o.texture){if(o.texture!==P.WHITE){const l=((i=o.matrix)==null?void 0:i.invert())||new G;l.scale(1/o.texture.frame.width,1/o.texture.frame.height),o.matrix=l}const u=o.texture.source.style;u.addressMode==="clamp-to-edge"&&(u.addressMode="repeat")}const a=K.shared.setValue(o.color);return o.alpha*=a.alpha,o.color=a.toNumber(),o.matrix=o.matrix?o.matrix.clone():null,o}var Gx=Object.defineProperty,Dh=Object.getOwnPropertySymbols,Bx=Object.prototype.hasOwnProperty,Ix=Object.prototype.propertyIsEnumerable,Uh=(r,t,e)=>t in r?Gx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fe=(r,t)=>{for(var e in t||(t={}))Bx.call(t,e)&&Uh(r,e,t[e]);if(Dh)for(var e of Dh(t))Ix.call(t,e)&&Uh(r,e,t[e]);return r};const Fx=new V,kh=new G,oo=class Xt extends pt{constructor(){super(...arguments),this.uid=J("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Qt,this._transform=new G,this._fillStyle=Fe({},Xt.defaultFillStyle),this._strokeStyle=Fe({},Xt.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new lt,this._boundsDirty=!0}clone(){const t=new Xt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=Fe({},this._fillStyle),t._strokeStyle=Fe({},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=Yt(t,Xt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Yt(t,Xt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Yt(t,Xt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Yt(t,Xt.defaultStrokeStyle),this}texture(t,e,i,s,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?K.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Qt,this}fill(t,e){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=Yt(t,Xt.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(V.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Yt(t,Xt.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,s,n,o),this}arcTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(t,e,i,s,n,o,a){this._tick++;const u=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,u.a*o+u.c*a+u.tx,u.b*o+u.d*a+u.ty),this}bezierCurveTo(t,e,i,s,n,o,a){this._tick++;const u=this._transform;return this._activePath.bezierCurveTo(u.a*t+u.c*e+u.tx,u.b*t+u.d*e+u.ty,u.a*i+u.c*s+u.tx,u.b*i+u.d*s+u.ty,u.a*n+u.c*o+u.tx,u.b*n+u.d*o+u.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,o),this}roundPoly(t,e,i,s,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,o),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,o),this}star(t,e,i,s,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,s,n,o,this._transform.clone()),this}svg(t){return this._tick++,Oh(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:Fe({},this._fillStyle),strokeStyle:Fe({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,s,n,o){return t instanceof G?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,s,n,o),this)}transform(t,e,i,s,n,o){return t instanceof G?(this._transform.append(t),this):(kh.set(t,e,i,s,n,o),this._transform.append(kh),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;et in r?Ux(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xr=(r,t)=>{for(var e in t||(t={}))kx.call(t,e)&&Hh(r,e,t[e]);if(Nh)for(var e of Nh(t))Lx.call(t,e)&&Hh(r,e,t[e]);return r};const uo=class Ze extends pt{constructor(t={}){super(),$x(t);const e=xr(xr({},Ze.defaultTextStyle),t);for(const i in e){const s=i;this[s]=e[i]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=xr(xr({},Ze.defaultDropShadow),t):this._dropShadow=t?xr({},Ze.defaultDropShadow):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._fill=Yt(t===0?"black":t,It.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._stroke=Yt(t,It.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=ao(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Ze.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Ze({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var e,i,s,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(o),(s=this._stroke)!=null&&s.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}};uo.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},uo.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 Ft=uo;function $x(r){var t,e,i,s,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Ft.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(i=o.dropShadowBlur)!=null?i:a.blur,color:(s=o.dropShadowColor)!=null?s:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;r.stroke={color:a,width:o.strokeThickness}}if(Array.isArray(o.fill)){const a=new Ai(0,0,0,r.fontSize*1.7),u=o.fill.map(l=>K.shared.setValue(l).toNumber());u.forEach((l,c)=>{var h;const p=(h=o.fillGradientStops[c])!=null?h:c/u.length;a.addColorStop(p,l)}),r.fill={fill:a}}}const Nx=new lt;function lo(r,t,e,i){const s=Nx;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=ct.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}const Hx=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Tr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Hx.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const co={willReadFrequently:!0},Dt=class C{static get experimentalLetterSpacingSupported(){let t=C._experimentalLetterSpacingSupported;if(t!==void 0){const e=z.get().getCanvasRenderingContext2D().prototype;t=C._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,u,l){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=u,this.fontProperties=l}static measureText(t=" ",e,i=C._canvas,s=e.wordWrap){var n;const o=`${t}:${e.styleKey}`;if(C._measurementCache[o])return C._measurementCache[o];const a=Tr(e),u=C.measureFont(a);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize);const l=C.__context;l.font=a;const c=(s?C._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),h=new Array(c.length);let p=0;for(let b=0;b0&&(s?n-=e:n+=(C.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=C._canvas){const s=i.getContext("2d",co);let n=0,o="",a="";const u=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,h=C._collapseSpaces(c),p=C._collapseNewlines(c);let f=!h;const m=e.wordWrapWidth+l,_=C._tokenize(t);for(let g=0;g<_.length;g++){let b=_[g];if(C._isNewline(b)){if(!p){a+=C._addLine(o),f=!h,o="",n=0;continue}b=" "}if(h){const y=C.isBreakingSpace(b),T=C.isBreakingSpace(o[o.length-1]);if(y&&T)continue}const v=C._getFromCache(b,l,u,s);if(v>m)if(o!==""&&(a+=C._addLine(o),o="",n=0),C.canBreakWords(b,e.breakWords)){const y=C.wordWrapSplit(b);for(let T=0;Tm&&(a+=C._addLine(o),f=!1,o="",n=0),o+=E,n+=M}}else{o.length>0&&(a+=C._addLine(o),o="",n=0);const y=g===_.length-1;a+=C._addLine(b,!y),f=!1,o="",n=0}else v+n>m&&(f=!1,a+=C._addLine(o),o="",n=0),(o.length>0||!C.isBreakingSpace(b)||f)&&(o+=b,n+=v)}return a+=C._addLine(o,!1),a}static _addLine(t,e=!0){return t=C._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=C._measureText(t,e,s)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!C.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:C._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:C._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),Dt.experimentalLetterSpacing=!1,Dt._fonts={},Dt._newlines=[10,13],Dt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Dt._measurementCache={};let Ut=Dt;function Sr(r,t){if(r.texture===P.WHITE&&!r.fill)return K.shared.setValue(r.color).toHex();if(r.fill){if(r.fill instanceof so){const e=r.fill,i=t.createPattern(e.texture.source.resource,"repeat"),s=e.transform.copyTo(G.shared);return s.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(s),i}else if(r.fill instanceof Ai){const e=r.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(s=>{i.addColorStop(s.offset,K.shared.setValue(s.color).toHex())}),i}}}else{const e=t.createPattern(r.texture.source.resource,"repeat"),i=r.matrix.copyTo(G.shared);return i.scale(r.texture.frame.width,r.texture.frame.height),e.setTransform(i),e}return"red"}class ho{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,i){const s=Ut.measureText(t||" ",i);let n=Math.ceil(Math.ceil(Math.max(1,s.width)+i.padding*2)*e),o=Math.ceil(Math.ceil(Math.max(1,s.height)+i.padding*2)*e);return n=Math.ceil(n-1e-6),o=Math.ceil(o-1e-6),n=he(n),o=he(o),{width:n,height:o}}getTexture(t,e,i,s){typeof t=="string"&&(bh("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof Ft||(t.style=new Ft(t.style));const{texture:n,canvasAndContext:o}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),Ht.returnCanvasAndContext(o),n}createTextureAndCanvas(t){var e;const{text:i,style:s}=t,n=(e=t.resolution)!=null?e:this._renderer.resolution,o=Ut.measureText(i||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+s.padding*2)*n),u=Math.ceil(Math.ceil(Math.max(1,o.height)+s.padding*2)*n),l=Ht.getOptimalCanvasAndContext(a,u),{canvas:c}=l;this.renderTextToCanvas(i,s,n,l);const h=lo(c,a,u,n);if(s.trim){const p=gh(c,n);h.frame.copyFrom(p),h.updateUvs()}return{texture:h,canvasAndContext:l}}getManagedTexture(t){const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:i,canvasAndContext:s}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:s,texture:i,usageCount:1},i}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){Ht.returnCanvasAndContext(e.canvasAndContext),ct.returnTexture(e.texture);const i=e.texture.source;i.resource=null,i.uploadMethodId="unknown",i.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,i,s){var n,o,a,u,l,c,h;const{canvas:p,context:f}=s,m=Tr(e),_=Ut.measureText(t||" ",e),g=_.lines,b=_.lineHeight,v=_.lineWidths,y=_.maxLineWidth,T=_.fontProperties,E=p.height;f.resetTransform(),f.scale(i,i);const R=e.padding*2;if(f.clearRect(0,0,_.width+4+R,_.height+4+R),(n=e._stroke)!=null&&n.width){const A=e._stroke;f.lineWidth=A.width,f.miterLimit=A.miterLimit,f.lineJoin=A.join,f.lineCap=A.cap}f.font=m;let w,M;const S=e.dropShadow?2:1;for(let A=0;Ae.texture.destroy(!0)),this.pages=null)}}function fo(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e!this._currentChars.includes(y)).filter((y,T,E)=>E.indexOf(y)===T);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:u,context:l}=a.canvasAndContext,c=a.texture.source;const h=this._style;let p=this._currentX,f=this._currentY;const m=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=this._padding*m,g=h.fontStyle==="italic"?2:1;let b=0,v=!1;for(let y=0;y512&&(f+=b,b=S,p=0,f+b>512)){c.update();const N=this._nextPage();u=N.canvasAndContext.canvas,l=N.canvasAndContext.context,c=N.texture.source,f=0}const A=R/m-((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)-((n=(s=h._stroke)==null?void 0:s.width)!=null?n:0);if(this.chars[T]={id:T.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:A,kerning:{}},v){this._drawGlyph(l,E,p+_,f+_,m,h);const N=c.width*m,L=c.height*m,O=new j(p/N*c.width,f/L*c.height,M/N*c.width,S/L*c.height);this.chars[T].texture=new P({source:c,frame:O}),p+=Math.ceil(M)}}c.update(),this._currentX=p,this._currentY=f,this._skipKerning&&this._applyKerning(o,l)}get pageTextures(){return this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s{const m=s.width;for(let _=0;_{let f=s.chars.length-1,m=s.chars[f];for(;m===" ";)s.width-=e.chars[m].xAdvance,m=s.chars[--f];i.width=Math.max(i.width,s.width),s={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,i.lines.push(s),i.height+=e.lineHeight},c=e.baseMeasurementFontSize/t.fontSize,h=t.letterSpacing*c,p=t.wordWrapWidth*c;for(let f=0;fp?(l(),u(a),_||s.charPositions.push(0)):(a.start=s.width,u(a),_||s.charPositions.push(0)),m==="\r"||m===` `)s.width!==0&&l();else if(!_){const b=g.xAdvance+(g.kerning[n]||0)+h;s.width+=b,s.spaceWidth=b,s.spacesIndex.push(s.charPositions.length),s.chars.push(m)}}else{const b=g.kerning[n]||0,v=g.xAdvance+b+h;a.positions[a.index++]=a.width+b,a.chars.push(m),a.width+=v}n=m}return l(),t.align==="center"?Xx(i):t.align==="right"?zx(i):t.align==="justify"&&jx(i),i}function Xx(r){for(let t=0;tt in r?Vx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_o=(r,t)=>{for(var e in t||(t={}))Wx.call(t,e)&&zh(r,e,t[e]);if(Xh)for(var e of Xh(t))Yx.call(t,e)&&zh(r,e,t[e]);return r};let Kx=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){var i;let s=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&(s+=e._fill.fill.uid,n=!1),!q.has(s)){const a=new mo(_o({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions));a.once("destroy",()=>q.remove(s)),q.set(s,a)}const o=q.get(s);return(i=o.ensureCharacters)==null||i.call(o,t),o}getLayout(t,e){const i=this.getFont(t,e);return go([...t],e,i)}measureText(t,e){return this.getLayout(t,e)}install(...t){var e,i,s,n;let o=t[0];typeof o=="string"&&(o={name:o,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(i=t[2])==null?void 0:i.resolution,padding:(s=t[2])==null?void 0:s.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const a=o==null?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=_o(_o({},this.defaultOptions),o);const u=o.style,l=u instanceof Ft?u:new Ft(u),c=l._fill.fill!==null&&l._fill.fill!==void 0,h=new mo({style:l,overrideFill:c,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1}),p=fo(o.chars);return h.ensureCharacters(p.join("")),q.set(`${a}-bitmap`,h),h.once("destroy",()=>q.remove(`${a}-bitmap`)),h}uninstall(t){const e=`${t}-bitmap`,i=q.get(e);i&&(q.remove(e),i.destroy())}};const Er=new Kx;class bo extends po{constructor(t,e){var i;super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],u=s[a.id];this.pages.push({texture:u})}),Object.keys(n.chars).forEach(o=>{var a;const u=n.chars[o],{frame:l,source:c}=s[u.page],h=new j(u.x+l.x,u.y+l.y,u.width,u.height),p=new P({source:c,frame:h});this.chars[o]={id:o.codePointAt(0),xOffset:u.xOffset,yOffset:u.yOffset,xAdvance:u.xAdvance,kerning:(a=u.kerning)!=null?a:{},texture:p}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(i=n.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?vo.test(z.get().parseXML(r)):!1},parse(r){return vo.parse(z.get().parseXML(r))}},qx=[".xml",".fnt"],jh={extension:x.CacheParser,test:r=>r instanceof bo,getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Vh={extension:{type:x.LoadParser,priority:_t.Normal},test(r){return qx.includes(ft.extname(r).toLowerCase())},async testParse(r){return Gi.test(r)||yo.test(r)},async parse(r,t,e){const i=Gi.test(r)?Gi.parse(r):yo.parse(r),{src:s}=t,{pages:n}=i,o=[];for(let l=0;la[l]);return new bo({data:i,textures:u},s)},async load(r,t){return await(await z.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};var Zx=Object.defineProperty,Bi=Object.getOwnPropertySymbols,Wh=Object.prototype.hasOwnProperty,Yh=Object.prototype.propertyIsEnumerable,Kh=(r,t,e)=>t in r?Zx(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qx=(r,t)=>{for(var e in t||(t={}))Wh.call(t,e)&&Kh(r,e,t[e]);if(Bi)for(var e of Bi(t))Yh.call(t,e)&&Kh(r,e,t[e]);return r},Jx=(r,t)=>{var e={};for(var i in r)Wh.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Bi)for(var i of Bi(r))t.indexOf(i)<0&&Yh.call(r,i)&&(e[i]=r[i]);return e};class De extends Y{constructor(t){t instanceof It&&(t={context:t});const e=t||{},{context:i,roundPixels:s}=e,n=Jx(e,["context","roundPixels"]);super(Qx({label:"Graphics"},n)),this.canBundle=!0,this.renderPipeId="graphics",this._roundPixels=0,i?this._context=i:this._context=this._ownedContext=new It,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s!=null?s:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}onViewUpdate(){if(this._didChangeId+=4096,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new De(this._context.clone()):(this._ownedContext=null,new De(this._context))}lineStyle(t,e,i){const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==It.defaultStrokeStyle.width||t.color!==It.defaultStrokeStyle.color||t.alpha!==It.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)}}let Ii;function qh(){if(!Ii){Ii="mediump";const r=xn();r&&r.getShaderPrecisionFormat&&(Ii=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Ii}function Zh(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${r} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${r} `}function Qh(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float; ${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Jh(r,t){return t?`#version 300 es ${r}`:r}const t0={},e0={};function td(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?t0:e0;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} ${r}`}function ed(r,t){return t?r.replace("#version 300 es",""):r}var r0=Object.defineProperty,rd=Object.getOwnPropertySymbols,i0=Object.prototype.hasOwnProperty,s0=Object.prototype.propertyIsEnumerable,id=(r,t,e)=>t in r?r0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sd=(r,t)=>{for(var e in t||(t={}))i0.call(t,e)&&id(r,e,t[e]);if(rd)for(var e of rd(t))s0.call(t,e)&&id(r,e,t[e]);return r};const xo={stripVersion:ed,ensurePrecision:Qh,addProgramDefines:Zh,setProgramName:td,insertVersion:Jh},To=Object.create(null),nd=class Qu{constructor(t){t=sd(sd({},Qu.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:qh()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(xo).forEach(o=>{const a=i[o];s=xo[o](s,a,!0),n=xo[o](n,a,!1)}),this.fragment=s,this.vertex=n,this._key=_r(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return To[e]||(To[e]=new Qu(t)),To[e]}};nd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Mt=nd;const od={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 Ue(r){var t;return(t=od[r])!=null?t:od.float32}const n0={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function ad({source:r,entryPoint:t}){var e;const i={},s=r.indexOf(`fn ${t}`);if(s!==-1){const n=r.indexOf("->",s);if(n!==-1){const o=r.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let u;for(;(u=a.exec(o))!==null;){const l=(e=n0[u[3]])!=null?e:"float32";i[u[2]]={location:parseInt(u[1],10),format:l,stride:Ue(l).stride,offset:0,instance:!1,start:0}}}}return i}function Fi(r){var t,e,i;const s=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,u=/:\s*(\w+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,p=(t=r.match(s))==null?void 0:t.map(m=>({group:parseInt(m.match(n)[1],10),binding:parseInt(m.match(o)[1],10),name:m.match(a)[2],isUniform:m.match(a)[1]==="",type:m.match(u)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(l))==null?void 0:e.map(m=>{const _=m.match(h)[1],g=m.match(c).reduce((b,v)=>{const[y,T]=v.split(":");return b[y.trim()]=T.trim(),b},{});return g?{name:_,members:g}:null}).filter(({name:m})=>p.some(_=>_.type===m)))!=null?i:[];return{groups:p,structs:f}}var ke=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(ke||{});function ud({groups:r}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const So=Object.create(null);class vt{constructor(t){this._layoutKey=0;var e,i;const{fragment:s,vertex:n,layout:o,gpuLayout:a,name:u}=t;if(this.name=u,this.fragment=s,this.vertex=n,s.source===n.source){const l=Fi(s.source);this.structsAndGroups=l}else{const l=Fi(n.source),c=Fi(s.source);this.structsAndGroups=cd(l,c)}this.layout=o!=null?o:ld(this.structsAndGroups),this.gpuLayout=a!=null?a:ud(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=_r(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=ad(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return So[e]||(So[e]=new vt(t)),So[e]}}function Eo(r,t,e){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=t[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const hd=/\{\{(.*?)\}\}/g;function Ao(r){var t,e;const i={};return((e=(t=r.match(hd))==null?void 0:t.map(s=>s.replace(/[{()}]/g,"")))!=null?e:[]).forEach(s=>{i[s]=[]}),i}function dd(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function Po(r,t,e=!1){const i=[];dd(t,i),r.forEach(a=>{a.header&&dd(a.header,i)});const s=i;e&&s.sort();const n=s.map((a,u)=>` @location(${u}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function pd(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function o0(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function a0(r){const t=/@.*?\s+/g;return r.replace(t,"")}function fd(r,t){const e=[];pd(t,e),r.forEach(u=>{u.header&&pd(u.header,e)});let i=0;const s=e.sort().map(u=>u.indexOf("builtin")>-1?u:`@location(${i++}) ${u}`).join(`, `),n=e.sort().map(u=>` var ${a0(u)};`).join(` `),o=`return VSOutput( ${e.sort().map(u=>` ${o0(u)}`).join(`, `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${s} `),a=a.replace("{{start}}",` ${n} `),a=a.replace("{{return}}",` ${o} `),a}function wo(r,t){let e=r;for(const i in t){const s=t[i];s.join(` `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${s.join(` `)} //----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const ve=Object.create(null),Ro=new Map;let u0=0;function md({template:r,bits:t}){const e=_d(r,t);if(ve[e])return ve[e];const{vertex:i,fragment:s}=l0(r,t);return ve[e]=bd(i,s,t),ve[e]}function gd({template:r,bits:t}){const e=_d(r,t);return ve[e]||(ve[e]=bd(r.vertex,r.fragment,t)),ve[e]}function l0(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let s=Po(e,r.vertex,!0);s=fd(e,s);const n=Po(i,r.fragment,!0);return{vertex:s,fragment:n}}function _d(r,t){return t.map(e=>(Ro.has(e)||Ro.set(e,u0++),Ro.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function bd(r,t,e){const i=Ao(r),s=Ao(t);return e.forEach(n=>{Eo(n.vertex,i,n.name),Eo(n.fragment,s,n.name)}),{vertex:wo(r,i),fragment:wo(t,s)}}const vd=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); var position = aPosition; var uv = aUV; {{start}} vColor = vec4(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,yd=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} return outColor * vColor; }; `,xd=` in vec2 aPosition; in vec2 aUV; out vec4 vColor; out vec2 vUV; {{header}} void main(void){ mat3 worldTransformMatrix = uWorldTransformMatrix; mat3 modelMatrix = mat3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); vec2 position = aPosition; vec2 uv = aUV; {{start}} vColor = vec4(1.); {{main}} vUV = uv; mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix; gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= uWorldColorAlpha; {{end}} } `,Td=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; } `,Sd={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},c0={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; vec4 uWorldColorAlpha; vec2 uResolution; }; `}},Ed={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};var h0=Object.defineProperty,Ad=Object.getOwnPropertySymbols,d0=Object.prototype.hasOwnProperty,p0=Object.prototype.propertyIsEnumerable,Pd=(r,t,e)=>t in r?h0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,f0=(r,t)=>{for(var e in t||(t={}))d0.call(t,e)&&Pd(r,e,t[e]);if(Ad)for(var e of Ad(t))p0.call(t,e)&&Pd(r,e,t[e]);return r};function Le({bits:r,name:t}){const e=md({template:{fragment:yd,vertex:vd},bits:[Sd,...r]});return vt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function $e({bits:r,name:t}){return new Mt(f0({name:t},gd({template:{vertex:xd,fragment:Td},bits:[Ed,...r]})))}const Di={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Ui={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Mo={};function m0(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` `)}function g0(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${m0(dt)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${g0(dt)} `}}),Mo[r]}const Co={};function _0(r){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},He={name:"round-pixels-bit",vertex:{header:` vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},wd=new Int32Array(dt);for(let r=0;r(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(yt||{}),b0=Object.defineProperty,Ni=Object.getOwnPropertySymbols,Rd=Object.prototype.hasOwnProperty,Md=Object.prototype.propertyIsEnumerable,Cd=(r,t,e)=>t in r?b0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v0=(r,t)=>{for(var e in t||(t={}))Rd.call(t,e)&&Cd(r,e,t[e]);if(Ni)for(var e of Ni(t))Md.call(t,e)&&Cd(r,e,t[e]);return r},y0=(r,t)=>{var e={};for(var i in r)Rd.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ni)for(var i of Ni(r))t.indexOf(i)<0&&Md.call(r,i)&&(e[i]=r[i]);return e};class xt extends pt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=yt.WEBGPU),i&&(o|=yt.WEBGL)),this.compatibleRenderers=o;const u={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const l in a)for(const c in a[l]){const h=a[l][c];u[h]={group:l,binding:c,name:h}}else if(e&&s&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c})}else if(n){if(e){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c})}else{a={},s={99:new Nt},this._ownedBindGroups.push(s[99]);let l=0;for(const c in n)u[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++}s={};for(const l in n){const c=l;let h=n[l];!h.source&&!h._resourceType&&(h=new nt(h));const p=u[c];p&&(s[p.group]||(s[p.group]=new Nt,this._ownedBindGroups.push(s[p.group])),s[p.group].setResource(h,p.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,u)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Nt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:i,gl:s}=e,n=y0(e,["gpu","gl"]);let o,a;return i&&(o=vt.from(i)),s&&(a=Mt.from(s)),new xt(v0({gpuProgram:o,glProgram:a},n))}}const Od={name:"local-uniform-msdf-bit",vertex:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32, uRound:f32, } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32 } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` outColor = vColor * calculateMSDFAlpha(outColor, localUniforms.uDistance); `}},Gd={name:"local-uniform-msdf-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; uniform float uRound; `,main:` vColor *= uColor; modelMatrix *= uTransformMatrix; `,end:` if(uRound == 1.) { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } `},fragment:{header:` uniform float uDistance; `,main:` outColor = vColor * calculateMSDFAlpha(outColor, uDistance); `}},Bd={name:"msdf-bit",fragment:{header:` fn calculateMSDFAlpha(msdfColor:vec4, distance:f32) -> f32 { // MSDF var median = msdfColor.r + msdfColor.g + msdfColor.b - min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - max(msdfColor.r, max(msdfColor.g, msdfColor.b)); // SDF median = min(median, msdfColor.a); var screenPxDistance = distance * (median - 0.5); var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); if (median < 0.01) { alpha = 0.0; } else if (median > 0.99) { alpha = 1.0; } return alpha; } `}},Id={name:"msdf-bit",fragment:{header:` float calculateMSDFAlpha(vec4 msdfColor, float distance) { // MSDF float median = msdfColor.r + msdfColor.g + msdfColor.b - min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - max(msdfColor.r, max(msdfColor.g, msdfColor.b)); // SDF median = min(median, msdfColor.a); float screenPxDistance = distance * (median - 0.5); float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); if (median < 0.01) { alpha = 0.0; } else if (median > 0.99) { alpha = 1.0; } return alpha; } `}};class Fd extends xt{constructor(){const t=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new G,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=Le({name:"sdf-shader",bits:[Di,ki(dt),Od,Bd,Ne]}),i=$e({name:"sdf-shader",bits:[Ui,Li(dt),Gd,Id,He]});super({glProgram:i,gpuProgram:e,resources:{localUniforms:t,batchSamplers:$i}})}}class Oo{constructor(t){this._gpuBitmapText={},this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Dd(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){W.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);Dd(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){var i;const{context:s}=e,n=Er.getFont(t.text,t._style);s.clear(),n.distanceField.type!=="none"&&(s.customShader||(this._sdfShader||(this._sdfShader=new Fd),s.customShader=this._sdfShader));const o=Array.from(t.text),a=t._style;let u=(((i=a._stroke)==null?void 0:i.width)||0)/2;u+=n.baseLineOffset;const l=go(o,a,n);let c=0;const h=a.padding,p=l.scale;s.translate(-t._anchor._x*l.width-h,-t._anchor._y*(l.height+l.offsetY)-h).scale(p,p);const f=a._fill.color;for(let m=0;m{this.destroyRenderable(t)}),this._gpuBitmapText[t.uid]}_updateDistanceField(t){var e;const i=this._getGpuBitmapText(t).context,s=t._style.fontFamily,n=q.get(`${s}-bitmap`),{a:o,b:a,c:u,d:l}=t.groupTransform,c=Math.sqrt(o*o+a*a),h=Math.sqrt(u*u+l*l),p=(Math.abs(c)+Math.abs(h))/2,f=n.baseRenderedFontSize/t._style.fontSize,m=(e=t.resolution)!=null?e:this._renderer.resolution,_=p*n.distanceField.range*(1/f)*m;i.customShader.resources.localUniforms.uniforms.uDistance=_}destroy(){var t;for(const e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,(t=this._sdfShader)==null||t.destroy(!0),this._sdfShader=null,this._renderer=null}}Oo.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"bitmapText"};function Dd(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}U.add(Oo,Vh,jh);class Go{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==i}addRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(e)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.htmlText.decreaseReferenceCount(e.currentKey),W.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),s=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t).catch(o=>{console.error(o)}),t._didTextUpdate=!1;const n=t._style.padding;lr(s.bounds,t._anchor,s.texture,n)}async _updateGpuText(t){var e;t._didTextUpdate=!1;const i=this._getGpuText(t);if(i.generatingTexture)return;const s=t._getKey();this._renderer.htmlText.decreaseReferenceCount(i.currentKey),i.generatingTexture=!0,i.currentKey=s;const n=(e=t.resolution)!=null?e:this._renderer.resolution,o=await this._renderer.htmlText.getManagedTexture(t.text,n,t._style,t._getKey()),a=i.batchableSprite;a.texture=i.texture=o,i.generatingTexture=!1,i.textureNeedsUploading=!0,t.onViewUpdate();const u=t._style.padding;lr(a.bounds,t._anchor,a.texture,u)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:P.EMPTY,currentKey:"--",batchableSprite:W.get(Ei),textureNeedsUploading:!1,generatingTexture:!1},i=e.batchableSprite;return i.renderable=t,i.texture=P.EMPTY,i.bounds={minX:0,maxX:1,minY:0,maxY:0},i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Go.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"htmlText"};function Ud(){const{userAgent:r}=z.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Bo="http://www.w3.org/2000/svg",Io="http://www.w3.org/1999/xhtml";class Fo{constructor(){this.svgRoot=document.createElementNS(Bo,"svg"),this.foreignObject=document.createElementNS(Bo,"foreignObject"),this.domElement=document.createElementNS(Io,"div"),this.styleElement=document.createElementNS(Io,"style"),this.image=new Image;const{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s)}}function kd(r){const t=r._stroke,e=r._fill,i=[`div { ${[`color: ${K.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-wrap: ${r.breakWords?"break-all":"break-word"}`,`max-width: ${r.wordWrapWidth}px`]:[],...t?[$d(t)]:[],...r.dropShadow?[Ld(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return x0(r.tagStyles,i),i.join(" ")}function Ld(r){const t=K.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),i=Math.round(Math.sin(r.angle)*r.distance),s=`${e}px ${i}px`;return r.blur>0?`text-shadow: ${s} ${r.blur}px ${t}`:`text-shadow: ${s} ${t}`}function $d(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${K.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${K.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const Nd={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"},Hd={fill:r=>`color: ${K.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:$d,dropShadow:Ld};function x0(r,t){for(const e in r){const i=r[e],s=[];for(const n in i)Hd[n]?s.push(Hd[n](i[n])):Nd[n]&&s.push(Nd[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${s.join(";")} }`)}}class ye extends Ft{constructor(t={}){var e,i;super(t),this._cssOverrides=[],(e=this.cssOverrides)!=null||(this.cssOverrides=t.cssOverrides),this.tagStyles=(i=t.tagStyles)!=null?i:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=ao(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new ye({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=kd(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}function Xd(r,t){const e=t.fontFamily,i=[],s={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(u){s[u]||(i.push(u),s[u]=!0)}if(Array.isArray(e))for(let u=0;u{const l=u.split(":")[1].trim();a(l)});for(const u in t.tagStyles){const l=t.tagStyles[u].fontFamily;a(l)}return i}async function zd(r){const t=await(await z.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,s)=>{e.onloadend=()=>i(e.result),e.onerror=s,e.readAsDataURL(t)})}async function Do(r,t){const e=await zd(t);return`@font-face { font-family: "${r.fontFamily}"; src: url('${e}'); font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; }`}const Ar=new Map;async function jd(r,t,e){const i=r.filter(s=>q.has(`${s}-and-url`)).map((s,n)=>{if(!Ar.has(s)){const{url:o}=q.get(`${s}-and-url`);n===0?Ar.set(s,Do(t,o)):Ar.set(s,Do({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:s},o))}return Ar.get(s)});return(await Promise.all(i)).join(` `)}function Vd(r,t,e,i,s){const{domElement:n,styleElement:o,svgRoot:a}=s;n.innerHTML=`
${r}
`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=i;const{width:u,height:l}=s.image;return a.setAttribute("width",u.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function Wd(r,t){const e=Ht.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),Ht.returnCanvasAndContext(e),e.canvas}function Yd(r,t,e){return new Promise(async i=>{e&&await new Promise(s=>setTimeout(s,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let Kd;function Uo(r,t,e,i){i=i||Kd||(Kd=new Fo);const{domElement:s,styleElement:n,svgRoot:o}=i;s.innerHTML=`
${r}
`,s.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const u=Ut.measureFont(t.fontStyle).descent;return{width:a.width,height:a.height+u}}class Hi{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===yt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,i,s){if(this._activeTextures[s])return this._increaseReferenceCount(s),this._activeTextures[s].promise;const n=this._buildTexturePromise(t,e,i).then(o=>(this._activeTextures[s].texture=o,o));return this._activeTextures[s]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,i){const s=W.get(Fo),n=Xd(t,i),o=await jd(n,i,ye.defaultTextStyle),a=Uo(t,i,o,s),u=Math.ceil(Math.ceil(Math.max(1,a.width)+i.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+i.padding*2)*e),c=s.image;c.width=u|0,c.height=l|0;const h=Vd(t,i,e,o,s);await Yd(c,h,Ud()&&n.length>0);let p=c;this._createCanvas&&(p=Wd(c,e));const f=lo(p,c.width,c.height,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),W.return(s),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(i=>{e.texture=i,this._cleanUp(e)}).catch(()=>{}),this._activeTextures[t]=null))}_cleanUp(t){ct.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}Hi.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"htmlText"},Hi.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"},U.add(Hi),U.add(Go);var T0=Object.defineProperty,qd=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,E0=Object.prototype.propertyIsEnumerable,Zd=(r,t,e)=>t in r?T0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qd=(r,t)=>{for(var e in t||(t={}))S0.call(t,e)&&Zd(r,e,t[e]);if(qd)for(var e of qd(t))E0.call(t,e)&&Zd(r,e,t[e]);return r};const Jd=class Ob extends Oe{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=Qd(Qd({},Ob.defaultOptions),i);const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=i.uvs||new Float32Array([0,0,1,0,1,1,0,1]),o=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit,u=new bt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:H.VERTEX|H.COPY_DST}),l=new bt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:H.VERTEX|H.COPY_DST}),c=new bt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:H.INDEX|H.COPY_DST});super({attributes:{aPosition:{buffer:u,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:l,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:i.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Jd.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Jt=Jd;var A0=Object.defineProperty,P0=Object.defineProperties,w0=Object.getOwnPropertyDescriptors,tp=Object.getOwnPropertySymbols,R0=Object.prototype.hasOwnProperty,M0=Object.prototype.propertyIsEnumerable,ep=(r,t,e)=>t in r?A0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rp=(r,t)=>{for(var e in t||(t={}))R0.call(t,e)&&ep(r,e,t[e]);if(tp)for(var e of tp(t))M0.call(t,e)&&ep(r,e,t[e]);return r},ip=(r,t)=>P0(r,w0(t));const Xe={name:"local-uniform-bit",vertex:{header:` struct LocalUniforms { uTransformMatrix:mat3x3, uColor:vec4, uRound:f32, } @group(1) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `}},sp=ip(rp({},Xe),{vertex:ip(rp({},Xe.vertex),{header:Xe.vertex.header.replace("group(1)","group(2)")})}),Xi={name:"local-uniform-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; uniform float uRound; `,main:` vColor *= uColor; modelMatrix = uTransformMatrix; `,end:` if(uRound == 1.) { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } `}},np={name:"tiling-bit",vertex:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy; position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy; `},fragment:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV); coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy; var unclamped = coord; coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw); var bias = 0.; if(unclamped.x == coord.x && unclamped.y == coord.y) { bias = -32.; } outColor = textureSampleBias(uTexture, uSampler, coord, bias); `}},op={name:"tiling-bit",vertex:{header:` uniform mat3 uTextureTransform; uniform vec4 uSizeAnchor; `,main:` uv = (uTextureTransform * vec3(aUV, 1.0)).xy; position = (position - uSizeAnchor.zw) * uSizeAnchor.xy; `},fragment:{header:` uniform sampler2D uTexture; uniform mat3 uMapCoord; uniform vec4 uClampFrame; uniform vec2 uClampOffset; `,main:` vec2 coord = vUV + ceil(uClampOffset - vUV); coord = (uMapCoord * vec3(coord, 1.0)).xy; vec2 unclamped = coord; coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0 `}};let ko,Lo;class ap extends xt{constructor(){ko!=null||(ko=Le({name:"tiling-sprite-shader",bits:[Xe,np,Ne]})),Lo!=null||(Lo=$e({name:"tiling-sprite-shader",bits:[Xi,op,He]}));const t=new nt({uMapCoord:{value:new G,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new G,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:Lo,gpuProgram:ko,resources:{localUniforms:new nt({uTransformMatrix:{value:new G,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:P.EMPTY.source,uSampler:P.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,o){const a=this.resources.tilingUniforms,u=o.width,l=o.height,c=o.textureMatrix,h=a.uniforms.uTextureTransform;h.set(i.a*u/t,i.b*u/e,i.c*l/t,i.d*l/e,i.tx/t,i.ty/e),h.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=h,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class up extends Jt{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 lp(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 cp(r,t,e,i){let s=0;const n=r.length/(t||2),o=i.a,a=i.b,u=i.c,l=i.d,c=i.tx,h=i.ty;for(e*=t;s{this.destroyRenderable(t)}),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),hp(t,i.uvs),lp(t,i.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===yt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}$o.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"tilingSprite"},U.add($o);var C0=Object.defineProperty,dp=Object.getOwnPropertySymbols,O0=Object.prototype.hasOwnProperty,G0=Object.prototype.propertyIsEnumerable,pp=(r,t,e)=>t in r?C0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fp=(r,t)=>{for(var e in t||(t={}))O0.call(t,e)&&pp(r,e,t[e]);if(dp)for(var e of dp(t))G0.call(t,e)&&pp(r,e,t[e]);return r};const mp=class Gb extends Jt{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,s,n;t=fp(fp({},Gb.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(s=this.width)!=null?s:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],u=[],l=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let _=0;_t in r?B0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bp=(r,t)=>{for(var e in t||(t={}))I0.call(t,e)&&_p(r,e,t[e]);if(gp)for(var e of gp(t))F0.call(t,e)&&_p(r,e,t[e]);return r};const vp=class Bb extends No{constructor(t={}){t=bp(bp({},Bb.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,i,s,n,o,a,u,l;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(s=t.originalWidth)!=null?s:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(u=t.topHeight)!=null?u:this._topHeight,this._bottomHeight=(l=t.bottomHeight)!=null?l:this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,i=this.width>e?1:this.width/e,s=this._topHeight+this._bottomHeight,n=this.height>s?1:this.height/s,o=Math.min(i,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*o,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*o,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*o,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*o,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};vp.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let te=vp;class Ho{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,i=this._getGpuSprite(t);return i.texture._source!==e._source?!i.batcher.checkAndUpdateTexture(i,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];W.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Si;return e.geometry=new te,e.mesh=t,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}Ho.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"nineSliceSprite"},U.add(Ho);class Xo{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}}Xo.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"filter"};const D0=new G;function yp(r,t){return t.clear(),zo(r,t),t.isValid||t.set(0,0,0,0),r.renderGroup?t.applyMatrix(r.renderGroup.localTransform):t.applyMatrix(r.parentRenderGroup.worldTransform),t}function zo(r,t){if(r.localDisplayStatus!==7||!r.measurable)return;const e=!!r.effects.length;let i=t;if((r.renderGroup||e)&&(i=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,r.worldTransform);else{if(r.renderPipeId){const n=r.bounds;i.addFrame(n.minX,n.minY,n.maxX,n.maxY,r.groupTransform)}const s=r.children;for(let n=0;n"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Nt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var e,i;const s=this.renderer,n=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const o=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,n.length===0){o.skip=!0;return}const a=o.bounds;t.renderables?xp(t.renderables,a):t.filterEffect.filterArea?(a.clear(),a.addRect(t.filterEffect.filterArea),a.applyMatrix(t.container.worldTransform)):yp(t.container,a);const u=s.renderTarget.rootRenderTarget.colorTexture.source;let l=u._resolution,c=0,h=u.antialias,p=!1,f=!1;for(let _=0;_0?this._filterStack[this._filterStackIndex-1].bounds:null,u=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(u,s,a)}e.backTexture=n;const o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),o.length===1)o[0].apply(this,i,e.previousRenderSurface,!1),ct.returnTexture(i);else{let a=e.inputTexture,u=ct.getOptimalTexture(s.width,s.height,a.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[h].skip;)--h;h>0&&(c=this._filterStack[h].inputTexture.source._resolution);const p=this._filterGlobalUniforms,f=p.uniforms,m=f.uOutputFrame,_=f.uInputSize,g=f.uInputPixel,b=f.uInputClamp,v=f.uGlobalFrame,y=f.uOutputTexture;if(l){let R=this._filterStackIndex;for(;R>0;){R--;const w=this._filterStack[this._filterStackIndex-1];if(!w.skip){u.x=w.bounds.minX,u.y=w.bounds.minY;break}}m[0]=a.minX-u.x,m[1]=a.minY-u.y}else m[0]=0,m[1]=0;m[2]=e.frame.width,m[3]=e.frame.height,_[0]=e.source.width,_[1]=e.source.height,_[2]=1/_[0],_[3]=1/_[1],g[0]=e.source.pixelWidth,g[1]=e.source.pixelHeight,g[2]=1/g[0],g[3]=1/g[1],b[0]=.5*g[2],b[1]=.5*g[3],b[2]=e.frame.width*_[2]-.5*g[2],b[3]=e.frame.height*_[3]-.5*g[3];const T=this.renderer.renderTarget.rootRenderTarget.colorTexture;v[0]=u.x*c,v[1]=u.y*c,v[2]=T.source.width*c,v[3]=T.source.height*c;const E=this.renderer.renderTarget.getRenderTarget(i);if(n.renderTarget.bind(i,!!s),i instanceof P?(y[0]=i.frame.width,y[1]=i.frame.height):(y[0]=E.width,y[1]=E.height),y[2]=E.isRoot?-1:1,p.update(),n.renderPipes.uniformBatch){const R=n.renderPipes.uniformBatch.getUboResource(p);this._globalFilterBindGroup.setResource(R,0)}else this._globalFilterBindGroup.setResource(p,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:U0,shader:t,state:t._state,topology:"triangle-list"}),n.type===yt.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new lt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(G.shared);return n.invert(),s.prepend(n),s.scale(1/e.texture.frame.width,1/e.texture.frame.height),s.translate(e.anchor.x,e.anchor.y),s}}jo.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"filter"},U.add(jo),U.add(Xo);var k0={__proto__:null};const Vo=[];U.handleByNamedList(x.Environment,Vo);async function Tp(r){if(r)for(let t=0;t(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))(mt||{});class Yo{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,u){const{name:l,items:c}=this;for(let h=0,p=c.length;ht in r?L0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ji=(r,t)=>{for(var e in t||(t={}))$0.call(t,e)&&Ep(r,e,t[e]);if(Sp)for(var e of Sp(t))N0.call(t,e)&&Ep(r,e,t[e]);return r};const H0=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Ap=class Ib extends pt{constructor(t){var e;super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name;const i=[...H0,...(e=t.runners)!=null?e:[]];this._addRunners(...i),this._addSystems(t.systems),this._addPipes(t.renderPipes,t.renderPipeAdaptors),this._unsafeEvalCheck()}async init(t={}){for(const e in this._systemsHash){const i=this._systemsHash[e].constructor.defaultOptions;t=ji(ji({},i),t)}t=ji(ji({},Ib.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let e=0;e{this.runners[e]=new Yo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Wo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Ap.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let wr=Ap,Ko;function Rr(r){return Ko!==void 0||(Ko=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:wr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!z.get().getWebGLRenderingContext())return!1;let i=z.get().createCanvas().getContext("webgl",e);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch(i){return!1}})()),Ko}let qo;async function Mr(r={}){return qo!==void 0||(qo=await(async()=>{if(!z.get().getNavigator().gpu)return!1;try{return await(await navigator.gpu.requestAdapter(r)).requestDevice(),!0}catch(t){return!1}})()),qo}var X0=Object.defineProperty,Pp=Object.getOwnPropertySymbols,z0=Object.prototype.hasOwnProperty,j0=Object.prototype.propertyIsEnumerable,wp=(r,t,e)=>t in r?X0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cr=(r,t)=>{for(var e in t||(t={}))z0.call(t,e)&&wp(r,e,t[e]);if(Pp)for(var e of Pp(t))j0.call(t,e)&&wp(r,e,t[e]);return r};const Rp=["webgl","webgpu","canvas"];async function Mp(r){var t,e;let i=[];r.preference?(i.push(r.preference),Rp.forEach(a=>{a!==r.preference&&i.push(a)})):i=Rp.slice();let s;await Tp((t=r.manageImports)!=null?t:!0);let n={};for(let a=0;at in r?V0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,K0=(r,t)=>{for(var e in t||(t={}))W0.call(t,e)&&Op(r,e,t[e]);if(Cp)for(var e of Cp(t))Y0.call(t,e)&&Op(r,e,t[e]);return r};const Gp=class Ju{constructor(...t){this.stage=new Y}async init(t){t=K0({},t),this.renderer=await Mp(t),Ju._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Ju._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Gp._plugins=[];let Bp=Gp;U.handleByList(x.Application,Bp._plugins);class Ip{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;iArray.isArray(r)&&r.every(t=>t instanceof P),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};async function Zo(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 Dp={extension:{type:x.DetectionParser,priority:1},test:async()=>Zo("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Up=["png","jpg","jpeg"],kp={extension:{type:x.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Up],remove:async r=>r.filter(t=>!Up.includes(t))},q0="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Vi(r){return q0?!1:document.createElement("video").canPlayType(r)!==""}const Lp={extension:{type:x.DetectionParser,priority:0},test:async()=>Vi("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},$p={extension:{type:x.DetectionParser,priority:0},test:async()=>Vi("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Np={extension:{type:x.DetectionParser,priority:0},test:async()=>Vi("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Hp={extension:{type:x.DetectionParser,priority:0},test:async()=>Zo("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var Z0=Object.defineProperty,Q0=Object.defineProperties,J0=Object.getOwnPropertyDescriptors,Xp=Object.getOwnPropertySymbols,t1=Object.prototype.hasOwnProperty,e1=Object.prototype.propertyIsEnumerable,zp=(r,t,e)=>t in r?Z0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,r1=(r,t)=>{for(var e in t||(t={}))t1.call(t,e)&&zp(r,e,t[e]);if(Xp)for(var e of Xp(t))e1.call(t,e)&&zp(r,e,t[e]);return r},i1=(r,t)=>Q0(r,J0(t));class jp{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var s,n;let o=null,a=null;if(e.loadParser&&(a=this._parserHash[e.loadParser]),!a){for(let u=0;u({alias:[l],src:l})),a=o.length,u=o.map(async l=>{const c=ft.toAbsolute(l.src);if(!s[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),s[l.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(h){throw delete this.promiseCache[c],delete s[l.src],new Error(`[Loader.load] Failed to load ${c}. ${h}`)}});return await Promise.all(u),n?s[o[0].src]:s}async unload(t){const e=Rt(t,i=>({alias:[i],src:i})).map(async i=>{var s,n;const o=ft.toAbsolute(i.src),a=this.promiseCache[o];if(a){const u=await a.promise;delete this.promiseCache[o],await((n=(s=a.parser)==null?void 0:s.unload)==null?void 0:n.call(s,u,i,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name&&t[e.name],i1(r1({},t),{[e.name]:e})),{})}}function xe(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 Ct(r,t){const e=r.split("?")[0],i=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const s1=".json",n1="application/json",Vp={extension:{type:x.LoadParser,priority:_t.Low},name:"loadJson",test(r){return xe(r,n1)||Ct(r,s1)},async load(r){return await(await z.get().fetch(r)).json()}},o1=".txt",a1="text/plain",Wp={name:"loadTxt",extension:{type:x.LoadParser,priority:_t.Low},test(r){return xe(r,a1)||Ct(r,o1)},async load(r){return await(await z.get().fetch(r)).text()}};var u1=Object.defineProperty,l1=Object.defineProperties,c1=Object.getOwnPropertyDescriptors,Yp=Object.getOwnPropertySymbols,h1=Object.prototype.hasOwnProperty,d1=Object.prototype.propertyIsEnumerable,Kp=(r,t,e)=>t in r?u1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,p1=(r,t)=>{for(var e in t||(t={}))h1.call(t,e)&&Kp(r,e,t[e]);if(Yp)for(var e of Yp(t))d1.call(t,e)&&Kp(r,e,t[e]);return r},f1=(r,t)=>l1(r,c1(t));const m1=["normal","bold","100","200","300","400","500","600","700","800","900"],g1=[".ttf",".otf",".woff",".woff2"],_1=["font/ttf","font/otf","font/woff","font/woff2"],b1=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function qp(r){const t=ft.extname(r),e=ft.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(b1)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const v1=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function y1(r){return v1.test(r)?r:encodeURI(r)}const Zp={extension:{type:x.LoadParser,priority:_t.Low},name:"loadWebFont",test(r){return xe(r,_1)||Ct(r,g1)},async load(r,t){var e,i,s,n,o,a;const u=z.get().getFontFaceSet();if(u){const l=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:qp(r),h=(o=(n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(f=>m1.includes(f)))!=null?o:["normal"],p=(a=t.data)!=null?a:{};for(let f=0;f{q.remove(t.family),z.get().getFontFaceSet().delete(t)})}};function Wi(r,t=1){var e;const i=(e=qt.RETINA_PREFIX)==null?void 0:e.exec(r);return i?parseFloat(i[1]):t}function ee(r,t,e){r.label=e,r._sourceOrigin=e;const i=new P({source:r,label:e}),s=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&s()}),i.once("destroy",()=>{r.destroyed||s()}),i}var x1=Object.defineProperty,Yi=Object.getOwnPropertySymbols,Qp=Object.prototype.hasOwnProperty,Jp=Object.prototype.propertyIsEnumerable,tf=(r,t,e)=>t in r?x1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,T1=(r,t)=>{for(var e in t||(t={}))Qp.call(t,e)&&tf(r,e,t[e]);if(Yi)for(var e of Yi(t))Jp.call(t,e)&&tf(r,e,t[e]);return r},S1=(r,t)=>{var e={};for(var i in r)Qp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Yi)for(var i of Yi(r))t.indexOf(i)<0&&Jp.call(r,i)&&(e[i]=r[i]);return e};const E1=".svg",A1="image/svg+xml",ef={extension:{type:x.LoadParser,priority:_t.Low},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return xe(r,A1)||Ct(r,E1)},async load(r,t,e){var i;return((i=t.data.parseAsGraphicsContext)!=null?i:this.config.parseAsGraphicsContext)?w1(r):P1(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function P1(r,t,e,i){var s,n,o,a,u;const l=await(await z.get().fetch(r)).blob(),c=URL.createObjectURL(l),h=new Image;h.src=c,h.crossOrigin=i,await h.decode(),URL.revokeObjectURL(c);const p=document.createElement("canvas"),f=p.getContext("2d"),m=((s=t.data)==null?void 0:s.resolution)||Wi(r),_=(o=(n=t.data)==null?void 0:n.width)!=null?o:h.width,g=(u=(a=t.data)==null?void 0:a.height)!=null?u:h.height;p.width=_*m,p.height=g*m,f.drawImage(h,0,0,_*m,g*m);const b=t.data,{parseAsGraphicsContext:v}=b,y=S1(b,["parseAsGraphicsContext"]),T=new pe(T1({resource:p,alphaMode:"premultiply-alpha-on-upload",resolution:m},y));return ee(T,e,r)}async function w1(r){const t=await(await z.get().fetch(r)).text(),e=new It;return e.svg(t),e}const R1=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})(); `;let ze=null,Qo=class{constructor(){ze||(ze=URL.createObjectURL(new Blob([R1],{type:"application/javascript"}))),this.worker=new Worker(ze)}};Qo.revokeObjectURL=function(){ze&&(URL.revokeObjectURL(ze),ze=null)};const M1='(function(){"use strict";async function e(t){const a=await fetch(t);if(!a.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${t}: ${a.status} ${a.statusText}`);const s=await a.blob();return await createImageBitmap(s)}self.onmessage=async t=>{try{const a=await e(t.data.data[0]);self.postMessage({data:a,uuid:t.data.uuid,id:t.data.id},[a])}catch(a){self.postMessage({error:a,uuid:t.data.uuid,id:t.data.id})}}})();\n';let je=null,rf=class{constructor(){je||(je=URL.createObjectURL(new Blob([M1],{type:"application/javascript"}))),this.worker=new Worker(je)}};rf.revokeObjectURL=function(){je&&(URL.revokeObjectURL(je),je=null)};let sf=0,Jo,C1=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 Qo;e.addEventListener("message",i=>{e.terminate(),Qo.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Jo===void 0&&(Jo=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[sf]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:sf++,id:i})}};const ta=new C1;var O1=Object.defineProperty,nf=Object.getOwnPropertySymbols,G1=Object.prototype.hasOwnProperty,B1=Object.prototype.propertyIsEnumerable,of=(r,t,e)=>t in r?O1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,I1=(r,t)=>{for(var e in t||(t={}))G1.call(t,e)&&of(r,e,t[e]);if(nf)for(var e of nf(t))B1.call(t,e)&&of(r,e,t[e]);return r};const F1=[".jpeg",".jpg",".png",".webp",".avif"],D1=["image/jpeg","image/png","image/webp","image/avif"];async function af(r){const t=await z.get().fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const ea={name:"loadTextures",extension:{type:x.LoadParser,priority:_t.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return xe(r,D1)||Ct(r,F1)},async load(r,t,e){var i;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ta.isImageBitmapSupported()?s=await ta.loadImageBitmap(r):s=await af(r):s=await new Promise(o=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):s.onload=()=>{o(s)}});const n=new pe(I1({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||Wi(r)},t.data));return ee(n,e,r)},unload(r){r.destroy(!0)}};var U1=Object.defineProperty,k1=Object.defineProperties,L1=Object.getOwnPropertyDescriptors,uf=Object.getOwnPropertySymbols,$1=Object.prototype.hasOwnProperty,N1=Object.prototype.propertyIsEnumerable,lf=(r,t,e)=>t in r?U1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ra=(r,t)=>{for(var e in t||(t={}))$1.call(t,e)&&lf(r,e,t[e]);if(uf)for(var e of uf(t))N1.call(t,e)&&lf(r,e,t[e]);return r},cf=(r,t)=>k1(r,L1(t));const hf=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],H1=hf.map(r=>`video/${r.substring(1)}`);function df(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=ff(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function pf(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),t()}function s(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function ff(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const mf={name:"loadVideo",extension:{type:x.LoadParser},config:null,test(r){const t=xe(r,H1),e=Ct(r,hf);return t||e},async load(r,t,e){var i,s;const n=ra(cf(ra({},cr.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||Wi(r),alphaMode:((s=t.data)==null?void 0:s.alphaMode)||await gn()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(c=>{const h=a[c];h!==void 0&&o.setAttribute(c,h)}),n.muted===!0&&(o.muted=!0),df(o,r,n.crossorigin);const u=document.createElement("source");let l;if(r.startsWith("data:"))l=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();l=cr.MIME_TYPES[c]||`video/${c}`}return u.src=r,l&&(u.type=l),new Promise(c=>{const h=async()=>{const p=new cr(cf(ra({},n),{resource:o}));o.removeEventListener("canplay",h),t.data.preload&&await pf(o),c(ee(p,e,r))};o.addEventListener("canplay",h),o.appendChild(u)})},unload(r){r.destroy(!0)}},ia={extension:x.ResolveParser,test:ea.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=qt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},gf={extension:x.ResolveParser,test:r=>qt.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:ia.parse};class _f{constructor(){this._detections=[],this._initialized=!1,this.resolver=new qt,this.loader=new jp,this.cache=q,this._backgroundLoader=new Ip(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,s;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let u=t.manifest;typeof u=="string"&&(u=await this.load(u)),this.resolver.addManifest(u)}const n=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(s=t.texturePreference)==null?void 0:s.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=ur(t),s=Rt(t).map(a=>{if(typeof a!="string"){const u=this.resolver.getAlias(a);return u.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(u)?u[0]:u}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,u=0;const l=()=>{e==null||e(++a/u)},c=o.map(h=>{const p=s[h];return u+=Object.keys(p).length,this._mapLoadToResolve(p,l).then(f=>{n[h]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return q.get(t);const e={};for(let i=0;i{const a=s[o.src],u=[o.src];o.alias&&u.push(...o.alias),u.forEach(l=>{n[l]=a}),q.set(u,a)}),n}async unload(t){this._initialized||await this.init();const e=Rt(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Rt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{q.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Or=new _f;U.handleByList(x.LoadParser,Or.loader.parsers).handleByList(x.ResolveParser,Or.resolver.parsers).handleByList(x.CacheParser,Or.cache.parsers).handleByList(x.DetectionParser,Or.detections),U.add(Fp,kp,Dp,Hp,Lp,$p,Np,Vp,Wp,Zp,ef,ea,mf,ia,gf);const bf={loader:x.LoadParser,resolver:x.ResolveParser,cache:x.CacheParser,detection:x.DetectionParser};U.handle(x.Asset,r=>{const t=r.ref;Object.entries(bf).filter(([e])=>!!t[e]).forEach(([e,i])=>{var s;return U.add(Object.assign(t[e],{extension:(s=t[e].extension)!=null?s:i}))})},r=>{const t=r.ref;Object.keys(bf).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))});const X1={extension:{type:x.DetectionParser,priority:3},test:async()=>!!(await Mr()||Rr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class Gr extends rt{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let Ki;function sa(){if(Ki)return Ki;const r=document.createElement("canvas").getContext("webgl");return r?(Ki=[...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"]:[]],Ki):[]}let qi;async function na(){if(qi)return qi;const r=await navigator.gpu.requestAdapter();return qi=[...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"]:[]],qi}let oa;async function aa(){return oa!==void 0||(oa=await(async()=>{const r=await Mr(),t=Rr();if(r&&t){const e=await na(),i=sa();return e.filter(s=>i.includes(s))}else{if(r)return await na();if(t)return sa()}return[]})()),oa}const vf=["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 Zi;async function Br(){if(Zi!==void 0)return Zi;const r=await aa();return Zi=[...vf,...r],Zi}const z1='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)}})();\n';let Ve=null,yf=class{constructor(){Ve||(Ve=URL.createObjectURL(new Blob([z1],{type:"application/javascript"}))),this.worker=new Worker(Ve)}};yf.revokeObjectURL=function(){Ve&&(URL.revokeObjectURL(Ve),Ve=null)};const Qi={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function j1(r){Object.assign(Qi,r)}let Ir;const xf={};function V1(r){return Ir||(Ir=new yf().worker,Ir.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load Basis texture",i),xf[i](s)},Ir.postMessage({type:"init",jsUrl:Qi.jsUrl,wasmUrl:Qi.wasmUrl,supportedTextures:r})),Ir}function Tf(r,t){const e=V1(t);return new Promise(i=>{xf[r]=i,e.postMessage({type:"load",url:r})})}const W1={extension:{type:x.LoadParser,priority:_t.High},name:"loadBasis",test(r){return Ct(r,[".basis"])},async load(r,t,e){const i=await Br(),s=await Tf(r,i),n=new Gr(s);return ee(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function Y1(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const s=[];for(let n=0;n(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))(Sf||{}),Ef=(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))(Ef||{});function ut(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Tt=(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=ut("UYVY")]="UYVY",r[r.R8G8_B8G8=ut("RGBG")]="R8G8_B8G8",r[r.YUY2=ut("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=ut("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=ut("DXT1")]="DXT1",r[r.DXT2=ut("DXT2")]="DXT2",r[r.DXT3=ut("DXT3")]="DXT3",r[r.DXT4=ut("DXT4")]="DXT4",r[r.DXT5=ut("DXT5")]="DXT5",r[r.ATI1=ut("ATI1")]="ATI1",r[r.AT1N=ut("AT1N")]="AT1N",r[r.ATI2=ut("ATI2")]="ATI2",r[r.AT2N=ut("AT2N")]="AT2N",r[r.BC4U=ut("BC4U")]="BC4U",r[r.BC4S=ut("BC4S")]="BC4S",r[r.BC5U=ut("BC5U")]="BC5U",r[r.BC5S=ut("BC5S")]="BC5S",r[r.DX10=ut("DX10")]="DX10",r))(Tt||{});const ua={[Tt.DXT1]:"bc1-rgba-unorm",[Tt.DXT2]:"bc2-rgba-unorm",[Tt.DXT3]:"bc2-rgba-unorm",[Tt.DXT4]:"bc3-rgba-unorm",[Tt.DXT5]:"bc3-rgba-unorm",[Tt.ATI1]:"bc4-r-unorm",[Tt.BC4U]:"bc4-r-unorm",[Tt.BC4S]:"bc4-r-snorm",[Tt.ATI2]:"bc5-rg-unorm",[Tt.BC5U]:"bc5-rg-unorm",[Tt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},gt={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},F={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:Z1,HEADER_DX10_FIELDS:Q1,DXGI_FORMAT:Sf,D3D10_RESOURCE_DIMENSION:Ef,D3DFMT:Tt},Af={"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 Pf(r,t){const{format:e,fourCC:i,width:s,height:n,dataOffset:o,mipmapCount:a}=tT(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:s,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const u=J1(e,s,n,o,a,r);return{format:e,width:s,height:n,resource:u,alphaMode:"no-premultiply-alpha"}}function J1(r,t,e,i,s,n){const o=[],a=Af[r];let u=t,l=e,c=i;for(let h=0;h>1,1),l=Math.max(l>>1,1)}return o}function tT(r){const t=new Uint32Array(r,0,F.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[F.HEADER_FIELDS.MAGIC]!==F.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[F.HEADER_FIELDS.HEIGHT],i=t[F.HEADER_FIELDS.WIDTH],s=Math.max(1,t[F.HEADER_FIELDS.MIPMAP_COUNT]),n=t[F.HEADER_FIELDS.PF_FLAGS],o=t[F.HEADER_FIELDS.FOURCC],a=eT(t,n,o,r),u=F.MAGIC_SIZE+F.HEADER_SIZE+(o===F.D3DFMT.DX10?F.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:i,height:e,dataOffset:u,mipmapCount:s}}function eT(r,t,e,i){if(t&F.PIXEL_FORMAT_FLAGS.FOURCC){if(e===F.D3DFMT.DX10){const s=new Uint32Array(i,F.MAGIC_SIZE+F.HEADER_SIZE,F.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(s[F.HEADER_DX10_FIELDS.MISC_FLAG]===F.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(s[F.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===F.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=s[F.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in gt)return gt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in ua)return ua[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&F.PIXEL_FORMAT_FLAGS.RGB||t&F.PIXEL_FORMAT_FLAGS.RGBA)return rT(r);throw t&F.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&F.PIXEL_FORMAT_FLAGS.LUMINANCE||t&F.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&F.PIXEL_FORMAT_FLAGS.ALPHA||t&F.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function rT(r){const t=r[F.HEADER_FIELDS.RGB_BITCOUNT],e=r[F.HEADER_FIELDS.R_BIT_MASK],i=r[F.HEADER_FIELDS.G_BIT_MASK],s=r[F.HEADER_FIELDS.B_BIT_MASK],n=r[F.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&s===16711680&&n===4278190080)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&s===255&&n===4278190080)return gt[F.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&s===1023&&n===3221225472)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&s===0&&n===0)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&s===0&&n===0)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&s===31&&n===32768)return gt[F.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&s===31&&n===0)return gt[F.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&s===15&&n===61440)return gt[F.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&s===0&&n===65280)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&s===0&&n===0)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&s===0&&n===0)return gt[F.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${n}`)}const iT={extension:{type:x.LoadParser,priority:_t.High},name:"loadDDS",test(r){return Ct(r,[".dds"])},async load(r,t,e){const i=await Br(),s=await(await fetch(r)).arrayBuffer(),n=Pf(s,i),o=new Gr(n);return ee(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var wf=(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))(wf||{}),sT=(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))(sT||{}),nT=(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))(nT||{});const et={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 Rf(r,t){const e=new DataView(r);if(!lT(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:s,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:u,numberOfMipmapLevels:l,offset:c}=uT(e),h=et.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!h)throw new Error(`Unknown texture format ${o}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=aT(s,n,o),f=oT(e,s,p,a,u,c,l,i);return{format:h,width:a,height:u,resource:f,alphaMode:"no-premultiply-alpha"}}function oT(r,t,e,i,s,n,o,a){const u=i+3&-4,l=s+3&-4;let c=i*s;t===0&&(c=u*l);let h=c*e,p=i,f=s,m=u,_=l,g=n;const b=new Array(o);for(let v=0;v>1||1,f=f>>1||1,m=p+4-1&-4,_=f+4-1&-4,h=m*_*e}return b}function aT(r,t,e){let i=et.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(et.TYPES_TO_BYTES_PER_COMPONENT[r]?i=et.TYPES_TO_BYTES_PER_COMPONENT[r]*et.FORMATS_TO_COMPONENTS[t]:i=et.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 uT(r){const t=r.getUint32(et.FIELDS.ENDIANNESS,!0)===et.ENDIANNESS,e=r.getUint32(et.FIELDS.GL_TYPE,t),i=r.getUint32(et.FIELDS.GL_FORMAT,t),s=r.getUint32(et.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(et.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(et.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(et.FIELDS.PIXEL_DEPTH,t)||1,u=r.getUint32(et.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,l=r.getUint32(et.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(et.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(et.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(l!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:s,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:c,offset:et.FILE_HEADER_SIZE+h}}function lT(r){for(let t=0;tt.destroy(!0)):r.destroy(!0)}},hT='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=y(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=async r=>{var t;const n=r.data,o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}})();\n';let We=null;class Mf{constructor(){We||(We=URL.createObjectURL(new Blob([hT],{type:"application/javascript"}))),this.worker=new Worker(We)}}Mf.revokeObjectURL=function(){We&&(URL.revokeObjectURL(We),We=null)};const Ji={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function dT(r){Object.assign(Ji,r)}let Fr;const Cf={};function pT(r){return Fr||(Fr=new Mf().worker,Fr.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load KTX texture",i),Cf[i](s)},Fr.postMessage({type:"init",jsUrl:Ji.jsUrl,wasmUrl:Ji.wasmUrl,supportedTextures:r})),Fr}function Of(r,t){const e=pT(t);return new Promise(i=>{Cf[r]=i,e.postMessage({type:"load",url:r})})}const fT={extension:{type:x.LoadParser,priority:_t.High},name:"loadKTX2",test(r){return Ct(r,".ktx2")},async load(r,t,e){const i=await Br(),s=await Of(r,i),n=new Gr(s);return ee(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},la={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:Gf},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:Gf}};function mT(r){const t=r.format;if(la[t]){const e=la[t].convertFunction,i=r.resource;for(let s=0;sCt(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const s=r.split(".");if(s.length>2){const n=s[s.length-2];ts.includes(n)&&(i=n)}else i=s[s.length-1];return{resolution:parseFloat((e=(t=qt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let es;const ST={extension:{type:x.DetectionParser,priority:2},test:async()=>!!(await Mr()||Rr()),add:async r=>{const t=await aa();return es=ET(t),[...es,...r]},remove:async r=>es?r.filter(t=>!(t in es)):r};function ET(r){const t=["basis"],e={};return r.forEach(i=>{const s=i.split("-")[0];s&&!e[s]&&(e[s]=!0,t.push(s))}),t.sort((i,s)=>{const n=ts.indexOf(i),o=ts.indexOf(s);return n===-1?1:o===-1?-1:n-o}),t}const AT=new lt,ca=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){var s;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(s=t.cullArea)!=null?s:rr(t,i,AT);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)}if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{Ff.shared.cull(this.stage,this.renderer.screen),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}Df.extension={priority:10,type:x.Application,name:"culler"};const PT={extension:{type:x.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return k0})}};var wT=Object.defineProperty,rs=Object.getOwnPropertySymbols,Uf=Object.prototype.hasOwnProperty,kf=Object.prototype.propertyIsEnumerable,Lf=(r,t,e)=>t in r?wT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ha=(r,t)=>{for(var e in t||(t={}))Uf.call(t,e)&&Lf(r,e,t[e]);if(rs)for(var e of rs(t))kf.call(t,e)&&Lf(r,e,t[e]);return r},RT=(r,t)=>{var e={};for(var i in r)Uf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&rs)for(var i of rs(r))t.indexOf(i)<0&&kf.call(r,i)&&(e[i]=r[i]);return e};const $f=class tl extends xt{constructor(t){t=ha(ha({},tl.defaultOptions),t),super(t),this.enabled=!0,this._state=Bt.for2d(),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.addResource("uTexture",0,1)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:s}=e,n=RT(e,["gpu","gl"]);let o,a;return i&&(o=vt.from(i)),s&&(a=Mt.from(s)),new tl(ha({gpuProgram:o,glProgram:a},n))}};$f.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let Kt=$f;var Nf=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uBlend; uniform sampler2D uTexture; uniform sampler2D uBackTexture; {FUNCTIONS} void main() { vec4 back = texture(uBackTexture, vTextureCoord); vec4 front = texture(uTexture, vTextureCoord); {MAIN} } `,Hf=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 backgroundUv; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } `,Xf=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlendUniforms { uBlend:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(0) @binding(3) var uBackTexture: texture_2d; @group(1) @binding(0) var blendUniforms : BlendUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } {FUNCTIONS} @fragment fn mainFragment( @location(0) uv: vec2 ) -> @location(0) vec4 { var back = textureSample(uBackTexture, uSampler, uv); var front = textureSample(uTexture, uSampler, uv); var out = vec4(0.0,0.0,0.0,0.0); {MAIN} return out; }`,MT=Object.defineProperty,zf=Object.getOwnPropertySymbols,CT=Object.prototype.hasOwnProperty,OT=Object.prototype.propertyIsEnumerable,jf=(r,t,e)=>t in r?MT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vf=(r,t)=>{for(var e in t||(t={}))CT.call(t,e)&&jf(r,e,t[e]);if(zf)for(var e of zf(t))OT.call(t,e)&&jf(r,e,t[e]);return r};class GT extends Kt{constructor(t){const e=t.gpu,i=Wf(Vf({source:Xf},e)),s=vt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),n=t.gl,o=Wf(Vf({source:Nf},n)),a=Mt.from({vertex:Hf,fragment:o}),u=new nt({uBlend:{value:1,type:"f32"}});super({gpuProgram:s,glProgram:a,blendRequired:!0,resources:{blendUniforms:u,uBackTexture:P.EMPTY}})}}function Wf(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const BT=` float getLuminosity(vec3 c) { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } vec3 setLuminosity(vec3 c, float lum) { float modLum = lum - getLuminosity(c); vec3 color = c.rgb + vec3(modLum); // clip back into legal range modLum = getLuminosity(color); vec3 modLumVec = vec3(modLum); float cMin = min(color.r, min(color.g, color.b)); float cMax = max(color.r, max(color.g, color.b)); if(cMin < 0.0) { color = mix(modLumVec, color, modLum / (modLum - cMin)); } if(cMax > 1.0) { color = mix(modLumVec, color, (1.0 - modLum) / (cMax - modLum)); } return color; } float getSaturation(vec3 c) { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } vec3 setSaturationMinMidMax(vec3 cSorted, float s) { vec3 colorSorted = cSorted; if(colorSorted.z > colorSorted.x) { colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x)); colorSorted.z = s; } else { colorSorted.y = 0.0; colorSorted.z = 0.0; } colorSorted.x = 0.0; return colorSorted; } vec3 setSaturation(vec3 c, float s) { vec3 color = c; if(color.r <= color.g && color.r <= color.b) { if(color.g <= color.b) { color = setSaturationMinMidMax(color.rgb, s).rgb; } else { color = setSaturationMinMidMax(color.rbg, s).rbg; } } else if(color.g <= color.r && color.g <= color.b) { if(color.r <= color.b) { color = setSaturationMinMidMax(color.grb, s).grb; } else { color = setSaturationMinMidMax(color.gbr, s).gbr; } } else { // Using bgr for both fixes part of hue if(color.r <= color.g) { color = setSaturationMinMidMax(color.brg, s).brg; } else { color = setSaturationMinMidMax(color.bgr, s).bgr; } } return color; } `,IT=` fn getLuminosity(c: vec3) -> f32 { return 0.3*c.r + 0.59*c.g + 0.11*c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { var modLum: f32 = lum - getLuminosity(c); var color: vec3 = c.rgb + modLum; // clip back into legal range modLum = getLuminosity(color); let modLumVec = vec3(modLum); let cMin: f32 = min(color.r, min(color.g, color.b)); let cMax: f32 = max(color.r, max(color.g, color.b)); if(cMin < 0.0) { color = mix(modLumVec, color, modLum / (modLum - cMin)); } if(cMax > 1.0) { color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum)); } return color; } fn getSaturation(c: vec3) -> f32 { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } fn setSaturationMinMidMax(cSorted: vec3, s: f32) -> vec3 { var colorSorted = cSorted; if(colorSorted.z > colorSorted.x) { colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x)); colorSorted.z = s; } else { colorSorted.y = 0; colorSorted.z = 0; } colorSorted.x = 0; return colorSorted; } fn setSaturation(c: vec3, s: f32) -> vec3 { var color = c; if (color.r <= color.g && color.r <= color.b) { if (color.g <= color.b) { color = vec3(setSaturationMinMidMax(color.rgb, s)).rgb; } else { color = vec3(setSaturationMinMidMax(color.rbg, s)).rbg; } } else if (color.g <= color.r && color.g <= color.b) { if (color.r <= color.b) { color = vec3(setSaturationMinMidMax(color.grb, s)).grb; } else { color = vec3(setSaturationMinMidMax(color.gbr, s)).gbr; } } else { // Using bgr for both fixes part of hue if (color.r <= color.g) { color = vec3(setSaturationMinMidMax(color.brg, s)).brg; } else { color = vec3(setSaturationMinMidMax(color.bgr, s)).bgr; } } return color; } `;var is=`in vec2 aPosition; out vec2 vTextureCoord; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } `,Yf=` in vec2 vTextureCoord; out vec4 finalColor; uniform float uAlpha; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } `,da=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct AlphaUniforms { uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var alphaUniforms : AlphaUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var sample = textureSample(uTexture, uSampler, uv); return sample * alphaUniforms.uAlpha; }`,FT=Object.defineProperty,DT=Object.defineProperties,UT=Object.getOwnPropertyDescriptors,ss=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,qf=Object.prototype.propertyIsEnumerable,Zf=(r,t,e)=>t in r?FT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pa=(r,t)=>{for(var e in t||(t={}))Kf.call(t,e)&&Zf(r,e,t[e]);if(ss)for(var e of ss(t))qf.call(t,e)&&Zf(r,e,t[e]);return r},kT=(r,t)=>DT(r,UT(t)),LT=(r,t)=>{var e={};for(var i in r)Kf.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&&qf.call(r,i)&&(e[i]=r[i]);return e};const Qf=class Fb extends Kt{constructor(t){t=pa(pa({},Fb.defaultOptions),t);const e=vt.from({vertex:{source:da,entryPoint:"mainVertex"},fragment:{source:da,entryPoint:"mainFragment"}}),i=Mt.from({vertex:is,fragment:Yf,name:"alpha-filter"}),s=t,{alpha:n}=s,o=LT(s,["alpha"]),a=new nt({uAlpha:{value:n,type:"f32"}});super(kT(pa({},o),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};Qf.defaultOptions={alpha:1};let $T=Qf;const fa={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]},NT=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(` `);function Jf(r){const t=fa[r],e=t.length;let i=NT,s="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a=e&&(o=r-a-1),u=u.replace("%value%",t[o].toString()),s+=u,s+=` `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const HT=` in vec2 aPosition; uniform float uStrength; out vec2 vBlurTexCoords[%size%]; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); float pixelStrength = uInputSize.%dimension% * uStrength; vec2 textureCoord = filterTextureCoord(); %blur% }`;function tm(r,t){const e=Math.ceil(r/2);let i=HT,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlurUniforms { uStrength:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var blurUniforms : BlurUniforms; struct VSOutput { @builtin(position) position: vec4, %blur-struct% }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { let filteredCord = filterTextureCoord(aPosition); let strength = gfu.uInputSize.w * blurUniforms.uStrength; return VSOutput( filterVertexPosition(aPosition), %blur-vertex-out% ); } @fragment fn mainFragment( @builtin(position) position: vec4, %blur-fragment-in% ) -> @location(0) vec4 { var finalColor = vec4(0.0); %blur-sampling% return finalColor; }`;function im(r,t){const e=fa[t],i=e.length,s=[],n=[],o=[];for(let h=0;h,`,r?n[h]=`filteredCord + vec2(${h-i+1} * strength, 0.0),`:n[h]=`filteredCord + vec2(0.0, ${h-i+1} * strength),`;const p=ht in r?XT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ma=(r,t)=>{for(var e in t||(t={}))zT.call(t,e)&&nm(r,e,t[e]);if(sm)for(var e of sm(t))jT.call(t,e)&&nm(r,e,t[e]);return r};const om=class Db extends Kt{constructor(t){t=ma(ma({},Db.defaultOptions),t);const e=em(t.horizontal,t.kernelSize),i=im(t.horizontal,t.kernelSize);super(ma({glProgram:e,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,i,s){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=ct.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;for(let u=0;ut in r?VT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dr=(r,t)=>{for(var e in t||(t={}))am.call(t,e)&&lm(r,e,t[e]);if(os)for(var e of os(t))um.call(t,e)&&lm(r,e,t[e]);return r},KT=(r,t)=>WT(r,YT(t)),qT=(r,t)=>{var e={};for(var i in r)am.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&os)for(var i of os(r))t.indexOf(i)<0&&um.call(r,i)&&(e[i]=r[i]);return e};class cm extends Kt{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]&&(i.quality=t[1]),t[2]&&(i.resolution=t[2]),t[3]&&(i.kernelSize=t[3])),i=Dr(Dr({},ns.defaultOptions),i);const s=i,{strength:n,quality:o}=s,a=qT(s,["strength","quality"]);super(KT(Dr({},a),{compatibleRenderers:yt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new ns(Dr({horizontal:!1},i)),this.blurYFilter=new ns(Dr({horizontal:!0},i)),this.quality=o,this.blur=n,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=ct.getSameSizeTexture(e);this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.apply(t,a,i,s),ct.returnTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get blur(){return this.blurXFilter.blur}set blur(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 blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}cm.defaultOptions={strength:8,quality:4,kernelSize:5};var hm=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uColorMatrix[20]; uniform float uAlpha; uniform sampler2D uTexture; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture(uTexture, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * 0.2); float diff = (randomValue - 0.5) * 0.5; if (uAlpha == 0.0) { finalColor = color; return; } if (color.a > 0.0) { color.rgb /= color.a; } vec4 result; result.r = (uColorMatrix[0] * color.r); result.r += (uColorMatrix[1] * color.g); result.r += (uColorMatrix[2] * color.b); result.r += (uColorMatrix[3] * color.a); result.r += uColorMatrix[4]; result.g = (uColorMatrix[5] * color.r); result.g += (uColorMatrix[6] * color.g); result.g += (uColorMatrix[7] * color.b); result.g += (uColorMatrix[8] * color.a); result.g += uColorMatrix[9]; result.b = (uColorMatrix[10] * color.r); result.b += (uColorMatrix[11] * color.g); result.b += (uColorMatrix[12] * color.b); result.b += (uColorMatrix[13] * color.a); result.b += uColorMatrix[14]; result.a = (uColorMatrix[15] * color.r); result.a += (uColorMatrix[16] * color.g); result.a += (uColorMatrix[17] * color.b); result.a += (uColorMatrix[18] * color.a); result.a += uColorMatrix[19]; vec3 rgb = mix(color.rgb, result.rgb, uAlpha); // Premultiply alpha again. rgb *= result.a; finalColor = vec4(rgb, result.a); } `,ga=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct ColorMatrixUniforms { uColorMatrix:array, 5>, uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var colorMatrixUniforms : ColorMatrixUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), ); } @fragment fn mainFragment( @location(0) uv: vec2, ) -> @location(0) vec4 { var c = textureSample(uTexture, uSampler, uv); if (colorMatrixUniforms.uAlpha == 0.0) { return c; } // Un-premultiply alpha before applying the color matrix. See issue #3539. if (c.a > 0.0) { c.r /= c.a; c.g /= c.a; c.b /= c.a; } var cm = colorMatrixUniforms.uColorMatrix; var result = vec4(0.); result.r = (cm[0][0] * c.r); result.r += (cm[0][1] * c.g); result.r += (cm[0][2] * c.b); result.r += (cm[0][3] * c.a); result.r += cm[1][0]; result.g = (cm[1][1] * c.r); result.g += (cm[1][2] * c.g); result.g += (cm[1][3] * c.b); result.g += (cm[2][0] * c.a); result.g += cm[2][1]; result.b = (cm[2][2] * c.r); result.b += (cm[2][3] * c.g); result.b += (cm[3][0] * c.b); result.b += (cm[3][1] * c.a); result.b += cm[3][2]; result.a = (cm[3][3] * c.r); result.a += (cm[4][0] * c.g); result.a += (cm[4][1] * c.b); result.a += (cm[4][2] * c.a); result.a += cm[4][3]; var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha); rgb.r *= result.a; rgb.g *= result.a; rgb.b *= result.a; return vec4(rgb, result.a); }`,ZT=Object.defineProperty,QT=Object.defineProperties,JT=Object.getOwnPropertyDescriptors,dm=Object.getOwnPropertySymbols,tS=Object.prototype.hasOwnProperty,eS=Object.prototype.propertyIsEnumerable,pm=(r,t,e)=>t in r?ZT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rS=(r,t)=>{for(var e in t||(t={}))tS.call(t,e)&&pm(r,e,t[e]);if(dm)for(var e of dm(t))eS.call(t,e)&&pm(r,e,t[e]);return r},iS=(r,t)=>QT(r,JT(t));class sS extends Kt{constructor(t={}){const e=new nt({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=vt.from({vertex:{source:ga,entryPoint:"mainVertex"},fragment:{source:ga,entryPoint:"mainFragment"}}),s=Mt.from({vertex:is,fragment:hm,name:"color-matrix-filter"});super(iS(rS({},t),{gpuProgram:i,glProgram:s,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.matrix,t),i=this._colorMatrix(i)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i,this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=K.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),u=i+(1-i)*o,l=o*(1-i)-a*s,c=o*(1-i)+a*s,h=o*(1-i)+a*s,p=i+o*(1-i),f=o*(1-i)-a*s,m=o*(1-i)-a*s,_=o*(1-i)+a*s,g=i+o*(1-i),b=[u,l,c,0,0,h,p,f,0,0,m,_,g,0,0,0,0,0,1,0];this._loadMatrix(b,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=K.shared,[a,u,l]=o.setValue(i).toArray(),[c,h,p]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,u,l,t,0,c,h,p,e,0,a-c,u-h,l-p,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var fm=` in vec2 vTextureCoord; in vec2 vFilterUv; out vec4 finalColor; uniform sampler2D uTexture; uniform sampler2D uMapTexture; uniform vec4 uInputClamp; uniform highp vec4 uInputSize; uniform mat2 uRotation; uniform vec2 uScale; void main() { vec4 map = texture(uMapTexture, vFilterUv); vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale; finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw)); } `,mm=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 vFilterUv; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; uniform mat3 uFilterMatrix; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } vec2 getFilterCoord( void ) { return ( uFilterMatrix * vec3( filterTextureCoord(), 1.0) ).xy; } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); vFilterUv = getFilterCoord(); } `,_a=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct DisplacementUniforms { uFilterMatrix:mat3x3, uScale:vec2, uRotation:mat2x2 }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : DisplacementUniforms; @group(1) @binding(1) var uMapTexture: texture_2d; @group(1) @binding(2) var uMapSampler : sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var map = textureSample(uMapTexture, uMapSampler, filterUv); var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale; return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw)); }`,nS=Object.defineProperty,oS=Object.defineProperties,aS=Object.getOwnPropertyDescriptors,as=Object.getOwnPropertySymbols,gm=Object.prototype.hasOwnProperty,_m=Object.prototype.propertyIsEnumerable,bm=(r,t,e)=>t in r?nS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uS=(r,t)=>{for(var e in t||(t={}))gm.call(t,e)&&bm(r,e,t[e]);if(as)for(var e of as(t))_m.call(t,e)&&bm(r,e,t[e]);return r},lS=(r,t)=>oS(r,aS(t)),cS=(r,t)=>{var e={};for(var i in r)gm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&as)for(var i of as(r))t.indexOf(i)<0&&_m.call(r,i)&&(e[i]=r[i]);return e};class hS extends Kt{constructor(...t){let e=t[0];e instanceof Gt&&(e={sprite:e,scale:t[1]});const i=e,{sprite:s,scale:n}=i,o=cS(i,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new V(a,a));const u=new nt({uFilterMatrix:{value:new G,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),l=Mt.from({vertex:mm,fragment:fm,name:"displacement-filter"}),c=vt.from({vertex:{source:_a,entryPoint:"mainVertex"},fragment:{source:_a,entryPoint:"mainFragment"}}),h=s.texture.source;super(lS(uS({},o),{gpuProgram:c,glProgram:l,resources:{filterUniforms:u,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,s){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),u=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&u!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/u,n.uRotation[3]=o.d/u),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,s)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var vm=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uNoise; uniform float uSeed; uniform sampler2D uTexture; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture(uTexture, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * uSeed); float diff = (randomValue - 0.5) * uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (color.a > 0.0) { color.rgb /= color.a; } color.r += diff; color.g += diff; color.b += diff; // Premultiply alpha again. color.rgb *= color.a; finalColor = color; } `,ba=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct NoiseUniforms { uNoise:f32, uSeed:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var noiseUniforms : NoiseUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } fn rand(co:vec2) -> f32 { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy); var sample = textureSample(uTexture, uSampler, uv); var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed); var diff = (randomValue - 0.5) * noiseUniforms.uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (sample.a > 0.0) { sample.r /= sample.a; sample.g /= sample.a; sample.b /= sample.a; } sample.r += diff; sample.g += diff; sample.b += diff; // Premultiply alpha again. sample.r *= sample.a; sample.g *= sample.a; sample.b *= sample.a; return sample; }`,dS=Object.defineProperty,pS=Object.defineProperties,fS=Object.getOwnPropertyDescriptors,us=Object.getOwnPropertySymbols,ym=Object.prototype.hasOwnProperty,xm=Object.prototype.propertyIsEnumerable,Tm=(r,t,e)=>t in r?dS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,va=(r,t)=>{for(var e in t||(t={}))ym.call(t,e)&&Tm(r,e,t[e]);if(us)for(var e of us(t))xm.call(t,e)&&Tm(r,e,t[e]);return r},mS=(r,t)=>pS(r,fS(t)),gS=(r,t)=>{var e={};for(var i in r)ym.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&&xm.call(r,i)&&(e[i]=r[i]);return e};const Sm=class Ub extends Kt{constructor(t={}){t=va(va({},Ub.defaultOptions),t);const e=vt.from({vertex:{source:ba,entryPoint:"mainVertex"},fragment:{source:ba,entryPoint:"mainFragment"}}),i=Mt.from({vertex:is,fragment:vm,name:"noise-filter"}),s=t,{noise:n,seed:o}=s,a=gS(s,["noise","seed"]);super(mS(va({},a),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new nt({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};Sm.defaultOptions={noise:.5};let _S=Sm;var Em=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; uniform sampler2D uMaskTexture; uniform float uAlpha; uniform vec4 uMaskClamp; out vec4 finalColor; void main(void) { float clip = step(3.5, step(uMaskClamp.x, vMaskCoord.x) + step(uMaskClamp.y, vMaskCoord.y) + step(vMaskCoord.x, uMaskClamp.z) + step(vMaskCoord.y, uMaskClamp.w)); // TODO look into why this is needed float npmAlpha = uAlpha; vec4 original = texture(uTexture, vTextureCoord); vec4 masky = texture(uMaskTexture, vMaskCoord); float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); original *= (alphaMul * masky.r * uAlpha * clip); finalColor = original; } `,Am=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 vMaskCoord; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; uniform mat3 uFilterMatrix; vec4 filterVertexPosition( vec2 aPosition ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( vec2 aPosition ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } vec2 getFilterCoord( vec2 aPosition ) { return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } void main(void) { gl_Position = filterVertexPosition(aPosition); vTextureCoord = filterTextureCoord(aPosition); vMaskCoord = getFilterCoord(aPosition); } `,ya=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct MaskUniforms { uFilterMatrix:mat3x3, uMaskClamp:vec4, uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : MaskUniforms; @group(1) @binding(1) var uMaskTexture: texture_2d; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var maskClamp = filterUniforms.uMaskClamp; var clip = step(3.5, step(maskClamp.x, filterUv.x) + step(maskClamp.y, filterUv.y) + step(filterUv.x, maskClamp.z) + step(filterUv.y, maskClamp.w)); var mask = textureSample(uMaskTexture, uSampler, filterUv); var source = textureSample(uTexture, uSampler, uv); var npmAlpha = 0.0; var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a); var a = (alphaMul * mask.r) * clip; return vec4(source.rgb, source.a) * a; }`,bS=Object.defineProperty,vS=Object.defineProperties,yS=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,Pm=Object.prototype.hasOwnProperty,wm=Object.prototype.propertyIsEnumerable,Rm=(r,t,e)=>t in r?bS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xS=(r,t)=>{for(var e in t||(t={}))Pm.call(t,e)&&Rm(r,e,t[e]);if(ls)for(var e of ls(t))wm.call(t,e)&&Rm(r,e,t[e]);return r},TS=(r,t)=>vS(r,yS(t)),SS=(r,t)=>{var e={};for(var i in r)Pm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ls)for(var i of ls(r))t.indexOf(i)<0&&wm.call(r,i)&&(e[i]=r[i]);return e};class Mm extends Kt{constructor(t){const e=t,{sprite:i}=e,s=SS(e,["sprite"]),n=new ln(i.texture),o=new nt({uFilterMatrix:{value:new G,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"}}),a=vt.from({vertex:{source:ya,entryPoint:"mainVertex"},fragment:{source:ya,entryPoint:"mainFragment"}}),u=Mt.from({vertex:Am,fragment:Em,name:"mask-filter"});super(TS(xS({},s),{gpuProgram:a,glProgram:u,resources:{filterUniforms:o,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=n}apply(t,e,i,s){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,s)}}var ES=`fn getLuminosity(c: vec3) -> f32 { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { let d: f32 = lum - getLuminosity(c); let newColor: vec3 = c.rgb + vec3(d, d, d); // clip back into legal range let newLum: f32 = getLuminosity(newColor); let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b)); let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b)); let t1: f32 = newLum / (newLum - cMin); let t2: f32 = (1.0 - newLum) / (cMax - newLum); let finalColor = mix(vec3(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0)); return finalColor; } fn getSaturation(c: vec3) -> f32 { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } // Set saturation if color components are sorted in ascending order. fn setSaturationMinMidMax(cSorted: vec3, s: f32) -> vec3 { var result: vec3; if (cSorted.z > cSorted.x) { let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x)); result = vec3(0.0, newY, s); } else { result = vec3(0.0, 0.0, 0.0); } return vec3(result.x, result.y, result.z); } fn setSaturation(c: vec3, s: f32) -> vec3 { var result: vec3 = c; if (c.r <= c.g && c.r <= c.b) { if (c.g <= c.b) { result = setSaturationMinMidMax(result, s); } else { var temp: vec3 = vec3(result.r, result.b, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.r, temp.b, temp.g); } } else if (c.g <= c.r && c.g <= c.b) { if (c.r <= c.b) { var temp: vec3 = vec3(result.g, result.r, result.b); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.r, temp.b); } else { var temp: vec3 = vec3(result.g, result.b, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.b, temp.r); } } else { if (c.r <= c.g) { var temp: vec3 = vec3(result.b, result.r, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.r, temp.g); } else { var temp: vec3 = vec3(result.b, result.g, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.g, temp.r); } } return result; }`;function xa(r,t,e,i,s,n,o,a){const u=o-e,l=a-i,c=s-e,h=n-i,p=r-e,f=t-i,m=u*u+l*l,_=u*c+l*h,g=u*p+l*f,b=c*c+h*h,v=c*p+h*f,y=1/(m*b-_*_),T=(b*g-_*v)*y,E=(m*v-_*g)*y;return T>=0&&E>=0&&T+E<1}class Ta{constructor(t=0,e=0,i=0,s=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=s,this.x3=n,this.y3=o}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),s=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=s<0&&i!==0&&s!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==i+s<=0}strokeContains(t,e,i){const s=i/2,n=s*s,{x:o,x2:a,x3:u,y:l,y2:c,y3:h}=this;return br(t,e,o,l,a,h)<=n||br(t,e,a,c,u,h)<=n||br(t,e,u,h,o,l)<=n}clone(){return new Ta(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 j;const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),s=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=s,t.width=i-e,t.height=n-s,t}}const Cm=class kb{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let i=0;for(;e.length&&i{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),ht.system.addOnce(this._tick,this,Vt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;it in r?AS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PS=(r,t)=>{for(var e in t||(t={}))Gm.call(t,e)&&Im(r,e,t[e]);if(cs)for(var e of cs(t))Bm.call(t,e)&&Im(r,e,t[e]);return r},wS=(r,t)=>{var e={};for(var i in r)Gm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&cs)for(var i of cs(r))t.indexOf(i)<0&&Bm.call(r,i)&&(e[i]=r[i]);return e};class Ur extends Y{constructor(...t){var e;let i=t[0];i instanceof Oe&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const s=i,{geometry:n,shader:o,texture:a,roundPixels:u,state:l}=s,c=wS(s,["geometry","shader","texture","roundPixels","state"]);super(PS({label:"Mesh"},c)),this.renderPipeId="mesh",this.canBundle=!0,this._roundPixels=0,this.allowChildren=!1,this.shader=o,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:P.WHITE,this.state=l!=null?l:Bt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=u!=null?u:!1}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader?!1:this._geometry instanceof Jt?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}addBounds(t){t.addBounds(this.geometry.bounds)}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let u=0;u+2=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrames)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;ithis.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?(ht.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ht.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Fm{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new G,this.observer=e,this.position=new it(this,0,0),this.scale=new it(this,1,1),this.pivot=new it(this,0,0),this.skew=new it(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var RS=Object.defineProperty,hs=Object.getOwnPropertySymbols,Dm=Object.prototype.hasOwnProperty,Um=Object.prototype.propertyIsEnumerable,km=(r,t,e)=>t in r?RS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lr=(r,t)=>{for(var e in t||(t={}))Dm.call(t,e)&&km(r,e,t[e]);if(hs)for(var e of hs(t))Um.call(t,e)&&km(r,e,t[e]);return r},MS=(r,t)=>{var e={};for(var i in r)Dm.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&&Um.call(r,i)&&(e[i]=r[i]);return e};const Lm=class Fs extends Y{constructor(...t){let e=t[0]||{};e instanceof P&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Lr(Lr({},Fs.defaultOptions),e);const i=e!=null?e:{},{texture:s,anchor:n,tilePosition:o,tileScale:a,tileRotation:u,width:l,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=MS(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Lr({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.canBundle=!0,this.batched=!0,this._roundPixels=0,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this.allowChildren=!1,this._anchor=new it({_onUpdate:()=>{this.onViewUpdate()}}),this._applyAnchorToTexture=h,this.texture=s,this._width=l!=null?l:s.width,this._height=c!=null?c:s.height,this._tileTransform=new Fm({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=u,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new Fs(Lr({texture:q.get(t)},e)):new Fs(Lr({texture:t},e))}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}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}_updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.maxX=-e._x*i,t.minX=t.maxX+i,t.maxY=-e._y*s,t.minY=t.maxY+s}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.minX,i=this.bounds.minY,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._boundsDirty=!0,this._didTilingSpriteUpdate=!0,this._didChangeId+=4096,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}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}};Lm.defaultOptions={texture:P.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let $m=Lm;var CS=Object.defineProperty,ds=Object.getOwnPropertySymbols,Nm=Object.prototype.hasOwnProperty,Hm=Object.prototype.propertyIsEnumerable,Xm=(r,t,e)=>t in r?CS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,OS=(r,t)=>{for(var e in t||(t={}))Nm.call(t,e)&&Xm(r,e,t[e]);if(ds)for(var e of ds(t))Hm.call(t,e)&&Xm(r,e,t[e]);return r},GS=(r,t)=>{var e={};for(var i in r)Nm.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&&Hm.call(r,i)&&(e[i]=r[i]);return e};class ps extends Y{constructor(t,e){const i=t,{text:s,resolution:n,style:o,anchor:a,width:u,height:l,roundPixels:c}=i,h=GS(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(OS({},h)),this.batched=!0,this.resolution=null,this._didTextUpdate=!0,this._roundPixels=0,this._bounds=new lt,this._boundsDirty=!0,this._styleClass=e,this.text=s!=null?s:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new it({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c!=null?c:!1,u&&(this.width=u),l&&(this.height=l)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}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 bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}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;let s,n;typeof t!="object"?(s=t,n=e!=null?e:t):(s=t.width,n=(i=t.height)!=null?i:t.width),s!==void 0&&this._setWidth(s,this.bounds.width),n!==void 0&&this._setHeight(n,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.maxX,i=this.bounds.maxY,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){if(this._didChangeId+=4096,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function fs(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}class Sa extends ps{constructor(...t){const e=fs(t,"Text");super(e,Ft),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._style.padding,i=this._anchor,s=Ut.measureText(this._text,this._style),{width:n,height:o}=s;t.minX=-i._x*n-e,t.maxX=t.minX+n+e*2,t.minY=-i._y*o-e,t.maxY=t.minY+o+e*2}}class zm extends Om{resolveQueueItem(t,e){return t instanceof Y?this.resolveContainerQueueItem(t,e):t instanceof rt||t instanceof P?e.push(t.source):t instanceof It&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Gt||t instanceof $m||t instanceof Ur?e.push(t.texture.source):t instanceof Sa?e.push(t):t instanceof De?e.push(t.context):t instanceof kr&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getContextRenderData(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;return s.source}else if(i.action==="fill"){const{texture:s}=i.data.style;return s.source}return null}}class jm extends ps{constructor(...t){var e,i,s;const n=fs(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(s=(i=n.style).fill)!=null||(i.fill=16777215),super(n,Ft),this.renderPipeId="bitmapText"}_updateBounds(){const t=this._bounds,e=this._style.padding,i=this._anchor,s=Er.measureText(this.text,this._style),n=s.scale,o=s.offsetY*n,a=s.width*n,u=s.height*n;t.minX=-i._x*a-e,t.maxX=t.minX+a,t.minY=-i._y*(u+o)-e,t.maxY=t.minY+u}}class Vm extends ps{constructor(...t){const e=fs(t,"HtmlText");super(e,ye),this.renderPipeId="htmlText"}_updateBounds(){const t=this._bounds,e=this._style.padding,i=this._anchor,s=Uo(this.text,this._style),{width:n,height:o}=s;t.minX=-i._x*n-e,t.maxX=t.minX+n,t.minY=-i._y*o-e,t.maxY=t.minY+o}}class Wm extends zm{uploadQueueItem(t){t instanceof rt?this.uploadTextureSource(t):t instanceof Sa?this.uploadText(t):t instanceof Vm?this.uploadHTMLText(t):t instanceof jm?this.uploadBitmapText(t):t instanceof It&&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.getContextRenderData(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;this.uploadTextureSource(s.source)}else if(i.action==="fill"){const{texture:s}=i.data.style;this.uploadTextureSource(s.source)}return null}}class Ym extends Wm{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}Ym.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"prepare"};class Ea{constructor(){this._didUpload=!1,this._tempState=Bt.for2d()}init(t){const e=$e({name:"batch",bits:[Ui,Li(dt),He]});this._shader=new xt({glProgram:e,resources:{batchSamplers:$i}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const i=t.renderer;i.shader.bind(this._shader,this._didUpload),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,this._shader.glProgram)}execute(t,e){const i=t.renderer;this._didUpload=!0,this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=e.textures.textures;for(let n=0;ni.trim()).filter(i=>i.length);let e="";return t.map(i=>{let s=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),s=e+i),s}).join(` `)}const Km={name:"texture-bit",vertex:{header:` struct TextureUniforms { uTextureMatrix:mat3x3, } @group(2) @binding(2) var textureUniforms : TextureUniforms; `,main:` uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy; `},fragment:{header:` @group(2) @binding(0) var uTexture: texture_2d; @group(2) @binding(1) var uSampler: sampler; `,main:` outColor = textureSample(uTexture, uSampler, vUV); `}},qm={name:"texture-bit",vertex:{header:` uniform mat3 uTextureMatrix; `,main:` uv = (uTextureMatrix * vec3(uv, 1.0)).xy; `},fragment:{header:` uniform sampler2D uTexture; `,main:` outColor = texture(uTexture, vUV); `}};function Zm(r,t){const e=r.root,i=r.instructionSet;i.reset(),t.batch.buildStart(i),t.blendMode.buildStart(),t.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),Qm(e,i,t,!0),t.batch.buildEnd(i),t.blendMode.buildEnd(i)}function $r(r,t,e){r.globalDisplayStatus<7||!r.includeInBuild||(r.sortableChildren&&r.sortChildren(),r.isSimple?DS(r,t,e):Qm(r,t,e,!1))}function DS(r,t,e){if(r.renderPipeId&&(e.blendMode.setBlendMode(r,r.groupBlendMode,t),r.didViewUpdate=!1,e[r.renderPipeId].addRenderable(r,t)),!r.renderGroup){const i=r.children,s=i.length;for(let n=0;n=0;o--){const a=r.effects[o];e[a.pipe].pop(a,r,t)}}}const US=new lt;class kS extends er{constructor(){super(),this.filters=[new Mm({sprite:new Gt(P.EMPTY)})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}}class wa{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,$r(n,i,s.renderPipes),n.includeInBuild=!1}s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const s=W.get(kS);if(i){t.mask.mask.measurable=!0;const n=rr(t.mask.mask,!0,US);t.mask.mask.measurable=!1,n.ceil();const o=ct.getOptimalTexture(n.width,n.height,1,!1);e.renderTarget.push(o,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const a=s.sprite;a.texture=o,a.worldTransform.tx=n.minX,a.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:o})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const s=this._activeMaskStage.pop();i&&ct.returnTexture(s.filterTexture),W.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}wa.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"alphaMask"};class Ra{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Ra.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"colorMask"};class LS{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){ci(this.mask,t,e)}addLocalBounds(t,e){hi(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}}class Ma{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s,n;const o=t,a=this._renderer;a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(o.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,canBundle:!1});const u=o.mask;u.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const l=this._maskHash.get(o);l.instructionsStart=i.instructionSize,$r(u,i,a.renderPipes),u.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const c=i.instructionSize-l.instructionsStart-1;l.instructionsLength=c;const h=a.renderTarget.renderTarget.uid;(n=(s=this._maskStackHash)[h])!=null||(s[h]=0)}pop(t,e,i){const s=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Nr||{});class Jm{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class Ca{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;if(this._boundBufferBases[e]!==t){const s=this.getGlBuffer(t);this._boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,s.buffer)}}bindBufferRange(t,e,i){const{_gl:s}=this;i=i||0;const n=this.getGlBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const s=t.data;if(i.byteLength>=t.data.byteLength)e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&H.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;i.byteLength=s.byteLength,e.bufferData(i.type,s,n)}return i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const i=this._gpuBuffers[t.uid],s=this._gl;e||s.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=Nr.ARRAY_BUFFER;t.descriptor.usage&H.INDEX?i=Nr.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&H.UNIFORM&&(i=Nr.UNIFORM_BUFFER);const s=new Jm(e.createBuffer(),i);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}}Ca.extension={type:[x.WebGLSystem],name:"buffer"};var $S=Object.defineProperty,NS=Object.defineProperties,HS=Object.getOwnPropertyDescriptors,tg=Object.getOwnPropertySymbols,XS=Object.prototype.hasOwnProperty,zS=Object.prototype.propertyIsEnumerable,eg=(r,t,e)=>t in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gs=(r,t)=>{for(var e in t||(t={}))XS.call(t,e)&&eg(r,e,t[e]);if(tg)for(var e of tg(t))zS.call(t,e)&&eg(r,e,t[e]);return r},rg=(r,t)=>NS(r,HS(t));const Oa=class Lb{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;if(t=gs(gs({},Lb.defaultOptions),t),t.context)this.initFromContext(t.context);else{const s=this._renderer.background.alpha<1,n=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:n,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof z.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const s=this._renderer.view.canvas;if(t===2&&(i=s.getContext("webgl2",e)),!i&&(i=s.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=rg(gs({},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=rg(gs({},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._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,s=this.webGLVersion===2,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices}};Oa.extension={type:[x.WebGLSystem],name:"context"},Oa.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let ig=Oa,Ga=0;const sg=500;function _s(...r){Ga!==sg&&(Ga++,Ga===sg?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function Ba(r,t){var e,i,s,n;for(const o in r.attributes){const a=r.attributes[o],u=t[o];u?((e=a.location)!=null||(a.location=u.location),(i=a.format)!=null||(a.format=u.format),(s=a.offset)!=null||(a.offset=u.offset),(n=a.instance)!=null||(a.instance=u.instance)):_s(`Attribute ${o} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}jS(r)}function jS(r){var t,e;const{buffers:i,attributes:s}=r,n={},o={};for(const a in i){const u=i[a];n[u.uid]=0,o[u.uid]=0}for(const a in s){const u=s[a];n[u.buffer.uid]+=Ue(u.format).stride}for(const a in s){const u=s[a];(t=u.stride)!=null||(u.stride=n[u.buffer.uid]),(e=u.start)!=null||(u.start=o[u.buffer.uid]),o[u.buffer.uid]+=Ue(u.format).stride}}var bs=(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))(bs||{}),Ia=(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))(Ia||{}),ng=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(ng||{}),X=(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))(X||{});const og={uint8x2:X.UNSIGNED_BYTE,uint8x4:X.UNSIGNED_BYTE,sint8x2:X.BYTE,sint8x4:X.BYTE,unorm8x2:X.UNSIGNED_BYTE,unorm8x4:X.UNSIGNED_BYTE,snorm8x2:X.BYTE,snorm8x4:X.BYTE,uint16x2:X.UNSIGNED_SHORT,uint16x4:X.UNSIGNED_SHORT,sint16x2:X.SHORT,sint16x4:X.SHORT,unorm16x2:X.UNSIGNED_SHORT,unorm16x4:X.UNSIGNED_SHORT,snorm16x2:X.SHORT,snorm16x4:X.SHORT,float16x2:X.HALF_FLOAT,float16x4:X.HALF_FLOAT,float32:X.FLOAT,float32x2:X.FLOAT,float32x3:X.FLOAT,float32x4:X.FLOAT,uint32:X.UNSIGNED_INT,uint32x2:X.UNSIGNED_INT,uint32x3:X.UNSIGNED_INT,uint32x4:X.UNSIGNED_INT,sint32:X.INT,sint32x2:X.INT,sint32x3:X.INT,sint32x4:X.INT};function ag(r){var t;return(t=og[r])!=null?t:og.float32}const VS={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Fa{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=s=>e.bindVertexArrayOES(s),t.deleteVertexArray=s=>e.deleteVertexArrayOES(s));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(s,n,o,a)=>{i.drawArraysInstancedANGLE(s,n,o,a)},t.drawElementsInstanced=(s,n,o,a,u)=>{i.drawElementsInstancedANGLE(s,n,o,a,u)},t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(i||0)*u,s):n.drawElements(a,e||o.indexBuffer.data.length,l,(i||0)*u)}else s>1?n.drawArraysInstanced(a,i||0,e||o.getSize(),s):n.drawArrays(a,i||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}Fa.extension={type:[x.WebGLSystem],name:"geometry"};var WS=Object.defineProperty,ug=Object.getOwnPropertySymbols,YS=Object.prototype.hasOwnProperty,KS=Object.prototype.propertyIsEnumerable,lg=(r,t,e)=>t in r?WS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cg=(r,t)=>{for(var e in t||(t={}))YS.call(t,e)&&lg(r,e,t[e]);if(ug)for(var e of ug(t))KS.call(t,e)&&lg(r,e,t[e]);return r};const qS=new Oe({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Da=class $b{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=cg(cg({},$b.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(_s("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Bt.for2d();const s=new Mt({vertex:` attribute vec2 aPosition; out vec2 vUv; void main() { gl_Position = vec4(aPosition, 0.0, 1.0); vUv = (aPosition + 1.0) / 2.0; // flip dem UVs vUv.y = 1.0 - vUv.y; }`,fragment:` in vec2 vUv; out vec4 finalColor; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vUv); }`,name:"big-triangle"});this._bigTriangleShader=new xt({glProgram:s,resources:{uTexture:P.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:qS,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new P({source:new rt({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)}};Da.extension={type:[x.WebGLSystem],name:"backBuffer",priority:1},Da.defaultOptions={useBackBuffer:!1};let hg=Da;class Ua{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)))}}Ua.extension={type:[x.WebGLSystem],name:"colorMask"};class ka{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:s,state:n,skipSync:o,topology:a,size:u,start:l,instanceCount:c}=t;e.shader.bind(s,o),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,u,l,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}ka.extension={type:[x.WebGLSystem],name:"encoder"};class dg{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const re=[];re[st.NONE]=void 0,re[st.DISABLED]={stencilWriteMask:0,stencilReadMask:0},re[st.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},re[st.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},re[st.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class La{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:st.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._stencilCache.enabled=!1,this._stencilCache.stencilMode=st.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:st.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=re[t],o=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===st.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}La.extension={type:[x.WebGLSystem],name:"stencil"};class $a{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Wo())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 bt({data:new Float32Array(e.layout.size/4),usage:H.UNIFORM|H.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const s=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(s),o=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);return t.buffer||(t.buffer=new bt({data:new Float32Array(s.layout.size/4),usage:H.UNIFORM|H.COPY_DST})),e||(e=t.buffer.data),i||(i=0),s.syncFunction(t.uniforms,e,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 Na={f32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function pg(r){const t=r.map(n=>({data:n,offset:0,size:0}));let e=0,i=0,s=0;for(let n=0;n1&&(e=Math.max(e,16)*o.data.size),o.size=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}const ie=[{type:"mat3x3",test:r=>r.value.a!==void 0,ubo:` var matrix = uv[name].toArray(true); data[offset] = matrix[0]; data[offset + 1] = matrix[1]; data[offset + 2] = matrix[2]; data[offset + 4] = matrix[3]; data[offset + 5] = matrix[4]; data[offset + 6] = matrix[5]; data[offset + 8] = matrix[6]; data[offset + 9] = matrix[7]; data[offset + 10] = matrix[8]; `,uniform:` gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true)); `},{type:"vec4",test:r=>r.type==="vec4"&&r.size===1&&r.value.width!==void 0,ubo:` v = uv[name]; data[offset] = v.x; data[offset + 1] = v.y; data[offset + 2] = v.width; data[offset + 3] = v.height; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) { cv[0] = v.x; cv[1] = v.y; cv[2] = v.width; cv[3] = v.height; gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height); } `},{type:"vec2",test:r=>r.type==="vec2"&&r.size===1&&r.value.x!==void 0,ubo:` v = uv[name]; data[offset] = v.x; data[offset + 1] = v.y; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.x || cv[1] !== v.y) { cv[0] = v.x; cv[1] = v.y; gl.uniform2f(ud[name].location, v.x, v.y); } `},{type:"vec4",test:r=>r.type==="vec4"&&r.size===1&&r.value.red!==void 0,ubo:` v = uv[name]; data[offset] = v.red; data[offset + 1] = v.green; data[offset + 2] = v.blue; data[offset + 3] = v.alpha; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; cv[3] = v.alpha; gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha); } `},{type:"vec3",test:r=>r.type==="vec3"&&r.size===1&&r.value.red!==void 0,ubo:` v = uv[name]; data[offset] = v.red; data[offset + 1] = v.green; data[offset + 2] = v.blue; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; gl.uniform3f(ud[name].location, v.red, v.green, v.blue); } `}];function Ha(r,t,e,i){const s=[` var v = null; var v2 = null; var t = 0; var index = 0; var name = null; var arrayOffset = null; `];let n=0;for(let a=0;a1)h=u.offset/4,s.push(e(u,h-n));else{const p=i[u.data.type];h=u.offset/4,s.push(` v = uv.${l}; offset += ${h-n}; ${p}; `)}n=h}const o=s.join(` `);return new Function("uv","data","offset",o)}var ZS=Object.defineProperty,QS=Object.defineProperties,JS=Object.getOwnPropertyDescriptors,fg=Object.getOwnPropertySymbols,t2=Object.prototype.hasOwnProperty,e2=Object.prototype.propertyIsEnumerable,mg=(r,t,e)=>t in r?ZS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,r2=(r,t)=>{for(var e in t||(t={}))t2.call(t,e)&&mg(r,e,t[e]);if(fg)for(var e of fg(t))e2.call(t,e)&&mg(r,e,t[e]);return r},i2=(r,t)=>QS(r,JS(t));function Ye(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } `}const Xa={f32:` data[offset] = v;`,i32:` data[offset] = v;`,"vec2":` data[offset] = v[0]; data[offset + 1] = v[1];`,"vec3":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2];`,"vec4":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3];`,"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 4] = v[2]; data[offset + 5] = v[3];`,"mat3x3":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 4] = v[3]; data[offset + 5] = v[4]; data[offset + 6] = v[5]; data[offset + 8] = v[6]; data[offset + 9] = v[7]; data[offset + 10] = v[8];`,"mat4x4":` for (let i = 0; i < 16; i++) { data[offset + i] = v[i]; }`,"mat3x2":Ye(3,2),"mat4x2":Ye(4,2),"mat2x3":Ye(2,3),"mat4x3":Ye(4,3),"mat2x4":Ye(2,4),"mat3x4":Ye(3,4)},gg=i2(r2({},Xa),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; `});function _g(r,t){const e=Math.max(Na[r.data.type]/16,1),i=r.data.value.length/r.data.size,s=(4-i%4)%4;return` v = uv.${r.data.name}; offset += ${t}; arrayOffset = offset; t = 0; for(var i=0; i < ${r.data.size*e}; i++) { for(var j = 0; j < ${i}; j++) { data[arrayOffset++] = v[t++]; } ${s!==0?`arrayOffset += ${s};`:""} } `}function bg(r){return Ha(r,"uboStd40",_g,Xa)}class za extends $a{constructor(){super({createUboElements:pg,generateUboSync:bg})}}za.extension={type:[x.WebGLSystem],name:"ubo"};class vg{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new j}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new j}copyToTexture(t,e,i,s,n){const o=this._renderTargetSystem,a=this._renderer,u=o.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,u.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let u=s.y;t.isRoot&&(u=o.pixelHeight-s.height),t.colorTextures.forEach(h=>{this._renderer.texture.unbind(h)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);const c=this._viewPortCache;(c.x!==s.x||c.y!==u||c.width!==s.width||c.height!==s.height)&&(c.x=s.x,c.y=u,c.width=s.width,c.height=s.height,l.viewport(s.x,u,s.width,s.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer,i=e.gl,s=new dg;return t.colorTexture.resource===e.gl.canvas?(s.framebuffer=null,s):(this._initColor(t,s),i.bindFramebuffer(i.FRAMEBUFFER,null),s)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const s=this._renderTargetSystem;typeof e=="boolean"&&(e=e?mt.ALL:mt.NONE);const n=this._renderer.gl;if(e&mt.COLOR){i!=null||(i=s.defaultClearColor);const o=this._clearColorCache,a=i;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),t.stencil&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const u=o.source;u.antialias&&(i.context.supports.msaa?e.msaa=!0:_s("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(u,0);const l=i.texture.getGlSource(u).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){const o=s.createFramebuffer();e.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=s.createRenderbuffer();e.msaaRenderBuffer[u]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((s,n)=>{n!==0&&s.source.resize(i.width,i.height,i._resolution)}),e.msaa){const s=this._renderer,n=s.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=a.source;s.texture.bindSource(l,0);const c=s.texture.getGlSource(l).internalFormat,h=e.msaaRenderBuffer[u];n.bindRenderbuffer(n.RENDERBUFFER,h),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+u,n.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}}function yg(r,t,e,i,s,n){const o=n?1:-1;return r.identity(),r.a=1/i*2,r.d=o*(1/s*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var s2=Object.defineProperty,xg=Object.getOwnPropertySymbols,n2=Object.prototype.hasOwnProperty,o2=Object.prototype.propertyIsEnumerable,Tg=(r,t,e)=>t in r?s2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,a2=(r,t)=>{for(var e in t||(t={}))n2.call(t,e)&&Tg(r,e,t[e]);if(xg)for(var e of xg(t))o2.call(t,e)&&Tg(r,e,t[e]);return r};const Ke=new Map;function ja(r,t){if(!Ke.has(r)){const e=new P({source:new de(a2({resource:r},t))}),i=()=>{Ke.get(r)===e&&Ke.delete(r)};e.once("destroy",i),e.source.once("destroy",i),Ke.set(r,e)}return Ke.get(r)}function u2(r){return Ke.has(r)}function Sg(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var l2=Object.defineProperty,Eg=Object.getOwnPropertySymbols,c2=Object.prototype.hasOwnProperty,h2=Object.prototype.propertyIsEnumerable,Ag=(r,t,e)=>t in r?l2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pg=(r,t)=>{for(var e in t||(t={}))c2.call(t,e)&&Ag(r,e,t[e]);if(Eg)for(var e of Eg(t))h2.call(t,e)&&Ag(r,e,t[e]);return r};const wg=class Nb{constructor(t={}){if(this.uid=J("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Pg(Pg({},Nb.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;ei.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof P||t.depthStencilTexture instanceof rt?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 rt({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{s&&o===0||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};wg.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let vs=wg;class Va{constructor(t){this.rootViewPort=new j,this.viewport=new j,this.onRenderTargetChange=new Yo("onRenderTargetChange"),this.projectionMatrix=new G,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Sg(this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const u=n.colorTexture,l=this.viewport,c=u.pixelWidth,h=u.pixelHeight;if(!s&&t instanceof P&&(s=t.frame),s){const p=u._resolution;l.x=s.x*p+.5|0,l.y=s.y*p+.5|0,l.width=s.width*p+.5|0,l.height=s.height*p+.5|0}else l.x=0,l.y=0,l.width=c,l.height=h;return yg(this.projectionMatrix,0,0,l.width/u.resolution,l.height/u.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,l),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=mt.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=mt.ALL,i,s){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,i,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:o,pixelHeight:a}=t;return s.width=Math.min(s.width,o-i.x),s.height=Math.min(s.height,a-i.y),this.adaptor.copyToTexture(t,e,i,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return de.test(t)&&(t=ja(t).source),t instanceof vs?e=t:t instanceof rt&&(e=new vs({colorTextures:[t]}),de.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy();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))}}class Wa extends Va{constructor(t){super(t),this.adaptor=new vg,this.adaptor.init(t,this)}}Wa.extension={type:[x.WebGLSystem],name:"renderTarget"};class ys extends pt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=J("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=J("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=J("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function Rg(r,t){const e=[],i=[` var g = s.groups; var sS = r.shader; var p = s.glProgram; var ugS = r.uniformGroup; var resources; `];let s=!1,n=0,o=0;const a=t._getProgramData(r.glProgram);for(const l in r.groups){const c=r.groups[l];e.push(` resources = g[${l}].resources; `);for(const h in c.resources){const p=c.resources[h];if(p instanceof nt)p.ubo?e.push(` sS.bindUniformBlock( resources[${h}], sS._uniformBindMap[${l}[${h}], ${n++} ); `):e.push(` ugS.updateUniformGroup(resources[${h}], p, sD); `);else if(p instanceof ys)e.push(` sS.bindUniformBlock( resources[${h}], sS._uniformBindMap[${l}[${h}], ${n++} ); `);else if(p instanceof rt){const f=r._uniformBindMap[l][h],m=a.uniformData[f];m&&(s||(s=!0,i.push(` var tS = r.texture; `)),t._gl.uniform1i(m.location,o),e.push(` tS.bind(resources[${h}], ${o}); `),o++)}}}const u=[...i,...e].join(` `);return new Function("r","s","sD",u)}class d2{}class Mg{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 Ya(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Ka(r){const t=new Array(r);for(let e=0;eo>a?1:-1);for(let o=0;o`${c}: ${l}`),i=r.getShaderInfoLog(t),s=i.split(` `),n={},o=s.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const u=e.join(` `);a[0]=u,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Dg(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Fg(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Fg(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function Ug(r,t){const e=Ya(r,r.VERTEX_SHADER,t.vertex),i=Ya(r,r.FRAGMENT_SHADER,t.fragment),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Dg(r,s,e,i),t._attributeData=Gg(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Ig(s,r),t._uniformBlockData=Bg(s,r),r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t._uniformData){const u=t._uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:qa(u.type,u.size)}}return new Mg(s,o)}const Ts={textureCount:0,blockIndex:0};class Qa{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Ts.textureCount=0,Ts.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),i(this._renderer,t,Ts)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Ts)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o&&this._renderer.ubo.updateUniformGroup(t),s.updateBuffer(t.buffer);let a=this._boundUniformsIdsToIndexHash[t.uid];if(a===void 0){const c=this._nextIndex++%this._maxBindings,h=this._boundIndexToUniformsHash[c];h&&(this._boundUniformsIdsToIndexHash[h.uid]=void 0),a=this._boundUniformsIdsToIndexHash[t.uid]=c,this._boundIndexToUniformsHash[c]=t,o?s.bindBufferRange(t.buffer,c,t.offset):s.bindBufferBase(t.buffer,c)}const u=this._gl,l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==a&&(n.uniformBlockBindings[i]=a,u.uniformBlockBinding(n.program,l,a))}_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]=Ug(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return Rg(t,e)}}Qa.extension={type:[x.WebGLSystem],name:"shader"};const kg={f32:`if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3f(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(location, v[0], v[1], v[2], v[3]); }`,i32:`if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,u32:`if (cv !== v) { cu.value = v; gl.uniform1ui(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2ui(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3ui(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4ui(location, v[0], v[1], v[2], v[3]); }`,bool:`if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,"mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);"},Lg={f32:"gl.uniform1fv(location, v);","vec2":"gl.uniform2fv(location, v);","vec3":"gl.uniform3fv(location, v);","vec4":"gl.uniform4fv(location, v);","mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);"};function $g(r,t){const e=[` var v = null; var cv = null; var cu = null; var t = 0; var gl = renderer.gl; var name = null; `];for(const i in r.uniforms){if(!t[i]){r.uniforms[i]instanceof nt?r.uniforms[i].ubo?e.push(` renderer.shader.bindUniformBlock(uv.${i}, "${i}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${i}); `):r.uniforms[i]instanceof ys&&e.push(` renderer.shader.bindBufferResource(uv.${i}, "${i}"); `);continue}const s=r.uniformStructures[i];let n=!1;for(let o=0;o>1,i++;this.stateId=t.data}for(let e=0;e>1,1),s=Math.max(s>>1,1)}}},tu={id:"image",upload(r,t,e,i){const s=r.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s);const n=t.width,o=t.height,a=r.pixelWidth,u=r.pixelHeight,l=r.resourceWidth,c=r.resourceHeight;l1){const l=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](u,i.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&t[s](u,t.TEXTURE_COMPARE_FUNC,Kg[r.compare])}function qg(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 E2=Object.defineProperty,A2=Object.defineProperties,P2=Object.getOwnPropertyDescriptors,Zg=Object.getOwnPropertySymbols,w2=Object.prototype.hasOwnProperty,R2=Object.prototype.propertyIsEnumerable,Qg=(r,t,e)=>t in r?E2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Te=(r,t)=>{for(var e in t||(t={}))w2.call(t,e)&&Qg(r,e,t[e]);if(Zg)for(var e of Zg(t))R2.call(t,e)&&Qg(r,e,t[e]);return r},M2=(r,t)=>A2(r,P2(t));function Jg(r,t){let e={},i=r.RGBA;return r instanceof z.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),Te(Te(Te(Te(Te(Te(M2(Te({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 t_(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 C2(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,ru(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:s}=this.getPixels(t),n=z.get().createCanvas();n.width=i,n.height=s;const o=n.getContext("2d");if(o){const a=o.createImageData(i,s);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),o=new Uint8Array(O2*s*n),a=this._renderer,u=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(u),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,l.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}iu.extension={type:[x.WebGLSystem],name:"texture"};class su{init(){const t=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new G,type:"mat3x3"},uRound:{value:0,type:"f32"}}),e=$e({name:"graphics",bits:[Ui,Li(dt),Xi,He]});this.shader=new xt({glProgram:e,resources:{localUniforms:t,batchSamplers:$i}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:u}=o.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(a,s.glProgram);const l=u.instructions;for(let c=0;c",value:new G}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return}else{s=this._shader;const n=e.texture,o=n.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}nu.extension={type:[x.WebGLPipesAdaptor],name:"mesh"};class ou{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}ou.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"customRender"};function au(r,t){const e=r.instructionSet,i=e.instructions;for(let s=0;s>16&255,s=r>>8&255,n=r&255,o=t>>16&255,a=t>>8&255,u=t&255,l=i+(o-i)*e,c=s+(a-s)*e,h=n+(u-n)*e;return(l<<16)+(c<<8)+h}const qe=16777215;function hu(r,t){return r===qe||t===qe?r+t-qe:cu(r,t,.5)}function G2(r,t,e){const i=(e>>24&255)/255,s=t*i*255,n=((r&255)<<16)+(r&65280)+(r>>16&255),o=e&16777215;let a;return n===qe||o===qe?a=n+o-qe:a=cu(n,o,.5),a+(s<<24)}const B2=new Y;function du(r,t=!1){e_(r);const e=r.childrenToUpdate,i=r.updateTick++;for(const s in e){const n=e[s],o=n.list,a=n.index;for(let u=0;u1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function pu(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const s=r.parent;if(s&&!s.renderGroup?(e=e|r._updateFlags,r.relativeGroupTransform.appendFrom(i,s.relativeGroupTransform),e&&r_(r,s,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&&r_(r,B2,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&Zs&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&sr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function i_(r,t){const{list:e,index:i}=r.childrenRenderablesToUpdate;let s=!1;for(let n=0;n{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)W.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}mu.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"sprite"};var D2=Object.defineProperty,s_=Object.getOwnPropertySymbols,U2=Object.prototype.hasOwnProperty,k2=Object.prototype.propertyIsEnumerable,n_=(r,t,e)=>t in r?D2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,o_=(r,t)=>{for(var e in t||(t={}))U2.call(t,e)&&n_(r,e,t[e]);if(s_)for(var e of s_(t))k2.call(t,e)&&n_(r,e,t[e]);return r};const gu=class Hb{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new K(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=o_(o_({},Hb.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(){}};gu.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"background",priority:0},gu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let a_=gu;const Hr={};U.handle(x.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Hr[r.name]=r.ref},r=>{delete Hr[r.name]});class _u{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,i){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(i),this._isAdvanced=!!Hr[e],this._isAdvanced&&(this._beginAdvancedBlendMode(i),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Hr[e])return;let i=this._filterHash[e];i||(i=this._filterHash[e]=new er,i.filters=[new Hr[e]]);const s={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:i,canBundle:!1};this._renderableList=s.renderables,t.add(s)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}_u.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"blendMode"};var L2=Object.defineProperty,u_=Object.getOwnPropertySymbols,$2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,l_=(r,t,e)=>t in r?L2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bu=(r,t)=>{for(var e in t||(t={}))$2.call(t,e)&&l_(r,e,t[e]);if(u_)for(var e of u_(t))N2.call(t,e)&&l_(r,e,t[e]);return r};const vu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},yu=class Xb{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Y||t instanceof P?bu({target:t},e):bu(bu({},e),t)}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Xb.defaultImageOptions);const{format:e,quality:i}=t,s=this.canvas(t);if(s.toBlob!==void 0)return new Promise((n,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const u=new FileReader;u.onload=()=>n(u.result),u.onerror=o,u.readAsDataURL(a)},vu[e],i)});if(s.toDataURL!==void 0)return s.toDataURL(vu[e],i);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:vu[e],quality:i});return new Promise((o,a)=>{const u=new FileReader;u.onload=()=>o(u.result),u.onerror=a,u.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof P)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,s=e instanceof P?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof Y&&s.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof P?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),s=document.createElement("a");s.download=(e=t.filename)!=null?e:"image.png",s.href=i.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const s=this.canvas(t),n=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const o=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};yu.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"extract"},yu.defaultImageOptions={format:"png",quality:1};let c_=yu;class h_ extends P{static create(t){return new P({source:new rt(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}var H2=Object.defineProperty,X2=Object.defineProperties,z2=Object.getOwnPropertyDescriptors,d_=Object.getOwnPropertySymbols,j2=Object.prototype.hasOwnProperty,V2=Object.prototype.propertyIsEnumerable,p_=(r,t,e)=>t in r?H2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W2=(r,t)=>{for(var e in t||(t={}))j2.call(t,e)&&p_(r,e,t[e]);if(d_)for(var e of d_(t))V2.call(t,e)&&p_(r,e,t[e]);return r},Y2=(r,t)=>X2(r,z2(t));const K2=new j,q2=new lt,Z2=[0,0,0,0];class xu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof Y&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:K.shared.setValue(o).toArray():o=Z2;const a=((e=t.frame)==null?void 0:e.copyTo(K2))||ei(n,q2).rectangle;a.width=Math.max(a.width,1/i)|0,a.height=Math.max(a.height,1/i)|0;const u=h_.create(Y2(W2({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:i,antialias:s})),l=G.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:u,clearColor:o}),u}destroy(){this._renderer=null}}xu.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"textureGenerator"};class Tu{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"},uWorldTransformMatrix:{value:new G,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null}}Tu.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"globalUniforms"};let f_=!1;const Su="8.1.4";function m_(r){if(!f_){if(z.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Su} (${r}) http://www.pixijs.com/ `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Su} - ${r} - http://www.pixijs.com/`);f_=!0}}class Es{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===yt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),m_(e)}}}Es.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"hello",priority:-2},Es.defaultOptions={hello:!1};var Q2=Object.defineProperty,g_=Object.getOwnPropertySymbols,J2=Object.prototype.hasOwnProperty,tE=Object.prototype.propertyIsEnumerable,__=(r,t,e)=>t in r?Q2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b_=(r,t)=>{for(var e in t||(t={}))J2.call(t,e)&&__(r,e,t[e]);if(g_)for(var e of g_(t))tE.call(t,e)&&__(r,e,t[e]);return r};const Eu=class zb{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t=b_(b_({},zb.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};Eu.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"textureGC"},Eu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:3600,textureGCCheckCountMax:600};let Au=Eu;U.add(Au);var eE=Object.defineProperty,v_=Object.getOwnPropertySymbols,rE=Object.prototype.hasOwnProperty,iE=Object.prototype.propertyIsEnumerable,y_=(r,t,e)=>t in r?eE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,x_=(r,t)=>{for(var e in t||(t={}))rE.call(t,e)&&y_(r,e,t[e]);if(v_)for(var e of v_(t))iE.call(t,e)&&y_(r,e,t[e]);return r};const Pu=class jb{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=x_(x_({},jb.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new j(0,0,t.width,t.height),this.canvas=t.canvas||z.get().createCanvas(),this.antialias=!!t.antialias,this.texture=ja(this.canvas,t),this.renderTarget=new vs({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.autoDensity&&(this.canvas.style.width=`${this.texture.width}px`,this.canvas.style.height=`${this.texture.height}px`),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,this.autoDensity&&(this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`)}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Pu.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"view",priority:0},Pu.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let T_=Pu;const wu=[a_,Tu,Es,T_,fu,Au,xu,c_],Ru=[_u,Pa,mu,uu,wa,Ma,Ra,ou],sE=[...wu,za,hg,ig,Ca,iu,Wa,Fa,Ja,Qa,ka,Xg,La,Ua],nE=[...Ru],oE=[Ea,nu,su],S_=[],E_=[],A_=[];U.handleByNamedList(x.WebGLSystem,S_),U.handleByNamedList(x.WebGLPipes,E_),U.handleByNamedList(x.WebGLPipesAdaptor,A_),U.add(...sE,...nE,...oE);class P_ extends wr{constructor(){const t={name:"webgl",type:yt.WEBGL,systems:S_,renderPipes:E_,renderPipeAdaptors:A_};super(t)}}var aE={__proto__:null,WebGLRenderer:P_};class Mu{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 s;const n=this._gpu.device,o=e.layout[i],a=[],u=this._renderer;for(const h in o){const p=(s=t.resources[h])!=null?s:t.resources[o[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;u.ubo.updateUniformGroup(m);const _=m.buffer;f={buffer:u.buffer.getGPUBuffer(_),offset:0,size:_.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:u.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:u.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=u.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=u.texture.getGpuSource(m).createView({})}a.push({binding:o[h],resource:f})}const l=u.shader.getProgramData(e).bindGroups[i],c=n.createBindGroup({layout:l,entries:a});return this._hash[t._key]=c,c}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}Mu.extension={type:[x.WebGPUSystem],name:"bindGroup"};class Cu{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(fi(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,this._managedBuffers.push(t),e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}Cu.extension={type:[x.WebGPUSystem],name:"buffer"};function uE(r,t){const e=r.descriptor.size,i=t.gpu.device,s=new bt({data:new Float32Array(24e5),usage:H.MAP_READ|H.COPY_DST}),n=t.buffer.createGPUBuffer(s),o=i.createCommandEncoder();o.copyBufferToBuffer(t.buffer.getGPUBuffer(r),0,n,0,e),i.queue.submit([o.finish()]),n.mapAsync(GPUMapMode.READ,0,e).then(()=>{n.getMappedRange(0,e),n.unmap()})}class w_{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{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}As.extension={type:[x.WebGPUSystem],name:"device"},As.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var lE=Object.defineProperty,R_=Object.getOwnPropertySymbols,cE=Object.prototype.hasOwnProperty,hE=Object.prototype.propertyIsEnumerable,M_=(r,t,e)=>t in r?lE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C_=(r,t)=>{for(var e in t||(t={}))cE.call(t,e)&&M_(r,e,t[e]);if(R_)for(var e of R_(t))hE.call(t,e)&&M_(r,e,t[e]);return r};class Gu{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,s){const n=this._renderer.pipeline.getPipeline(t,e,i,s);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t){for(const e in t.attributes){const i=t.attributes[e];this._setVertexBuffer(i.location,i.buffer)}t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:s,topology:n,size:o,start:a,instanceCount:u,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e),this._setShaderBindGroups(i,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,u||e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),u||e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=C_({},this._boundVertexBuffer),s=this._boundIndexBuffer,n=C_({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in i)this._setVertexBuffer(a,i[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(s)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}Gu.extension={type:[x.WebGPUSystem],name:"encoder",priority:1};class Bu{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:st.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Bu.extension={type:[x.WebGPUSystem],name:"stencil"};const Xr={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function O_(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i1&&(n=Math.max(n,o)*s.data.size),e=Math.ceil(e/o)*o,s.size=n,s.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function G_(r,t){const{size:e,align:i}=Xr[r.data.type],s=(i-e)/4;return` v = uv.${r.data.name}; ${t!==0?`offset += ${t};`:""} arrayOffset = offset; t = 0; for(var i=0; i < ${r.data.size*(e/4)}; i++) { for(var j = 0; j < ${e/4}; j++) { data[arrayOffset++] = v[t++]; } ${s!==0?`arrayOffset += ${s};`:""} } `}function B_(r){return Ha(r,"uboWgsl",G_,gg)}class Iu extends $a{constructor(){super({createUboElements:O_,generateUboSync:B_})}}Iu.extension={type:[x.WebGPUSystem],name:"ubo"};const se=128;class Fu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new w_({minUniformOffsetAlignment:se});const e=256/se;for(let i=0;it in r?dE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_E=(r,t)=>{for(var e in t||(t={}))mE.call(t,e)&&F_(r,e,t[e]);if(I_)for(var e of I_(t))gE.call(t,e)&&F_(r,e,t[e]);return r},bE=(r,t)=>pE(r,fE(t));const vE={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function yE(r,t,e,i,s){return r<<24|t<<16|e<<10|i<<5|s}function xE(r,t,e,i){return e<<6|r<<3|i<<1|t}class Du{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(st.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=re[t],this._updatePipeHash())}setPipeline(t,e,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(Ba(t,e.attributeData),this._generateBufferKey(t)),s=s||t.topology;const n=yE(t._layoutKey,e._layoutKey,i.data,i._blendModeId,vE[s]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,s),this._pipeCache[n])}_createPipeline(t,e,i,s){const n=this._gpu.device,o=this._createVertexBufferLayouts(t),a=this._renderer.state.getColorTargets(i);a[0].writeMask=this._stencilMode===st.RENDERING_MASK_ADD?0:this._colorMask;const u=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:i.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil=bE(_E({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),n.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const s=Object.keys(t.attributes).sort();for(let o=0;o{const s={arrayStride:0,stepMode:"vertex",attributes:[]},n=s.attributes;for(const o in t.attributes){const a=t.attributes[o];a.buffer===i&&(s.arrayStride=a.stride,s.stepMode=a.instance?"instance":"vertex",n.push({shaderLocation:a.location,offset:a.offset,format:a.format}))}n.length&&e.push(s)}),this._bufferLayoutsCache[t._layoutKey]=e,e}_updatePipeHash(){const t=xE(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Du.extension={type:[x.WebGPUSystem],name:"pipeline"};class D_{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class U_{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const o=this._renderer,a=this._getGpuColorTexture(t),u=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:i},{texture:u,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?mt.ALL:mt.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),o=t.colorTextures.map((u,l)=>{const c=n.contexts[l];let h,p;c?h=c.getCurrentTexture().createView():h=this._renderer.texture.getGpuSource(u).createView({mipLevelCount:1}),n.msaaTextures[l]&&(p=h,h=this._renderer.texture.getTextureView(n.msaaTextures[l]));const f=e&mt.COLOR?"clear":"load";return i!=null||(i=s.defaultClearColor),{view:h,resolveTarget:p,clearValue:i,storeOp:"store",loadOp:f}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const u=e&mt.STENCIL?"clear":"load",l=e&mt.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:u,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const u=a.createCommandEncoder(),l=this.getDescriptor(t,e,i),c=u.beginRenderPass(l);c.setViewport(s.x,s.y,s.width,s.height,0,1),c.end();const h=u.finish();a.queue.submit([h])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new D_;return t.colorTextures.forEach((i,s)=>{if(de.test(i.resource)){const n=i.resource.getContext("webgpu"),o=i.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[s]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new rt({width:0,height:0,sampleCount:4});e.msaaTextures[s]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,s)=>{const n=e.msaaTextures[s];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class Uu extends Va{constructor(t){super(t),this.adaptor=new U_,this.adaptor.init(t,this)}}Uu.extension={type:[x.WebGPUSystem],name:"renderTarget"};class ku{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}ku.extension={type:[x.WebGPUSystem],name:"shader"};const St={};St.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},St.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},St.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},St.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},St.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},St.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},St["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},St["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},St["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},St.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class Lu{constructor(){this.defaultState=new Bt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:St[t.blendMode]||St.normal}]}destroy(){this.gpu=null}}Lu.extension={type:[x.WebGPUSystem],name:"state"};const k_={type:"image",upload(r,t,e){const i=r.resource,s=(r.pixelWidth|0)*(r.pixelHeight|0),n=i.byteLength/s;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},$u={"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}},TE={blockBytes:4,blockWidth:1,blockHeight:1},L_={type:"compressed",upload(r,t,e){let i=r.pixelWidth,s=r.pixelHeight;const n=$u[r.format]||TE;for(let o=0;o>1,1),s=Math.max(s>>1,1)}}},Nu={type:"image",upload(r,t,e){const i=r.resource;if(!i)return;const s=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:o},{width:s,height:n})}},$_={type:"video",upload(r,t,e){Nu.upload(r,t,e)}};class N_{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:` var pos : array, 3> = array, 3>( vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0)); struct VertexOutput { @builtin(position) position : vec4, @location(0) texCoord : vec2, }; @vertex fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { var output : VertexOutput; output.texCoord = pos[vertexIndex] * vec2(0.5, -0.5) + vec2(0.5); output.position = vec4(pos[vertexIndex], 0.0, 1.0); return output; } @group(0) @binding(0) var imgSampler : sampler; @group(0) @binding(1) var img : texture_2d; @fragment fn fragmentMain(@location(0) texCoord : vec2) -> @location(0) vec4 { return textureSample(img, imgSampler, texCoord); } `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const u={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(u)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let u=0;u1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new N_(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return(e=this._bindGroupHash[t.uid])!=null?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source,i=e.uid;return this._bindGroupHash[i]=new Nt({0:e,1:e.style}),this._bindGroupHash[i]}getTextureView(t){var e;const i=t.source;return(e=this._textureViewHash[i.uid])!=null?e:this._createTextureView(i)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),s=z.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){const e=this.generateCanvas(t),i=Ht.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:o}=e,a=s.getImageData(0,0,n,o),u=new Uint8ClampedArray(a.data.buffer);return Ht.returnCanvasAndContext(i),{pixels:u,width:n,height:o}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Hu.extension={type:[x.WebGPUSystem],name:"texture"};class Xu{init(){const t=new nt({uTransformMatrix:{value:new G,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),e=Le({name:"graphics",bits:[Di,ki(dt),sp,Ne]});this.shader=new xt({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:u}=o.getContextRenderData(i),l=n.encoder;l.setPipelineFromGeometryProgramAndState(a,s.gpuProgram,t.state),l.setGeometry(a);const c=n.globalUniforms.bindGroup;l.setBindGroup(0,c,s.gpuProgram);const h=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);l.setBindGroup(2,h,s.gpuProgram);const p=u.instructions;for(let f=0;f",value:new G}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(!s)s=this._shader,s.resources.uTexture=e.texture.source,s.resources.uSampler=e.texture.source.style,s.resources.textureUniforms.uniforms.uTextureMatrix=e.texture.textureMatrix.mapCoord;else if(!s.gpuProgram)return;const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}zu.extension={type:[x.WebGPUPipesAdaptor],name:"mesh"};const SE=[...wu,Iu,Gu,As,Cu,Hu,Uu,ku,Lu,Du,Ou,Bu,Mu],EE=[...Ru,Fu],AE=[Aa,zu,Xu],H_=[],X_=[],z_=[];U.handleByNamedList(x.WebGPUSystem,H_),U.handleByNamedList(x.WebGPUPipes,X_),U.handleByNamedList(x.WebGPUPipesAdaptor,z_),U.add(...SE,...EE,...AE);class j_ extends wr{constructor(){const t={name:"webgpu",type:yt.WEBGPU,systems:H_,renderPipes:X_,renderPipeAdaptors:z_};super(t)}}var PE={__proto__:null,WebGPURenderer:j_};const wE={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},RE=new Proxy(wE,{get(r,t){return r[t]}}),ME=new j(0,0,1,1);function CE(r,t,e){e||(e=ME);const i=t.pixelWidth,s=t.pixelHeight;return r.x=e.x*i|0,r.y=e.y*s|0,r.width=e.width*i|0,r.height=e.height*s|0,r}var V_=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(V_||{}),ju=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(ju||{});const OE=new Proxy(ju,{get(r,t){return r[t]}});var Vu=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Vu||{});const GE=new Proxy(Vu,{get(r,t){return r[t]}});class BE{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,u=t.x/s+o,l=t.y/n+a;i=k.add(i,k.NW),this.x0=u+o*k.uX(i),this.y0=l+a*k.uY(i),i=k.add(i,2),this.x1=u+o*k.uX(i),this.y1=l+a*k.uY(i),i=k.add(i,2),this.x2=u+o*k.uX(i),this.y2=l+a*k.uY(i),i=k.add(i,2),this.x3=u+o*k.uX(i),this.y3=l+a*k.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}let IE=0;function FE(){return IE++}function DE(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()}var UE=Object.defineProperty,Ps=Object.getOwnPropertySymbols,W_=Object.prototype.hasOwnProperty,Y_=Object.prototype.propertyIsEnumerable,K_=(r,t,e)=>t in r?UE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kE=(r,t)=>{for(var e in t||(t={}))W_.call(t,e)&&K_(r,e,t[e]);if(Ps)for(var e of Ps(t))Y_.call(t,e)&&K_(r,e,t[e]);return r},LE=(r,t)=>{var e={};for(var i in r)W_.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&&Y_.call(r,i)&&(e[i]=r[i]);return e};class $E extends Y{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const s=t,{render:n}=s,o=LE(s,["render"]);super(kE({label:"RenderContainer"},o)),this.batched=!1,this.bounds=new lt,this.canBundle=!1,this.renderPipeId="customRender",n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(i=t.addBounds)!=null?i:()=>!1}render(t){}}function NE(r,t){const e=t._scale,i=t._pivot,s=t._position,n=e._x,o=e._y,a=i._x,u=i._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=s._x-(a*r.a+u*r.c),r.ty=s._y-(a*r.b+u*r.d)}function HE(r,t,e){const i=r.a,s=r.b,n=r.c,o=r.d,a=r.tx,u=r.ty,l=t.a,c=t.b,h=t.c,p=t.d;e.a=i*l+s*h,e.b=i*c+s*p,e.c=n*l+o*h,e.d=n*c+o*p,e.tx=a*l+u*h+t.tx,e.ty=a*c+u*p+t.ty}const XE={rectangle:Fn,polygon:In,triangle:Dn,circle:fe,ellipse:fe,roundedRectangle:fe};function zE(r){r instanceof Qt&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],s=r.path.shapePath,n=r.textureMatrix;s.shapePrimitives.forEach(({shape:a,transform:u})=>{const l=i.length,c=t.length/2,h=[],p=XE[a.type];p.build(a,h),u&&mi(h,u),p.triangulate(h,t,2,c,i,l);const f=e.length/2;n?(u&&n.append(u.clone().invert()),wn(t,2,c,e,f,2,t.length/2-c,n)):Rn(e,f,2,t.length/2-c)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(i),o):new Jt({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var jE=Object.defineProperty,VE=Object.defineProperties,WE=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertySymbols,q_=Object.prototype.hasOwnProperty,Z_=Object.prototype.propertyIsEnumerable,Q_=(r,t,e)=>t in r?jE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,YE=(r,t)=>{for(var e in t||(t={}))q_.call(t,e)&&Q_(r,e,t[e]);if(ws)for(var e of ws(t))Z_.call(t,e)&&Q_(r,e,t[e]);return r},KE=(r,t)=>VE(r,WE(t)),qE=(r,t)=>{var e={};for(var i in r)q_.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&&Z_.call(r,i)&&(e[i]=r[i]);return e};class ZE extends Ur{constructor(t){const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=qE(e,["texture","verticesX","verticesY"]),a=new No(Zt({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(Zt(KE(YE({},o),{geometry:a,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:i}=this.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var QE=Object.defineProperty,J_=Object.getOwnPropertySymbols,JE=Object.prototype.hasOwnProperty,tA=Object.prototype.propertyIsEnumerable,tb=(r,t,e)=>t in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eb=(r,t)=>{for(var e in t||(t={}))JE.call(t,e)&&tb(r,e,t[e]);if(J_)for(var e of J_(t))tA.call(t,e)&&tb(r,e,t[e]);return r};const rb=class Vb extends Jt{constructor(t){const{width:e,points:i,textureScale:s}=eb(eb({},Vb.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=s,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,u=t[0];const l=this._width*this.textureScale,c=t.length;for(let p=0;p0){const m=u.x-t[p].x,_=u.y-t[p].y,g=Math.sqrt(m*m+_*_);u=t[p],a+=g/l}else a=p/(c-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let h=0;for(let p=0;p0?this.textureScale*this._width/2:this._width/2;for(let l=0;l1&&(p=1);const f=Math.sqrt(s*s+n*n);f<1e-6?(s=0,n=0):(s/=f,n/=f,s*=u,n*=u),o[h]=c.x+s,o[h+1]=c.y+n,o[h+2]=c.x-s,o[h+3]=c.y-n,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};rb.defaultOptions={width:200,points:[],textureScale:0};let ib=rb;var eA=Object.defineProperty,rA=Object.defineProperties,iA=Object.getOwnPropertyDescriptors,Rs=Object.getOwnPropertySymbols,sb=Object.prototype.hasOwnProperty,nb=Object.prototype.propertyIsEnumerable,ob=(r,t,e)=>t in r?eA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wu=(r,t)=>{for(var e in t||(t={}))sb.call(t,e)&&ob(r,e,t[e]);if(Rs)for(var e of Rs(t))nb.call(t,e)&&ob(r,e,t[e]);return r},sA=(r,t)=>rA(r,iA(t)),nA=(r,t)=>{var e={};for(var i in r)sb.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Rs)for(var i of Rs(r))t.indexOf(i)<0&&nb.call(r,i)&&(e[i]=r[i]);return e};const ab=class Wb extends Ur{constructor(t){const e=Wu(Wu({},Wb.defaultOptions),t),{texture:i,points:s,textureScale:n}=e,o=nA(e,["texture","points","textureScale"]),a=new ib(Zt({width:i.height,points:s,textureScale:n}));n>0&&(i.source.style.addressMode="repeat"),super(Zt(sA(Wu({},o),{texture:i,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};ab.defaultOptions={textureScale:0};let oA=ab;var aA=Object.defineProperty,uA=Object.defineProperties,lA=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,ub=Object.prototype.hasOwnProperty,lb=Object.prototype.propertyIsEnumerable,cb=(r,t,e)=>t in r?aA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cA=(r,t)=>{for(var e in t||(t={}))ub.call(t,e)&&cb(r,e,t[e]);if(Ms)for(var e of Ms(t))lb.call(t,e)&&cb(r,e,t[e]);return r},hA=(r,t)=>uA(r,lA(t)),dA=(r,t)=>{var e={};for(var i in r)ub.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&&lb.call(r,i)&&(e[i]=r[i]);return e};class pA extends Ur{constructor(t){const e=t,{texture:i,vertices:s,uvs:n,indices:o,topology:a}=e,u=dA(e,["texture","vertices","uvs","indices","topology"]),l=new Jt(Zt({positions:s,uvs:n,indices:o,topology:a}));super(Zt(hA(cA({},u),{texture:i,geometry:l}))),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 fA(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}var mA=Object.defineProperty,Cs=Object.getOwnPropertySymbols,hb=Object.prototype.hasOwnProperty,db=Object.prototype.propertyIsEnumerable,pb=(r,t,e)=>t in r?mA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gA=(r,t)=>{for(var e in t||(t={}))hb.call(t,e)&&pb(r,e,t[e]);if(Cs)for(var e of Cs(t))db.call(t,e)&&pb(r,e,t[e]);return r},_A=(r,t)=>{var e={};for(var i in r)hb.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Cs)for(var i of Cs(r))t.indexOf(i)<0&&db.call(r,i)&&(e[i]=r[i]);return e};const fb=class Yb extends Y{constructor(t){var e,i,s,n,o,a,u,l,c,h;t instanceof P&&(t={texture:t});const p=t,{width:f,height:m,leftWidth:_,rightWidth:g,topHeight:b,bottomHeight:v,texture:y,roundPixels:T}=p,E=_A(p,["width","height","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(gA({label:"NineSliceSprite"},E)),this._roundPixels=0,this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this.bounds={minX:0,minY:0,maxX:0,maxY:0},this._leftWidth=(i=_!=null?_:(e=y==null?void 0:y.defaultBorders)==null?void 0:e.left)!=null?i:te.defaultOptions.leftWidth,this._topHeight=(n=b!=null?b:(s=y==null?void 0:y.defaultBorders)==null?void 0:s.top)!=null?n:te.defaultOptions.topHeight,this._rightWidth=(a=g!=null?g:(o=y==null?void 0:y.defaultBorders)==null?void 0:o.right)!=null?a:te.defaultOptions.rightWidth,this._bottomHeight=(l=v!=null?v:(u=y==null?void 0:y.defaultBorders)==null?void 0:u.bottom)!=null?l:te.defaultOptions.bottomHeight,this.bounds.maxX=this._width=(c=f!=null?f:y.width)!=null?c:te.defaultOptions.width,this.bounds.maxY=this._height=(h=m!=null?m:y.height)!=null?h:te.defaultOptions.height,this.allowChildren=!1,this.texture=y!=null?y:Yb.defaultOptions.texture,this.roundPixels=T!=null?T:!1}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=P.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didChangeId+=4096,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds;return t.x>=e.minX&&t.x<=e.maxX&&t.y>=e.minY&&t.y<=e.maxY}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,this.bounds=null}};fb.defaultOptions={texture:P.EMPTY};let mb=fb;class bA extends mb{constructor(...t){let e=t[0];e instanceof P&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function vA(r,t){return t instanceof Ft||t instanceof ye?t:r==="html"?new ye(t):new Ft(t)}const yA=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;async function xA(r,t,e=200){const i=await t.extract.base64(r);await t.encoder.commandFinished;const s=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var TA=Object.defineProperty,SA=Object.defineProperties,EA=Object.getOwnPropertyDescriptors,gb=Object.getOwnPropertySymbols,AA=Object.prototype.hasOwnProperty,PA=Object.prototype.propertyIsEnumerable,_b=(r,t,e)=>t in r?TA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bb=(r,t)=>{for(var e in t||(t={}))AA.call(t,e)&&_b(r,e,t[e]);if(gb)for(var e of gb(t))PA.call(t,e)&&_b(r,e,t[e]);return r},wA=(r,t)=>SA(r,EA(t));const RA=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let MA=0;function vb(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=RA[MA++]);let i="";for(let o=0;o