From c2bc9ee06367d16d4518ebefc2c353545b7a0090 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 17 Jul 2024 16:22:57 -0500 Subject: [PATCH 01/32] add pixi --- index.html | 23 +- js/pixi.min.mjs | 2009 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2023 insertions(+), 9 deletions(-) create mode 100644 js/pixi.min.mjs diff --git a/index.html b/index.html index 57f9a45e..3619b4c9 100644 --- a/index.html +++ b/index.html @@ -37,14 +37,18 @@

Example input files (right click to save): -

+

@@ -189,6 +193,7 @@

+ @@ -196,4 +201,4 @@

- + \ No newline at end of file diff --git a/js/pixi.min.mjs b/js/pixi.min.mjs new file mode 100644 index 00000000..80529631 --- /dev/null +++ b/js/pixi.min.mjs @@ -0,0 +1,2009 @@ +/*! + * PixiJS - v8.2.5 + * Compiled Fri, 12 Jul 2024 12:30:00 UTC + * + * PixiJS is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var Ob=Object.defineProperty,Cb=Object.defineProperties,Gb=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,Ib=Object.prototype.hasOwnProperty,Bb=Object.prototype.propertyIsEnumerable,vl=(r,t,e)=>t in r?Ob(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yl=(r,t)=>{for(var e in t||(t={}))Ib.call(t,e)&&vl(r,e,t[e]);if(bl)for(var e of bl(t))Bb.call(t,e)&&vl(r,e,t[e]);return r},Fb=(r,t)=>Cb(r,Gb(t)),v=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r))(v||{});const Vi=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=Fb(yl({},t),{ref:r})}if(typeof r=="object")r=yl({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},or=(r,t)=>{var e;return(e=Vi(r).priority)!=null?e:t},D={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Vi).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(Vi).forEach(t=>{t.type.forEach(e=>{var s,i;const n=this._addHandlers,o=this._queue;n[e]?(i=n[e])==null||i.call(n,t):(o[e]=o[e]||[],(s=o[e])==null||s.push(t))})}),this},handle(r,t,e){var s;const i=this._addHandlers,n=this._removeHandlers;i[r]=t,n[r]=e;const o=this._queue;return o[r]&&((s=o[r])==null||s.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(i=>i.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((i,n)=>or(n.value,e)-or(i.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>or(n,e)-or(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})}};var NP=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Wi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function HP(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function XP(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function zP(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var Yi={exports:{}},jP=Yi.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function n(u,l,h,c,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var p=new i(h,c||u,d),f=e?e+l:l;return u._events[f]?u._events[f].fn?u._events[f]=[u._events[f],p]:u._events[f].push(p):(u._events[f]=p,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new s:delete u._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,c;if(this._eventsCount===0)return l;for(c in h=this._events)t.call(h,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=e?e+l:l,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d0:typeof r=="number"},nt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},wt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Tl=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Sl=function(r){return{r:wt(r.r,0,255),g:wt(r.g,0,255),b:wt(r.b,0,255),a:wt(r.a)}},Ki=function(r){return{r:nt(r.r),g:nt(r.g),b:nt(r.b),a:nt(r.a,3)}},kb=/^#([0-9a-f]{3,8})$/i,as=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},El=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},Al=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),u=s*(1-(1-t+n)*e),l=n%6;return{r:255*[s,a,o,o,u,s][l],g:255*[u,s,s,a,o,o][l],b:255*[o,o,u,s,s,a][l],a:i}},Pl=function(r){return{h:Tl(r.h),s:wt(r.s,0,100),l:wt(r.l,0,100),a:wt(r.a)}},wl=function(r){return{h:nt(r.h),s:nt(r.s),l:nt(r.l),a:nt(r.a,3)}},Rl=function(r){return Al((e=(t=r).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},ar=function(r){return{h:(t=El(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},$b=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Nb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qi={string:[[function(r){var t=kb.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?nt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?nt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Nb.exec(r)||Hb.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Sl({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=$b.exec(r)||Lb.exec(r);if(!t)return null;var e,s,i=Pl({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Ub[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Rl(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return Xt(t)&&Xt(e)&&Xt(s)?Sl({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!Xt(t)||!Xt(e)||!Xt(s))return null;var o=Pl({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return Rl(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!Xt(t)||!Xt(e)||!Xt(s))return null;var o=function(a){return{h:Tl(a.h),s:wt(a.s,0,100),v:wt(a.v,0,100),a:wt(a.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return Al(o)},"hsv"]]},Ml=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Ki(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?as(nt(255*n)):"","#"+as(e)+as(s)+as(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return Ki(this.rgba)},r.prototype.toRgbString=function(){return t=Ki(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return wl(ar(this.rgba))},r.prototype.toHslString=function(){return t=wl(ar(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=El(this.rgba),{h:nt(t.h),s:nt(t.s),v:nt(t.v),a:nt(t.a,3)};var t},r.prototype.invert=function(){return Ut({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),Ut(Zi(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ut(Zi(this.rgba,-t))},r.prototype.grayscale=function(){return Ut(Zi(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ut(Cl(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ut(Cl(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"?Ut({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):nt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=ar(this.rgba);return typeof t=="number"?Ut({h:t,s:e.s,l:e.l,a:e.a}):nt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ut(t).toHex()},r}(),Ut=function(r){return r instanceof us?r:new us(r)},Gl=[],Xb=function(r){r.forEach(function(t){Gl.indexOf(t)<0&&(t(us,qi),Gl.push(t))})},WP=function(){return new us({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function zb(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,u,l=s[this.toHex()];if(l)return l;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var g=(a=h,u=n[f],Math.pow(a.r-u.r,2)+Math.pow(a.g-u.g,2)+Math.pow(a.b-u.b,2));gt in r?jb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yb=(r,t)=>{for(var e in t||(t={}))Vb.call(t,e)&&Bl(r,e,t[e]);if(Il)for(var e of Il(t))Wb.call(t,e)&&Bl(r,e,t[e]);return r};Xb([zb]);const we=class ts{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 ts)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?Yb({},t):t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((i,n)=>i===e[n]);if(t!==null&&e!==null){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,i,n]=ts._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=ts.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ut(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ts||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 X=we;const Fl={cullArea:null,cullable:!1,cullableChildren:!0},Dl=Math.PI*2,Ul=180/Math.PI,kl=Math.PI/180;class W{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new W(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 Ji.x=0,Ji.y=0,Ji}}const Ji=new W;class C{constructor(t=1,e=0,s=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,i,n,o){return this.a=t,this.b=e,this.c=s,this.d=i,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new W;const s=t.x,i=t.y;return e.x=this.a*s+this.c*i+this.tx,e.y=this.b*s+this.d*i+this.ty,e}applyInverse(t,e){e=e||new W;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,u=this.ty,l=1/(s*o+n*-i),h=t.x,c=t.y;return e.x=o*l*h+-n*l*c+(u*n-a*o)*l,e.y=s*l*c+-i*l*h+(-u*s+a*i)*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),s=Math.sin(t),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*s,this.b=i*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}appendFrom(t,e){const s=t.a,i=t.b,n=t.c,o=t.d,a=t.tx,u=t.ty,l=e.a,h=e.b,c=e.c,d=e.d;return this.a=s*l+i*c,this.b=s*h+i*d,this.c=n*l+o*c,this.d=n*h+o*d,this.tx=a*l+u*c+e.tx,this.ty=a*h+u*d+e.ty,this}setTransform(t,e,s,i,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-(s*this.a+i*this.c),this.ty=e-(s*this.b+i*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,i=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),u=Math.atan2(s,e),l=Math.abs(a+u);return l<1e-5||Math.abs(Dl-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+s*s),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new C;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 qb.identity()}static get shared(){return Kb.identity()}}const Kb=new C,qb=new C;class rt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new rt(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 ur={default:-1};function Q(r="default"){return ur[r]===void 0&&(ur[r]=-1),++ur[r]}function Zb(){for(const r in ur)delete ur[r]}class ls{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?s=this._pool[--this._index]:s=new this._classType,(e=s.init)==null||e.call(s,t),s}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}}class $l{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 ls(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const z=new $l;function tn(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i0&&s<=e){for(let o=e-1;o>=r;o--){const a=this.children[o];a&&(i.push(a),a.parent=null)}tn(this.children,r,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(i);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 i=r.parent.children.indexOf(r);if(r.parent===this&&i===t)return r;i!==-1&&r.parent.children.splice(i,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 s=this.renderGroup||this.parentRenderGroup;return s&&s.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),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didChangeId++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r}};class lr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;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-s.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),hs.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=hs.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 lr);r=r;const s=(r==null?void 0:r.length)>0,i=((t=e.filters)==null?void 0:t.length)>0,n=s!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new lr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Xl={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s=this.x&&t=this.y&&e=u&&t<=l&&e>=h&&e<=c&&!(t>d&&tf&&et.right?t.right:this.right)<=R)return!1;const S=this.yt.bottom?t.bottom:this.bottom)>S}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=cs[0].set(t.left,t.top),u=cs[1].set(t.left,t.bottom),l=cs[2].set(t.right,t.top),h=cs[3].set(t.right,t.bottom);if(l.x<=a.x||u.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(u,u),e.apply(l,l),e.apply(h,h),Math.max(a.x,u.x,l.x,h.x)<=s||Math.min(a.x,u.x,l.x,h.x)>=i||Math.max(a.y,u.y,l.y,h.y)<=n||Math.min(a.y,u.y,l.y,h.y)>=o))return!1;const d=c*(u.y-a.y),p=c*(a.x-u.x),f=d*s+p*n,g=d*i+p*n,m=d*s+p*o,_=d*i+p*o;if(Math.max(f,g,m,_)<=d*a.x+p*a.y||Math.min(f,g,m,_)>=d*h.x+p*h.y)return!1;const x=c*(a.y-l.y),b=c*(l.x-a.x),y=x*s+b*n,T=x*i+b*n,w=x*s+b*o,P=x*i+b*o;return!(Math.max(y,T,w,P)<=x*a.x+b*a.y||Math.min(y,T,w,P)>=x*h.x+b*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=i-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t=t||new V,t.copyFrom(this),t}}const zl=new C;class lt{constructor(t=1/0,e=1/0,s=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=zl,this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new V);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=zl,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,u=n.c,l=n.d,h=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,m=o*t+u*e+h,_=a*t+l*e+c;mf&&(f=m),_>g&&(g=_),m=o*s+u*e+h,_=a*s+l*e+c,mf&&(f=m),_>g&&(g=_),m=o*t+u*i+h,_=a*t+l*i+c,mf&&(f=m),_>g&&(g=_),m=o*s+u*i+h,_=a*s+l*i+c,mf&&(f=m),_>g&&(g=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+u*n+h,p=a*e+l*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+u*n+h,p=a*i+l*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,i){return this.minXe&&(this.maxX=e),this.minYi&&(this.maxY=i),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new 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,s,i){let n=this.minX,o=this.minY,a=this.maxX,u=this.maxY;i||(i=this.matrix);const l=i.a,h=i.b,c=i.c,d=i.d,p=i.tx,f=i.ty;for(let g=e;ga?x:a,u=b>u?b: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 kt=new ls(C),$t=new ls(lt);function hr(r,t,e){e.clear();let s,i;return r.parent?t?s=r.parent.worldTransform:(i=kt.get().identity(),s=cr(r,i)):s=C.IDENTITY,en(r,e,s,t),i&&kt.return(i),e.isValid||e.set(0,0,0,0),e}function en(r,t,e,s){var i,n;if(!r.visible||!r.measurable)return;let o;s?o=r.worldTransform:(r.updateLocalTransform(),o=kt.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),rn(this,r),r.didChange&&ds(this,r.localBounds,Qb),r.localBounds},getBounds(r,t){return hr(this,r,t||new lt)}},Yl={_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}},Kl={_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(Jb))}};function Jb(r,t){return r._zIndex-t._zIndex}const ql={getGlobalPosition(r=new W,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 s=cr(this,new C);return s.append(this.localTransform),s.apply(r,t)}return this.worldTransform.apply(r,t)},toLocal(r,t,e,s){if(t&&(r=t.toGlobal(r,e,s)),!s){this.updateLocalTransform();const i=cr(this,new C);return i.append(this.localTransform),i.applyInverse(r,e)}return this.worldTransform.applyInverse(r,e)}};class sn{constructor(){this.uid=Q("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 Zl{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new C,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 sn,this._onRenderContainers=[]}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(i)),this.effects=[],(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(Y.prototype,Object.getOwnPropertyDescriptors(t))}addChild(...t){if(t.length>1){for(let i=0;i1){for(let i=0;i-1&&(this._didChangeId+=4096,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),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){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=z.get(Zl,this),this.groupTransform=C.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),z.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new C),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*Ul}set angle(t){this.rotation=t*kl}get pivot(){return this._pivot===on&&(this._pivot=new rt(this,0,0)),this._pivot}set pivot(t){this._pivot===on&&(this._pivot=new rt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===nn&&(this._skew=new rt(this,0,0)),this._skew}set skew(t){this._skew===nn&&(this._skew=new rt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===an&&(this._scale=new rt(this,1,1)),this._scale}set scale(t){this._scale===an&&(this._scale=new rt(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 s;const i=this.getLocalBounds();let n,o;typeof t!="object"?(n=t,o=e!=null?e:t):(n=t.width,o=(s=t.height)!=null?s:t.width),n!==void 0&&this._setWidth(n,i.width),o!==void 0&&this._setHeight(o,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didChangeId&4095;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,i=this._pivot,n=this._position,o=s._x,a=s._y,u=i._x,l=i._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=n._x-(u*e.a+l*e.c),e.ty=n._y-(u*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=dr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=X.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=dr,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|=ps,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Re,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Re,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|=Re,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;const s=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 ev(r){return function(t){return t.test(r)}}function hh(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var i=ev(e),n={apple:{phone:i(un)&&!i(zt),ipod:i(Jl),tablet:!i(un)&&(i(th)||lh(t))&&!i(zt),universal:i(eh),device:(i(un)||i(Jl)||i(th)||i(eh)||lh(t))&&!i(zt)},amazon:{phone:i(Me),tablet:!i(Me)&&i(fs),device:i(Me)||i(fs)},android:{phone:!i(zt)&&i(Me)||!i(zt)&&i(ln),tablet:!i(zt)&&!i(Me)&&!i(ln)&&(i(fs)||i(rh)),device:!i(zt)&&(i(Me)||i(fs)||i(ln)||i(rh))||i(/\bokhttp\b/i)},windows:{phone:i(zt),tablet:i(sh),device:i(zt)||i(sh)},other:{blackberry:i(ih),blackberry10:i(nh),opera:i(oh),firefox:i(uh),chrome:i(ah),device:i(ih)||i(nh)||i(oh)||i(uh)||i(ah)},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 ch;const rv=(ch=hh.default)!=null?ch:hh,dh=rv(globalThis.navigator),sv=9,ms=100,iv=0,nv=0,ph=2,fh=1,ov=-1e3,av=-1e3,uv=2;class hn{constructor(t,e=dh){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 s=document.createElement("div");s.style.width=`${ms}px`,s.style.height=`${ms}px`,s.style.position="absolute",s.style.top=`${iv}px`,s.style.left=`${nv}px`,s.style.zIndex=ph.toString(),this._div=s,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=`${fh}px`,t.style.height=`${fh}px`,t.style.position="absolute",t.style.top=`${ov}px`,t.style.left=`${av}px`,t.style.zIndex=uv.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 s=0;s 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:s}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}_addChild(t){let e=this._pool.pop();e||(e=document.createElement("button"),e.style.width=`${ms}px`,e.style.height=`${ms}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=ph.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:s}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new Je(i),{target:s});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===sv&&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}}hn.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"accessibility"};const mh={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};D.add(hn),Y.mixin(mh);class cn{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,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}cn.extension=v.Application;var jt=(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))(jt||{});class gs{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const gh=class Et{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 gs(null,null,1/0),this.deltaMS=1/Et.targetFPMS,this.elapsedMS=1/Et.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=jt.NORMAL){return this._addListener(new gs(t,e,s))}addOnce(t,e,s=jt.NORMAL){return this._addListener(new gs(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{this._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()}}}dn.extension=v.Application,D.add(cn),D.add(dn);let lv=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,jt.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,pointerType:t.pointerType,pointerId:t.pointerId}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTimes.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let s=0,i=e.length;s=0;i--)if(t.currentTarget=s[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=s[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let s=0;s=0;c--){const d=h[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,i,n,o||n(t,s));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const 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,s)&&i(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Vt.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children,l=s;for(let h=u.length-1;h>=0;h--){const c=u[h],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,l,i,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const p=t.isInteractive();return(d.length>0||p)&&d.push(t),d}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&i(t,s)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.includeInBuild||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,fr),!t.hitArea.contains(fr.x,fr.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s0&&u!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,u);if(this.dispatchEvent(d,"pointerout"),o&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(u)){const p=this.createPointerEvent(t,"pointerleave",u);for(p.eventPhase=p.AT_TARGET;p.target&&!n.composedPath().includes(p.target);)p.currentTarget=p.target,this.notifyTarget(p),o&&this.notifyTarget(p,"mouseleave"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}if(u!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(n,c);this.dispatchEvent(d,"pointerover"),o&&this.dispatchEvent(d,"mouseover");let p=u==null?void 0:u.parent;for(;p&&p!==this.rootTarget.parent&&p!==n.target;)p=p.parent;if(!p||p===this.rootTarget.parent){const f=this.clonePointerEvent(n,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==u&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}const l=[],h=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&l.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&l.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.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 Rt))return;const s=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;s.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Rt))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Rt))return;const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const u=s.button===2;this.notifyTarget(s,u?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const u=i.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(s)}mapPointerUpOutside(t){if(!(t instanceof Rt))return;const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(s){let n=s;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof de))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;st in r?dv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mv=(r,t)=>{for(var e in t||(t={}))pv.call(t,e)&&bh(r,e,t[e]);if(xh)for(var e of xh(t))fv.call(t,e)&&bh(r,e,t[e]);return r};const gv=1,_v={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},pn=class al{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new _h(null),Vt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Rt(null),this._rootWheelEvent=new de(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(mv({},al.defaultEventFeatures),{set:(e,s,i)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[s]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,s;const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,al._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(s=t.eventFeatures)!=null?s:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let s=0,i=e.length;s0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n{u.off(r,a,o)}),n?u.once(r,a,o):u.on(r,a,o)},removeEventListener(r,t,e){const s=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;r=s?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,i)},dispatchEvent(r){if(!(r instanceof Je))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}};D.add(fn),Y.mixin(vh);var bt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(bt||{});const yh={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 Th=yh;const j={get(){return Th},set(r){Th=r}};function Gt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function mr(r){return r.split("?")[0].split("#")[0]}function xv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bv(r,t,e){return r.replace(new RegExp(xv(t),"g"),e)}function vv(r,t){let e="",s=0,i=-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="",s=0):(e=e.slice(0,u),s=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const pt={toPosix(r){return bv(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){Gt(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(Gt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=mr(this.toPosix(t!=null?t:j.get().getBaseUrl())),i=mr(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?pt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Gt(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=vv(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Gt(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let s=0;s0)if(e===void 0)e=i;else{const n=(t=r[s-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Gt(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){Gt(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){Gt(r),t&&Gt(t),r=mr(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const u=r.charCodeAt(n);if(u===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(u===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){Gt(r),r=mr(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){Gt(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=mr(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;const n="";t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let o=-1,a=0,u=-1,l=!0,h=r.length-1,c=0;for(;h>=i;--h){if(e=r.charCodeAt(h),e===47){if(!l){a=h+1;break}continue}u===-1&&(l=!1,u=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||u===-1||c===0||c===1&&o===u-1&&o===a+1?u!==-1&&(a===0&&s?t.base=t.name=r.slice(1,u):t.base=t.name=r.slice(a,u)):(a===0&&s?(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"]},Mt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function Sh(r,t,e,s,i){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");i.push(o)}),Sh(r,i,0,e,s)}else s.push(r);return s}const gr=r=>!Array.isArray(r);var yv=Object.defineProperty,Tv=Object.defineProperties,Sv=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,Ev=Object.prototype.hasOwnProperty,Av=Object.prototype.propertyIsEnumerable,Ph=(r,t,e)=>t in r?yv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oe=(r,t)=>{for(var e in t||(t={}))Ev.call(t,e)&&Ph(r,e,t[e]);if(Ah)for(var e of Ah(t))Av.call(t,e)&&Ph(r,e,t[e]);return r},Pv=(r,t)=>Tv(r,Sv(t));class Zt{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,i;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(i=t.extractAssetIdFromBundle)!=null?i:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Mt(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Oe({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let u;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),u=[a,l]}else{const l=a.map(h=>this._createBundleAssetId(t,h));s.push(...l),u=[...a,...l]}this.add(Pv(Oe({},n),{alias:u,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;Mt(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:u}=i;const l=Mt(n).map(d=>typeof d=="string"?Eh(d):Array.isArray(d)?d:[d]),h=this.getAlias(i),c=[];l.forEach(d=>{d.forEach(p=>{var f,g,m;let _={};if(typeof p!="object"){_.src=p;for(let x=0;x{this._assetMap[d]=c})})}resolveBundle(t){const e=gr(t);t=Mt(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const u in o){const l=o[u];a[this._extractAssetIdFromBundle(i,u)]=l}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=gr(t);t=Mt(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(u=>{const l=n.filter(h=>h[a]?h[a]===u:!1);l.length&&(n=l)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var s,i;const{aliases:n,data:o,loadParser:a,format:u}=e;return(this._basePath||this._rootPath)&&(t.src=pt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=n!=null?n:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Oe(Oe({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=(i=u!=null?u:t.format)!=null?i:wh(t.src),t}}Zt.RETINA_PREFIX=/@([0-9\.]+)x/;function wh(r){return r.split(".").pop().split("?").shift().split("#").shift()}const _s=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},pe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],fe=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],me=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ge=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],mn=[],Rh=[],xs=Math.sign;function wv(){for(let r=0;r<16;r++){const t=[];mn.push(t);for(let e=0;e<16;e++){const s=xs(pe[r]*pe[e]+me[r]*fe[e]),i=xs(fe[r]*pe[e]+ge[r]*fe[e]),n=xs(pe[r]*me[e]+me[r]*ge[e]),o=xs(fe[r]*me[e]+ge[r]*ge[e]);for(let a=0;a<16;a++)if(pe[a]===s&&fe[a]===i&&me[a]===n&&ge[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new C;t.set(pe[r],fe[r],me[r],ge[r],0,0),Rh.push(t)}}wv();const U={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>pe[r],uY:r=>fe[r],vX:r=>me[r],vY:r=>ge[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>mn[r][t],sub:(r,t)=>mn[r][U.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?U.S:U.N:Math.abs(t)*2<=Math.abs(r)?r>0?U.E:U.W:t>0?r>0?U.SE:U.SW:r>0?U.NE:U.NW,matrixAppendRotationInv:(r,t,e=0,s=0)=>{const i=Rh[U.inv(t)];i.tx=e,i.ty=s,r.append(i)}},gn=()=>{};function _e(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 _n(r){return!(r&r-1)&&!!r}function Rv(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 Qt(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var Mv=Object.defineProperty,Mh=Object.getOwnPropertySymbols,Ov=Object.prototype.hasOwnProperty,Cv=Object.prototype.propertyIsEnumerable,Oh=(r,t,e)=>t in r?Mv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ch=(r,t)=>{for(var e in t||(t={}))Ov.call(t,e)&&Oh(r,e,t[e]);if(Mh)for(var e of Mh(t))Cv.call(t,e)&&Oh(r,e,t[e]);return r};const Gh=Object.create(null);function Gv(r){const t=Gh[r];return t===void 0&&(Gh[r]=Q("resource")),t}const Ih=class rb extends dt{constructor(t={}){var e,s,i,n,o,a,u;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Ch(Ch({},rb.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(i=t.addressModeW)!=null?i:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(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=Gv(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ih.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Bh=Ih;var Iv=Object.defineProperty,Fh=Object.getOwnPropertySymbols,Bv=Object.prototype.hasOwnProperty,Fv=Object.prototype.propertyIsEnumerable,Dh=(r,t,e)=>t in r?Iv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uh=(r,t)=>{for(var e in t||(t={}))Bv.call(t,e)&&Dh(r,e,t[e]);if(Fh)for(var e of Fh(t))Fv.call(t,e)&&Dh(r,e,t[e]);return r};const kh=class sb extends dt{constructor(t={}){var e,s,i;super(),this.options=t,this.uid=Q("textureSource"),this._resourceType="textureSource",this._resourceId=Q("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=Uh(Uh({},sb.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Bh(Qt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}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=Q("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,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Q("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=_n(this.pixelWidth)&&_n(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};kh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let tt=kh;var Dv=Object.defineProperty,Uv=Object.defineProperties,kv=Object.getOwnPropertyDescriptors,$h=Object.getOwnPropertySymbols,$v=Object.prototype.hasOwnProperty,Lv=Object.prototype.propertyIsEnumerable,Lh=(r,t,e)=>t in r?Dv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nv=(r,t)=>{for(var e in t||(t={}))$v.call(t,e)&&Lh(r,e,t[e]);if($h)for(var e of $h(t))Lv.call(t,e)&&Lh(r,e,t[e]);return r},Hv=(r,t)=>Uv(r,kv(t));class bs extends tt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super(Hv(Nv({},t),{resource:e,format:s})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}bs.extension=v.TextureSource;const Nh=new C;class xn{constructor(t,e){this.mapCoord=new C,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;i{this._callback=t,this._batchIndex=0,this._frameKeys.length<=es.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=es.BATCH_SIZE;for(;e-t{this._batchIndex*es.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[i]=t.textures[i]}),!e){const i=pt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Xh([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const zh={extension:v.Asset,cache:{test:r=>r instanceof bn,getCacheableAssets:(r,t)=>Xh(r,t,!1)},resolver:{extension:{type:v.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&Xv.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=Zt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:v.LoadParser,priority:bt.Normal,name:"spritesheetLoader"},async testParse(r,t){return pt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a}=(s=t==null?void 0:t.data)!=null?s:{};let u=pt.dirname(t.src);u&&u.lastIndexOf("/")!==u.length-1&&(u+="/");let l;if(o instanceof A)l=o;else{const d=_s(u+(a!=null?a:r.meta.image),t.src);l=(await e.load([d]))[d]}const h=new bn(l.source,r);await h.parse();const c=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(c)){const d=[];for(const f of c){if(typeof f!="string")continue;let g=u+f;(n=t.data)!=null&&n.ignoreMultiPack||(g=_s(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);h.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[h].concat(h.linkedSheets.filter(g=>g!==f))})}return h},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};D.add(zh);function _r(r,t,e,s){const{width:i,height:n}=e.orig,o=e.trim;if(o){const a=o.width,u=o.height;r.minX=o.x-t._x*i-s,r.maxX=r.minX+a,r.minY=o.y-t._y*n-s,r.maxY=r.minY+u}else r.minX=-t._x*i-s,r.maxX=r.minX+i,r.minY=-t._y*n-s,r.maxY=r.minY+n}var zv=Object.defineProperty,vs=Object.getOwnPropertySymbols,jh=Object.prototype.hasOwnProperty,Vh=Object.prototype.propertyIsEnumerable,Wh=(r,t,e)=>t in r?zv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jv=(r,t)=>{for(var e in t||(t={}))jh.call(t,e)&&Wh(r,e,t[e]);if(vs)for(var e of vs(t))Vh.call(t,e)&&Wh(r,e,t[e]);return r},Vv=(r,t)=>{var e={};for(var s in r)jh.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&vs)for(var s of vs(r))t.indexOf(s)<0&&Vh.call(r,s)&&(e[s]=r[s]);return e};class Dt extends Y{constructor(t=A.EMPTY){t instanceof A&&(t={texture:t});const e=t,{texture:s=A.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,u=Vv(e,["texture","anchor","roundPixels","width","height"]);super(jv({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 rt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof A?new Dt(t):new Dt(A.from(t,e))}set texture(t){t||(t=A.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get 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(){_r(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:i,height:n}=e.orig;s.maxX=-t._x*i,s.minX=s.maxX+i,s.maxY=-t._y*n,s.minY=s.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),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var s;let i,n;typeof t!="object"?(i=t,n=e!=null?e:t):(i=t.width,n=(s=t.height)!=null?s:t.width),i!==void 0&&this._setWidth(i,this._texture.orig.width),n!==void 0&&this._setHeight(n,this._texture.orig.height)}}const Wv=new lt;function ys(r,t,e){const s=Wv;r.measurable=!0,hr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function Ts(r,t,e){const s=$t.get();r.measurable=!0;const i=kt.get().identity(),n=vn(r,e,i);ds(r,s,n),r.measurable=!1,t.addBoundsMask(s),kt.return(i),$t.return(s)}function vn(r,t,e){return r&&r!==t&&(vn(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class yn{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 Dt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){ys(this.mask,t,e)}addLocalBounds(t,e){Ts(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Dt}}yn.extension=v.MaskEffect;class Tn{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"}}Tn.extension=v.MaskEffect;class Sn{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){ys(this.mask,t,e)}addLocalBounds(t,e){Ts(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Y}}Sn.extension=v.MaskEffect;class xe extends tt{constructor(t){t.resource||(t.resource=j.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,s=this._resolution){const i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}}xe.extension=v.TextureSource;class be extends tt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=j.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}}be.extension=v.TextureSource;let En;async function An(){return En!=null||(En=(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 s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),En}var Yv=Object.defineProperty,Kv=Object.defineProperties,qv=Object.getOwnPropertyDescriptors,Yh=Object.getOwnPropertySymbols,Zv=Object.prototype.hasOwnProperty,Qv=Object.prototype.propertyIsEnumerable,Kh=(r,t,e)=>t in r?Yv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pn=(r,t)=>{for(var e in t||(t={}))Zv.call(t,e)&&Kh(r,e,t[e]);if(Yh)for(var e of Yh(t))Qv.call(t,e)&&Kh(r,e,t[e]);return r},Jv=(r,t)=>Kv(r,qv(t));const Ss=class ib extends tt{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=Pn(Pn({},ib.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 An(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(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}};Ss.extension=v.TextureSource,Ss.defaultOptions=Jv(Pn({},tt.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Ss.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let xr=Ss,ty=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const s=Mt(t);let i;for(let u=0;u{n.set(u,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(u=>{this._cacheMap.set(u,a)}),o.forEach(u=>{const l=i?i[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(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const K=new ty,wn=[];D.handleByList(v.TextureSource,wn);function ey(r={}){return Rn(r)}function Rn(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{K.has(s)&&K.remove(s)}),t||K.set(s,n),n}function Zh(r,t=!1){return typeof r=="string"?K.get(r):r instanceof tt?new A({source:r}):qh(r,t)}A.from=Zh,tt.from=Rn,D.add(yn,Tn,Sn,xr,be,xe,bs);class Lt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=t.off)==null||s.call(t,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}let br;function Mn(){return(!br||br!=null&&br.isContextLost())&&(br=j.get().createCanvas().getContext("webgl",{})),br}const ry=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +`);function sy(r){let t="";for(let e=0;e0&&(t+=` +else `),e>>0;return Jh[e]||iy(r,t,e)}let On=0;function iy(r,t,e){const s={};let i=0;On||(On=Jt());for(let o=0;o0){const n=new Uint8Array(r,e*8,i);new Uint8Array(t,e*8,i).set(n)}}const tc={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 vr(r,t){return t.alphaMode==="no-premultiply-alpha"&&tc[r]||r}class ec{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;tt in r?ny(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ic=(r,t)=>{for(var e in t||(t={}))oy.call(t,e)&&sc(r,e,t[e]);if(rc)for(var e of rc(t))ay.call(t,e)&&sc(r,e,t[e]);return r};class nc{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ec,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const oc=[];let Gn=0;function ac(){return Gn>0?oc[--Gn]:new nc}function uc(r){oc[Gn++]=r}let yr=0;const lc=class nb{constructor(t={}){this.uid=Q("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],t=ic(ic({},nb.defaultOptions),t);const{vertexSize:e,indexSize:s}=t;this.attributeBuffer=new Cn(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(s),this._maxTextures=Jt()}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,l=this.indexBuffer;let h=this._batchIndexSize,c=this._batchIndexStart,d="startBatch";const p=this._maxTextures;for(let f=this.elementStart;f=p||x)&&(this._finishBatch(s,c,h-c,i,o,t,d),d="renderBatch",c=h,o=_,s=ac(),i=s.textures,i.clear(),++yr),g.textureId=m._textureBindLocation=i.count,i.ids[m.uid]=i.count,i.textures[i.count++]=m,g.batch=s,h+=g.indexSize,g.packAttributes(a,u,g.location,g.textureId),g.packIndex(l,g.indexStart,g.location/this._vertexSize)}i.count>0&&(this._finishBatch(s,c,h-c,i,o,t,d),c=h,++yr),this.elementStart=this.elementSize,this._batchIndexStart=c,this._batchIndexSize=h}_finishBatch(t,e,s,i,n,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=i,t.blendMode=n,t.start=e,t.size=s,++yr,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Cn(e);As(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(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))(N||{});class vt extends dt{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this.uid=Q("buffer"),this._resourceType="buffer",this._resourceId=Q("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s!=null?s:e==null?void 0:e.byteLength;const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&N.STATIC)}set static(t){t?this.descriptor.usage|=N.STATIC:this.descriptor.usage&=~N.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,i.length!==t.length){!this.shrinkToFit&&t.byteLengtha&&(a=p),f>u&&(u=f),pe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const ly=new Float32Array(1),hy=new Uint32Array(1);class Fn extends Ge{constructor(){const t=new vt({data:ly,label:"attribute-batch-buffer",usage:N.VERTEX|N.COPY_DST,shrinkToFit:!1}),e=new vt({data:hy,label:"index-batch-buffer",usage:N.INDEX|N.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0,location:1},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4,location:3},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4,location:0},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4,location:2}},indexBuffer:e})}}function Dn(r,t,e,s,i,n,o,a=null){let u=0;e*=t,i*=n;const l=a.a,h=a.b,c=a.c,d=a.d,p=a.tx,f=a.ty;for(;u>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,u=e*n/255,l=s*o/255,h=i*a/255;return(u<<16)+(l<<8)+h}class ws{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,s){const i=this.geometryData.indices;for(let n=0;n>16|c&65280|(c&255)<<16;if(this.applyTransform){const p=cc(d,o.groupColor)+(this.alpha*o.groupAlpha*255<<24),f=o.groupTransform,g=i<<16|this.roundPixels&65535,m=f.a,_=f.b,x=f.c,b=f.d,y=f.tx,T=f.ty;for(let w=l;wt in r?cy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rs=(r,t)=>{for(var e in t||(t={}))fy.call(t,e)&&pc(r,e,t[e]);if(dc)for(var e of dc(t))my.call(t,e)&&pc(r,e,t[e]);return r},Ms=(r,t)=>dy(r,py(t));const Wt={extension:{type:v.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const y=r;e=y.x,s=y.y,o=a=y.radius,i=n=0}else if(r.type==="ellipse"){const y=r;e=y.x,s=y.y,o=y.halfWidth,a=y.halfHeight,i=n=0}else{const y=r,T=y.width/2,w=y.height/2;e=y.x+T,s=y.y+w,o=a=Math.max(0,Math.min(y.radius,Math.min(T,w))),i=T-o,n=w-a}if(!(o>=0&&a>=0&&i>=0&&n>=0))return t;const u=Math.ceil(2.3*Math.sqrt(o+a)),l=u*8+(i?4:0)+(n?4:0);if(l===0)return t;if(u===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,t;let h=0,c=u*4+(i?2:0)+2,d=c,p=l,f=i+o,g=n,m=e+f,_=e-f,x=s+g;if(t[h++]=m,t[h++]=x,t[--c]=x,t[--c]=_,n){const y=s-g;t[d++]=_,t[d++]=y,t[--p]=y,t[--p]=m}for(let y=1;y0&&(i[n++]=u,i[n++]=l,i[n++]=u-1),u++;i[n++]=l+1,i[n++]=l,i[n++]=u-1}},fc=Ms(Rs({},Wt),{extension:Ms(Rs({},Wt.extension),{name:"ellipse"})}),mc=Ms(Rs({},Wt),{extension:Ms(Rs({},Wt.extension),{name:"roundedRectangle"})}),gc=1e-4,kn=1e-4;function _c(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];sc&&(c+=Math.PI*2);let d=h;const p=c-h,f=Math.abs(p),g=Math.sqrt(u*u+l*l),m=(15*f*Math.sqrt(g)/Math.PI>>0)+1,_=p/m;if(d+=_,a){o.push(r,t),o.push(e,s);for(let x=1,b=d;x=0&&(h.join==="round"?x+=ve(S,E,S-O*I,E-G*I,S-q*I,E-$*I,m,!1)+4:x+=2,m.push(S-q*F,E-$*F),m.push(S+q*I,E+$*I));continue}const gl=(-O+P)*(-G+E)-(-O+S)*(-G+R),_l=(-q+L)*(-$+E)-(-q+S)*(-$+k),ns=(qt*_l-sr*gl)/is,os=(ir*gl-rr*_l)/is,ji=(ns-S)*(ns-S)+(os-E)*(os-E),ue=S+(ns-S)*I,le=E+(os-E)*I,he=S-(ns-S)*F,ce=E-(os-E)*F,Rb=Math.min(qt*qt+rr*rr,sr*sr+ir*ir),xl=nr?I:F,Mb=Rb+xl*xl*T;ji<=Mb?h.join==="bevel"||ji/T>w?(nr?(m.push(ue,le),m.push(S+O*F,E+G*F),m.push(ue,le),m.push(S+q*F,E+$*F)):(m.push(S-O*I,E-G*I),m.push(he,ce),m.push(S-q*I,E-$*I),m.push(he,ce)),x+=2):h.join==="round"?nr?(m.push(ue,le),m.push(S+O*F,E+G*F),x+=ve(S,E,S+O*F,E+G*F,S+q*F,E+$*F,m,!0)+4,m.push(ue,le),m.push(S+q*F,E+$*F)):(m.push(S-O*I,E-G*I),m.push(he,ce),x+=ve(S,E,S-O*I,E-G*I,S-q*I,E-$*I,m,!1)+4,m.push(S-q*I,E-$*I),m.push(he,ce)):(m.push(ue,le),m.push(he,ce)):(m.push(S-O*I,E-G*I),m.push(S+O*F,E+G*F),h.join==="round"?nr?x+=ve(S,E,S+O*F,E+G*F,S+q*F,E+$*F,m,!0)+2:x+=ve(S,E,S-O*I,E-G*I,S-q*I,E-$*I,m,!1)+2:h.join==="miter"&&ji/T<=w&&(nr?(m.push(he,ce),m.push(he,ce)):(m.push(ue,le),m.push(ue,le)),x+=2),m.push(S-q*I,E-$*I),m.push(S+q*F,E+$*F),x+=2)}P=r[(_-2)*2],R=r[(_-2)*2+1],S=r[(_-1)*2],E=r[(_-1)*2+1],O=-(R-E),G=P-S,xt=Math.sqrt(O*O+G*G),O/=xt,G/=xt,O*=y,G*=y,m.push(S-O*I,E-G*I),m.push(S+O*F,E+G*F),f||(h.cap==="round"?x+=ve(S-O*(I-F)*.5,E-G*(I-F)*.5,S-O*I,E-G*I,S+O*F,E+G*F,m,!1)+2:h.cap==="square"&&(x+=xc(S,E,O,G,I,F,!1,m)));const wb=kn*kn;for(let Z=b;Z80*e){a=l=r[0],u=h=r[1];for(var f=e;fl&&(l=c),d>h&&(h=d);p=Math.max(l-a,h-u),p=p!==0?32767/p:0}return Tr(n,o,e,a,u,p,0),o}function vc(r,t,e,s,i){var n,o;if(i===Nn(r,t,e,s)>0)for(n=t;n=t;n-=s)o=Sc(n,r[n],r[n+1],o);return o&&Gs(o,o.next)&&(Er(o),o=o.next),o}function ye(r,t){if(!r)return r;t||(t=r);var e=r,s;do if(s=!1,!e.steiner&&(Gs(e,e.next)||J(e.prev,e,e.next)===0)){if(Er(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Tr(r,t,e,s,i,n,o){if(r){!o&&n&&Ay(r,s,i,n);for(var a=r,u,l;r.prev!==r.next;){if(u=r.prev,l=r.next,n?_y(r,s,i,n):gy(r)){t.push(u.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Er(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=xy(ye(r),t,e),Tr(r,t,e,s,i,n,2)):o===2&&by(r,t,e,s,i,n):Tr(ye(r),t,e,s,i,n,1);break}}}}function gy(r){var t=r.prev,e=r,s=r.next;if(J(t,e,s)>=0)return!1;for(var i=t.x,n=e.x,o=s.x,a=t.y,u=e.y,l=s.y,h=in?i>o?i:o:n>o?n:o,p=a>u?a>l?a:l:u>l?u:l,f=s.next;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&Ie(i,a,n,u,o,l,f.x,f.y)&&J(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function _y(r,t,e,s){var i=r.prev,n=r,o=r.next;if(J(i,n,o)>=0)return!1;for(var a=i.x,u=n.x,l=o.x,h=i.y,c=n.y,d=o.y,p=au?a>l?a:l:u>l?u:l,m=h>c?h>d?h:d:c>d?c:d,_=$n(p,f,t,e,s),x=$n(g,m,t,e,s),b=r.prevZ,y=r.nextZ;b&&b.z>=_&&y&&y.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==i&&b!==o&&Ie(a,h,u,c,l,d,b.x,b.y)&&J(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&Ie(a,h,u,c,l,d,y.x,y.y)&&J(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=_;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==i&&b!==o&&Ie(a,h,u,c,l,d,b.x,b.y)&&J(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=x;){if(y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&Ie(a,h,u,c,l,d,y.x,y.y)&&J(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function xy(r,t,e){var s=r;do{var i=s.prev,n=s.next.next;!Gs(i,n)&&yc(i,s,s.next,n)&&Sr(i,n)&&Sr(n,i)&&(t.push(i.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Er(s),Er(s.next),s=r=n),s=s.next}while(s!==r);return ye(s)}function by(r,t,e,s,i,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Ry(o,a)){var u=Tc(o,a);o=ye(o,o.next),u=ye(u,u.next),Tr(o,t,e,s,i,n,0),Tr(u,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function vy(r,t,e,s){var i=[],n,o,a,u,l;for(n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){var a=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=s&&a>n&&(n=a,o=e.x=e.x&&e.x>=l&&s!==e.x&&Ie(io.x||e.x===o.x&&Ey(o,e)))&&(o=e,c=d)),e=e.next;while(e!==u);return o}function Ey(r,t){return J(r.prev,r,t.prev)<0&&J(t.next,r,r.next)<0}function Ay(r,t,e,s){var i=r;do i.z===0&&(i.z=$n(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Py(i)}function Py(r){var t,e,s,i,n,o,a,u,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,s=e,a=0,t=0;t0||u>0&&s;)a!==0&&(u===0||!s||e.z<=s.z)?(i=e,e=e.nextZ,a--):(i=s,s=s.nextZ,u--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;e=s}n.nextZ=null,l*=2}while(o>1);return r}function $n(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function wy(r){var t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function Ry(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!My(r,t)&&(Sr(r,t)&&Sr(t,r)&&Oy(r,t)&&(J(r.prev,r,t.prev)||J(r,t.prev,t))||Gs(r,t)&&J(r.prev,r,r.next)>0&&J(t.prev,t,t.next)>0)}function J(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Gs(r,t){return r.x===t.x&&r.y===t.y}function yc(r,t,e,s){var i=Bs(J(r,t,e)),n=Bs(J(r,t,s)),o=Bs(J(e,s,r)),a=Bs(J(e,s,t));return!!(i!==n&&o!==a||i===0&&Is(r,e,t)||n===0&&Is(r,s,t)||o===0&&Is(e,r,s)||a===0&&Is(e,t,s))}function Is(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 Bs(r){return r>0?1:r<0?-1:0}function My(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&&yc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Sr(r,t){return J(r.prev,r,r.next)<0?J(r,t,r.next)>=0&&J(r,r.prev,t)>=0:J(r,t,r.prev)<0||J(r,r.next,t)<0}function Oy(r,t){var e=r,s=!1,i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function Tc(r,t){var e=new Ln(r.i,r.x,r.y),s=new Ln(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function Sc(r,t,e,s){var i=new Ln(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Er(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Ln(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}Cs.deviation=function(r,t,e,s){var i=t&&t.length,n=i?t[0]*e:r.length,o=Math.abs(Nn(r,0,n,e));if(i)for(var a=0,u=t.length;a0&&(s+=r[i-1].length,e.holes.push(s))}return e};var Cy=Os.exports,Ec=Wi(Cy);function Hn(r,t,e,s,i,n,o){const a=Ec(r,t,2);if(!a)return;for(let l=0;l=0&&o>=0&&(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o),t},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},jn={extension:{type:v.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,t},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}},Ar={};D.handleByMap(v.ShapeBuilder,Ar),D.add(zn,Xn,jn,Wt,fc,mc);const Iy=new V;function Ac(r,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i{var p;const f=u.length,g=o.length/2,m=[],_=Ar[h.type];if(_.build(h,m),c&&Ps(m,c),s){const T=(p=h.closePath)!=null?p:!0;bc(m,t,!1,T,o,2,g,u,f)}else if(e&&l===d){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const T=[],w=m.slice();Fy(e.shapePath).forEach(P=>{T.push(w.length/2),w.push(...P)}),Hn(w,T,o,2,g,u,f)}else _.triangulate(m,o,2,g,u,f);const x=a.length/2,b=t.texture;if(b!==A.WHITE){const T=t.matrix;T&&(c&&T.append(c.clone().invert()),Dn(o,2,g,a,x,2,o.length/2-g,T))}else Un(a,x,2,o.length/2-g);const y=z.get(ws);y.indexOffset=f,y.indexSize=u.length-f,y.vertexOffset=g,y.vertexSize=o.length/2-g,y.color=t.color,y.alpha=t.alpha,y.texture=b,y.geometryData=n,i.push(y)})}function Fy(r){if(!r)return[];const t=r.shapePrimitives,e=[];for(let s=0;s{z.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Vn.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"graphicsContext"},Vn.defaultOptions={bezierSmoothness:.5};let Fs=Vn;const Dy={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8},Wn=0,Yn=1,Kn=2,qn=3,Zn=4,Qn=5,Jn=class ob{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[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function Pr(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class to{constructor(t,e){this.state=It.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,s=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),s.isBatchable?this._addToBatcher(t):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let s=0;s{const a=z.get(ws);return o.copyTo(a),a.renderable=t,a.roundPixels=i,a});return this._graphicsBatchesHash[t.uid]===void 0&&t.on("destroyed",()=>{this.destroyRenderable(t)}),this._graphicsBatchesHash[t.uid]=n,n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{z.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}}to.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"graphics"},D.add(to),D.add(Fs);const eo=Object.create(null),Mc=Object.create(null);function wr(r,t){let e=Mc[r];return e===void 0&&(eo[t]===void 0&&(eo[t]=1),Mc[r]=e=eo[t]++),e}const ro=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Oc=ro.reduce((r,t)=>(r[t]=!0,r),{});function Cc(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 ky=Object.defineProperty,Gc=Object.getOwnPropertySymbols,$y=Object.prototype.hasOwnProperty,Ly=Object.prototype.propertyIsEnumerable,Ic=(r,t,e)=>t in r?ky(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bc=(r,t)=>{for(var e in t||(t={}))$y.call(t,e)&&Ic(r,e,t[e]);if(Gc)for(var e of Gc(t))Ly.call(t,e)&&Ic(r,e,t[e]);return r};const Fc=class ab{constructor(t,e){this._touched=0,this.uid=Q("uniform"),this._resourceType="uniformGroup",this._resourceId=Q("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=Bc(Bc({},ab.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(s=a.size)!=null?s:1,!Oc[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${ro.join(", ")}`);(i=a.value)!=null||(a.value=Cc(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=wr(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Fc.defaultOptions={ubo:!1,isStatic:!1};let it=Fc;class Ds{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,s){const i=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 Lt({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),s=e.batched,i=t.batched;if(e.batched=i,s!==i)return!0;if(i){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t),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 s=this.renderer.renderPipes.batch,{batched:i}=this._getMeshData(t);if(i){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,s.addToBatch(n)}else s.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&&(z.return(e),this._gpuBatchableMeshHash[t.uid]=null)}execute({mesh:t}){if(!t.isRenderable)return;t.state.blendMode=vr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Pr(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,s;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(s=t._geometry.positions)==null?void 0:s.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=z.get(Ds);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]&&z.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}}so.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"mesh"},D.add(so);class Us{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,s,i){const n=this.renderable,o=this.texture,a=n.groupTransform,u=a.a,l=a.b,h=a.c,c=a.d,d=a.tx,p=a.ty,f=this.bounds,g=f.maxX,m=f.minX,_=f.maxY,x=f.minY,b=o.uvs,y=n.groupColorAlpha,T=i<<16|this.roundPixels&65535;t[s+0]=u*m+h*x+d,t[s+1]=c*x+l*m+p,t[s+2]=b.x0,t[s+3]=b.y0,e[s+4]=y,e[s+5]=T,t[s+6]=u*g+h*x+d,t[s+7]=c*x+l*g+p,t[s+8]=b.x1,t[s+9]=b.y1,e[s+10]=y,e[s+11]=T,t[s+12]=u*g+h*_+d,t[s+13]=c*_+l*g+p,t[s+14]=b.x2,t[s+15]=b.y2,e[s+16]=y,e[s+17]=T,t[s+18]=u*m+h*_+d,t[s+19]=c*_+l*m+p,t[s+20]=b.x3,t[s+21]=b.y3,e[s+22]=y,e[s+23]=T}packIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class io{constructor(t){this._gpuText=Object.create(null),this._renderer=t,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const t in this._gpuText){const e=this._gpuText[t].batchableSprite.renderable;e._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();if(e.currentKey!==s){const{width:i,height:n}=this._renderer.canvasText.getTextureSize(t.text,t.resolution,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&i===e.texture._source.width&&n===e.texture._source.height)}return!1}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s)}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),z.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),i=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;_r(i.bounds,t._anchor,i.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),s=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=s.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),s.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:z.get(Us)};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,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,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}}io.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"text"};class Dc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=j.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=_e(t),e=_e(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Nt=new Dc;var Ny=Object.defineProperty,Hy=Object.defineProperties,Xy=Object.getOwnPropertyDescriptors,Uc=Object.getOwnPropertySymbols,zy=Object.prototype.hasOwnProperty,jy=Object.prototype.propertyIsEnumerable,kc=(r,t,e)=>t in r?Ny(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vy=(r,t)=>{for(var e in t||(t={}))zy.call(t,e)&&kc(r,e,t[e]);if(Uc)for(var e of Uc(t))jy.call(t,e)&&kc(r,e,t[e]);return r},Wy=(r,t)=>Hy(r,Xy(t));let Yy=0;class $c{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,s){const i=new tt(Wy(Vy({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!0}));return new A({source:i,label:`texturePool_${Yy++}`})}getOptimalTexture(t,e,s=1,i){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=_e(n),o=_e(o);const a=(n<<17)+(o<<1)+(i?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let u=this._texturePool[a].pop();return u||(u=this.createTexture(n,o,i)),u.source._resolution=s,u.source.width=n/s,u.source.height=o/s,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 s=t.source;return this.getOptimalTexture(t.width,t.height,s._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 s=this._texturePool[e];if(s)for(let i=0;i`${i.offset}-${i.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};jc.defaultTextureSize=256;let Be=jc;const Vc={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Rr{constructor(t,e){this.uid=Q("fillPattern"),this.transform=new C,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Vc[e].addressModeU,t.source.style.addressModeV=Vc[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var qy=Qy,no={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Zy=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Qy(r){var t=[];return r.replace(Zy,function(e,s,i){var n=s.toLowerCase();for(i=t0(i),n=="m"&&i.length>2&&(t.push([s].concat(i.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(i.length==no[n])return i.unshift(s),t.push(i);if(i.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}l!=="Z"&&l!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}class Hi{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Hi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const i=this.x-t,n=this.y-e,o=this.radius,a=s/2,u=Math.sqrt(i*i+n*n);return uo-a}getBounds(t){return t=t||new V,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 Xi{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new Xi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s){const{halfWidth:i,halfHeight:n}=this;if(i<=0||n<=0)return!1;const o=s/2,a=i-o,u=n-o,l=i+o,h=n+o,c=t-this.x,d=e-this.y,p=c*c/(a*a)+d*d/(u*u),f=c*c/(l*l)+d*d/(h*h);return p>1&&f<=1}getBounds(t){return t=t||new V,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function Mr(r,t,e,s,i,n){const o=r-e,a=t-s,u=i-e,l=n-s,h=o*u+a*l,c=u*u+l*l;let d=-1;c!==0&&(d=h/c);let p,f;d<0?(p=e,f=s):d>1?(p=i,f=n):(p=e+d*u,f=s+d*l);const g=r-p,m=t-f;return g*g+m*m}class tr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;ie!=h>e&&t<(l-a)*((e-u)/(h-u))+a&&(s=!s)}return s}strokeContains(t,e,s){const i=s/2,n=i*i,{points:o}=this,a=o.length-(this.closePath?0:2);for(let u=0;ui?l:i,n=ho?h:o}return t.x=s,t.width=i-s,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ks=(r,t,e,s,i,n)=>{const o=r-e,a=t-s,u=Math.sqrt(o*o+a*a);return u>=i-n&&u<=i+n};class zi{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t=t||new V,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new zi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s){const{x:i,y:n,width:o,height:a,radius:u}=this,l=s/2,h=i+u,c=n+u,d=o-u*2,p=a-u*2,f=i+o,g=n+a;return(t>=i-l&&t<=i+l||t>=f-l&&t<=f+l)&&e>=c&&e<=c+p||(e>=n-l&&e<=n+l||e>=g-l&&e<=g+l)&&t>=h&&t<=h+d?!0:tf-u&&ef-u&&e>g-u&&ks(t,e,f-u,g-u,u,l)||tg-u&&ks(t,e,h,g-u,u,l)}}const r0=8,$s=11920929e-14,s0=1,oo=.01,Fe=0,Te=0;function ao(r,t,e,s,i,n,o,a,u,l){const h=Math.min(.99,Math.max(0,l!=null?l:Fs.defaultOptions.bezierSmoothness));let c=(s0-h)/1;return c*=c,i0(t,e,s,i,n,o,a,u,r,c),r}function i0(r,t,e,s,i,n,o,a,u,l){uo(r,t,e,s,i,n,o,a,u,l,0),u.push(o,a)}function uo(r,t,e,s,i,n,o,a,u,l,h){if(h>r0)return;const c=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,g=(s+n)/2,m=(i+o)/2,_=(n+a)/2,x=(d+f)/2,b=(p+g)/2,y=(f+m)/2,T=(g+_)/2,w=(x+y)/2,P=(b+T)/2;if(h>0){let R=o-r,S=a-t;const E=Math.abs((e-o)*S-(s-a)*R),L=Math.abs((i-o)*S-(n-a)*R);let k,O;if(E>$s&&L>$s){if((E+L)*(E+L)<=l*(R*R+S*S)){if(Fe=c&&(k=2*c-k),O>=c&&(O=2*c-O),k+OTe){u.push(e,s);return}if(O>Te){u.push(i,n);return}}}}else if(E>$s){if(E*E<=l*(R*R+S*S)){if(Fe=c&&(k=2*c-k),kTe){u.push(e,s);return}}}else if(L>$s){if(L*L<=l*(R*R+S*S)){if(Fe=c&&(k=2*c-k),kTe){u.push(i,n);return}}}else if(R=w-(r+o)/2,S=P-(t+a)/2,R*R+S*S<=l){u.push(w,P);return}}uo(r,t,d,p,x,b,w,P,u,l,h+1),uo(w,P,y,T,m,_,o,a,u,l,h+1)}const n0=8,o0=11920929e-14,a0=1,u0=.01,Yc=0;function Kc(r,t,e,s,i,n,o,a){const u=Math.min(.99,Math.max(0,a!=null?a:Fs.defaultOptions.bezierSmoothness));let l=(a0-u)/1;return l*=l,l0(t,e,s,i,n,o,r,l),r}function l0(r,t,e,s,i,n,o,a){lo(o,r,t,e,s,i,n,a,0),o.push(i,n)}function lo(r,t,e,s,i,n,o,a,u){if(u>n0)return;const l=Math.PI,h=(t+s)/2,c=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(h+d)/2,g=(c+p)/2;let m=n-t,_=o-e;const x=Math.abs((s-n)*_-(i-o)*m);if(x>o0){if(x*x<=a*(m*m+_*_)){if(Yc=l&&(b=2*l-b),bn||o&&n>i)&&(u=2*Math.PI-u),a=a||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(u/Math.PI))),a=Math.max(a,3);let l=u/a,h=i;l*=o?-1:1;for(let c=0;ch*a)}const Or=Math.PI*2,co={centerX:0,centerY:0,ang1:0,ang2:0},po=({x:r,y:t},e,s,i,n,o,a,u)=>{r*=e,t*=s;const l=i*r-n*t,h=n*r+i*t;return u.x=l+o,u.y=h+a,u};function h0(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Zc=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},c0=(r,t,e,s,i,n,o,a,u,l,h,c,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),g=Math.pow(h,2),m=Math.pow(c,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const x=_*i/n*c,b=_*-n/i*h,y=l*x-u*b+(r+e)/2,T=u*x+l*b+(t+s)/2,w=(h-x)/i,P=(c-b)/n,R=(-h-x)/i,S=(-c-b)/n,E=Zc(1,0,w,P);let L=Zc(w,P,R,S);a===0&&L>0&&(L-=Or),a===1&&L<0&&(L+=Or),d.centerX=y,d.centerY=T,d.ang1=E,d.ang2=L};function Qc(r,t,e,s,i,n,o,a=0,u=0,l=0){if(n===0||o===0)return;const h=Math.sin(a*Or/360),c=Math.cos(a*Or/360),d=c*(t-s)/2+h*(e-i)/2,p=-h*(t-s)/2+c*(e-i)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),c0(t,e,s,i,n,o,u,l,h,c,d,p,co);let{ang1:g,ang2:m}=co;const{centerX:_,centerY:x}=co;let b=Math.abs(m)/(Or/4);Math.abs(1-b)<1e-7&&(b=1);const y=Math.max(Math.ceil(b),1);m/=y;let T=r[r.length-2],w=r[r.length-1];const P={x:0,y:0};for(let R=0;R{const l=u.x-a.x,h=u.y-a.y,c=Math.sqrt(l*l+h*h),d=l/c,p=h/c;return{len:c,nx:d,ny:p}},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&&(f=-1,g=!0);const m=p/2;let _,x=Math.abs(Math.cos(m)*l/Math.sin(m));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),_=Math.abs(x*Math.sin(m)/Math.cos(m))):_=l;const b=u.x+d.nx*x+-d.ny*_*f,y=u.y+d.ny*x+d.nx*_*f,T=Math.atan2(c.ny,c.nx)+Math.PI/2*f,w=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(b+Math.cos(T)*_,y+Math.sin(T)*_),r.arc(b,y,_,T,w,g),o=u}}function td(r,t,e,s){var i;const n=(u,l)=>Math.sqrt((u.x-l.x)**2+(u.y-l.y)**2),o=(u,l,h)=>({x:u.x+(l.x-u.x)*h,y:u.y+(l.y-u.y)*h}),a=t.length;for(let u=0;u=2;c-=2)h[c]===h[c-2]&&h[c-1]===h[c-3]&&h.splice(c-1,2);return this.poly(h,!0,o)}ellipse(t,e,s,i,n){return this.drawShape(new Xi(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new zi(t,e,s,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new tr,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new tr,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;et in r?p0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ls=(r,t)=>{for(var e in t||(t={}))f0.call(t,e)&&sd(r,e,t[e]);if(rd)for(var e of rd(t))m0.call(t,e)&&sd(r,e,t[e]);return r};function id(r,t){if(typeof r=="string"){const s=document.createElement("div");s.innerHTML=r.trim(),r=s.querySelector("svg")}const e={context:t,path:new ae};return nd(r,e,null,null),t}function nd(r,t,e,s){const i=r.children,{fillStyle:n,strokeStyle:o}=g0(r);n&&e?e=Ls(Ls({},e),n):n&&(e=n),o&&s?s=Ls(Ls({},s),o):o&&(s=o),t.context.fillStyle=e,t.context.strokeStyle=s;let a,u,l,h,c,d,p,f,g,m,_,x,b,y,T,w,P;switch(r.nodeName.toLowerCase()){case"path":y=r.getAttribute("d"),T=new ae(y),t.context.path(T),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":p=ot(r,"cx",0),f=ot(r,"cy",0),g=ot(r,"r",0),t.context.ellipse(p,f,g,g),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":a=ot(r,"x",0),u=ot(r,"y",0),w=ot(r,"width",0),P=ot(r,"height",0),m=ot(r,"rx",0),_=ot(r,"ry",0),m||_?t.context.roundRect(a,u,w,P,m||_):t.context.rect(a,u,w,P),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":p=ot(r,"cx",0),f=ot(r,"cy",0),m=ot(r,"rx",0),_=ot(r,"ry",0),t.context.beginPath(),t.context.ellipse(p,f,m,_),e&&t.context.fill(),s&&t.context.stroke();break;case"line":l=ot(r,"x1",0),h=ot(r,"y1",0),c=ot(r,"x2",0),d=ot(r,"y2",0),t.context.beginPath(),t.context.moveTo(l,h),t.context.lineTo(c,d),s&&t.context.stroke();break;case"polygon":b=r.getAttribute("points"),x=b.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(x,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=r.getAttribute("points"),x=b.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(x,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}for(let R=0;Rt in r?_0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yt=(r,t)=>{for(var e in t||(t={}))od.call(t,e)&&ud(r,e,t[e]);if(Ns)for(var e of Ns(t))ad.call(t,e)&&ud(r,e,t[e]);return r},x0=(r,t)=>{var e={};for(var s in r)od.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ns)for(var s of Ns(r))t.indexOf(s)<0&&ad.call(r,s)&&(e[s]=r[s]);return e};function b0(r){return X.isColorLike(r)}function ld(r){return r instanceof Rr}function hd(r){return r instanceof Be}function v0(r,t,e){const s=X.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=A.WHITE,Yt(Yt({},e),r)}function cd(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Yt(Yt({},e),r)}function dd(r,t,e){return t.buildLinearGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Yt(Yt({},e),r)}function y0(r,t){var e;const s=Yt(Yt({},t),r);if(s.texture){if(s.texture!==A.WHITE){const o=((e=s.matrix)==null?void 0:e.invert())||new C;o.translate(s.texture.frame.x,s.texture.frame.y),o.scale(1/s.texture.source.width,1/s.texture.source.height),s.matrix=o}const n=s.texture.source.style;n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update())}const i=X.shared.setValue(s.color);return s.alpha*=i.alpha,s.color=i.toNumber(),s.matrix=s.matrix?s.matrix.clone():null,s}function te(r,t){if(r==null)return null;const e={},s=r;return b0(r)?v0(e,r,t):ld(r)?cd(e,r,t):hd(r)?dd(e,r,t):s.fill&&ld(s.fill)?cd(s,s.fill,t):s.fill&&hd(s.fill)?dd(s,s.fill,t):y0(s,t)}function Gr(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a}=e,u=x0(e,["width","alignment","miterLimit","cap","join"]),l=te(r,u);return l?Yt({width:s,alignment:i,miterLimit:n,cap:o,join:a},l):null}var T0=Object.defineProperty,pd=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,E0=Object.prototype.propertyIsEnumerable,fd=(r,t,e)=>t in r?T0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,De=(r,t)=>{for(var e in t||(t={}))S0.call(t,e)&&fd(r,e,t[e]);if(pd)for(var e of pd(t))E0.call(t,e)&&fd(r,e,t[e]);return r};const A0=new W,md=new C,fo=class Ht extends dt{constructor(){super(...arguments),this.uid=Q("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ae,this._transform=new C,this._fillStyle=De({},Ht.defaultFillStyle),this._strokeStyle=De({},Ht.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new lt,this._boundsDirty=!0}clone(){const t=new Ht;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=De({},this._fillStyle),t._strokeStyle=De({},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=te(t,Ht.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Gr(t,Ht.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=te(t,Ht.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=te(t,Ht.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?X.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ae,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=te(t,Ht.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(W.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Gr(t,Ht.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,i,n,o),this}arcTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const u=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,u.a*o+u.c*a+u.tx,u.b*o+u.d*a+u.ty),this}bezierCurveTo(t,e,s,i,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*s+u.c*i+u.tx,u.b*s+u.d*i+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,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,id(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:De({},this._fillStyle),strokeStyle:De({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,i,n,o){return t instanceof C?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof C?(this._transform.append(t),this):(md.set(t,e,s,i,n,o),this._transform.append(md),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;et in r?R0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yt=(r,t)=>{for(var e in t||(t={}))C0.call(t,e)&&bd(r,e,t[e]);if(xd)for(var e of xd(t))G0.call(t,e)&&bd(r,e,t[e]);return r},I0=(r,t)=>M0(r,O0(t));const go=class Qe extends dt{constructor(t={}){super(),B0(t);const e=yt(yt({},Qe.defaultTextStyle),t);for(const s in e){const i=s;this[i]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(yt(yt({},Qe.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(yt({},Qe.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._isFillStyle(t)&&(this._originalFill=this._createProxy(yt(yt({},ct.defaultFillStyle),t),()=>{this._fill=te(yt({},this._originalFill),ct.defaultFillStyle)})),this._fill=te(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(yt(yt({},ct.defaultStrokeStyle),t),()=>{this._stroke=Gr(yt({},this._originalStroke),ct.defaultStrokeStyle)})),this._stroke=Gr(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=mo(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Qe.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Qe({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?yt({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var e,s,i,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(o),(i=this._stroke)!=null&&i.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,i,n)=>(s[i]=n,e==null||e(i,n),this.update(),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(X.isColorLike(t)||t instanceof Be||t instanceof Rr)}};go.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},go.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 Tt=go;function B0(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Tt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(s=o.dropShadowBlur)!=null?s:a.blur,color:(i=o.dropShadowColor)!=null?i:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let u={};if(X.isColorLike(a))u.color=a;else if(a instanceof Be||a instanceof Rr)u.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))u=a;else throw new Error("Invalid stroke value.");r.stroke=I0(yt({},u),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){let a;r.fontSize==null?r.fontSize=Tt.defaultTextStyle.fontSize:typeof r.fontSize=="string"?a=parseInt(r.fontSize,10):a=r.fontSize;const u=new Be(0,0,0,a*1.7),l=o.fillGradientStops.map(h=>X.shared.setValue(h).toNumber());l.forEach((h,c)=>{const d=c/(l.length-1);u.addColorStop(d,h)}),r.fill={fill:u}}}const F0=new lt;function _o(r,t,e,s){const i=F0;i.minX=0,i.minY=0,i.maxX=r.width/s|0,i.maxY=r.height/s|0;const n=ut.getOptimalTexture(i.width,i.height,s,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/s,n.frame.height=e/s,n.source.emit("update",n.source),n.updateUvs(),n}const D0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ir(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!D0.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const xo={willReadFrequently:!0},Bt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,u,l){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=u,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,i=e.wordWrap){var n;const o=`${t}:${e.styleKey}`;if(M._measurementCache[o])return M._measurementCache[o];const a=Ir(e),u=M.measureFont(a);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize);const l=M.__context;l.font=a;const h=(i?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let d=0;for(let _=0;_0&&(i?n-=e:n+=(M.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=M._canvas){const i=s.getContext("2d",xo);let n=0,o="",a="";const u=Object.create(null),{letterSpacing:l,whiteSpace:h}=e,c=M._collapseSpaces(h),d=M._collapseNewlines(h);let p=!c;const f=e.wordWrapWidth+l,g=M._tokenize(t);for(let m=0;mf)if(o!==""&&(a+=M._addLine(o),o="",n=0),M.canBreakWords(_,e.breakWords)){const b=M.wordWrapSplit(_);for(let y=0;yf&&(a+=M._addLine(o),p=!1,o="",n=0),o+=T,n+=R}}else{o.length>0&&(a+=M._addLine(o),o="",n=0);const b=m===g.length-1;a+=M._addLine(_,!b),p=!1,o="",n=0}else x+n>f&&(p=!1,a+=M._addLine(o),o="",n=0),(o.length>0||!M.isBreakingSpace(_)||p)&&(o+=_,n+=x)}return a+=M._addLine(o,!1),a}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} +`:t,t}static _getFromCache(t,e,s,i){let n=s[t];return typeof n!="number"&&(n=M._measureText(t,e,i)+e,s[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 s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let i=0;i{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]})(),Bt.experimentalLetterSpacing=!1,Bt._fonts={},Bt._newlines=[10,13],Bt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Bt._measurementCache={};let Ft=Bt;function Br(r,t){if(r.texture===A.WHITE&&!r.fill)return X.shared.setValue(r.color).toHex();if(r.fill){if(r.fill instanceof Rr){const e=r.fill,s=t.createPattern(e.texture.source.resource,"repeat"),i=e.transform.copyTo(C.shared);return i.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(i),s}else if(r.fill instanceof Be){const e=r.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(i=>{s.addColorStop(i.offset,X.shared.setValue(i.color).toHex())}),s}}}else{const e=t.createPattern(r.texture.source.resource,"repeat"),s=r.matrix.copyTo(C.shared);return s.scale(r.texture.frame.width,r.texture.frame.height),e.setTransform(s),e}return"red"}class bo{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,s){const i=Ft.measureText(t||" ",s);let n=Math.ceil(Math.ceil(Math.max(1,i.width)+s.padding*2)*e),o=Math.ceil(Math.ceil(Math.max(1,i.height)+s.padding*2)*e);return n=Math.ceil(n-1e-6),o=Math.ceil(o-1e-6),n=_e(n),o=_e(o),{width:n,height:o}}getTexture(t,e,s,i){typeof t=="string"&&(zc("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Tt||(t.style=new Tt(t.style));const{texture:n,canvasAndContext:o}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),Nt.returnCanvasAndContext(o),n}createTextureAndCanvas(t){var e;const{text:s,style:i}=t,n=(e=t.resolution)!=null?e:this._renderer.resolution,o=Ft.measureText(s||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*n),u=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*n),l=Nt.getOptimalCanvasAndContext(a,u),{canvas:h}=l;this.renderTextToCanvas(s,i,n,l);const c=_o(h,a,u,n);if(i.trim){const d=Hc(h,n);c.frame.copyFrom(d),c.updateUvs()}return{texture:c,canvasAndContext:l}}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:s,canvasAndContext:i}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:i,texture:s,usageCount:1},s}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){Nt.returnCanvasAndContext(e.canvasAndContext),ut.returnTexture(e.texture);const s=e.texture.source;s.resource=null,s.uploadMethodId="unknown",s.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,s,i){var n,o,a,u,l,h,c;const{canvas:d,context:p}=i,f=Ir(e),g=Ft.measureText(t||" ",e),m=g.lines,_=g.lineHeight,x=g.lineWidths,b=g.maxLineWidth,y=g.fontProperties,T=d.height;p.resetTransform(),p.scale(s,s);const w=e.padding*2;if(p.clearRect(0,0,g.width+4+w,g.height+4+w),(n=e._stroke)!=null&&n.width){const E=e._stroke;p.lineWidth=E.width,p.miterLimit=E.miterLimit,p.lineJoin=E.join,p.lineCap=E.cap}p.font=f;let P,R;const S=e.dropShadow?2:1;for(let E=0;Et in r?U0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k0=(r,t)=>{for(var e in t||(t={}))vd.call(t,e)&&Td(r,e,t[e]);if(Hs)for(var e of Hs(t))yd.call(t,e)&&Td(r,e,t[e]);return r},$0=(r,t)=>{var e={};for(var s in r)vd.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Hs)for(var s of Hs(r))t.indexOf(s)<0&&yd.call(r,s)&&(e[s]=r[s]);return e};class er extends Y{constructor(t){t instanceof ct&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=$0(e,["context","roundPixels"]);super(k0({label:"Graphics"},n)),this.canBundle=!0,this.renderPipeId="graphics",this._roundPixels=0,s?this._context=s:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i!=null?i:!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 er(this._context.clone()):(this._ownedContext=null,new er(this._context))}lineStyle(t,e,s){const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.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 Xs;function Sd(){if(!Xs){Xs="mediump";const r=Mn();r&&r.getShaderPrecisionFormat&&(Xs=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Xs}function Ed(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 Ad(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float; +${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Pd(r,t){return t?`#version 300 es +${r}`:r}const L0={},N0={};function wd(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?L0:N0;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} +${r}`}function Rd(r,t){return t?r.replace("#version 300 es",""):r}var H0=Object.defineProperty,Md=Object.getOwnPropertySymbols,X0=Object.prototype.hasOwnProperty,z0=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?H0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cd=(r,t)=>{for(var e in t||(t={}))X0.call(t,e)&&Od(r,e,t[e]);if(Md)for(var e of Md(t))z0.call(t,e)&&Od(r,e,t[e]);return r};const vo={stripVersion:Rd,ensurePrecision:Ad,addProgramDefines:Ed,setProgramName:wd,insertVersion:Pd},yo=Object.create(null),Gd=class hl{constructor(t){t=Cd(Cd({},hl.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Sd()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(vo).forEach(o=>{const a=s[o];i=vo[o](i,a,!0),n=vo[o](n,a,!1)}),this.fragment=i,this.vertex=n,this._key=wr(`${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 yo[e]||(yo[e]=new hl(t)),yo[e]}};Gd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Ot=Gd;const Id={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=Id[r])!=null?t:Id.float32}const j0={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 Bd({source:r,entryPoint:t}){var e;const s={},i=r.indexOf(`fn ${t}`);if(i!==-1){const n=r.indexOf("->",i);if(n!==-1){const o=r.substring(i,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=j0[u[3]])!=null?e:"float32";s[u[2]]={location:parseInt(u[1],10),format:l,stride:Ue(l).stride,offset:0,instance:!1,start:0}}}}return s}function zs(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,u=/:\s*(\w+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>({group:parseInt(f.match(n)[1],10),binding:parseInt(f.match(o)[1],10),name:f.match(a)[2],isUniform:f.match(a)[1]==="",type:f.match(u)[1]}));if(!d)return{groups:[],structs:[]};const p=(s=(e=r.match(l))==null?void 0:e.map(f=>{const g=f.match(c)[1],m=f.match(h).reduce((_,x)=>{const[b,y]=x.split(":");return _[b.trim()]=y.trim(),_},{});return m?{name:g,members:m}:null}).filter(({name:f})=>d.some(g=>g.type===f)))!=null?s:[];return{groups:d,structs:p}}var ke=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(ke||{});function Fd({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 s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const To=Object.create(null);class At{constructor(t){this._layoutKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:u}=t;if(this.name=u,this.fragment=i,this.vertex=n,i.source===n.source){const l=zs(i.source);this.structsAndGroups=l}else{const l=zs(n.source),h=zs(i.source);this.structsAndGroups=Ud(l,h)}this.layout=o!=null?o:Dd(this.structsAndGroups),this.gpuLayout=a!=null?a:Fd(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((s=this.layout[1])==null?void 0:s.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=wr(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Bd(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 To[e]||(To[e]=new At(t)),To[e]}}function So(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const kd=/\{\{(.*?)\}\}/g;function Eo(r){var t,e;const s={};return((e=(t=r.match(kd))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function $d(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Ao(r,t,e=!1){const s=[];$d(t,s),r.forEach(a=>{a.header&&$d(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,u)=>` @location(${u}) ${a},`).join(` +`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` +${n} +`),o}function Ld(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function V0(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function W0(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Nd(r,t){const e=[];Ld(t,e),r.forEach(u=>{u.header&&Ld(u.header,e)});let s=0;const i=e.sort().map(u=>u.indexOf("builtin")>-1?u:`@location(${s++}) ${u}`).join(`, +`),n=e.sort().map(u=>` var ${W0(u)};`).join(` +`),o=`return VSOutput( + ${e.sort().map(u=>` ${V0(u)}`).join(`, +`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` +${i} +`),a=a.replace("{{start}}",` +${n} +`),a=a.replace("{{return}}",` +${o} +`),a}function Po(r,t){let e=r;for(const s in t){const i=t[s];i.join(` +`).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// +${i.join(` +`)} +//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Se=Object.create(null),wo=new Map;let Y0=0;function Hd({template:r,bits:t}){const e=zd(r,t);if(Se[e])return Se[e];const{vertex:s,fragment:i}=K0(r,t);return Se[e]=jd(s,i,t),Se[e]}function Xd({template:r,bits:t}){const e=zd(r,t);return Se[e]||(Se[e]=jd(r.vertex,r.fragment,t)),Se[e]}function K0(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=Ao(e,r.vertex,!0);i=Nd(e,i);const n=Ao(s,r.fragment,!0);return{vertex:i,fragment:n}}function zd(r,t){return t.map(e=>(wo.has(e)||wo.set(e,Y0++),wo.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function jd(r,t,e){const s=Eo(r),i=Eo(t);return e.forEach(n=>{So(n.vertex,s,n.name),So(n.fragment,i,n.name)}),{vertex:Po(r,s),fragment:Po(t,i)}}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}} + }; +`,Wd=` + @in vUV : vec2; + @in vColor : vec4; + + {{header}} + + @fragment + fn main( + {{in}} + ) -> @location(0) vec4 { + + {{start}} + + var outColor:vec4; + + {{main}} + + return outColor * vColor; + }; +`,Yd=` + 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}} + } +`,Kd=` + + in vec4 vColor; + in vec2 vUV; + + out vec4 finalColor; + + {{header}} + + void main(void) { + + {{start}} + + vec4 outColor; + + {{main}} + + finalColor = outColor * vColor; + } +`,qd={name:"global-uniforms-bit",vertex:{header:` + struct GlobalUniforms { + uProjectionMatrix:mat3x3, + uWorldTransformMatrix:mat3x3, + uWorldColorAlpha: vec4, + uResolution: vec2, + } + + @group(0) @binding(0) var globalUniforms : GlobalUniforms; + `}},q0={name:"global-uniforms-ubo-bit",vertex:{header:` + uniform globalUniforms { + mat3 uProjectionMatrix; + mat3 uWorldTransformMatrix; + vec4 uWorldColorAlpha; + vec2 uResolution; + }; + `}},Zd={name:"global-uniforms-bit",vertex:{header:` + uniform mat3 uProjectionMatrix; + uniform mat3 uWorldTransformMatrix; + uniform vec4 uWorldColorAlpha; + uniform vec2 uResolution; + `}};var Z0=Object.defineProperty,Qd=Object.getOwnPropertySymbols,Q0=Object.prototype.hasOwnProperty,J0=Object.prototype.propertyIsEnumerable,Jd=(r,t,e)=>t in r?Z0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,t1=(r,t)=>{for(var e in t||(t={}))Q0.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))J0.call(t,e)&&Jd(r,e,t[e]);return r};function $e({bits:r,name:t}){const e=Hd({template:{fragment:Wd,vertex:Vd},bits:[qd,...r]});return At.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Le({bits:r,name:t}){return new Ot(t1({name:t},Xd({template:{vertex:Yd,fragment:Kd},bits:[Zd,...r]})))}const js={name:"color-bit",vertex:{header:` + @in aColor: vec4; + `,main:` + vColor *= vec4(aColor.rgb * aColor.a, aColor.a); + `}},Vs={name:"color-bit",vertex:{header:` + in vec4 aColor; + `,main:` + vColor *= vec4(aColor.rgb * aColor.a, aColor.a); + `}},Ro={};function e1(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 s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` +`)}function r1(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; + + ${e1(r)} + `,main:` + var uvDx = dpdx(vUV); + var uvDy = dpdy(vUV); + + ${r1(r)} + `}}),Ro[r]}const Mo={};function s1(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; + } + `}},tp={};function Ks(r){let t=tp[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(ft||{}),i1=Object.defineProperty,qs=Object.getOwnPropertySymbols,ep=Object.prototype.hasOwnProperty,rp=Object.prototype.propertyIsEnumerable,sp=(r,t,e)=>t in r?i1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,n1=(r,t)=>{for(var e in t||(t={}))ep.call(t,e)&&sp(r,e,t[e]);if(qs)for(var e of qs(t))rp.call(t,e)&&sp(r,e,t[e]);return r},o1=(r,t)=>{var e={};for(var s in r)ep.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&qs)for(var s of qs(r))t.indexOf(s)<0&&rp.call(r,s)&&(e[s]=r[s]);return e};class Pt extends dt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=ft.WEBGPU),s&&(o|=ft.WEBGL)),this.compatibleRenderers=o;const u={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&a)for(const l in a)for(const h in a[l]){const c=a[l][h];u[c]={group:l,binding:h,name:c}}else if(e&&i&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,u[h.name]=h})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,u[h.name]=h});let l=0;for(const h in n)u[h]||(i[99]||(i[99]=new Lt,this._ownedBindGroups.push(i[99])),u[h]={group:99,binding:l,name:h},a[99]=a[99]||{},a[99][l]=h,l++);for(const h in n){const c=h;let d=n[h];!d.source&&!d._resourceType&&(d=new it(d));const p=u[c];p&&(i[p.group]||(i[p.group]=new Lt,this._ownedBindGroups.push(i[p.group])),i[p.group].setResource(d,p.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,u)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Lt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:s,gl:i}=e,n=o1(e,["gpu","gl"]);let o,a;return s&&(o=At.from(s)),i&&(a=Ot.from(i)),new Pt(n1({gpuProgram:o,glProgram:a},n))}}const ip={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 = vec4(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance)); + `}},np={name:"local-uniform-msdf-bit",vertex:{header:` + uniform mat3 uTransformMatrix; + uniform vec4 uColor; + uniform float uRound; + `,main:` + vColor *= uColor; + modelMatrix *= uTransformMatrix; + `,end:` + if(uRound == 1.) + { + gl_Position.xy = roundPixels(gl_Position.xy, uResolution); + } + `},fragment:{header:` + uniform float uDistance; + `,main:` + outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance)); + `}},op={name:"msdf-bit",fragment:{header:` + fn calculateMSDFAlpha(msdfColor:vec4, shapeColor: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; + } + + // Gamma correction for coverage-like alpha + var luma: f32 = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114)); + var gamma: f32 = mix(1.0, 1.0 / 2.2, luma); + var coverage: f32 = pow(shapeColor.a * alpha, gamma); + + return coverage; + + } + `}},ap={name:"msdf-bit",fragment:{header:` + float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) { + + // MSDF + float median = msdfColor.r + msdfColor.g + msdfColor.b - + min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - + max(msdfColor.r, max(msdfColor.g, msdfColor.b)); + + // SDF + median = min(median, msdfColor.a); + + float screenPxDistance = distance * (median - 0.5); + float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); + + if (median < 0.01) { + alpha = 0.0; + } else if (median > 0.99) { + alpha = 1.0; + } + + // Gamma correction for coverage-like alpha + float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114)); + float gamma = mix(1.0, 1.0 / 2.2, luma); + float coverage = pow(shapeColor.a * alpha, gamma); + + return coverage; + } + `}};let Oo,Co;class up extends Pt{constructor(){const t=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new C,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=Jt();Oo!=null||(Oo=$e({name:"sdf-shader",bits:[js,Ws(e),ip,op,Ne]})),Co!=null||(Co=Le({name:"sdf-shader",bits:[Vs,Ys(e),np,ap,He]})),super({glProgram:Co,gpuProgram:Oo,resources:{localUniforms:t,batchSamplers:Ks(e)}})}}let Go=0;const lp=500;function Xe(...r){Go!==lp&&(Go++,Go===lp?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}class Io extends dt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}function Bo(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,s=r.length;et in r?a1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dp=(r,t)=>{for(var e in t||(t={}))u1.call(t,e)&&cp(r,e,t[e]);if(hp)for(var e of hp(t))l1.call(t,e)&&cp(r,e,t[e]);return r};const pp=class ub extends Io{constructor(t){var e,s,i;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=dp(dp({},ub.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=A.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const u=Ir(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,this.fontMetrics=Ft.measureFont(u),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=Bo(t).filter(b=>!this._currentChars.includes(b)).filter((b,y,T)=>T.indexOf(b)===y);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:u,context:l}=a.canvasAndContext,h=a.texture.source;const c=this._style;let d=this._currentX,p=this._currentY;const f=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*f,m=c.fontStyle==="italic"?2:1;let _=0,x=!1;for(let b=0;bthis._textureSize&&(p+=_,_=S,d=0,p+_>this._textureSize)){h.update();const L=this._nextPage();u=L.canvasAndContext.canvas,l=L.canvasAndContext.context,h=L.texture.source,p=0}const E=w/f-((s=(e=c.dropShadow)==null?void 0:e.distance)!=null?s:0)-((n=(i=c._stroke)==null?void 0:i.width)!=null?n:0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:E,kerning:{}},x){this._drawGlyph(l,T,d+g,p+g,f,c);const L=h.width*f,k=h.height*f,O=new V(d/L*h.width,p/k*h.height,R/L*h.width,S/k*h.height);this.chars[y].texture=new A({source:h,frame:O}),d+=Math.ceil(R)}}h.update(),this._currentX=d,this._currentY=p,this._skipKerning&&this._applyKerning(o,l)}get pageTextures(){return this.pages}_applyKerning(t,e){const s=this._measureCache;for(let i=0;i{const f=i.width;for(let g=0;g{let p=i.chars.length-1,f=i.chars[p];for(;f===" ";)i.width-=e.chars[f].xAdvance,f=i.chars[--p];s.width=Math.max(s.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,s.lines.push(i),s.height+=e.lineHeight},h=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*h,d=t.wordWrapWidth*h;for(let p=0;pd?(l(),u(a),g||i.charPositions.push(0)):(a.start=i.width,u(a),g||i.charPositions.push(0)),f==="\r"||f===` +`)i.width!==0&&l();else if(!g){const _=m.xAdvance+(m.kerning[n]||0)+c;i.width+=_,i.spaceWidth=_,i.spacesIndex.push(i.charPositions.length),i.chars.push(f)}}else{const _=m.kerning[n]||0,x=m.xAdvance+_+c;a.positions[a.index++]=a.width+_,a.chars.push(f),a.width+=x}n=f}return l(),t.align==="center"?h1(s):t.align==="right"?c1(s):t.align==="justify"&&d1(s),s}function h1(r){for(let t=0;tt in r?p1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uo=(r,t)=>{for(var e in t||(t={}))f1.call(t,e)&&mp(r,e,t[e]);if(fp)for(var e of fp(t))m1.call(t,e)&&mp(r,e,t[e]);return r};let Zs=0,g1=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 s;let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let a=e.styleKey;a=a.substring(0,a.lastIndexOf("-")),i=`${a}-bitmap`,n=!1}if(!K.has(i)){const a=new Fo(Uo({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions));Zs++,Zs>50&&Xe("BitmapText",`You have dynamically created ${Zs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{Zs--,K.remove(i)}),K.set(i,a)}const o=K.get(i);return(s=o.ensureCharacters)==null||s.call(o,t),o}getLayout(t,e){const s=this.getFont(t,e);return Do([...t],e,s)}measureText(t,e){return this.getLayout(t,e)}install(...t){var e,s,i,n;let o=t[0];typeof o=="string"&&(o={name:o,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(s=t[2])==null?void 0:s.resolution,padding:(i=t[2])==null?void 0:i.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const a=o==null?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=Uo(Uo({},this.defaultOptions),o);const u=o.style,l=u instanceof Tt?u:new Tt(u),h=l._fill.fill!==null&&l._fill.fill!==void 0,c=new Fo({style:l,overrideFill:h,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1}),d=Bo(o.chars);return c.ensureCharacters(d.join("")),K.set(`${a}-bitmap`,c),c.once("destroy",()=>K.remove(`${a}-bitmap`)),c}uninstall(t){const e=`${t}-bitmap`,s=K.get(e);s&&(K.remove(e),s.destroy())}};const Fr=new g1;class ko{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 s=this._getGpuBitmapText(t);gp(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){const e=this._gpuBitmapText[t].context;e.customShader&&(z.return(e.customShader),e.customShader=null),z.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);gp(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=Fr.getFont(t.text,t._style);s.clear(),i.distanceField.type!=="none"&&(s.customShader||(s.customShader=z.get(up)));const n=Array.from(t.text),o=t._style;let a=i.baseLineOffset;const u=Do(n,o,i);let l=0;const h=o.padding,c=u.scale;let d=u.width,p=u.height+u.offsetY;o._stroke&&(d+=o._stroke.width/c,p+=o._stroke.width/c),s.translate(-t._anchor._x*d-h,-t._anchor._y*p-h).scale(c,c);const f=i.applyFillAsTint?o._fill.color:16777215;for(let g=0;g{this.destroyRenderable(t)}),this._gpuBitmapText[t.uid]}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,s=t._style.fontFamily,i=K.get(`${s}-bitmap`),{a:n,b:o,c:a,d:u}=t.groupTransform,l=Math.sqrt(n*n+o*o),h=Math.sqrt(a*a+u*u),c=(Math.abs(l)+Math.abs(h))/2,d=i.baseRenderedFontSize/t._style.fontSize,p=c*i.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){for(const t in this._gpuBitmapText)this._destroyRenderableByUid(t);this._gpuBitmapText=null,this._renderer=null}}ko.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"bitmapText"};function gp(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}D.add(ko);class $o{constructor(t){this._gpuText=Object.create(null),this._renderer=t,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const t in this._gpuText){const e=this._gpuText[t].batchableSprite.renderable;e._autoResolution&&(e._resolution=this._renderer.resolution,e.onViewUpdate())}}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==s}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s)}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),z.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),i=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t).catch(o=>{console.error(o)}),t._didTextUpdate=!1;const n=t._style.padding;_r(i.bounds,t._anchor,i.texture,n)}async _updateGpuText(t){var e;t._didTextUpdate=!1;const s=this._getGpuText(t);if(s.generatingTexture)return;const i=t._getKey();this._renderer.htmlText.decreaseReferenceCount(s.currentKey),s.generatingTexture=!0,s.currentKey=i;const n=(e=t.resolution)!=null?e:this._renderer.resolution,o=await this._renderer.htmlText.getManagedTexture(t.text,n,t._style,t._getKey()),a=s.batchableSprite;a.texture=s.texture=o,s.generatingTexture=!1,s.textureNeedsUploading=!0,t.onViewUpdate();const u=t._style.padding;_r(a.bounds,t._anchor,a.texture,u)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:A.EMPTY,currentKey:"--",batchableSprite:z.get(Us),textureNeedsUploading:!1,generatingTexture:!1},s=e.batchableSprite;return s.renderable=t,s.texture=A.EMPTY,s.bounds={minX:0,maxX:1,minY:0,maxY:0},s.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,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}}$o.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"htmlText"};function _p(){const{userAgent:r}=j.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Lo="http://www.w3.org/2000/svg",No="http://www.w3.org/1999/xhtml";class Ho{constructor(){this.svgRoot=document.createElementNS(Lo,"svg"),this.foreignObject=document.createElementNS(Lo,"foreignObject"),this.domElement=document.createElementNS(No,"div"),this.styleElement=document.createElementNS(No,"style"),this.image=new Image;const{foreignObject:t,svgRoot:e,styleElement:s,domElement:i}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(i)}}function xp(r){const t=r._stroke,e=r._fill,s=[`div { ${[`color: ${X.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${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?[vp(t)]:[],...r.dropShadow?[bp(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return _1(r.tagStyles,s),s.join(" ")}function bp(r){const t=X.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),s=Math.round(Math.sin(r.angle)*r.distance),i=`${e}px ${s}px`;return r.blur>0?`text-shadow: ${i} ${r.blur}px ${t}`:`text-shadow: ${i} ${t}`}function vp(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${X.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${X.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const yp={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"},Tp={fill:r=>`color: ${X.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:vp,dropShadow:bp};function _1(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)Tp[n]?i.push(Tp[n](s[n])):yp[n]&&i.push(yp[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}var x1=Object.defineProperty,Sp=Object.getOwnPropertySymbols,b1=Object.prototype.hasOwnProperty,v1=Object.prototype.propertyIsEnumerable,Ep=(r,t,e)=>t in r?x1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,y1=(r,t)=>{for(var e in t||(t={}))b1.call(t,e)&&Ep(r,e,t[e]);if(Sp)for(var e of Sp(t))v1.call(t,e)&&Ep(r,e,t[e]);return r};class Pe extends Tt{constructor(t={}){var e,s;super(t),this._cssOverrides=[],(e=this.cssOverrides)!=null||(this.cssOverrides=t.cssOverrides),this.tagStyles=(s=t.tagStyles)!=null?s:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=mo(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Pe({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?y1({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=xp(this)),this._cssStyle}addOverride(...t){const e=t.filter(s=>!this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(s=>this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(s=>!e.includes(s)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}function Ap(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(u){i[u]||(s.push(u),i[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 s}async function Pp(r){const t=await(await j.get().fetch(r)).blob(),e=new FileReader;return await new Promise((s,i)=>{e.onloadend=()=>s(e.result),e.onerror=i,e.readAsDataURL(t)})}async function Xo(r,t){const e=await Pp(t);return`@font-face { + font-family: "${r.fontFamily}"; + src: url('${e}'); + font-weight: ${r.fontWeight}; + font-style: ${r.fontStyle}; + }`}const Dr=new Map;async function wp(r,t,e){const s=r.filter(i=>K.has(`${i}-and-url`)).map((i,n)=>{if(!Dr.has(i)){const{url:o}=K.get(`${i}-and-url`);n===0?Dr.set(i,Xo({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:i},o)):Dr.set(i,Xo({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:i},o))}return Dr.get(i)});return(await Promise.all(s)).join(` +`)}function Rp(r,t,e,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`
${r}
`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:u,height:l}=i.image;return a.setAttribute("width",u.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function Mp(r,t){const e=Nt.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),Nt.returnCanvasAndContext(e),e.canvas}function Op(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let Cp;function zo(r,t,e,s){s=s||Cp||(Cp=new Ho);const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`
${r}
`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=i.getBoundingClientRect();o.remove();const u=Ft.measureFont(t.fontStyle).descent;return{width:a.width,height:a.height+u}}class Qs{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===ft.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,s,i){if(this._activeTextures[i])return this._increaseReferenceCount(i),this._activeTextures[i].promise;const n=this._buildTexturePromise(t,e,s).then(o=>(this._activeTextures[i].texture=o,o));return this._activeTextures[i]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,s){const i=z.get(Ho),n=Ap(t,s),o=await wp(n,s,Pe.defaultTextStyle),a=zo(t,s,o,i),u=Math.ceil(Math.ceil(Math.max(1,a.width)+s.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+s.padding*2)*e),h=i.image;h.width=u|0,h.height=l|0;const c=Rp(t,s,e,o,i);await Op(h,c,_p()&&n.length>0);let d=h;this._createCanvas&&(d=Mp(h,e));const p=_o(d,h.width,h.height,e);return this._createCanvas&&this._renderer.texture.initSource(p.source),z.return(i),p}_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(s=>{e.texture=s,this._cleanUp(e)}).catch(()=>{}),this._activeTextures[t]=null))}_cleanUp(t){ut.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}Qs.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"htmlText"},Qs.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"},D.add(Qs),D.add($o);var T1=Object.defineProperty,Gp=Object.getOwnPropertySymbols,S1=Object.prototype.hasOwnProperty,E1=Object.prototype.propertyIsEnumerable,Ip=(r,t,e)=>t in r?T1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Bp=(r,t)=>{for(var e in t||(t={}))S1.call(t,e)&&Ip(r,e,t[e]);if(Gp)for(var e of Gp(t))E1.call(t,e)&&Ip(r,e,t[e]);return r};const Fp=class lb extends Ge{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=Bp(Bp({},lb.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=s.uvs||new Float32Array([0,0,1,0,1,1,0,1]),o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,u=new vt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:N.VERTEX|N.COPY_DST}),l=new vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:N.VERTEX|N.COPY_DST}),h=new vt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:N.INDEX|N.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:h,topology:s.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Fp.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ee=Fp;var A1=Object.defineProperty,P1=Object.defineProperties,w1=Object.getOwnPropertyDescriptors,Dp=Object.getOwnPropertySymbols,R1=Object.prototype.hasOwnProperty,M1=Object.prototype.propertyIsEnumerable,Up=(r,t,e)=>t in r?A1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kp=(r,t)=>{for(var e in t||(t={}))R1.call(t,e)&&Up(r,e,t[e]);if(Dp)for(var e of Dp(t))M1.call(t,e)&&Up(r,e,t[e]);return r},$p=(r,t)=>P1(r,w1(t));const ze={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); + } + `}},Lp=$p(kp({},ze),{vertex:$p(kp({},ze.vertex),{header:ze.vertex.header.replace("group(1)","group(2)")})}),Js={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); + `}},Hp={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 jo,Vo;class Xp extends Pt{constructor(){jo!=null||(jo=$e({name:"tiling-sprite-shader",bits:[ze,Np,Ne]})),Vo!=null||(Vo=Le({name:"tiling-sprite-shader",bits:[Js,Hp,He]}));const t=new it({uMapCoord:{value:new C,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new C,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:Vo,gpuProgram:jo,resources:{localUniforms:new it({uTransformMatrix:{value:new C,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:A.EMPTY.source,uSampler:A.EMPTY.source.style}})}updateUniforms(t,e,s,i,n,o){const a=this.resources.tilingUniforms,u=o.width,l=o.height,h=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(s.a*u/t,s.b*u/e,s.c*l/t,s.d*l/e,s.tx/t,s.ty/e),c.invert(),a.uniforms.uMapCoord=h.mapCoord,a.uniforms.uClampFrame=h.uClampFrame,a.uniforms.uClampOffset=h.uClampOffset,a.uniforms.uTextureTransform=c,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class zp extends ee{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 jp(r,t){const e=r.anchor.x,s=r.anchor.y;t[0]=-e*r.width,t[1]=-s*r.height,t[2]=(1-e)*r.width,t[3]=-s*r.height,t[4]=(1-e)*r.width,t[5]=(1-s)*r.height,t[6]=-e*r.width,t[7]=(1-s)*r.height}function Vp(r,t,e,s){let i=0;const n=r.length/(t||2),o=s.a,a=s.b,u=s.c,l=s.d,h=s.tx,c=s.ty;for(e*=t;i{this.destroyRenderable(t)}),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:s}=e,i=t.texture.source.style;i.addressMode!=="repeat"&&(i.addressMode="repeat",i.update()),Wp(t,s.uvs),jp(t,s.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),s=t.texture;let i=!0;return this._renderer.type===ft.WEBGL&&(i=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=s.textureMatrix.isSimple&&(i||s.source.isPowerOfTwo),e.canBatch}}Wo.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"tilingSprite"},D.add(Wo);var O1=Object.defineProperty,Yp=Object.getOwnPropertySymbols,C1=Object.prototype.hasOwnProperty,G1=Object.prototype.propertyIsEnumerable,Kp=(r,t,e)=>t in r?O1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qp=(r,t)=>{for(var e in t||(t={}))C1.call(t,e)&&Kp(r,e,t[e]);if(Yp)for(var e of Yp(t))G1.call(t,e)&&Kp(r,e,t[e]);return r};const Zp=class hb extends ee{constructor(...t){var e;super({});let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={width:s,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(s)}build(t){var e,s,i,n;t=qp(qp({},hb.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(s=this.verticesY)!=null?s:t.verticesY,this.width=(i=this.width)!=null?i:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],u=[],l=[],h=this.verticesX-1,c=this.verticesY-1,d=this.width/h,p=this.height/c;for(let g=0;gt in r?I1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tf=(r,t)=>{for(var e in t||(t={}))B1.call(t,e)&&Jp(r,e,t[e]);if(Qp)for(var e of Qp(t))F1.call(t,e)&&Jp(r,e,t[e]);return r};const ef=class cb extends Yo{constructor(t={}){t=tf(tf({},cb.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,s,i,n,o,a,u,l;this.width=(e=t.width)!=null?e:this.width,this.height=(s=t.height)!=null?s:this.height,this._originalWidth=(i=t.originalWidth)!=null?i:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(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,s=this.width>e?1:this.width/e,i=this._topHeight+this._bottomHeight,n=this.height>i?1:this.height/i,o=Math.min(s,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,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};ef.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let re=ef;class Ko{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,s=this._getGpuSprite(t);return s.texture._source!==e._source?!s.batcher.checkAndUpdateTexture(s,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];z.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 Ds;return e.geometry=new re,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}}Ko.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"nineSliceSprite"},D.add(Ko);class qo{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}qo.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"filter"};const D1=new C;function rf(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 s=t;if((r.renderGroup||e)&&(s=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,r.worldTransform);else{if(r.renderPipeId){const n=r.bounds;s.addFrame(n.minX,n.minY,n.maxX,n.maxY,r.groupTransform)}const i=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 Lt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var e,s;const i=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?sf(t.renderables,a):t.filterEffect.filterArea?(a.clear(),a.addRect(t.filterEffect.filterArea),a.applyMatrix(t.container.worldTransform)):rf(t.container,a);const u=i.renderTarget.renderTarget.colorTexture.source;let l=1/0,h=0,c=!0,d=!1,p=!1;for(let g=0;g0?this._filterStack[this._filterStackIndex-1].bounds:null,u=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(u,i,a)}e.backTexture=n;const o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),o.length===1)o[0].apply(this,s,e.previousRenderSurface,!1),ut.returnTexture(s);else{let a=e.inputTexture,u=ut.getOptimalTexture(i.width,i.height,a.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[c].skip;)--c;c>0&&(h=this._filterStack[c].inputTexture.source._resolution);const d=this._filterGlobalUniforms,p=d.uniforms,f=p.uOutputFrame,g=p.uInputSize,m=p.uInputPixel,_=p.uInputClamp,x=p.uGlobalFrame,b=p.uOutputTexture;if(l){let w=this._filterStackIndex;for(;w>0;){w--;const P=this._filterStack[this._filterStackIndex-1];if(!P.skip){u.x=P.bounds.minX,u.y=P.bounds.minY;break}}f[0]=a.minX-u.x,f[1]=a.minY-u.y}else f[0]=0,f[1]=0;f[2]=e.frame.width,f[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[1],m[0]=e.source.pixelWidth,m[1]=e.source.pixelHeight,m[2]=1/m[0],m[3]=1/m[1],_[0]=.5*m[2],_[1]=.5*m[3],_[2]=e.frame.width*g[2]-.5*m[2],_[3]=e.frame.height*g[3]-.5*m[3];const y=this.renderer.renderTarget.rootRenderTarget.colorTexture;x[0]=u.x*h,x[1]=u.y*h,x[2]=y.source.width*h,x[3]=y.source.height*h;const T=this.renderer.renderTarget.getRenderTarget(s);if(n.renderTarget.bind(s,!!i),s instanceof A?(b[0]=s.frame.width,b[1]=s.frame.height):(b[0]=T.width,b[1]=T.height),b[2]=T.isRoot?-1:1,d.update(),n.renderPipes.uniformBatch){const w=n.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(w,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:U1,shader:t,state:t._state,topology:"triangle-list"}),n.type===ft.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 s=this._activeFilterData,i=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(C.shared);return n.invert(),i.prepend(n),i.scale(1/e.texture.frame.width,1/e.texture.frame.height),i.translate(e.anchor.x,e.anchor.y),i}}Qo.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"filter"},D.add(Qo),D.add(qo);var k1={__proto__:null};const Jo=[];D.handleByNamedList(v.Environment,Jo);async function ta(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 ra{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,u){const{name:l,items:h}=this;for(let c=0,d=h.length;ct in r?L1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ei=(r,t)=>{for(var e in t||(t={}))N1.call(t,e)&&of(r,e,t[e]);if(nf)for(var e of nf(t))H1.call(t,e)&&of(r,e,t[e]);return r};const X1=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],af=class db extends dt{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,this.config=t;const s=[...X1,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await ta(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash){const i=this._systemsHash[s].constructor.defaultOptions;t=ei(ei({},i),t)}t=ei(ei({},db.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[e]=new ra(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(t,e){const s=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{const n=i.value,o=i.name,a=s[o];this.renderPipes[o]=new n(this,a?new a:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ea())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};af.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let kr=af,sa;function $r(r){return sa!==void 0||(sa=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:kr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let s=j.get().createCanvas().getContext("webgl",e);const i=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,i}catch(s){return!1}})()),sa}let ia;async function Lr(r={}){return ia!==void 0||(ia=await(async()=>{if(!j.get().getNavigator().gpu)return!1;try{return await(await navigator.gpu.requestAdapter(r)).requestDevice(),!0}catch(t){return!1}})()),ia}var z1=Object.defineProperty,uf=Object.getOwnPropertySymbols,j1=Object.prototype.hasOwnProperty,V1=Object.prototype.propertyIsEnumerable,lf=(r,t,e)=>t in r?z1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nr=(r,t)=>{for(var e in t||(t={}))j1.call(t,e)&&lf(r,e,t[e]);if(uf)for(var e of uf(t))V1.call(t,e)&&lf(r,e,t[e]);return r};const hf=["webgl","webgpu","canvas"];async function cf(r){var t;let e=[];r.preference?(e.push(r.preference),hf.forEach(o=>{o!==r.preference&&e.push(o)})):e=hf.slice();let s,i={};for(let o=0;ot in r?W1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,q1=(r,t)=>{for(var e in t||(t={}))Y1.call(t,e)&&pf(r,e,t[e]);if(df)for(var e of df(t))K1.call(t,e)&&pf(r,e,t[e]);return r};const ff=class cl{constructor(...t){this.stage=new Y}async init(t){t=q1({},t),this.renderer=await cf(t),cl._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=cl._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};ff._plugins=[];let mf=ff;D.handleByList(v.Application,mf._plugins),D.add(na);class aa extends Io{constructor(t,e){var s;super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],u=i[a.id];this.pages.push({texture:u})}),Object.keys(n.chars).forEach(o=>{var a;const u=n.chars[o],{frame:l,source:h}=i[u.page],c=new V(u.x+l.x,u.y+l.y,u.width,u.height),d=new A({source:h,frame:c});this.chars[o]={id:o.codePointAt(0),xOffset:u.xOffset,yOffset:u.yOffset,xAdvance:u.xAdvance,kerning:(a=u.kerning)!=null?a:{},texture:d}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(s=n.distanceField)!=null?s:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?ua.test(j.get().parseXML(r)):!1},parse(r){return ua.parse(j.get().parseXML(r))}},Z1=[".xml",".fnt"],gf={extension:{type:v.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof aa,getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},_f={extension:{type:v.LoadParser,priority:bt.Normal},name:"loadBitmapFont",test(r){return Z1.includes(pt.extname(r).toLowerCase())},async testParse(r){return ri.test(r)||la.test(r)},async parse(r,t,e){const s=ri.test(r)?ri.parse(r):la.parse(r),{src:i}=t,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let h=0;hu[h.src]);return new aa({data:s,textures:l},i)},async load(r,t){return await(await j.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),r.destroy()}};class xf{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(r)&&r.every(t=>t instanceof A),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function ha(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 vf={extension:{type:v.DetectionParser,priority:1},test:async()=>ha("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},yf=["png","jpg","jpeg"],Tf={extension:{type:v.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...yf],remove:async r=>r.filter(t=>!yf.includes(t))},Q1="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function si(r){return Q1?!1:document.createElement("video").canPlayType(r)!==""}const Sf={extension:{type:v.DetectionParser,priority:0},test:async()=>si("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Ef={extension:{type:v.DetectionParser,priority:0},test:async()=>si("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Af={extension:{type:v.DetectionParser,priority:0},test:async()=>si("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Pf={extension:{type:v.DetectionParser,priority:0},test:async()=>ha("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var J1=Object.defineProperty,tT=Object.defineProperties,eT=Object.getOwnPropertyDescriptors,wf=Object.getOwnPropertySymbols,rT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable,Rf=(r,t,e)=>t in r?J1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,iT=(r,t)=>{for(var e in t||(t={}))rT.call(t,e)&&Rf(r,e,t[e]);if(wf)for(var e of wf(t))sT.call(t,e)&&Rf(r,e,t[e]);return r},nT=(r,t)=>tT(r,eT(t));class Mf{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var i,n;let o=null,a=null;if(e.loadParser&&(a=this._parserHash[e.loadParser]),!a){for(let u=0;u({alias:[l],src:l,data:{}})),a=o.length,u=o.map(async l=>{const h=pt.toAbsolute(l.src);if(!i[l.src])try{this.promiseCache[h]||(this.promiseCache[h]=this._getLoadPromiseAndParser(h,l)),i[l.src]=await this.promiseCache[h].promise,e&&e(++s/a)}catch(c){throw delete this.promiseCache[h],delete i[l.src],new Error(`[Loader.load] Failed to load ${h}. +${c}`)}});return await Promise.all(u),n?i[o[0].src]:i}async unload(t){const e=Mt(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=pt.toAbsolute(s.src),a=this.promiseCache[o];if(a){const u=await a.promise;delete this.promiseCache[o],await((n=(i=a.parser)==null?void 0:i.unload)==null?void 0:n.call(i,u,s,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],nT(iT({},t),{[e.name]:e})),{})}}function Ee(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],s=pt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const oT=".json",aT="application/json",Of={extension:{type:v.LoadParser,priority:bt.Low},name:"loadJson",test(r){return Ee(r,aT)||Ct(r,oT)},async load(r){return await(await j.get().fetch(r)).json()}},uT=".txt",lT="text/plain",Cf={name:"loadTxt",extension:{type:v.LoadParser,priority:bt.Low,name:"loadTxt"},test(r){return Ee(r,lT)||Ct(r,uT)},async load(r){return await(await j.get().fetch(r)).text()}};var hT=Object.defineProperty,cT=Object.defineProperties,dT=Object.getOwnPropertyDescriptors,Gf=Object.getOwnPropertySymbols,pT=Object.prototype.hasOwnProperty,fT=Object.prototype.propertyIsEnumerable,If=(r,t,e)=>t in r?hT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mT=(r,t)=>{for(var e in t||(t={}))pT.call(t,e)&&If(r,e,t[e]);if(Gf)for(var e of Gf(t))fT.call(t,e)&&If(r,e,t[e]);return r},gT=(r,t)=>cT(r,dT(t));const _T=["normal","bold","100","200","300","400","500","600","700","800","900"],xT=[".ttf",".otf",".woff",".woff2"],bT=["font/ttf","font/otf","font/woff","font/woff2"],vT=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Bf(r){const t=pt.extname(r),e=pt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(vT)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const yT=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function TT(r){return yT.test(r)?r:encodeURI(r)}const Ff={extension:{type:v.LoadParser,priority:bt.Low},name:"loadWebFont",test(r){return Ee(r,bT)||Ct(r,xT)},async load(r,t){var e,s,i,n,o,a;const u=j.get().getFontFaceSet();if(u){const l=[],h=(s=(e=t.data)==null?void 0:e.family)!=null?s:Bf(r),c=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>_T.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;p{K.remove(t.family),j.get().getFontFaceSet().delete(t)})}};function ii(r,t=1){var e;const s=(e=Zt.RETINA_PREFIX)==null?void 0:e.exec(r);return s?parseFloat(s[1]):t}function se(r,t,e){r.label=e,r._sourceOrigin=e;const s=new A({source:r,label:e}),i=()=>{delete t.promiseCache[e],K.has(e)&&K.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var ST=Object.defineProperty,ni=Object.getOwnPropertySymbols,Df=Object.prototype.hasOwnProperty,Uf=Object.prototype.propertyIsEnumerable,kf=(r,t,e)=>t in r?ST(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ET=(r,t)=>{for(var e in t||(t={}))Df.call(t,e)&&kf(r,e,t[e]);if(ni)for(var e of ni(t))Uf.call(t,e)&&kf(r,e,t[e]);return r},AT=(r,t)=>{var e={};for(var s in r)Df.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ni)for(var s of ni(r))t.indexOf(s)<0&&Uf.call(r,s)&&(e[s]=r[s]);return e};const PT=".svg",wT="image/svg+xml",$f={extension:{type:v.LoadParser,priority:bt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Ee(r,wT)||Ct(r,PT)},async load(r,t,e){var s;return((s=t.data.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?MT(r):RT(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function RT(r,t,e,s){var i,n,o,a,u;const l=await(await j.get().fetch(r)).blob(),h=URL.createObjectURL(l),c=new Image;c.src=h,c.crossOrigin=s,await c.decode(),URL.revokeObjectURL(h);const d=document.createElement("canvas"),p=d.getContext("2d"),f=((i=t.data)==null?void 0:i.resolution)||ii(r),g=(o=(n=t.data)==null?void 0:n.width)!=null?o:c.width,m=(u=(a=t.data)==null?void 0:a.height)!=null?u:c.height;d.width=g*f,d.height=m*f,p.drawImage(c,0,0,g*f,m*f);const _=t.data,{parseAsGraphicsContext:x}=_,b=AT(_,["parseAsGraphicsContext"]),y=new be(ET({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:f},b));return se(y,e,r)}async function MT(r){const t=await(await j.get().fetch(r)).text(),e=new ct;return e.svg(t),e}const OT=`(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 je=null,ca=class{constructor(){je||(je=URL.createObjectURL(new Blob([OT],{type:"application/javascript"}))),this.worker=new Worker(je)}};ca.revokeObjectURL=function(){je&&(URL.revokeObjectURL(je),je=null)};const CT='(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 Ve=null,Lf=class{constructor(){Ve||(Ve=URL.createObjectURL(new Blob([CT],{type:"application/javascript"}))),this.worker=new Worker(Ve)}};Lf.revokeObjectURL=function(){Ve&&(URL.revokeObjectURL(Ve),Ve=null)};let Nf=0,da,GT=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 ca;e.addEventListener("message",s=>{e.terminate(),ca.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){da===void 0&&(da=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 s=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[Nf]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Nf++,id:s})}};const pa=new GT;var IT=Object.defineProperty,Hf=Object.getOwnPropertySymbols,BT=Object.prototype.hasOwnProperty,FT=Object.prototype.propertyIsEnumerable,Xf=(r,t,e)=>t in r?IT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,DT=(r,t)=>{for(var e in t||(t={}))BT.call(t,e)&&Xf(r,e,t[e]);if(Hf)for(var e of Hf(t))FT.call(t,e)&&Xf(r,e,t[e]);return r};const UT=[".jpeg",".jpg",".png",".webp",".avif"],kT=["image/jpeg","image/png","image/webp","image/avif"];async function zf(r){const t=await j.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 fa={name:"loadTextures",extension:{type:v.LoadParser,priority:bt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ee(r,kT)||Ct(r,UT)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await pa.isImageBitmapSupported()?i=await pa.loadImageBitmap(r):i=await zf(r):i=await new Promise(o=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):i.onload=()=>{o(i)}});const n=new be(DT({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||ii(r)},t.data));return se(n,e,r)},unload(r){r.destroy(!0)}};var $T=Object.defineProperty,LT=Object.defineProperties,NT=Object.getOwnPropertyDescriptors,jf=Object.getOwnPropertySymbols,HT=Object.prototype.hasOwnProperty,XT=Object.prototype.propertyIsEnumerable,Vf=(r,t,e)=>t in r?$T(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ma=(r,t)=>{for(var e in t||(t={}))HT.call(t,e)&&Vf(r,e,t[e]);if(jf)for(var e of jf(t))XT.call(t,e)&&Vf(r,e,t[e]);return r},Wf=(r,t)=>LT(r,NT(t));const Yf=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],zT=Yf.map(r=>`video/${r.substring(1)}`);function Kf(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Zf(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function qf(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",s),r.addEventListener("error",i),r.load();function s(){n(),t()}function i(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",s),r.removeEventListener("error",i)}})}function Zf(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 Qf={name:"loadVideo",extension:{type:v.LoadParser,name:"loadVideo"},test(r){const t=Ee(r,zT),e=Ct(r,Yf);return t||e},async load(r,t,e){var s,i;const n=ma(Wf(ma({},xr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||ii(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await An()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(h=>{const c=a[h];c!==void 0&&o.setAttribute(h,c)}),n.muted===!0&&(o.muted=!0),Kf(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 h=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();l=xr.MIME_TYPES[h]||`video/${h}`}return u.src=r,l&&(u.type=l),new Promise(h=>{const c=async()=>{const d=new xr(Wf(ma({},n),{resource:o}));o.removeEventListener("canplay",c),t.data.preload&&await qf(o),h(se(d,e,r))};o.addEventListener("canplay",c),o.appendChild(u)})},unload(r){r.destroy(!0)}},ga={extension:{type:v.ResolveParser,name:"resolveTexture"},test:fa.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=Zt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Jf={extension:{type:v.ResolveParser,priority:-2,name:"resolveJson"},test:r=>Zt.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:ga.parse};class tm{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Zt,this.loader=new Mf,this.cache=K,this._backgroundLoader=new xf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,i;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let u=t.manifest;typeof u=="string"&&(u=await this.load(u)),this.resolver.addManifest(u)}const n=(s=(e=t.texturePreference)==null?void 0:e.resolution)!=null?s:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(i=t.texturePreference)==null?void 0:i.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=gr(t),i=Mt(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(i),o=await this._mapLoadToResolve(n,e);return s?o[i[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const i=this.resolver.resolveBundle(t),n={},o=Object.keys(i);let a=0,u=0;const l=()=>{e==null||e(++a/u)},h=o.map(c=>{const d=i[c];return u+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[c]=p})});return await Promise.all(h),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return K.get(t);const e={};for(let s=0;s{const a=i[o.src],u=[o.src];o.alias&&u.push(...o.alias),u.forEach(l=>{n[l]=a}),K.set(u,a)}),n}async unload(t){this._initialized||await this.init();const e=Mt(t).map(i=>typeof i!="string"?i.src:i),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Mt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(i=>this._unloadFromResolved(e[i]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{K.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,i)=>e.indexOf(s)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Hr=new tm;D.handleByList(v.LoadParser,Hr.loader.parsers).handleByList(v.ResolveParser,Hr.resolver.parsers).handleByList(v.CacheParser,Hr.cache.parsers).handleByList(v.DetectionParser,Hr.detections),D.add(bf,Tf,vf,Pf,Sf,Ef,Af,Of,Cf,Ff,$f,fa,Qf,_f,gf,ga,Jf);const em={loader:v.LoadParser,resolver:v.ResolveParser,cache:v.CacheParser,detection:v.DetectionParser};D.handle(v.Asset,r=>{const t=r.ref;Object.entries(em).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return D.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(em).filter(e=>!!t[e]).forEach(e=>D.remove(t[e]))});const jT={extension:{type:v.DetectionParser,priority:3},test:async()=>!!(await Lr()||$r()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class Xr extends tt{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let oi;function _a(){if(oi)return oi;const r=document.createElement("canvas").getContext("webgl");return r?(oi=[...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"]:[]],oi):[]}let ai;async function xa(){if(ai)return ai;const r=await navigator.gpu.requestAdapter();return ai=[...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"]:[]],ai}let ba;async function va(){return ba!==void 0||(ba=await(async()=>{const r=await Lr(),t=$r();if(r&&t){const e=await xa(),s=_a();return e.filter(i=>s.includes(i))}else{if(r)return await xa();if(t)return _a()}return[]})()),ba}const rm=["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 ui;async function zr(){if(ui!==void 0)return ui;const r=await va();return ui=[...rm,...r],ui}const VT='(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 We=null,sm=class{constructor(){We||(We=URL.createObjectURL(new Blob([VT],{type:"application/javascript"}))),this.worker=new Worker(We)}};sm.revokeObjectURL=function(){We&&(URL.revokeObjectURL(We),We=null)};const li={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function WT(r){Object.assign(li,r)}let jr;const im={};function YT(r){return jr||(jr=new sm().worker,jr.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),im[s](i)},jr.postMessage({type:"init",jsUrl:li.jsUrl,wasmUrl:li.wasmUrl,supportedTextures:r})),jr}function nm(r,t){const e=YT(t);return new Promise(s=>{im[r]=s,e.postMessage({type:"load",url:r})})}const KT={extension:{type:v.LoadParser,priority:bt.High,name:"loadBasis"},name:"loadBasis",test(r){return Ct(r,[".basis"])},async load(r,t,e){const s=await zr(),i=await nm(r,s),n=new Xr(i);return se(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function qT(r,t){const e=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const i=[];for(let n=0;n(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))(ya||{}),Ta=(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))(Ta||{});function at(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var gt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=at("UYVY")]="UYVY",r[r.R8G8_B8G8=at("RGBG")]="R8G8_B8G8",r[r.YUY2=at("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=at("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=at("DXT1")]="DXT1",r[r.DXT2=at("DXT2")]="DXT2",r[r.DXT3=at("DXT3")]="DXT3",r[r.DXT4=at("DXT4")]="DXT4",r[r.DXT5=at("DXT5")]="DXT5",r[r.ATI1=at("ATI1")]="ATI1",r[r.AT1N=at("AT1N")]="AT1N",r[r.ATI2=at("ATI2")]="ATI2",r[r.AT2N=at("AT2N")]="AT2N",r[r.BC4U=at("BC4U")]="BC4U",r[r.BC4S=at("BC4S")]="BC4S",r[r.BC5U=at("BC5U")]="BC5U",r[r.BC5S=at("BC5S")]="BC5S",r[r.DX10=at("DX10")]="DX10",r))(gt||{});const Sa={[gt.DXT1]:"bc1-rgba-unorm",[gt.DXT2]:"bc2-rgba-unorm",[gt.DXT3]:"bc2-rgba-unorm",[gt.DXT4]:"bc3-rgba-unorm",[gt.DXT5]:"bc3-rgba-unorm",[gt.ATI1]:"bc4-r-unorm",[gt.BC4U]:"bc4-r-unorm",[gt.BC4S]:"bc4-r-snorm",[gt.ATI2]:"bc5-rg-unorm",[gt.BC5U]:"bc5-rg-unorm",[gt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},_t={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"},B={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:JT,HEADER_DX10_FIELDS:tS,DXGI_FORMAT:ya,D3D10_RESOURCE_DIMENSION:Ta,D3DFMT:gt},om={"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 am(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=rS(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${s} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:i,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const u=eS(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:u,alphaMode:"no-premultiply-alpha"}}function eS(r,t,e,s,i,n){const o=[],a=om[r];let u=t,l=e,h=s;for(let c=0;c>1,1),l=Math.max(l>>1,1)}return o}function rS(r){const t=new Uint32Array(r,0,B.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[B.HEADER_FIELDS.MAGIC]!==B.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[B.HEADER_FIELDS.HEIGHT],s=t[B.HEADER_FIELDS.WIDTH],i=Math.max(1,t[B.HEADER_FIELDS.MIPMAP_COUNT]),n=t[B.HEADER_FIELDS.PF_FLAGS],o=t[B.HEADER_FIELDS.FOURCC],a=sS(t,n,o,r),u=B.MAGIC_SIZE+B.HEADER_SIZE+(o===B.D3DFMT.DX10?B.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:s,height:e,dataOffset:u,mipmapCount:i}}function sS(r,t,e,s){if(t&B.PIXEL_FORMAT_FLAGS.FOURCC){if(e===B.D3DFMT.DX10){const i=new Uint32Array(s,B.MAGIC_SIZE+B.HEADER_SIZE,B.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(i[B.HEADER_DX10_FIELDS.MISC_FLAG]===B.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[B.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===B.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=i[B.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in _t)return _t[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Sa)return Sa[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&B.PIXEL_FORMAT_FLAGS.RGB||t&B.PIXEL_FORMAT_FLAGS.RGBA)return iS(r);throw t&B.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&B.PIXEL_FORMAT_FLAGS.LUMINANCE||t&B.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&B.PIXEL_FORMAT_FLAGS.ALPHA||t&B.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 iS(r){const t=r[B.HEADER_FIELDS.RGB_BITCOUNT],e=r[B.HEADER_FIELDS.R_BIT_MASK],s=r[B.HEADER_FIELDS.G_BIT_MASK],i=r[B.HEADER_FIELDS.B_BIT_MASK],n=r[B.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&s===65280&&i===16711680&&n===4278190080)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return _t[B.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return _t[B.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return _t[B.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return _t[B.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return _t[B.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: + bitCount = ${t}, rBitMask = ${e}, gBitMask = ${s}, aBitMask = ${n}`)}const nS={extension:{type:v.LoadParser,priority:bt.High,name:"loadDDS"},name:"loadDDS",test(r){return Ct(r,[".dds"])},async load(r,t,e){const s=await zr(),i=await(await fetch(r)).arrayBuffer(),n=am(i,s),o=new Xr(n);return se(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var um=(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))(um||{}),oS=(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))(oS||{}),aS=(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))(aS||{});const uS={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"},lS=[171,75,84,88,32,49,49,187,13,10,26,10],hS={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},cS=64,dS=67305985,pS={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},fS={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},mS={32819:2,32820:2,33635:2},gS={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},et={FILE_HEADER_SIZE:cS,FILE_IDENTIFIER:lS,FORMATS_TO_COMPONENTS:fS,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:gS,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:uS,FIELDS:hS,TYPES_TO_BYTES_PER_COMPONENT:pS,TYPES_TO_BYTES_PER_PIXEL:mS,ENDIANNESS:dS};function lm(r,t){const e=new DataView(r);if(!vS(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:s,glType:i,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:u,numberOfMipmapLevels:l,offset:h}=bS(e),c=et.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!c)throw new Error(`Unknown texture format ${o}`);if(!t.includes(c))throw new Error(`Unsupported texture format: ${c}, supportedFormats: ${t}`);const d=xS(i,n,o),p=_S(e,i,d,a,u,h,l,s);return{format:c,width:a,height:u,resource:p,alphaMode:"no-premultiply-alpha"}}function _S(r,t,e,s,i,n,o,a){const u=s+3&-4,l=i+3&-4;let h=s*i;t===0&&(h=u*l);let c=h*e,d=s,p=i,f=u,g=l,m=n;const _=new Array(o);for(let x=0;x>1||1,p=p>>1||1,f=d+4-1&-4,g=p+4-1&-4,c=f*g*e}return _}function xS(r,t,e){let s=et.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(et.TYPES_TO_BYTES_PER_COMPONENT[r]?s=et.TYPES_TO_BYTES_PER_COMPONENT[r]*et.FORMATS_TO_COMPONENTS[t]:s=et.TYPES_TO_BYTES_PER_PIXEL[r]),s===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return s}function bS(r){const t=r.getUint32(et.FIELDS.ENDIANNESS,!0)===et.ENDIANNESS,e=r.getUint32(et.FIELDS.GL_TYPE,t),s=r.getUint32(et.FIELDS.GL_FORMAT,t),i=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),h=r.getUint32(et.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=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:s,glInternalFormat:i,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:h,offset:et.FILE_HEADER_SIZE+c}}function vS(r){for(let t=0;tt.destroy(!0)):r.destroy(!0)}},TS='(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 Ye=null;class hm{constructor(){Ye||(Ye=URL.createObjectURL(new Blob([TS],{type:"application/javascript"}))),this.worker=new Worker(Ye)}}hm.revokeObjectURL=function(){Ye&&(URL.revokeObjectURL(Ye),Ye=null)};const hi={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function SS(r){Object.assign(hi,r)}let Vr;const cm={};function ES(r){return Vr||(Vr=new hm().worker,Vr.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load KTX texture",s),cm[s](i)},Vr.postMessage({type:"init",jsUrl:hi.jsUrl,wasmUrl:hi.wasmUrl,supportedTextures:r})),Vr}function dm(r,t){const e=ES(t);return new Promise(s=>{cm[r]=s,e.postMessage({type:"load",url:r})})}const AS={extension:{type:v.LoadParser,priority:bt.High,name:"loadKTX2"},name:"loadKTX2",test(r){return Ct(r,".ktx2")},async load(r,t,e){const s=await zr(),i=await dm(r,s),n=new Xr(i);return se(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ea={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:pm},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:pm}};function PS(r){const t=r.format;if(Ea[t]){const e=Ea[t].convertFunction,s=r.resource;for(let i=0;iCt(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let s;const i=r.split(".");if(i.length>2){const n=i[i.length-2];ci.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=Zt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let di;const BS={extension:{type:v.DetectionParser,priority:2},test:async()=>!!(await Lr()||$r()),add:async r=>{const t=await va();return di=FS(t),[...di,...r]},remove:async r=>di?r.filter(t=>!(t in di)):r};function FS(r){const t=["basis"],e={};return r.forEach(s=>{const i=s.split("-")[0];i&&!e[i]&&(e[i]=!0,t.push(i))}),t.sort((s,i)=>{const n=ci.indexOf(s),o=ci.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const DS=new lt,Aa=class{cull(t,e,s=!0){this._cullRecursive(t,e,s)}_cullRecursive(t,e,s=!0){var i;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(i=t.cullArea)!=null?i:hr(t,s,DS);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{gm.shared.cull(this.stage,this.renderer.screen),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}_m.extension={priority:10,type:v.Application,name:"culler"};const US={extension:{type:v.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return k1})}};var kS=Object.defineProperty,pi=Object.getOwnPropertySymbols,xm=Object.prototype.hasOwnProperty,bm=Object.prototype.propertyIsEnumerable,vm=(r,t,e)=>t in r?kS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pa=(r,t)=>{for(var e in t||(t={}))xm.call(t,e)&&vm(r,e,t[e]);if(pi)for(var e of pi(t))bm.call(t,e)&&vm(r,e,t[e]);return r},$S=(r,t)=>{var e={};for(var s in r)xm.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&pi)for(var s of pi(r))t.indexOf(s)<0&&bm.call(r,s)&&(e[s]=r[s]);return e};const ym=class dl extends Pt{constructor(t){t=Pa(Pa({},dl.defaultOptions),t),super(t),this.enabled=!0,this._state=It.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.addResource("uTexture",0,1)}apply(t,e,s,i){t.applyFilter(this,e,s,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:s,gl:i}=e,n=$S(e,["gpu","gl"]);let o,a;return s&&(o=At.from(s)),i&&(a=Ot.from(i)),new dl(Pa({gpuProgram:o,glProgram:a},n))}};ym.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let Kt=ym;var Tm=` +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} +} +`,Sm=`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(); +} +`,Em=` +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; +}`,LS=Object.defineProperty,Am=Object.getOwnPropertySymbols,NS=Object.prototype.hasOwnProperty,HS=Object.prototype.propertyIsEnumerable,Pm=(r,t,e)=>t in r?LS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wm=(r,t)=>{for(var e in t||(t={}))NS.call(t,e)&&Pm(r,e,t[e]);if(Am)for(var e of Am(t))HS.call(t,e)&&Pm(r,e,t[e]);return r};class XS extends Kt{constructor(t){const e=t.gpu,s=Rm(wm({source:Em},e)),i=At.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=Rm(wm({source:Tm},n)),a=Ot.from({vertex:Sm,fragment:o}),u=new it({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:u,uBackTexture:A.EMPTY}})}}function Rm(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const zS=` + 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; + } + `,jS=` + 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 fi=`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(); +} +`,Mm=` +in vec2 vTextureCoord; + +out vec4 finalColor; + +uniform float uAlpha; +uniform sampler2D uTexture; + +void main() +{ + finalColor = texture(uTexture, vTextureCoord) * uAlpha; +} +`,wa=`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; +}`,VS=Object.defineProperty,WS=Object.defineProperties,YS=Object.getOwnPropertyDescriptors,mi=Object.getOwnPropertySymbols,Om=Object.prototype.hasOwnProperty,Cm=Object.prototype.propertyIsEnumerable,Gm=(r,t,e)=>t in r?VS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ra=(r,t)=>{for(var e in t||(t={}))Om.call(t,e)&&Gm(r,e,t[e]);if(mi)for(var e of mi(t))Cm.call(t,e)&&Gm(r,e,t[e]);return r},KS=(r,t)=>WS(r,YS(t)),qS=(r,t)=>{var e={};for(var s in r)Om.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&mi)for(var s of mi(r))t.indexOf(s)<0&&Cm.call(r,s)&&(e[s]=r[s]);return e};const Im=class pb extends Kt{constructor(t){t=Ra(Ra({},pb.defaultOptions),t);const e=At.from({vertex:{source:wa,entryPoint:"mainVertex"},fragment:{source:wa,entryPoint:"mainFragment"}}),s=Ot.from({vertex:fi,fragment:Mm,name:"alpha-filter"}),i=t,{alpha:n}=i,o=qS(i,["alpha"]),a=new it({uAlpha:{value:n,type:"f32"}});super(KS(Ra({},o),{gpuProgram:e,glProgram:s,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};Im.defaultOptions={alpha:1};let ZS=Im;const Ma={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]},QS=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(` +`);function Bm(r){const t=Ma[r],e=t.length;let s=QS,i="";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()),i+=u,i+=` +`}return s=s.replace("%blur%",i),s=s.replace("%size%",r.toString()),s}const JS=` + 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 Fm(r,t){const e=Math.ceil(r/2);let s=JS,i="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o, + 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 km(r,t){const e=Ma[t],s=e.length,i=[],n=[],o=[];for(let c=0;c,`,r?n[c]=`filteredCord + vec2(${c-s+1} * strength, 0.0),`:n[c]=`filteredCord + vec2(0.0, ${c-s+1} * strength),`;const d=ct in r?t2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Oa=(r,t)=>{for(var e in t||(t={}))e2.call(t,e)&&Lm(r,e,t[e]);if($m)for(var e of $m(t))r2.call(t,e)&&Lm(r,e,t[e]);return r};const Nm=class fb extends Kt{constructor(t){t=Oa(Oa({},fb.defaultOptions),t);const e=Dm(t.horizontal,t.kernelSize),s=km(t.horizontal,t.kernelSize);super(Oa({glProgram:e,gpuProgram:s,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,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,i);else{const n=ut.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;for(let u=0;ut in r?s2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wr=(r,t)=>{for(var e in t||(t={}))Hm.call(t,e)&&zm(r,e,t[e]);if(_i)for(var e of _i(t))Xm.call(t,e)&&zm(r,e,t[e]);return r},o2=(r,t)=>i2(r,n2(t)),a2=(r,t)=>{var e={};for(var s in r)Hm.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&_i)for(var s of _i(r))t.indexOf(s)<0&&Xm.call(r,s)&&(e[s]=r[s]);return e};class jm extends Kt{constructor(...t){var e;let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={strength:s},t[1]!==void 0&&(s.quality=t[1]),t[2]!==void 0&&(s.resolution=t[2]||"inherit"),t[3]!==void 0&&(s.kernelSize=t[3])),s=Wr(Wr({},gi.defaultOptions),s);const i=s,{strength:n,quality:o}=i,a=a2(i,["strength","quality"]);super(o2(Wr({},a),{compatibleRenderers:ft.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new gi(Wr({horizontal:!1},s)),this.blurYFilter=new gi(Wr({horizontal:!0},s)),this.quality=o,this.blur=n,this.repeatEdgePixels=!1}apply(t,e,s,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=ut.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,s,i),ut.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,s,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,s,i))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get 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 repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}jm.defaultOptions={strength:8,quality:4,kernelSize:5};var Vm=` +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); +} +`,Ca=`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); +}`,u2=Object.defineProperty,l2=Object.defineProperties,h2=Object.getOwnPropertyDescriptors,Wm=Object.getOwnPropertySymbols,c2=Object.prototype.hasOwnProperty,d2=Object.prototype.propertyIsEnumerable,Ym=(r,t,e)=>t in r?u2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,p2=(r,t)=>{for(var e in t||(t={}))c2.call(t,e)&&Ym(r,e,t[e]);if(Wm)for(var e of Wm(t))d2.call(t,e)&&Ym(r,e,t[e]);return r},f2=(r,t)=>l2(r,h2(t));class m2 extends Kt{constructor(t={}){const e=new it({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),s=At.from({vertex:{source:Ca,entryPoint:"mainVertex"},fragment:{source:Ca,entryPoint:"mainFragment"}}),i=Ot.from({vertex:fi,fragment:Vm,name:"color-matrix-filter"});super(f2(p2({},t),{gpuProgram:s,glProgram:i,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.matrix,t),s=this._colorMatrix(s)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=s,this.resources.colorMatrixUniforms.update()}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}_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 s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,i,n]=X.shared.setValue(t).toArray(),o=[s,0,0,0,0,0,i,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),i=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),u=s+(1-s)*o,l=o*(1-s)-a*i,h=o*(1-s)+a*i,c=o*(1-s)+a*i,d=s+o*(1-s),p=o*(1-s)-a*i,f=o*(1-s)-a*i,g=o*(1-s)+a*i,m=s+o*(1-s),_=[u,l,h,0,0,c,d,p,0,0,f,g,m,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const s=(t||0)+1,i=-.5*(s-1),n=[s,0,0,0,i,0,s,0,0,i,0,0,s,0,i,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,i=(s-1)*-.5,n=[s,i,i,0,0,i,s,i,0,0,i,i,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,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,s,i,n){t=t||.2,e=e||.15,s=s||16770432,i=i||3375104;const o=X.shared,[a,u,l]=o.setValue(s).toArray(),[h,c,d]=o.setValue(i).toArray(),p=[.3,.59,.11,0,0,a,u,l,t,0,h,c,d,e,0,a-h,u-c,l-d,0,0];this._loadMatrix(p,n)}night(t,e){t=t||.1;const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(s,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var Km=` +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)); +} +`,qm=`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(); +} +`,Ga=` +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)); +}`,g2=Object.defineProperty,_2=Object.defineProperties,x2=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertySymbols,Zm=Object.prototype.hasOwnProperty,Qm=Object.prototype.propertyIsEnumerable,Jm=(r,t,e)=>t in r?g2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,b2=(r,t)=>{for(var e in t||(t={}))Zm.call(t,e)&&Jm(r,e,t[e]);if(xi)for(var e of xi(t))Qm.call(t,e)&&Jm(r,e,t[e]);return r},v2=(r,t)=>_2(r,x2(t)),y2=(r,t)=>{var e={};for(var s in r)Zm.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&xi)for(var s of xi(r))t.indexOf(s)<0&&Qm.call(r,s)&&(e[s]=r[s]);return e};class T2 extends Kt{constructor(...t){let e=t[0];e instanceof Dt&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=y2(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new W(a,a));const u=new it({uFilterMatrix:{value:new C,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),l=Ot.from({vertex:qm,fragment:Km,name:"displacement-filter"}),h=At.from({vertex:{source:Ga,entryPoint:"mainVertex"},fragment:{source:Ga,entryPoint:"mainFragment"}}),c=i.texture.source;super(v2(b2({},o),{gpuProgram:h,glProgram:l,resources:{filterUniforms:u,uMapTexture:c,uMapSampler:c.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,s,i){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),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,s,i)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var tg=` +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; +} +`,Ia=` + +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; +}`,S2=Object.defineProperty,E2=Object.defineProperties,A2=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,eg=Object.prototype.hasOwnProperty,rg=Object.prototype.propertyIsEnumerable,sg=(r,t,e)=>t in r?S2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ba=(r,t)=>{for(var e in t||(t={}))eg.call(t,e)&&sg(r,e,t[e]);if(bi)for(var e of bi(t))rg.call(t,e)&&sg(r,e,t[e]);return r},P2=(r,t)=>E2(r,A2(t)),w2=(r,t)=>{var e={};for(var s in r)eg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&bi)for(var s of bi(r))t.indexOf(s)<0&&rg.call(r,s)&&(e[s]=r[s]);return e};const ig=class mb extends Kt{constructor(t={}){t=Ba(Ba({},mb.defaultOptions),t);const e=At.from({vertex:{source:Ia,entryPoint:"mainVertex"},fragment:{source:Ia,entryPoint:"mainFragment"}}),s=Ot.from({vertex:fi,fragment:tg,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=w2(i,["noise","seed"]);super(P2(Ba({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new it({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};ig.defaultOptions={noise:.5};let R2=ig;var ng=`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; +} +`,og=`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); +} +`,Fa=`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; +}`,M2=Object.defineProperty,O2=Object.defineProperties,C2=Object.getOwnPropertyDescriptors,vi=Object.getOwnPropertySymbols,ag=Object.prototype.hasOwnProperty,ug=Object.prototype.propertyIsEnumerable,lg=(r,t,e)=>t in r?M2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,G2=(r,t)=>{for(var e in t||(t={}))ag.call(t,e)&&lg(r,e,t[e]);if(vi)for(var e of vi(t))ug.call(t,e)&&lg(r,e,t[e]);return r},I2=(r,t)=>O2(r,C2(t)),B2=(r,t)=>{var e={};for(var s in r)ag.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&vi)for(var s of vi(r))t.indexOf(s)<0&&ug.call(r,s)&&(e[s]=r[s]);return e};class hg extends Kt{constructor(t){const e=t,{sprite:s}=e,i=B2(e,["sprite"]),n=new xn(s.texture),o=new it({uFilterMatrix:{value:new C,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"}}),a=At.from({vertex:{source:Fa,entryPoint:"mainVertex"},fragment:{source:Fa,entryPoint:"mainFragment"}}),u=Ot.from({vertex:og,fragment:ng,name:"mask-filter"});super(I2(G2({},i),{gpuProgram:a,glProgram:u,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}apply(t,e,s,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,i)}}var F2=`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 Da(r,t,e,s,i,n,o,a){const u=o-e,l=a-s,h=i-e,c=n-s,d=r-e,p=t-s,f=u*u+l*l,g=u*h+l*c,m=u*d+l*p,_=h*h+c*c,x=h*d+c*p,b=1/(f*_-g*g),y=(_*m-g*x)*b,T=(f*x-g*m)*b;return y>=0&&T>=0&&y+T<1}class fl{constructor(t=0,e=0,s=0,i=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=s,this.y2=i,this.x3=n,this.y3=o}contains(t,e){const s=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),i=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(s<0!=i<0&&s!==0&&i!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==s+i<=0}strokeContains(t,e,s){const i=s/2,n=i*i,{x:o,x2:a,x3:u,y:l,y2:h,y3:c}=this;return Mr(t,e,o,l,a,c)<=n||Mr(t,e,a,h,u,c)<=n||Mr(t,e,u,c,o,l)<=n}clone(){return new fl(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 V;const e=Math.min(this.x,this.x2,this.x3),s=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=i,t.width=s-e,t.height=n-i,t}}const cg=class gb{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let s=0;for(;e.length&&s{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),ht.system.addOnce(this._tick,this,jt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;st in r?D2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,U2=(r,t)=>{for(var e in t||(t={}))pg.call(t,e)&&mg(r,e,t[e]);if(yi)for(var e of yi(t))fg.call(t,e)&&mg(r,e,t[e]);return r},k2=(r,t)=>{var e={};for(var s in r)pg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&yi)for(var s of yi(r))t.indexOf(s)<0&&fg.call(r,s)&&(e[s]=r[s]);return e};class Yr extends Y{constructor(...t){var e;let s=t[0];s instanceof Ge&&(s={geometry:s,shader:t[1]},t[3]&&(s.geometry.topology=t[3]));const i=s,{geometry:n,shader:o,texture:a,roundPixels:u,state:l}=i,h=k2(i,["geometry","shader","texture","roundPixels","state"]);super(U2({label:"Mesh"},h)),this.renderPipeId="mesh",this.canBundle=!0,this._shader=null,this._roundPixels=0,this.allowChildren=!1,this.shader=o!=null?o:null,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:A.WHITE,this.state=l!=null?l:It.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=A.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 ee?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:s}=t;if(!this.bounds.containsPoint(e,s))return!1;const i=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let 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+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramei)&&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 s=0;sthis.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 gg{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new C,this.observer=e,this.position=new rt(this,0,0),this.scale=new rt(this,1,1),this.pivot=new rt(this,0,0),this.skew=new rt(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){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 $2=Object.defineProperty,Ti=Object.getOwnPropertySymbols,_g=Object.prototype.hasOwnProperty,xg=Object.prototype.propertyIsEnumerable,bg=(r,t,e)=>t in r?$2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Kr=(r,t)=>{for(var e in t||(t={}))_g.call(t,e)&&bg(r,e,t[e]);if(Ti)for(var e of Ti(t))xg.call(t,e)&&bg(r,e,t[e]);return r},L2=(r,t)=>{var e={};for(var s in r)_g.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ti)for(var s of Ti(r))t.indexOf(s)<0&&xg.call(r,s)&&(e[s]=r[s]);return e};const vg=class Ni extends Y{constructor(...t){let e=t[0]||{};e instanceof A&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Kr(Kr({},Ni.defaultOptions),e);const s=e!=null?e:{},{texture:i,anchor:n,tilePosition:o,tileScale:a,tileRotation:u,width:l,height:h,applyAnchorToTexture:c,roundPixels:d}=s,p=L2(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Kr({label:"TilingSprite"},p)),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 rt({_onUpdate:()=>{this.onViewUpdate()}}),this._applyAnchorToTexture=c,this.texture=i,this._width=l!=null?l:i.width,this._height=h!=null?h:i.height,this._tileTransform=new gg({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=u,this.roundPixels=d!=null?d:!1}static from(t,e={}){return typeof t=="string"?new Ni(Kr({texture:K.get(t)},e)):new Ni(Kr({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=A.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,s=this._width,i=this._height;t.maxX=-e._x*s,t.minX=t.maxX+s,t.maxY=-e._y*i,t.minY=t.maxY+i}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this._width,s=this._height,i=-e*this._anchor._x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this._anchor._y,t.y>=n&&t.y<=n+s)}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}};vg.defaultOptions={texture:A.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let yg=vg;var N2=Object.defineProperty,Si=Object.getOwnPropertySymbols,Tg=Object.prototype.hasOwnProperty,Sg=Object.prototype.propertyIsEnumerable,Eg=(r,t,e)=>t in r?N2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H2=(r,t)=>{for(var e in t||(t={}))Tg.call(t,e)&&Eg(r,e,t[e]);if(Si)for(var e of Si(t))Sg.call(t,e)&&Eg(r,e,t[e]);return r},X2=(r,t)=>{var e={};for(var s in r)Tg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Si)for(var s of Si(r))t.indexOf(s)<0&&Sg.call(r,s)&&(e[s]=r[s]);return e};class Ei extends Y{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:u,height:l,roundPixels:h}=s,c=X2(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(H2({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._roundPixels=0,this._bounds=new lt,this._boundsDirty=!0,this._styleClass=e,this.text=i!=null?i:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new rt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=h!=null?h:!1,u!==void 0&&(this.width=u),l!==void 0&&(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}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get 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 s;let i,n;typeof t!="object"?(i=t,n=e!=null?e:t):(i=t.width,n=(s=t.height)!=null?s:t.width),i!==void 0&&this._setWidth(i,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.width,s=this.bounds.height,i=-e*this.anchor.x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){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}:${this._resolution}`}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 Ai(r,t){var e;let s=(e=r[0])!=null?e:{};return(typeof s=="string"||r[1])&&(s={text:s,style:r[1]}),s}class Ua extends Ei{constructor(...t){const e=Ai(t,"Text");super(e,Tt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Ft.measureText(this._text,this._style),{width:i,height:n}=s;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}class Ag extends dg{resolveQueueItem(t,e){return t instanceof Y?this.resolveContainerQueueItem(t,e):t instanceof tt||t instanceof A?e.push(t.source):t instanceof ct&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Dt||t instanceof yg||t instanceof Yr?e.push(t.texture.source):t instanceof Ua?e.push(t):t instanceof er?e.push(t.context):t instanceof rs&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getContextRenderData(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;return i.source}else if(s.action==="fill"){const{texture:i}=s.data.style;return i.source}return null}}class Pg extends Ei{constructor(...t){var e,s,i;const n=Ai(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,Tt),this.renderPipeId="bitmapText"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Fr.measureText(this.text,this._style),i=s.scale,n=s.offsetY*i;let o=s.width*i,a=s.height*i;const u=this._style._stroke;u&&(o+=u.width,a+=u.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}}class wg extends Ei{constructor(...t){const e=Ai(t,"HtmlText");super(e,Pe),this.renderPipeId="htmlText"}_updateBounds(){const t=this._bounds,e=this._anchor,s=zo(this.text,this._style),{width:i,height:n}=s;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}class Rg extends Ag{uploadQueueItem(t){t instanceof tt?this.uploadTextureSource(t):t instanceof Ua?this.uploadText(t):t instanceof wg?this.uploadHTMLText(t):t instanceof Pg?this.uploadBitmapText(t):t instanceof ct&&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 s of e)if(s.action==="texture"){const{image:i}=s.data;this.uploadTextureSource(i.source)}else if(s.action==="fill"){const{texture:i}=s.data.style;this.uploadTextureSource(i.source)}return null}}class Mg extends Rg{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}Mg.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"prepare"};class ka{constructor(){this._didUpload=!1,this._tempState=It.for2d()}init(t){const e=Jt(),s=Le({name:"batch",bits:[Vs,Ys(e),He]});this._shader=new Pt({glProgram:s,resources:{batchSamplers:Ks(e)}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const s=t.renderer;s.shader.bind(this._shader,this._didUpload),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,this._shader.glProgram)}execute(t,e){const s=t.renderer;this._didUpload=!0,this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const i=e.textures.textures;for(let n=0;ns.trim()).filter(s=>s.length);let e="";return t.map(s=>{let i=e+s;return s==="{"?e+=" ":s==="}"&&(e=e.substr(0,e.length-4),i=e+s),i}).join(` +`)}const Og={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); + `}},Cg={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 Gg(r,t){const e=r.root,s=r.instructionSet;s.reset(),t.batch.buildStart(s),t.blendMode.buildStart(),t.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),Ig(e,s,t,!0),t.batch.buildEnd(s),t.blendMode.buildEnd(s)}function qr(r,t,e){r.globalDisplayStatus<7||!r.includeInBuild||(r.sortableChildren&&r.sortChildren(),r.isSimple?W2(r,t,e):Ig(r,t,e,!1))}function W2(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 s=r.children,i=s.length;for(let n=0;n=0;o--){const a=r.effects[o];e[a.pipe].pop(a,r,t)}}}const Y2=new lt;let K2=class extends lr{constructor(){super(),this.filters=[new hg({sprite:new Dt(A.EMPTY),resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}};class Na{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,qr(n,s,i.renderPipes),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=z.get(K2);if(s){t.mask.mask.measurable=!0;const n=hr(t.mask.mask,!0,Y2);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=ut.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const u=i.sprite;u.texture=a,u.worldTransform.tx=n.minX,u.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===ft.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const i=this._activeMaskStage.pop();s&&ut.returnTexture(i.filterTexture),z.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Na.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"alphaMask"};class Ha{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Ha.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"colorMask"};class q2{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){ys(this.mask,t,e)}addLocalBounds(t,e){Ts(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}}class Xa{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var i,n;const o=t,a=this._renderer;a.renderPipes.batch.break(s),a.renderPipes.blendMode.setBlendMode(o.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,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=s.instructionSize,qr(u,s,a.renderPipes),u.includeInBuild=!1,a.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const h=s.instructionSize-l.instructionsStart-1;l.instructionsLength=h;const c=a.renderTarget.renderTarget.uid;(n=(i=this._maskStackHash)[c])!=null||(i[c]=0)}pop(t,e,s){const i=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",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))(Zr||{});class Bg{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class za{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,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;if(this._boundBufferBases[e]!==t){const i=this.getGlBuffer(t);this._boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,i.buffer)}}bindBufferRange(t,e,s){const{_gl:i}=this;s=s||0;const n=this.getGlBuffer(t);i.bindBufferRange(i.UNIFORM_BUFFER,e||0,n.buffer,s*256,256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const i=t.data;if(s.byteLength>=t.data.byteLength)e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&N.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=i.byteLength,e.bufferData(s.type,i,n)}return s}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 s=this._gpuBuffers[t.uid],i=this._gl;e||i.deleteBuffer(s.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let s=Zr.ARRAY_BUFFER;t.descriptor.usage&N.INDEX?s=Zr.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&N.UNIFORM&&(s=Zr.UNIFORM_BUFFER);const i=new Bg(e.createBuffer(),s);return this._gpuBuffers[t.uid]=i,t.on("destroy",this.onBufferDestroy,this),i}}za.extension={type:[v.WebGLSystem],name:"buffer"};var Z2=Object.defineProperty,Q2=Object.defineProperties,J2=Object.getOwnPropertyDescriptors,Fg=Object.getOwnPropertySymbols,tE=Object.prototype.hasOwnProperty,eE=Object.prototype.propertyIsEnumerable,Dg=(r,t,e)=>t in r?Z2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wi=(r,t)=>{for(var e in t||(t={}))tE.call(t,e)&&Dg(r,e,t[e]);if(Fg)for(var e of Fg(t))eE.call(t,e)&&Dg(r,e,t[e]);return r},Ug=(r,t)=>Q2(r,J2(t));const ja=class _b{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,s;if(t=wi(wi({},_b.defaultOptions),t),t.context)this.initFromContext(t.context);else{const i=this._renderer.background.alpha<1,n=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:i,premultipliedAlpha:n,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(s=t.powerPreference)!=null?s:"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof j.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let s;const i=this._renderer.view.canvas;if(t===2&&(s=i.getContext("webgl2",e)),!s&&(s=i.getContext("webgl",e),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=Ug(wi({},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=Ug(wi({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const s=t.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const s=this.supports,i=this.webGLVersion===2,n=this.extensions;s.uint32Indices=i||!!n.uint32ElementIndex,s.uniformBufferObject=i,s.vertexArrayObject=i||!!n.vertexArrayObject,s.srgbTextures=i||!!n.srgb,s.nonPowOf2wrapping=i,s.nonPowOf2mipmaps=i,s.msaa=i,s.uint32Indices}};ja.extension={type:[v.WebGLSystem],name:"context"},ja.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let kg=ja;function Va(r,t){var e,s,i,n;for(const o in r.attributes){const a=r.attributes[o],u=t[o];u?((e=a.location)!=null||(a.location=u.location),(s=a.format)!=null||(a.format=u.format),(i=a.offset)!=null||(a.offset=u.offset),(n=a.instance)!=null||(a.instance=u.instance)):Xe(`Attribute ${o} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}rE(r)}function rE(r){var t,e;const{buffers:s,attributes:i}=r,n={},o={};for(const a in s){const u=s[a];n[u.uid]=0,o[u.uid]=0}for(const a in i){const u=i[a];n[u.buffer.uid]+=Ue(u.format).stride}for(const a in i){const u=i[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 Ri=(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))(Ri||{}),Wa=(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))(Wa||{}),$g=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))($g||{}),H=(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))(H||{});const Lg={uint8x2:H.UNSIGNED_BYTE,uint8x4:H.UNSIGNED_BYTE,sint8x2:H.BYTE,sint8x4:H.BYTE,unorm8x2:H.UNSIGNED_BYTE,unorm8x4:H.UNSIGNED_BYTE,snorm8x2:H.BYTE,snorm8x4:H.BYTE,uint16x2:H.UNSIGNED_SHORT,uint16x4:H.UNSIGNED_SHORT,sint16x2:H.SHORT,sint16x4:H.SHORT,unorm16x2:H.UNSIGNED_SHORT,unorm16x4:H.UNSIGNED_SHORT,snorm16x2:H.SHORT,snorm16x4:H.SHORT,float16x2:H.HALF_FLOAT,float16x4:H.HALF_FLOAT,float32:H.FLOAT,float32x2:H.FLOAT,float32x3:H.FLOAT,float32x4:H.FLOAT,uint32:H.UNSIGNED_INT,uint32x2:H.UNSIGNED_INT,uint32x3:H.UNSIGNED_INT,uint32x4:H.UNSIGNED_INT,sint32:H.INT,sint32x2:H.INT,sint32x3:H.INT,sint32x4:H.INT};function Ng(r){var t;return(t=Lg[r])!=null?t:Lg.float32}const sE={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ya{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=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,u)=>{s.drawElementsInstancedANGLE(i,n,o,a,u)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const s=this.gl;this._activeGeometry=t;const i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(s||0)*u,i):n.drawElements(a,e||o.indexBuffer.data.length,l,(s||0)*u)}else i>1?n.drawArraysInstanced(a,s||0,e||o.getSize(),i):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}Ya.extension={type:[v.WebGLSystem],name:"geometry"};var iE=Object.defineProperty,Hg=Object.getOwnPropertySymbols,nE=Object.prototype.hasOwnProperty,oE=Object.prototype.propertyIsEnumerable,Xg=(r,t,e)=>t in r?iE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zg=(r,t)=>{for(var e in t||(t={}))nE.call(t,e)&&Xg(r,e,t[e]);if(Hg)for(var e of Hg(t))oE.call(t,e)&&Xg(r,e,t[e]);return r};const aE=new Ge({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Ka=class xb{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=zg(zg({},xb.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(Xe("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=It.for2d();const i=new Ot({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 Pt({glProgram:i,resources:{uTexture:A.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:aE,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new A({source:new tt({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)}};Ka.extension={type:[v.WebGLSystem],name:"backBuffer",priority:1},Ka.defaultOptions={useBackBuffer:!1};let jg=Ka;class qa{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)))}}qa.extension={type:[v.WebGLSystem],name:"colorMask"};class Za{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:s,shader:i,state:n,skipSync:o,topology:a,size:u,start:l,instanceCount:h}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,u,l,h!=null?h:s.instanceCount)}destroy(){this._renderer=null}}Za.extension={type:[v.WebGLSystem],name:"encoder"};class Vg{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ie=[];ie[st.NONE]=void 0,ie[st.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ie[st.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ie[st.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ie[st.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class Qa{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 s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=ie[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===st.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Qa.extension={type:[v.WebGLSystem],name:"stencil"};class Ja{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!ea())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new vt({data:new Float32Array(e.layout.size/4),usage:N.UNIFORM|N.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const i=this.getUniformGroupData(t);return t.buffer||(t.buffer=new vt({data:new Float32Array(i.layout.size/4),usage:N.UNIFORM|N.COPY_DST})),e||(e=t.buffer.data),s||(s=0),i.syncFunction(t.uniforms,e,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const tu={f32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function Wg(r){const t=r.map(n=>({data:n,offset:0,size:0}));let e=0,s=0,i=0;for(let n=0;n1&&(e=Math.max(e,16)*o.data.size),o.size=e,s%e!==0&&s<16){const a=s%e%16;s+=a,i+=a}s+e>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=e,s=e):(o.offset=i,s+=e,i+=e)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}const ne=[{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 eu(r,t,e,s){const i=[` + var v = null; + var v2 = null; + var t = 0; + var index = 0; + var name = null; + var arrayOffset = null; + `];let n=0;for(let a=0;a1)c=u.offset/4,i.push(e(u,c-n));else{const d=s[u.data.type];c=u.offset/4,i.push(` + v = uv.${l}; + offset += ${c-n}; + ${d}; + `)}n=c}const o=i.join(` +`);return new Function("uv","data","offset",o)}var uE=Object.defineProperty,lE=Object.defineProperties,hE=Object.getOwnPropertyDescriptors,Yg=Object.getOwnPropertySymbols,cE=Object.prototype.hasOwnProperty,dE=Object.prototype.propertyIsEnumerable,Kg=(r,t,e)=>t in r?uE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pE=(r,t)=>{for(var e in t||(t={}))cE.call(t,e)&&Kg(r,e,t[e]);if(Yg)for(var e of Yg(t))dE.call(t,e)&&Kg(r,e,t[e]);return r},fE=(r,t)=>lE(r,hE(t));function Ke(r,t){return` + for (let i = 0; i < ${r*t}; i++) { + data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; + } + `}const ru={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":Ke(3,2),"mat4x2":Ke(4,2),"mat2x3":Ke(2,3),"mat4x3":Ke(4,3),"mat2x4":Ke(2,4),"mat3x4":Ke(3,4)},qg=fE(pE({},ru),{"mat2x2":` + data[offset] = v[0]; + data[offset + 1] = v[1]; + data[offset + 2] = v[2]; + data[offset + 3] = v[3]; + `});function Zg(r,t){const e=Math.max(tu[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%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 < ${s}; j++) + { + data[arrayOffset++] = v[t++]; + } + ${i!==0?`arrayOffset += ${i};`:""} + } + `}function Qg(r){return eu(r,"uboStd40",Zg,ru)}class su extends Ja{constructor(){super({createUboElements:Wg,generateUboSync:Qg})}}su.extension={type:[v.WebGLSystem],name:"ubo"};class Jg{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V}copyToTexture(t,e,s,i,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,s.x,s.y,i.width,i.height),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let u=i.y;t.isRoot&&(u=o.pixelHeight-i.height),t.colorTextures.forEach(c=>{this._renderer.texture.unbind(c)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);const h=this._viewPortCache;(h.x!==i.x||h.y!==u||h.width!==i.width||h.height!==i.height)&&(h.x=i.x,h.y=u,h.width=i.width,h.height=i.height,l.viewport(i.x,u,i.width,i.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,e.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,e.framebuffer),s.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer,s=e.gl,i=new Vg;return t.colorTexture.resource===e.gl.canvas?(i.framebuffer=null,i):(this._initColor(t,i),s.bindFramebuffer(s.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer=null}clear(t,e,s){if(!e)return;const i=this._renderTargetSystem;typeof e=="boolean"&&(e=e?mt.ALL:mt.NONE);const n=this._renderer.gl;if(e&mt.COLOR){s!=null||(s=i.defaultClearColor);const o=this._clearColorCache,a=s;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const u=o.source;u.antialias&&(s.context.supports.msaa?e.msaa=!0:Xe("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(u,0);const l=s.texture.getGlSource(u).texture;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){const o=i.createFramebuffer();e.framebuffer=o,i.bindFramebuffer(i.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=i.createRenderbuffer();e.msaaRenderBuffer[u]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(s.width,s.height,s._resolution)}),e.msaa){const i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=a.source;i.texture.bindSource(l,0);const h=i.texture.getGlSource(l).internalFormat,c=e.msaaRenderBuffer[u];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,h,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+u,n.RENDERBUFFER,c)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}}function t_(r,t,e,s,i,n){const o=n?1:-1;return r.identity(),r.a=1/s*2,r.d=o*(1/i*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var mE=Object.defineProperty,e_=Object.getOwnPropertySymbols,gE=Object.prototype.hasOwnProperty,_E=Object.prototype.propertyIsEnumerable,r_=(r,t,e)=>t in r?mE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xE=(r,t)=>{for(var e in t||(t={}))gE.call(t,e)&&r_(r,e,t[e]);if(e_)for(var e of e_(t))_E.call(t,e)&&r_(r,e,t[e]);return r};const qe=new Map;function iu(r,t){if(!qe.has(r)){const e=new A({source:new xe(xE({resource:r},t))}),s=()=>{qe.get(r)===e&&qe.delete(r)};e.once("destroy",s),e.source.once("destroy",s),qe.set(r,e)}return qe.get(r)}function bE(r){return qe.has(r)}function s_(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var vE=Object.defineProperty,i_=Object.getOwnPropertySymbols,yE=Object.prototype.hasOwnProperty,TE=Object.prototype.propertyIsEnumerable,n_=(r,t,e)=>t in r?vE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,o_=(r,t)=>{for(var e in t||(t={}))yE.call(t,e)&&n_(r,e,t[e]);if(i_)for(var e of i_(t))TE.call(t,e)&&n_(r,e,t[e]);return r};const a_=class bb{constructor(t={}){if(this.uid=Q("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=o_(o_({},bb.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;es.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 A||t.depthStencilTexture instanceof tt?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 tt({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};a_.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Mi=a_;class nu{constructor(t){this.rootViewPort=new V,this.viewport=new V,this.onRenderTargetChange=new ra("onRenderTargetChange"),this.projectionMatrix=new C,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:s,frame:i}){this._renderTargetStack.length=0,this.push(t,e,s,i),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=s_(this.rootRenderTarget)}bind(t,e=!0,s,i){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,h=u.pixelWidth,c=u.pixelHeight;if(!i&&t instanceof A&&(i=t.frame),i){const d=u._resolution;l.x=i.x*d+.5|0,l.y=i.y*d+.5|0,l.width=i.width*d+.5|0,l.height=i.height*d+.5|0}else l.x=0,l.y=0,l.width=h,l.height=c;return t_(this.projectionMatrix,0,0,l.width/u.resolution,l.height/u.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,s,l),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=mt.ALL,s){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=mt.ALL,s,i){const n=this.bind(t,e,s,i);return this._renderTargetStack.push({renderTarget:n,frame:i}),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,s,i,n){s.x<0&&(i.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(i.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(t,e,s,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}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 xe.test(t)&&(t=iu(t).source),t instanceof Mi?e=t:t instanceof tt&&(e=new Mi({colorTextures:[t]}),xe.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy();const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}}class ou extends nu{constructor(t){super(t),this.adaptor=new Jg,this.adaptor.init(t,this)}}ou.extension={type:[v.WebGLSystem],name:"renderTarget"};class Oi extends dt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=Q("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Q("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Q("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function u_(r,t){const e=[],s=[` + var g = s.groups; + var sS = r.shader; + var p = s.glProgram; + var ugS = r.uniformGroup; + var resources; + `];let i=!1,n=0,o=0;const a=t._getProgramData(r.glProgram);for(const l in r.groups){const h=r.groups[l];e.push(` + resources = g[${l}].resources; + `);for(const c in h.resources){const d=h.resources[c];if(d instanceof it)d.ubo?e.push(` + sS.bindUniformBlock( + resources[${c}], + sS._uniformBindMap[${l}[${c}], + ${n++} + ); + `):e.push(` + ugS.updateUniformGroup(resources[${c}], p, sD); + `);else if(d instanceof Oi)e.push(` + sS.bindUniformBlock( + resources[${c}], + sS._uniformBindMap[${l}[${c}], + ${n++} + ); + `);else if(d instanceof tt){const p=r._uniformBindMap[l][c],f=a.uniformData[p];f&&(i||(i=!0,s.push(` + var tS = r.texture; + `)),t._gl.uniform1i(f.location,o),e.push(` + tS.bind(resources[${c}], ${o}); + `),o++)}}}const u=[...s,...e].join(` +`);return new Function("r","s","sD",u)}class SE{}class l_{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 au(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function uu(r){const t=new Array(r);for(let e=0;eo>a?1:-1);for(let o=0;o`${h}: ${l}`),s=r.getShaderInfoLog(t),i=s.split(` +`),n={},o=i.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(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function g_(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||m_(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||m_(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function __(r,t){const e=au(r,r.VERTEX_SHADER,t.vertex),s=au(r,r.FRAGMENT_SHADER,t.fragment),i=r.createProgram();r.attachShader(i,e),r.attachShader(i,s);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||g_(r,i,e,s),t._attributeData=d_(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=f_(i,r),t._uniformBlockData=p_(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const a in t._uniformData){const u=t._uniformData[a];o[a]={location:r.getUniformLocation(i,a),value:lu(u.type,u.size)}}return new l_(i,o)}const Gi={textureCount:0,blockIndex:0};class cu{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._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Gi.textureCount=0,Gi.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),s(this._renderer,t,Gi)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Gi)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o&&this._renderer.ubo.updateUniformGroup(t),i.updateBuffer(t.buffer);let a=this._boundUniformsIdsToIndexHash[t.uid];if(a===void 0){const h=this._nextIndex++%this._maxBindings,c=this._boundIndexToUniformsHash[h];c&&(this._boundUniformsIdsToIndexHash[c.uid]=void 0),a=this._boundUniformsIdsToIndexHash[t.uid]=h,this._boundIndexToUniformsHash[h]=t,o?i.bindBufferRange(t.buffer,h,t.offset):i.bindBufferBase(t.buffer,h)}const u=this._gl,l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==a&&(n.uniformBlockBindings[s]=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]=__(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 u_(t,e)}}cu.extension={type:[v.WebGLSystem],name:"shader"};const x_={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);"},b_={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 v_(r,t){const e=[` + var v = null; + var cv = null; + var cu = null; + var t = 0; + var gl = renderer.gl; + var name = null; + `];for(const s in r.uniforms){if(!t[s]){r.uniforms[s]instanceof it?r.uniforms[s].ubo?e.push(` + renderer.shader.bindUniformBlock(uv.${s}, "${s}"); + `):e.push(` + renderer.shader.updateUniformGroup(uv.${s}); + `):r.uniforms[s]instanceof Oi&&e.push(` + renderer.shader.bindBufferResource(uv.${s}, "${s}"); + `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o>1,s++;this.stateId=t.data}for(let e=0;e>1,1),i=Math.max(i>>1,1)}}},pu={id:"image",upload(r,t,e,s){const i=r.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i);const n=t.width,o=t.height,a=r.pixelWidth,u=r.pixelHeight,l=r.resourceWidth,h=r.resourceHeight;l1){const l=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](u,s.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&t[i](u,t.TEXTURE_COMPARE_FUNC,M_[r.compare])}function O_(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 FE=Object.defineProperty,DE=Object.defineProperties,UE=Object.getOwnPropertyDescriptors,C_=Object.getOwnPropertySymbols,kE=Object.prototype.hasOwnProperty,$E=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?FE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ae=(r,t)=>{for(var e in t||(t={}))kE.call(t,e)&&G_(r,e,t[e]);if(C_)for(var e of C_(t))$E.call(t,e)&&G_(r,e,t[e]);return r},LE=(r,t)=>DE(r,UE(t));function I_(r,t){let e={},s=r.RGBA;return r instanceof j.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},s=r.RGBA8),Ae(Ae(Ae(Ae(Ae(Ae(LE(Ae({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:s,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function B_(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 NE(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.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,s=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,s,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 s=this.getGlSource(t);this._gl.generateMipmap(s.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,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,mu(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:i}=this.getPixels(t),n=j.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,i=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array(HE*i*n),a=this._renderer,u=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(u),h=a.gl;return h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),h.readPixels(Math.round(s.x*e),Math.round(s.y*e),i,n,h.RGBA,h.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}gu.extension={type:[v.WebGLSystem],name:"texture"};class _u{init(){const t=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new C,type:"mat3x3"},uRound:{value:0,type:"f32"}}),e=Jt(),s=Le({name:"graphics",bits:[Vs,Ys(e),Js,He]});this.shader=new Pt({glProgram:s,resources:{localUniforms:t,batchSamplers:Ks(e)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:u}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a,i.glProgram);const l=u.instructions;for(let h=0;h",value:new C}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(i){if(!i.glProgram)return}else{i=this._shader;const n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=s.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}xu.extension={type:[v.WebGLPipesAdaptor],name:"mesh"};class bu{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}}bu.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"customRender"};function vu(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i>16&255,i=r>>8&255,n=r&255,o=t>>16&255,a=t>>8&255,u=t&255,l=s+(o-s)*e,h=i+(a-i)*e,c=n+(u-n)*e;return(l<<16)+(h<<8)+c}const Ze=16777215;function Eu(r,t){return r===Ze||t===Ze?r+t-Ze:Su(r,t,.5)}function XE(r,t,e){const s=(e>>24&255)/255,i=t*s*255,n=((r&255)<<16)+(r&65280)+(r>>16&255),o=e&16777215;let a;return n===Ze||o===Ze?a=n+o-Ze:a=Su(n,o,.5),a+(i<<24)}const zE=new Y,F_=Re|dr|ps;function Au(r,t=!1){D_(r);const e=r.childrenToUpdate,s=r.updateTick++;for(const i in e){const n=Number(i),o=e[i],a=o.list,u=o.index;for(let l=0;l1?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 s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(e=e|r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&F_&&U_(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&F_&&U_(r,zE,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&ps&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&Re&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function k_(r,t){const{list:e,index:s}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)z.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}Ru.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"sprite"};var WE=Object.defineProperty,$_=Object.getOwnPropertySymbols,YE=Object.prototype.hasOwnProperty,KE=Object.prototype.propertyIsEnumerable,L_=(r,t,e)=>t in r?WE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,N_=(r,t)=>{for(var e in t||(t={}))YE.call(t,e)&&L_(r,e,t[e]);if($_)for(var e of $_(t))KE.call(t,e)&&L_(r,e,t[e]);return r};const Mu=class vb{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new X(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=N_(N_({},vb.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(){}};Mu.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"background",priority:0},Mu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let H_=Mu;const Qr={};D.handle(v.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Qr[r.name]=r.ref},r=>{delete Qr[r.name]});class Ou{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,s){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(s),this._isAdvanced=!!Qr[e],this._isAdvanced&&(this._beginAdvancedBlendMode(s),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Qr[e])return;let s=this._filterHash[e];s||(s=this._filterHash[e]=new lr,s.filters=[new Qr[e]]);const i={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:s,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_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}}Ou.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"blendMode"};var qE=Object.defineProperty,X_=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,z_=(r,t,e)=>t in r?qE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cu=(r,t)=>{for(var e in t||(t={}))ZE.call(t,e)&&z_(r,e,t[e]);if(X_)for(var e of X_(t))QE.call(t,e)&&z_(r,e,t[e]);return r};const Gu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Iu=class yb{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Y||t instanceof A?Cu({target:t},e):Cu(Cu({},e),t)}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,yb.defaultImageOptions);const{format:e,quality:s}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const u=new FileReader;u.onload=()=>n(u.result),u.onerror=o,u.readAsDataURL(a)},Gu[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(Gu[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:Gu[e],quality:s});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,s=this._renderer;if(e instanceof A)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof A?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof Y&&i.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof A?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const s=this.canvas(t),i=document.createElement("a");i.download=(e=t.filename)!=null?e:"image.png",i.href=s.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){var e;const s=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const i=this.canvas(t),n=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const o=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};Iu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"extract"},Iu.defaultImageOptions={format:"png",quality:1};let j_=Iu;class V_ extends A{static create(t){return new A({source:new tt(t)})}resize(t,e,s){return this.source.resize(t,e,s),this}}var JE=Object.defineProperty,tA=Object.defineProperties,eA=Object.getOwnPropertyDescriptors,W_=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,sA=Object.prototype.propertyIsEnumerable,Y_=(r,t,e)=>t in r?JE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,iA=(r,t)=>{for(var e in t||(t={}))rA.call(t,e)&&Y_(r,e,t[e]);if(W_)for(var e of W_(t))sA.call(t,e)&&Y_(r,e,t[e]);return r},nA=(r,t)=>tA(r,eA(t));const oA=new V,aA=new lt,uA=[0,0,0,0];class Bu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof Y&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const s=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:X.shared.setValue(o).toArray():o=uA;const a=((e=t.frame)==null?void 0:e.copyTo(oA))||ds(n,aA).rectangle;a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const u=V_.create(nA(iA({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i})),l=C.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:u,clearColor:o}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Bu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGenerator"};class Fu{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 C,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null}}Fu.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"globalUniforms"};let K_=!1;const Du="8.2.5";function q_(r){if(!K_){if(j.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Du} (${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 ${Du} - ${r} - http://www.pixijs.com/`);K_=!0}}class Bi{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===ft.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),q_(e)}}}Bi.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"hello",priority:-2},Bi.defaultOptions={hello:!1};var lA=Object.defineProperty,Z_=Object.getOwnPropertySymbols,hA=Object.prototype.hasOwnProperty,cA=Object.prototype.propertyIsEnumerable,Q_=(r,t,e)=>t in r?lA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,J_=(r,t)=>{for(var e in t||(t={}))hA.call(t,e)&&Q_(r,e,t[e]);if(Z_)for(var e of Z_(t))cA.call(t,e)&&Q_(r,e,t[e]);return r};const Uu=class Tb{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t=J_(J_({},Tb.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-s._touched>this.maxIdle&&(s._touched=-1,s.unload())}}destroy(){this._renderer=null}};Uu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGC"},Uu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:60*60,textureGCCheckCountMax:600};let ku=Uu;D.add(ku);var dA=Object.defineProperty,tx=Object.getOwnPropertySymbols,pA=Object.prototype.hasOwnProperty,fA=Object.prototype.propertyIsEnumerable,ex=(r,t,e)=>t in r?dA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rx=(r,t)=>{for(var e in t||(t={}))pA.call(t,e)&&ex(r,e,t[e]);if(tx)for(var e of tx(t))fA.call(t,e)&&ex(r,e,t[e]);return r};const $u=class Sb{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=rx(rx({},Sb.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new V(0,0,t.width,t.height),this.canvas=t.canvas||j.get().createCanvas(),this.antialias=!!t.antialias,this.texture=iu(this.canvas,t),this.renderTarget=new Mi({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,s){this.texture.source.resize(t,e,s),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)}};$u.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"view",priority:0},$u.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let sx=$u;const Lu=[H_,Fu,Bi,sx,wu,ku,Bu,j_,oa],Nu=[Ou,La,Ru,yu,Na,Xa,Ha,bu],mA=[...Lu,su,jg,kg,za,gu,ou,Ya,du,cu,Za,S_,Qa,qa],gA=[...Nu],_A=[ka,xu,_u],ix=[],nx=[],ox=[];D.handleByNamedList(v.WebGLSystem,ix),D.handleByNamedList(v.WebGLPipes,nx),D.handleByNamedList(v.WebGLPipesAdaptor,ox),D.add(...mA,...gA,..._A);class ax extends kr{constructor(){const t={name:"webgl",type:ft.WEBGL,systems:ix,renderPipes:nx,renderPipeAdaptors:ox};super(t)}}var xA={__proto__:null,WebGLRenderer:ax};class Hu{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){var i;const n=this._gpu.device,o=e.layout[s],a=[],u=this._renderer;for(const c in o){const d=(i=t.resources[c])!=null?i:t.resources[o[c]];let p;if(d._resourceType==="uniformGroup"){const f=d;u.ubo.updateUniformGroup(f);const g=f.buffer;p={buffer:u.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(d._resourceType==="buffer"){const f=d;p={buffer:u.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="bufferResource"){const f=d;p={buffer:u.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(d._resourceType==="textureSampler"){const f=d;p=u.texture.getGpuSampler(f)}else if(d._resourceType==="textureSource"){const f=d;p=u.texture.getGpuSource(f).createView({})}a.push({binding:o[c],resource:p})}const l=u.shader.getProgramData(e).bindGroups[s],h=n.createBindGroup({layout:l,entries:a});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}Hu.extension={type:[v.WebGPUSystem],name:"bindGroup"};class Xu{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),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(As(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}Xu.extension={type:[v.WebGPUSystem],name:"buffer"};function bA(r,t){const e=r.descriptor.size,s=t.gpu.device,i=new vt({data:new Float32Array(24e5),usage:N.MAP_READ|N.COPY_DST}),n=t.buffer.createGPUBuffer(i),o=s.createCommandEncoder();o.copyBufferToBuffer(t.buffer.getGPUBuffer(r),0,n,0,e),s.queue.submit([o.finish()]),n.mapAsync(GPUMapMode.READ,0,e).then(()=>{n.getMappedRange(0,e),n.unmap()})}class ux{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;s{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}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:i}}destroy(){this.gpu=null,this._renderer=null}}Fi.extension={type:[v.WebGPUSystem],name:"device"},Fi.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var vA=Object.defineProperty,lx=Object.getOwnPropertySymbols,yA=Object.prototype.hasOwnProperty,TA=Object.prototype.propertyIsEnumerable,hx=(r,t,e)=>t in r?vA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cx=(r,t)=>{for(var e in t||(t={}))yA.call(t,e)&&hx(r,e,t[e]);if(lx)for(var e of lx(t))TA.call(t,e)&&hx(r,e,t[e]);return r};class ju{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,i){const n=this._renderer.pipeline.getPipeline(t,e,s,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const i=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t){for(const e in t.attributes){const s=t.attributes[e];this._setVertexBuffer(s.location,s.buffer)}t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const i=t.groups[s];e||this._syncBindGroup(i),this.setBindGroup(s,i,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:i,topology:n,size:o,start:a,instanceCount:u,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,i,n),this.setGeometry(e),this._setShaderBindGroups(s,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,s=cx({},this._boundVertexBuffer),i=this._boundIndexBuffer,n=cx({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}ju.extension={type:[v.WebGPUSystem],name:"encoder",priority:1};class Vu{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 s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Vu.extension={type:[v.WebGPUSystem],name:"stencil"};const Jr={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 dx(r){const t=r.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function px(r,t){const{size:e,align:s}=Jr[r.data.type],i=(s-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++]; + } + ${i!==0?`arrayOffset += ${i};`:""} + } + `}function fx(r){return eu(r,"uboWgsl",px,qg)}class Wu extends Ja{constructor(){super({createUboElements:dx,generateUboSync:fx})}}Wu.extension={type:[v.WebGPUSystem],name:"ubo"};const oe=128;class Yu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new ux({minUniformOffsetAlignment:oe});const e=256/oe;for(let s=0;st in r?SA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,RA=(r,t)=>{for(var e in t||(t={}))PA.call(t,e)&&gx(r,e,t[e]);if(mx)for(var e of mx(t))wA.call(t,e)&&gx(r,e,t[e]);return r},MA=(r,t)=>EA(r,AA(t));const OA={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function CA(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function GA(r,t,e,s){return e<<6|r<<3|s<<1|t}class Ku{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=ie[t],this._updatePipeHash())}setPipeline(t,e,s,i){const n=this.getPipeline(t,e,s);i.setPipeline(n)}getPipeline(t,e,s,i){t._layoutKey||(Va(t,e.attributeData),this._generateBufferKey(t)),i=i||t.topology;const n=CA(t._layoutKey,e._layoutKey,s.data,s._blendModeId,OA[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,i),this._pipeCache[n])}_createPipeline(t,e,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(t),a=this._renderer.state.getColorTargets(s);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:i,cullMode:s.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil=MA(RA({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.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 s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o{var i;const n={arrayStride:0,stepMode:"vertex",attributes:[]},o=n.attributes;for(const a in t.attributes){const u=t.attributes[a];((i=u.divisor)!=null?i:1)!==1&&Xe(`Attribute ${a} has an invalid divisor value of '${u.divisor}'. WebGPU only supports a divisor value of 1`),u.buffer===s&&(n.arrayStride=u.stride,n.stepMode=u.instance?"instance":"vertex",o.push({shaderLocation:u.location,offset:u.offset,format:u.format}))}o.length&&e.push(n)}),this._bufferLayoutsCache[t._layoutKey]=e,e}_updatePipeHash(){const t=GA(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}}Ku.extension={type:[v.WebGPUSystem],name:"pipeline"};class _x{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class xx{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(t),u=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:u,origin:n},i),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,s);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s){typeof e=="boolean"&&(e=e?mt.ALL:mt.NONE);const i=this._renderTargetSystem,n=i.getGpuRenderTarget(t),o=t.colorTextures.map((u,l)=>{const h=n.contexts[l];let c,d;h?c=h.getCurrentTexture().createView():c=this._renderer.texture.getGpuSource(u).createView({mipLevelCount:1}),n.msaaTextures[l]&&(d=c,c=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e&mt.COLOR?"clear":"load";return s!=null||(s=i.defaultClearColor),{view:c,resolveTarget:d,clearValue:s,storeOp:"store",loadOp:p}});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,s,i){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,s),h=u.beginRenderPass(l);h.setViewport(i.x,i.y,i.width,i.height,0,1),h.end();const c=u.finish();a.queue.submit([c])}else this.startRenderPass(t,e,s,i)}initGpuRenderTarget(t){t.isRoot=!0;const e=new _x;return t.colorTextures.forEach((s,i)=>{if(xe.test(s.resource)){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new tt({width:0,height:0,sampleCount:4});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,i)=>{const n=e.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class qu extends nu{constructor(t){super(t),this.adaptor=new xx,this.adaptor.init(t,this)}}qu.extension={type:[v.WebGPUSystem],name:"renderTarget"};class Zu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Zu.extension={type:[v.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 Qu{constructor(){this.defaultState=new It,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}}Qu.extension={type:[v.WebGPUSystem],name:"state"};const bx={type:"image",upload(r,t,e){const s=r.resource,i=(r.pixelWidth|0)*(r.pixelHeight|0),n=s.byteLength/i;e.device.queue.writeTexture({texture:t},s,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},Ju={"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}},IA={blockBytes:4,blockWidth:1,blockHeight:1},vx={type:"compressed",upload(r,t,e){let s=r.pixelWidth,i=r.pixelHeight;const n=Ju[r.format]||IA;for(let o=0;o>1,1),i=Math.max(i>>1,1)}}},tl={type:"image",upload(r,t,e){const s=r.resource;if(!s)return;const i=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:s},{texture:t,premultipliedAlpha:o},{width:i,height:n})}},yx={type:"video",upload(r,t,e){tl.upload(r,t,e)}};class Tx{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 s=t;const i=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:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=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 Tx(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,s=e.uid;return this._bindGroupHash[s]=new Lt({0:e,1:e.style}),this._bindGroupHash[s]}getTextureView(t){var e;const s=t.source;return(e=this._textureViewHash[s.uid])!=null?e:this._createTextureView(s)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=j.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([s.finish()]),i}getPixels(t){const e=this.generateCanvas(t),s=Nt.getOptimalCanvasAndContext(e.width,e.height),i=s.context;i.drawImage(e,0,0);const{width:n,height:o}=e,a=i.getImageData(0,0,n,o),u=new Uint8ClampedArray(a.data.buffer);return Nt.returnCanvasAndContext(s),{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),s=this._bindGroupHash[e];s==null||s.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}el.extension={type:[v.WebGPUSystem],name:"texture"};class rl{init(){const t=new it({uTransformMatrix:{value:new C,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),e=$e({name:"graphics",bits:[js,Ws(Jt()),Lp,Ne]});this.shader=new Pt({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:u}=o.getContextRenderData(s),l=n.encoder;l.setPipelineFromGeometryProgramAndState(a,i.gpuProgram,t.state),l.setGeometry(a);const h=n.globalUniforms.bindGroup;l.setBindGroup(0,h,i.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);l.setBindGroup(2,c,i.gpuProgram);const d=u.instructions;for(let p=0;p",value:new C}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.resources.uTexture=e.texture.source,i.resources.uSampler=e.texture.source.style,i.resources.textureUniforms.uniforms.uTextureMatrix=e.texture.textureMatrix.mapCoord;else if(!i.gpuProgram)return;const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}sl.extension={type:[v.WebGPUPipesAdaptor],name:"mesh"};const BA=[...Lu,Wu,ju,Fi,Xu,el,qu,Zu,Qu,Ku,zu,Vu,Hu],FA=[...Nu,Yu],DA=[$a,sl,rl],Sx=[],Ex=[],Ax=[];D.handleByNamedList(v.WebGPUSystem,Sx),D.handleByNamedList(v.WebGPUPipes,Ex),D.handleByNamedList(v.WebGPUPipesAdaptor,Ax),D.add(...BA,...FA,...DA);class Px extends kr{constructor(){const t={name:"webgpu",type:ft.WEBGPU,systems:Sx,renderPipes:Ex,renderPipeAdaptors:Ax};super(t)}}var UA={__proto__:null,WebGPURenderer:Px};const kA={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},$A=new Proxy(kA,{get(r,t){return r[t]}}),LA=new V(0,0,1,1);function NA(r,t,e){e||(e=LA);const s=t.pixelWidth,i=t.pixelHeight;return r.x=e.x*s|0,r.y=e.y*i|0,r.width=e.width*s|0,r.height=e.height*i|0,r}var wx=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(wx||{}),il=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(il||{});const HA=new Proxy(il,{get(r,t){return r[t]}});var nl=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(nl||{});const XA=new Proxy(nl,{get(r,t){return r[t]}});class zA{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const i=e.width,n=e.height;if(s){const o=t.width/2/i,a=t.height/2/n,u=t.x/i+o,l=t.y/n+a;s=U.add(s,U.NW),this.x0=u+o*U.uX(s),this.y0=l+a*U.uY(s),s=U.add(s,2),this.x1=u+o*U.uX(s),this.y1=l+a*U.uY(s),s=U.add(s,2),this.x2=u+o*U.uX(s),this.y2=l+a*U.uY(s),s=U.add(s,2),this.x3=u+o*U.uX(s),this.y3=l+a*U.uY(s)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}let jA=0;function VA(){return jA++}function WA(r){const t=r.toString(),e=t.indexOf("{"),s=t.lastIndexOf("}");if(e===-1||s===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,s).trim()}var YA=Object.defineProperty,Di=Object.getOwnPropertySymbols,Rx=Object.prototype.hasOwnProperty,Mx=Object.prototype.propertyIsEnumerable,Ox=(r,t,e)=>t in r?YA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KA=(r,t)=>{for(var e in t||(t={}))Rx.call(t,e)&&Ox(r,e,t[e]);if(Di)for(var e of Di(t))Mx.call(t,e)&&Ox(r,e,t[e]);return r},qA=(r,t)=>{var e={};for(var s in r)Rx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Di)for(var s of Di(r))t.indexOf(s)<0&&Mx.call(r,s)&&(e[s]=r[s]);return e};class ZA extends Y{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=qA(i,["render"]);super(KA({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=(s=t.addBounds)!=null?s:()=>!1}render(t){}}function QA(r,t){const e=t._scale,s=t._pivot,i=t._position,n=e._x,o=e._y,a=s._x,u=s._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=i._x-(a*r.a+u*r.c),r.ty=i._y-(a*r.b+u*r.d)}function JA(r,t,e){const s=r.a,i=r.b,n=r.c,o=r.d,a=r.tx,u=r.ty,l=t.a,h=t.b,c=t.c,d=t.d;e.a=s*l+i*c,e.b=s*h+i*d,e.c=n*l+o*c,e.d=n*h+o*d,e.tx=a*l+u*c+t.tx,e.ty=a*h+u*d+t.ty}const tP={rectangle:zn,polygon:Xn,triangle:jn,circle:Wt,ellipse:Wt,roundedRectangle:Wt};function eP(r){r instanceof ae&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],s=[],i=r.path.shapePath,n=r.textureMatrix;i.shapePrimitives.forEach(({shape:a,transform:u})=>{const l=s.length,h=t.length/2,c=[],d=tP[a.type];d.build(a,c),u&&Ps(c,u),d.triangulate(c,t,2,h,s,l);const p=e.length/2;n?(u&&n.append(u.clone().invert()),Dn(t,2,h,e,p,2,t.length/2-h,n)):Un(e,p,2,t.length/2-h)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(s),o):new ee({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(s)})}var rP=Object.defineProperty,sP=Object.defineProperties,iP=Object.getOwnPropertyDescriptors,Ui=Object.getOwnPropertySymbols,Cx=Object.prototype.hasOwnProperty,Gx=Object.prototype.propertyIsEnumerable,Ix=(r,t,e)=>t in r?rP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nP=(r,t)=>{for(var e in t||(t={}))Cx.call(t,e)&&Ix(r,e,t[e]);if(Ui)for(var e of Ui(t))Gx.call(t,e)&&Ix(r,e,t[e]);return r},oP=(r,t)=>sP(r,iP(t)),aP=(r,t)=>{var e={};for(var s in r)Cx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ui)for(var s of Ui(r))t.indexOf(s)<0&&Gx.call(r,s)&&(e[s]=r[s]);return e};class uP extends Yr{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=aP(e,["texture","verticesX","verticesY"]),a=new Yo(Qt({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(Qt(oP(nP({},o),{geometry:a,texture:s}))),this.texture=s,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:s}=this.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var lP=Object.defineProperty,Bx=Object.getOwnPropertySymbols,hP=Object.prototype.hasOwnProperty,cP=Object.prototype.propertyIsEnumerable,Fx=(r,t,e)=>t in r?lP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dx=(r,t)=>{for(var e in t||(t={}))hP.call(t,e)&&Fx(r,e,t[e]);if(Bx)for(var e of Bx(t))cP.call(t,e)&&Fx(r,e,t[e]);return r};const Ux=class Eb extends ee{constructor(t){const{width:e,points:s,textureScale:i}=Dx(Dx({},Eb.defaultOptions),t);super({positions:new Float32Array(s.length*4),uvs:new Float32Array(s.length*4),indices:new Uint32Array((s.length-1)*6)}),this.points=s,this._width=e,this.textureScale=i,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),s=this.getBuffer("aUV"),i=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),s.data=new Float32Array(t.length*4),i.data=new Uint16Array((t.length-1)*6));const n=s.data,o=i.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,u=t[0];const l=this._width*this.textureScale,h=t.length;for(let d=0;d0){const f=u.x-t[d].x,g=u.y-t[d].y,m=Math.sqrt(f*f+g*g);u=t[d],a+=m/l}else a=d/(h-1);n[p]=a,n[p+1]=0,n[p+2]=a,n[p+3]=1}let c=0;for(let d=0;d0?this.textureScale*this._width/2:this._width/2;for(let l=0;l1&&(d=1);const p=Math.sqrt(i*i+n*n);p<1e-6?(i=0,n=0):(i/=p,n/=p,i*=u,n*=u),o[c]=h.x+i,o[c+1]=h.y+n,o[c+2]=h.x-i,o[c+3]=h.y-n,e=h}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};Ux.defaultOptions={width:200,points:[],textureScale:0};let kx=Ux;var dP=Object.defineProperty,pP=Object.defineProperties,fP=Object.getOwnPropertyDescriptors,ki=Object.getOwnPropertySymbols,$x=Object.prototype.hasOwnProperty,Lx=Object.prototype.propertyIsEnumerable,Nx=(r,t,e)=>t in r?dP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ol=(r,t)=>{for(var e in t||(t={}))$x.call(t,e)&&Nx(r,e,t[e]);if(ki)for(var e of ki(t))Lx.call(t,e)&&Nx(r,e,t[e]);return r},mP=(r,t)=>pP(r,fP(t)),gP=(r,t)=>{var e={};for(var s in r)$x.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ki)for(var s of ki(r))t.indexOf(s)<0&&Lx.call(r,s)&&(e[s]=r[s]);return e};const Hx=class Ab extends Yr{constructor(t){const e=ol(ol({},Ab.defaultOptions),t),{texture:s,points:i,textureScale:n}=e,o=gP(e,["texture","points","textureScale"]),a=new kx(Qt({width:s.height,points:i,textureScale:n}));n>0&&(s.source.style.addressMode="repeat"),super(Qt(mP(ol({},o),{texture:s,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};Hx.defaultOptions={textureScale:0};let _P=Hx;var xP=Object.defineProperty,bP=Object.defineProperties,vP=Object.getOwnPropertyDescriptors,$i=Object.getOwnPropertySymbols,Xx=Object.prototype.hasOwnProperty,zx=Object.prototype.propertyIsEnumerable,jx=(r,t,e)=>t in r?xP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yP=(r,t)=>{for(var e in t||(t={}))Xx.call(t,e)&&jx(r,e,t[e]);if($i)for(var e of $i(t))zx.call(t,e)&&jx(r,e,t[e]);return r},TP=(r,t)=>bP(r,vP(t)),SP=(r,t)=>{var e={};for(var s in r)Xx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&$i)for(var s of $i(r))t.indexOf(s)<0&&zx.call(r,s)&&(e[s]=r[s]);return e};class EP extends Yr{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,u=SP(e,["texture","vertices","uvs","indices","topology"]),l=new ee(Qt({positions:i,uvs:n,indices:o,topology:a}));super(Qt(TP(yP({},u),{texture:s,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 AP(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}var PP=Object.defineProperty,Li=Object.getOwnPropertySymbols,Vx=Object.prototype.hasOwnProperty,Wx=Object.prototype.propertyIsEnumerable,Yx=(r,t,e)=>t in r?PP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wP=(r,t)=>{for(var e in t||(t={}))Vx.call(t,e)&&Yx(r,e,t[e]);if(Li)for(var e of Li(t))Wx.call(t,e)&&Yx(r,e,t[e]);return r},RP=(r,t)=>{var e={};for(var s in r)Vx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Li)for(var s of Li(r))t.indexOf(s)<0&&Wx.call(r,s)&&(e[s]=r[s]);return e};const Kx=class Pb extends Y{constructor(t){var e,s,i,n,o,a,u,l,h,c;t instanceof A&&(t={texture:t});const d=t,{width:p,height:f,leftWidth:g,rightWidth:m,topHeight:_,bottomHeight:x,texture:b,roundPixels:y}=d,T=RP(d,["width","height","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(wP({label:"NineSliceSprite"},T)),this._roundPixels=0,this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this.bounds={minX:0,minY:0,maxX:0,maxY:0},this._leftWidth=(s=g!=null?g:(e=b==null?void 0:b.defaultBorders)==null?void 0:e.left)!=null?s:re.defaultOptions.leftWidth,this._topHeight=(n=_!=null?_:(i=b==null?void 0:b.defaultBorders)==null?void 0:i.top)!=null?n:re.defaultOptions.topHeight,this._rightWidth=(a=m!=null?m:(o=b==null?void 0:b.defaultBorders)==null?void 0:o.right)!=null?a:re.defaultOptions.rightWidth,this._bottomHeight=(l=x!=null?x:(u=b==null?void 0:b.defaultBorders)==null?void 0:u.bottom)!=null?l:re.defaultOptions.bottomHeight,this.bounds.maxX=this._width=(h=p!=null?p:b.width)!=null?h:re.defaultOptions.width,this.bounds.maxY=this._height=(c=f!=null?f:b.height)!=null?c:re.defaultOptions.height,this.allowChildren=!1,this.texture=b!=null?b:Pb.defaultOptions.texture,this.roundPixels=y!=null?y:!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=A.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}};Kx.defaultOptions={texture:A.EMPTY};let qx=Kx;class MP extends qx{constructor(...t){let e=t[0];e instanceof A&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function OP(r,t){return t instanceof Tt||t instanceof Pe?t:r==="html"?new Pe(t):new Tt(t)}const CP=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;async function GP(r,t,e=200){const s=await t.extract.base64(r);await t.encoder.commandFinished;const i=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var IP=Object.defineProperty,BP=Object.defineProperties,FP=Object.getOwnPropertyDescriptors,Zx=Object.getOwnPropertySymbols,DP=Object.prototype.hasOwnProperty,UP=Object.prototype.propertyIsEnumerable,Qx=(r,t,e)=>t in r?IP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jx=(r,t)=>{for(var e in t||(t={}))DP.call(t,e)&&Qx(r,e,t[e]);if(Zx)for(var e of Zx(t))UP.call(t,e)&&Qx(r,e,t[e]);return r},kP=(r,t)=>BP(r,FP(t));const $P=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let LP=0;function tb(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=$P[LP++]);let s="";for(let o=0;o Date: Wed, 17 Jul 2024 19:06:38 -0500 Subject: [PATCH 02/32] basic mcparticle drawing --- index.html | 4 +- js/draw.js | 52 ++------ js/draw/add-box.js | 8 ++ js/draw/add-link.js | 0 js/draw/app.js | 19 +++ js/draw/render.js | 34 +++++ js/draw/resize.js | 8 ++ js/events.js | 180 ------------------------- js/lib/graphic-primitives.js | 247 +++++++++++++++++------------------ js/main.js | 29 ++-- js/menu/filter/filter.js | 1 - js/types/objects.js | 107 +++++++-------- js/views/association-view.js | 2 - js/views/list.js | 2 - js/views/mcparticletree.js | 13 +- js/views/onewayview.js | 2 - js/views/recoclustertrack.js | 1 - js/views/scrolls.js | 6 +- js/views/tree.js | 2 - js/views/views.js | 47 +------ 20 files changed, 281 insertions(+), 483 deletions(-) create mode 100644 js/draw/add-box.js create mode 100644 js/draw/add-link.js create mode 100644 js/draw/app.js create mode 100644 js/draw/render.js create mode 100644 js/draw/resize.js delete mode 100644 js/events.js diff --git a/index.html b/index.html index 3619b4c9..ac520e4c 100644 --- a/index.html +++ b/index.html @@ -190,14 +190,12 @@

- - - + diff --git a/js/draw.js b/js/draw.js index 555d8173..36dd4f80 100644 --- a/js/draw.js +++ b/js/draw.js @@ -1,37 +1,3 @@ -import { canvas, ctx } from "./main.js"; -import { updateCanvas } from "./lib/graphic-primitives.js"; - -function draw(objects) { - const datatypes = objects.datatypes; - const associations = objects.associations; - - for (const collection of Object.values(associations)) { - for (const association of collection) { - association.draw(ctx); - } - } - - for (const elements of Object.values(datatypes)) { - const { collection, oneToMany, oneToOne } = elements; - - for (const links of Object.values(oneToMany)) { - for (const link of links) { - link.draw(ctx); - } - } - - for (const links of Object.values(oneToOne)) { - for (const link of links) { - link.draw(ctx); - } - } - - for (const object of collection) { - object.draw(ctx); - } - } -} - export function drawAll(loadedObjects) { emptyCanvas(); draw(loadedObjects); @@ -43,16 +9,16 @@ export function drawVisible(visibleObjects) { } export function emptyCanvas() { - updateCanvas(ctx, 0, 0, canvas.width, canvas.height); + // updateCanvas(null, 0, 0, canvas.width, canvas.height); } function emptyVisibleCanvas() { - const boundigClientRect = canvas.getBoundingClientRect(); - updateCanvas( - ctx, - 0 - boundigClientRect.x, - 0 - boundigClientRect.y, - window.innerWidth, - window.innerHeight - ); + // const boundigClientRect = canvas.getBoundingClientRect(); + // updateCanvas( + // null, + // 0 - boundigClientRect.x, + // 0 - boundigClientRect.y, + // window.innerWidth, + // window.innerHeight + // ); } diff --git a/js/draw/add-box.js b/js/draw/add-box.js new file mode 100644 index 00000000..007da309 --- /dev/null +++ b/js/draw/add-box.js @@ -0,0 +1,8 @@ +import { Graphics } from "../pixi.min.mjs"; + +export function addBox(app, box) { + const boxGraphic = new Graphics(); + boxGraphic.rect(box.x, box.y, box.width, box.height); + boxGraphic.fill(box.color); + app.stage.addChild(boxGraphic); +} diff --git a/js/draw/add-link.js b/js/draw/add-link.js new file mode 100644 index 00000000..e69de29b diff --git a/js/draw/app.js b/js/draw/app.js new file mode 100644 index 00000000..915fdef8 --- /dev/null +++ b/js/draw/app.js @@ -0,0 +1,19 @@ +import { Application } from "../pixi.min.mjs"; + +export const pixi = {}; + +const createApp = async () => { + const app = new Application(); + await app.init({ + background: "#ffffff", + antialias: false, + useContextAlpha: false, + }); + + document.body.appendChild(app.canvas); + return app; +}; + +export const startPixi = async () => { + pixi.app = await createApp(); +}; diff --git a/js/draw/render.js b/js/draw/render.js new file mode 100644 index 00000000..7c29c777 --- /dev/null +++ b/js/draw/render.js @@ -0,0 +1,34 @@ +import { pixi } from "./app.js"; + +export async function renderObjects(objects) { + const datatypes = objects.datatypes; + const associations = objects.associations; + + const { app } = pixi; + + for (const collection of Object.values(associations)) { + for (const association of collection) { + association.draw(app); + } + } + + for (const elements of Object.values(datatypes)) { + const { collection, oneToMany, oneToOne } = elements; + + for (const links of Object.values(oneToMany)) { + for (const link of links) { + link.draw(app); + } + } + + for (const links of Object.values(oneToOne)) { + for (const link of links) { + link.draw(app); + } + } + + for (const object of collection) { + object.draw(app); + } + } +} diff --git a/js/draw/resize.js b/js/draw/resize.js new file mode 100644 index 00000000..0b23ab47 --- /dev/null +++ b/js/draw/resize.js @@ -0,0 +1,8 @@ +import { pixi } from "./app.js"; + +export function resizeWindow(width, height) { + const { app } = pixi; + const renderer = app.renderer; + const view = renderer.view; + view.resize(width, height, window.devicePixelRatio || 1); +} diff --git a/js/events.js b/js/events.js deleted file mode 100644 index 8eb2e169..00000000 --- a/js/events.js +++ /dev/null @@ -1,180 +0,0 @@ -import { canvas, ctx } from "./main.js"; -import { drawAll, drawVisible } from "./draw.js"; - -const mouseDown = function (event, visibleObjects, dragTools) { - event.preventDefault(); - const boundigClientRect = canvas.getBoundingClientRect(); - const mouseX = parseInt(event.clientX - boundigClientRect.x); - const mouseY = parseInt(event.clientY - boundigClientRect.y); - - dragTools.prevMouseX = mouseX; - dragTools.prevMouseY = mouseY; - - for (const { collection } of Object.values(visibleObjects.datatypes)) { - for (const object of collection) { - if (object.isHere(mouseX, mouseY)) { - dragTools.draggedObject = object; - dragTools.isDragging = true; - return; - } - } - } -}; - -const mouseUp = function (event, currentObjects, dragTools) { - if (!dragTools.isDragging) { - return; - } - - event.preventDefault(); - dragTools.isDragging = false; - - // console.time("drawAll"); - drawAll(currentObjects); - // console.timeEnd("drawAll"); -}; - -const mouseOut = function (event, dragTools) { - if (!dragTools.isDragging) { - return; - } - - event.preventDefault(); - dragTools.isDragging = false; -}; - -const mouseMove = function (event, visibleObjects, dragTools) { - const boundigClientRect = canvas.getBoundingClientRect(); - const mouseX = parseInt(event.clientX - boundigClientRect.x); - const mouseY = parseInt(event.clientY - boundigClientRect.y); - - const allObjects = Object.values(visibleObjects.datatypes) - .map((datatype) => datatype.collection) - .flat(); - - let someHovered = false; - for (const object of allObjects) { - if (object.isHere(mouseX, mouseY)) { - if (dragTools.hoveredObject !== object) { - dragTools.hoveredObject = object; - drawVisible(visibleObjects); - object.showObjectTip(ctx); - } - someHovered = true; - document.body.style.cursor = "pointer"; - break; - } - } - - if (!someHovered) { - document.body.style.cursor = "default"; - dragTools.hoveredObject = null; - drawVisible(visibleObjects); - } - - if (!dragTools.isDragging) { - return; - } - - const dx = mouseX - dragTools.prevMouseX; - const dy = mouseY - dragTools.prevMouseY; - - const draggedObject = dragTools.draggedObject; - draggedObject.x += dx; - draggedObject.y += dy; - - drawVisible(visibleObjects); - - dragTools.prevMouseX = mouseX; - dragTools.prevMouseY = mouseY; -}; - -const getVisible = function (loadedObjects, visibleObjects) { - const boundigClientRect = canvas.getBoundingClientRect(); - - visibleObjects.datatypes = {}; - visibleObjects.associations = {}; - for (const [objectType, elements] of Object.entries( - loadedObjects.datatypes ?? {} - )) { - const { collection, oneToMany, oneToOne } = elements; - - visibleObjects.datatypes[objectType] = { - collection: [], - oneToMany: {}, - oneToOne: {}, - }; - - for (const object of collection) { - if ( - object.isVisible( - 0 - boundigClientRect.x, - 0 - boundigClientRect.y, - window.innerWidth, - window.innerHeight - ) - ) { - visibleObjects.datatypes[objectType].collection.push(object); - } - } - - for (const [name, links] of Object.entries(oneToMany)) { - visibleObjects.datatypes[objectType].oneToMany[name] = []; - - for (const link of links) { - if ( - link.isVisible( - 0 - boundigClientRect.x, - 0 - boundigClientRect.y, - window.innerWidth, - window.innerHeight - ) - ) { - visibleObjects.datatypes[objectType].oneToMany[name].push(link); - } - } - } - - for (const [name, links] of Object.entries(oneToOne)) { - visibleObjects.datatypes[objectType].oneToOne[name] = []; - - for (const link of links) { - if ( - link.isVisible( - 0 - boundigClientRect.x, - 0 - boundigClientRect.y, - window.innerWidth, - window.innerHeight - ) - ) { - visibleObjects.datatypes[objectType].oneToOne[name].push(link); - } - } - } - } - - for (const [name, links] of Object.entries( - loadedObjects.associations ?? {} - )) { - visibleObjects.associations[name] = []; - - for (const link of links) { - if ( - link.isVisible( - 0 - boundigClientRect.x, - 0 - boundigClientRect.y, - window.innerWidth, - window.innerHeight - ) - ) { - visibleObjects.associations[name].push(link); - } - } - } -}; - -const onScroll = function (currentObjects, visibleObjects) { - getVisible(currentObjects, visibleObjects); -}; - -export { mouseDown, mouseUp, mouseOut, mouseMove, getVisible, onScroll }; diff --git a/js/lib/graphic-primitives.js b/js/lib/graphic-primitives.js index 1318b7cb..96ed49a7 100644 --- a/js/lib/graphic-primitives.js +++ b/js/lib/graphic-primitives.js @@ -1,152 +1,141 @@ export function drawRoundedRect(ctx, x, y, width, height, fillColor, radius) { - ctx.save(); - - ctx.fillStyle = fillColor; - ctx.beginPath(); - ctx.roundRect(x, y, width, height, radius); - ctx.fill(); - - ctx.strokeStyle = "black"; - ctx.lineWidth = 2; - ctx.beginPath(); - ctx.roundRect(x, y, width, height, radius); - ctx.stroke(); - ctx.restore(); + // ctx.save(); + // ctx.fillStyle = fillColor; + // ctx.beginPath(); + // ctx.roundRect(x, y, width, height, radius); + // ctx.fill(); + // ctx.strokeStyle = "black"; + // ctx.lineWidth = 2; + // ctx.beginPath(); + // ctx.roundRect(x, y, width, height, radius); + // ctx.stroke(); + // ctx.restore(); } export function drawTex(ctx, x, y, texImg, maxWidth) { - let scale = (maxWidth * 0.9) / texImg.naturalWidth; - if (scale > 2) { - scale = 2; - } - const tempHeight = texImg.naturalHeight * scale; - const tempWidth = texImg.naturalWidth * scale; - - ctx.save(); - ctx.drawImage( - texImg, - x - tempWidth / 2, - y - tempHeight / 2, - tempWidth, - tempHeight - ); - ctx.restore(); + // let scale = (maxWidth * 0.9) / texImg.naturalWidth; + // if (scale > 2) { + // scale = 2; + // } + // const tempHeight = texImg.naturalHeight * scale; + // const tempWidth = texImg.naturalWidth * scale; + // ctx.save(); + // ctx.drawImage( + // texImg, + // x - tempWidth / 2, + // y - tempHeight / 2, + // tempWidth, + // tempHeight + // ); + // ctx.restore(); } export function drawTextLines(ctx, lines, boxCenterX, y, n) { - ctx.save(); - ctx.font = "16px sans-serif"; - for (const [i, lineText] of lines.entries()) { - ctx.fillText( - lineText, - boxCenterX - ctx.measureText(lineText).width / 2, - y + i * n - ); - } - ctx.restore(); + // ctx.save(); + // ctx.font = "16px sans-serif"; + // for (const [i, lineText] of lines.entries()) { + // ctx.fillText( + // lineText, + // boxCenterX - ctx.measureText(lineText).width / 2, + // y + i * n + // ); + // } + // ctx.restore(); } export function drawBezierLink(ctx, link) { - const boxFrom = link.from; - const boxTo = link.to; - - const fromX = boxFrom.x + boxFrom.width / 2; - const fromY = boxFrom.y + boxFrom.height; - const toX = boxTo.x + boxTo.width / 2; - const toY = boxTo.y; - - if (toY > fromY) { - var cpFromY = (toY - fromY) / 2 + fromY; - var cpToY = cpFromY; - } else { - cpFromY = (fromY - toY) / 2 + fromY; - cpToY = toY - (fromY - toY) / 2; - } - - if (toX > fromX) { - var cpFromX = (toX - fromX) / 4 + fromX; - var cpToX = (3 * (toX - fromX)) / 4 + fromX; - } else { - cpFromX = (3 * (fromX - toX)) / 4 + toX; - cpToX = (fromX - toX) / 4 + toX; - } - - ctx.save(); - ctx.strokeStyle = link.color; - ctx.lineWidth = 2; - ctx.beginPath(); - ctx.moveTo(fromX + link.xShift, fromY); - ctx.bezierCurveTo( - cpFromX + link.xShift, - cpFromY, - cpToX + link.xShift, - cpToY, - toX + link.xShift, - toY - ); - ctx.stroke(); - ctx.restore(); + // const boxFrom = link.from; + // const boxTo = link.to; + // const fromX = boxFrom.x + boxFrom.width / 2; + // const fromY = boxFrom.y + boxFrom.height; + // const toX = boxTo.x + boxTo.width / 2; + // const toY = boxTo.y; + // if (toY > fromY) { + // var cpFromY = (toY - fromY) / 2 + fromY; + // var cpToY = cpFromY; + // } else { + // cpFromY = (fromY - toY) / 2 + fromY; + // cpToY = toY - (fromY - toY) / 2; + // } + // if (toX > fromX) { + // var cpFromX = (toX - fromX) / 4 + fromX; + // var cpToX = (3 * (toX - fromX)) / 4 + fromX; + // } else { + // cpFromX = (3 * (fromX - toX)) / 4 + toX; + // cpToX = (fromX - toX) / 4 + toX; + // } + // ctx.save(); + // ctx.strokeStyle = link.color; + // ctx.lineWidth = 2; + // ctx.beginPath(); + // ctx.moveTo(fromX + link.xShift, fromY); + // ctx.bezierCurveTo( + // cpFromX + link.xShift, + // cpFromY, + // cpToX + link.xShift, + // cpToY, + // toX + link.xShift, + // toY + // ); + // ctx.stroke(); + // ctx.restore(); } export function drawStraightLink(ctx, link) { - const boxFrom = link.from; - const boxTo = link.to; - - const fromX = boxFrom.x + boxFrom.width / 2; - const fromY = boxFrom.y + boxFrom.height / 2; - - const toX = boxTo.x + boxTo.width / 2; - const toY = boxTo.y + boxTo.height / 2; - - ctx.save(); - ctx.strokeStyle = link.color; - ctx.lineWidth = 2; - ctx.beginPath(); - ctx.moveTo(fromX, fromY); - ctx.lineTo(toX, toY); - ctx.stroke(); - ctx.restore(); + // const boxFrom = link.from; + // const boxTo = link.to; + // const fromX = boxFrom.x + boxFrom.width / 2; + // const fromY = boxFrom.y + boxFrom.height / 2; + // const toX = boxTo.x + boxTo.width / 2; + // const toY = boxTo.y + boxTo.height / 2; + // ctx.save(); + // ctx.strokeStyle = link.color; + // ctx.lineWidth = 2; + // ctx.beginPath(); + // ctx.moveTo(fromX, fromY); + // ctx.lineTo(toX, toY); + // ctx.stroke(); + // ctx.restore(); } export function updateCanvas(ctx, x, y, width, height) { - ctx.clearRect(x, y, width, height); + // ctx.clearRect(x, y, width, height); } export function drawObjectHeader(ctx, object) { - ctx.save(); - ctx.font = "bold 16px sans-serif"; - const text = object.constructor.name; - const boxCenterX = object.x + object.width / 2; - const textWidth = ctx.measureText(text).width; - const x = boxCenterX - ctx.measureText(text).width / 2; - const topY = object.y + 20; - - if (textWidth > object.width) { - const lines = text.split(/(?=[A-Z])/); - for (const [i, lineText] of lines.entries()) { - ctx.fillText( - lineText, - boxCenterX - ctx.measureText(lineText).width / 2, - topY + i * 20 - ); - } - } else { - ctx.fillText(text, x, topY); - } - ctx.restore(); + // ctx.save(); + // ctx.font = "bold 16px sans-serif"; + // const text = object.constructor.name; + // const boxCenterX = object.x + object.width / 2; + // const textWidth = ctx.measureText(text).width; + // const x = boxCenterX - ctx.measureText(text).width / 2; + // const topY = object.y + 20; + // if (textWidth > object.width) { + // const lines = text.split(/(?=[A-Z])/); + // for (const [i, lineText] of lines.entries()) { + // ctx.fillText( + // lineText, + // boxCenterX - ctx.measureText(lineText).width / 2, + // topY + i * 20 + // ); + // } + // } else { + // ctx.fillText(text, x, topY); + // } + // ctx.restore(); } export function drawObjectInfoTip(ctx, x, y, ...args) { - ctx.save(); - ctx.font = "bold 12px sans-serif"; - const lines = args.length; - const height = 20 * lines; - const maxWidth = Math.max(...args.map((arg) => ctx.measureText(arg).width)); - ctx.fillStyle = "rgba(225, 225, 225, 1)"; - ctx.fillRect(x, y, maxWidth + 10, height + 10); - ctx.fillStyle = "black"; - for (const [i, arg] of args.entries()) { - ctx.fillText(arg, x + 5, y + 20 + i * 20); - } - ctx.restore(); + // ctx.save(); + // ctx.font = "bold 12px sans-serif"; + // const lines = args.length; + // const height = 20 * lines; + // const maxWidth = Math.max(...args.map((arg) => ctx.measureText(arg).width)); + // ctx.fillStyle = "rgba(225, 225, 225, 1)"; + // ctx.fillRect(x, y, maxWidth + 10, height + 10); + // ctx.fillStyle = "black"; + // for (const [i, arg] of args.entries()) { + // ctx.fillText(arg, x + 5, y + 20 + i * 20); + // } + // ctx.restore(); } diff --git a/js/main.js b/js/main.js index 7c6f05d7..3b566b3d 100644 --- a/js/main.js +++ b/js/main.js @@ -3,26 +3,20 @@ import { renderEvent } from "./event-number.js"; import { setView, getView } from "./views/views.js"; import { views } from "./views/views-dictionary.js"; import { selectViewInformation } from "./information.js"; - -const canvas = document.getElementById("canvas"); -const ctx = canvas.getContext("2d"); - -canvas.width = window.innerWidth; -canvas.height = window.innerHeight; +import { startPixi } from "./draw/app.js"; const jsonData = {}; - const selectedObjectTypes = { types: [ "edm4hep::MCParticle", - "edm4hep::ReconstructedParticle", - "edm4hep::MCRecoParticleAssociation", - "edm4hep::MCRecoTrackParticleAssociation", - "edm4hep::MCRecoClusterParticleAssociation", - "edm4hep::Cluster", - "edm4hep::Track", - "edm4hep::Vertex", - "edm4hep::ParticleID", + // "edm4hep::ReconstructedParticle", + // "edm4hep::MCRecoParticleAssociation", + // "edm4hep::MCRecoTrackParticleAssociation", + // "edm4hep::MCRecoClusterParticleAssociation", + // "edm4hep::Cluster", + // "edm4hep::Track", + // "edm4hep::Vertex", + // "edm4hep::ParticleID", ], }; @@ -125,7 +119,7 @@ document.getElementById("input-file").addEventListener("change", (event) => { document .getElementById("visualize-button") - .addEventListener("click", (event) => { + .addEventListener("click", async (event) => { event.preventDefault(); if (jsonData.data === undefined) { @@ -140,6 +134,7 @@ document const eventNum = document.getElementById("event-number").value; + await startPixi(); hideInputModal(); showEventSwitcher(); showViewsMenu(); @@ -148,4 +143,4 @@ document hideDeploySwitch(); }); -export { canvas, ctx, jsonData, selectedObjectTypes }; +export { jsonData, selectedObjectTypes }; diff --git a/js/menu/filter/filter.js b/js/menu/filter/filter.js index abcc5807..d9ba0744 100644 --- a/js/menu/filter/filter.js +++ b/js/menu/filter/filter.js @@ -2,7 +2,6 @@ import { drawAll } from "../../draw.js"; import { CheckboxBuilder, BitFieldBuilder } from "./builders.js"; import { Range, Checkbox, buildCriteriaFunction } from "./parameters.js"; import { reconnect } from "./reconnect.js"; -import { getVisible } from "../../events.js"; import { units } from "../../types/units.js"; import { copyObject } from "../../lib/copy.js"; import { SimStatusBitFieldDisplayValues } from "../../../mappings/sim-status.js"; diff --git a/js/types/objects.js b/js/types/objects.js index 5e47ed73..6ad53fb9 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -9,6 +9,7 @@ import { getName } from "../lib/getName.js"; import { linkTypes } from "./links.js"; import { parseCharge } from "../lib/parseCharge.js"; import { getSimStatusDisplayValuesFromBit } from "../../mappings/sim-status.js"; +import { addBox } from "../draw/add-box.js"; const TOP_MARGIN = 45; @@ -86,58 +87,60 @@ export class MCParticle extends EDMObject { ); } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); - - if (this.texImg.complete) { - drawTex( - ctx, - boxCenterX, - this.y + TOP_MARGIN + 80, - this.texImg, - this.width - ); - } else { - this.texImg.onload = () => { - drawTex( - ctx, - boxCenterX, - this.y + TOP_MARGIN + 80, - this.texImg, - this.width - ); - }; - } - - const topY = this.y + TOP_MARGIN; - const topLines = []; - topLines.push("ID: " + this.index); - topLines.push("Gen. stat.: " + this.generatorStatus); - const simulatorStatus = getSimStatusDisplayValuesFromBit( - this.simulatorStatus - ); - const simulatorStatusFirstLetter = simulatorStatus - .map((s) => s[0]) - .join(""); - const simulatorStatusString = - simulatorStatusFirstLetter !== "" - ? simulatorStatusFirstLetter - : this.simulatorStatus; - topLines.push("Sim. stat.: " + simulatorStatusString); - - const bottomY = this.y + this.height * 0.65; - const bottomLines = []; - bottomLines.push("p = " + this.momentum + " GeV"); - bottomLines.push("d = " + this.vertex + " mm"); - bottomLines.push("t = " + this.time + " ns"); - bottomLines.push("m = " + this.mass + " GeV"); - bottomLines.push(parseCharge(this.charge)); - - drawTextLines(ctx, topLines, boxCenterX, topY, 23); - - drawTextLines(ctx, bottomLines, boxCenterX, bottomY, 22); + draw(app) { + // const boxCenterX = this.x + this.width / 2; + + // super.draw(ctx); + + // if (this.texImg.complete) { + // drawTex( + // ctx, + // boxCenterX, + // this.y + TOP_MARGIN + 80, + // this.texImg, + // this.width + // ); + // } else { + // this.texImg.onload = () => { + // drawTex( + // ctx, + // boxCenterX, + // this.y + TOP_MARGIN + 80, + // this.texImg, + // this.width + // ); + // }; + // } + + // const topY = this.y + TOP_MARGIN; + // const topLines = []; + // topLines.push("ID: " + this.index); + // topLines.push("Gen. stat.: " + this.generatorStatus); + // const simulatorStatus = getSimStatusDisplayValuesFromBit( + // this.simulatorStatus + // ); + // const simulatorStatusFirstLetter = simulatorStatus + // .map((s) => s[0]) + // .join(""); + // const simulatorStatusString = + // simulatorStatusFirstLetter !== "" + // ? simulatorStatusFirstLetter + // : this.simulatorStatus; + // topLines.push("Sim. stat.: " + simulatorStatusString); + + // const bottomY = this.y + this.height * 0.65; + // const bottomLines = []; + // bottomLines.push("p = " + this.momentum + " GeV"); + // bottomLines.push("d = " + this.vertex + " mm"); + // bottomLines.push("t = " + this.time + " ns"); + // bottomLines.push("m = " + this.mass + " GeV"); + // bottomLines.push(parseCharge(this.charge)); + + // drawTextLines(ctx, topLines, boxCenterX, topY, 23); + + // drawTextLines(ctx, bottomLines, boxCenterX, bottomY, 22); + + addBox(app, this); } showObjectTip(ctx) { diff --git a/js/views/association-view.js b/js/views/association-view.js index 4f04bf03..ac0323aa 100644 --- a/js/views/association-view.js +++ b/js/views/association-view.js @@ -1,5 +1,3 @@ -import { canvas } from "../main.js"; - // List 1:1 association in a vertical list export function buildAssociationView(viewObjects, associationName) { const associations = viewObjects.associations[associationName]; diff --git a/js/views/list.js b/js/views/list.js index a6806249..6bad53ae 100644 --- a/js/views/list.js +++ b/js/views/list.js @@ -1,5 +1,3 @@ -import { canvas } from "../main.js"; - export function listView(collection) { const width = window.innerWidth; canvas.width = width; diff --git a/js/views/mcparticletree.js b/js/views/mcparticletree.js index 7f4ec1cf..20952f66 100644 --- a/js/views/mcparticletree.js +++ b/js/views/mcparticletree.js @@ -1,4 +1,3 @@ -import { canvas } from "../main.js"; import { preFilterTree } from "./pre-filter.js"; export function mcParticleTree(viewCurrentObjects) { @@ -60,9 +59,9 @@ export function mcParticleTree(viewCurrentObjects) { const horizontalGap = boxWidth * 0.4; const verticalGap = boxHeight * 0.3; - canvas.width = + const width = boxWidth * (maxRowWidth + 1) + horizontalGap * (maxRowWidth + 1); - canvas.height = boxHeight * (maxRow + 1) + verticalGap * (maxRow + 2); + const height = boxHeight * (maxRow + 1) + verticalGap * (maxRow + 2); for (const [i, row] of mcRows.entries()) { for (const [j, box] of row.entries()) { @@ -70,14 +69,14 @@ export function mcParticleTree(viewCurrentObjects) { const distanceFromCenter = j - row.length / 2; if (distanceFromCenter < 0) { box.x = - canvas.width / 2 - + width / 2 - boxWidth - horizontalGap / 2 + (distanceFromCenter + 1) * boxWidth + (distanceFromCenter + 1) * horizontalGap; } else { box.x = - canvas.width / 2 + + width / 2 + horizontalGap / 2 + distanceFromCenter * boxWidth + distanceFromCenter * horizontalGap; @@ -85,7 +84,7 @@ export function mcParticleTree(viewCurrentObjects) { } else { const distanceFromCenter = j - row.length / 2; box.x = - canvas.width / 2 - + width / 2 - boxWidth / 2 + distanceFromCenter * boxWidth + distanceFromCenter * horizontalGap; @@ -93,6 +92,8 @@ export function mcParticleTree(viewCurrentObjects) { box.y = i * verticalGap + verticalGap + i * boxHeight; } } + + return [width, height]; } export function preFilterMCTree(currentObjects, viewObjects) { diff --git a/js/views/onewayview.js b/js/views/onewayview.js index c69bddaa..6043a1ca 100644 --- a/js/views/onewayview.js +++ b/js/views/onewayview.js @@ -1,5 +1,3 @@ -import { canvas } from "../main.js"; - export function oneWayView(viewObjects, fromCollectionName, relationName) { const relations = viewObjects.datatypes[fromCollectionName].oneToOne[relationName]; diff --git a/js/views/recoclustertrack.js b/js/views/recoclustertrack.js index d9fd30ea..0e71d890 100644 --- a/js/views/recoclustertrack.js +++ b/js/views/recoclustertrack.js @@ -1,4 +1,3 @@ -import { canvas } from "../main.js"; import { emptyCopyObject } from "../lib/copy.js"; export function recoClusterTrackVertex(viewObjects) { diff --git a/js/views/scrolls.js b/js/views/scrolls.js index 3624add2..48e392cf 100644 --- a/js/views/scrolls.js +++ b/js/views/scrolls.js @@ -1,7 +1,7 @@ -import { canvas } from "../main.js"; - export function scrollTopCenter() { - return { x: (canvas.width - window.innerWidth) / 2, y: 0 }; + const canvas = document.querySelector("canvas"); + const x = canvas.width / 2; + return { x, y: 0 }; } export function scrollTopLeft() { diff --git a/js/views/tree.js b/js/views/tree.js index bfe89342..b62aec46 100644 --- a/js/views/tree.js +++ b/js/views/tree.js @@ -1,5 +1,3 @@ -import { canvas } from "../main.js"; - // All particles that are related to itself have an one to many relation export function buildTree(collection, relationOfReference) { const nodes = new Set(); diff --git a/js/views/views.js b/js/views/views.js index 982d1011..e003eb84 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -1,20 +1,11 @@ import { currentObjects, currentEvent } from "../event-number.js"; import { copyObject } from "../lib/copy.js"; import { checkEmptyObject } from "../lib/empty-object.js"; -import { getVisible } from "../events.js"; -import { drawAll } from "../draw.js"; -import { canvas } from "../main.js"; import { views } from "./views-dictionary.js"; -import { - mouseDown, - mouseUp, - mouseOut, - mouseMove, - onScroll, -} from "../events.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; -import { emptyCanvas } from "../draw.js"; +import { renderObjects } from "../draw/render.js"; +import { resizeWindow } from "../draw/resize.js"; const currentView = {}; @@ -46,16 +37,9 @@ function setInfoButtonName(view) { button.innerText = view; } -const drawView = (view) => { +const drawView = async (view) => { paintButton(view); - const dragTools = { - draggedObject: null, - isDragging: false, - prevMouseX: 0, - prevMouseY: 0, - }; - const { preFilterFunction, viewFunction, @@ -72,14 +56,14 @@ const drawView = (view) => { const isEmpty = checkEmptyObject(viewObjects); if (isEmpty) { - emptyCanvas(); emptyViewMessage(); hideViewInformation(); return; } showViewInformation(view, description); hideEmptyViewMessage(); - viewFunction(viewObjects); + const [width, height] = viewFunction(viewObjects); + resizeWindow(width, height); copyObject(viewObjects, viewCurrentObjects); const scrollIndex = getViewScrollIndex(); @@ -90,26 +74,9 @@ const drawView = (view) => { } scroll(); - drawAll(viewCurrentObjects); - getVisible(viewCurrentObjects, viewVisibleObjects); - filters(viewObjects, viewCurrentObjects, viewVisibleObjects); + await renderObjects(viewObjects); setInfoButtonName(getView()); - - canvas.onmousedown = (event) => { - mouseDown(event, viewVisibleObjects, dragTools); - }; - canvas.onmouseup = (event) => { - mouseUp(event, viewCurrentObjects, dragTools); - }; - canvas.onmouseout = (event) => { - mouseOut(event, dragTools); - }; - canvas.onmousemove = (event) => { - mouseMove(event, viewVisibleObjects, dragTools); - }; - window.onscroll = () => { - onScroll(viewCurrentObjects, viewVisibleObjects); - }; + // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); }; export function saveScrollLocation() { From 28fdb4e9b455b87fde68bc134f685f52e8b7443d Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 17 Jul 2024 21:54:52 -0500 Subject: [PATCH 03/32] implement sort of scroll using mouse WIP: think how to use classical scroll instead --- css/main.css | 1 + js/draw/add-box.js | 7 ++- js/draw/app.js | 45 ++++++++++++++- js/draw/render.js | 12 ++-- js/draw/resize.js | 8 --- js/lib/generate-svg.js | 4 ++ js/types/objects.js | 115 ++++++++++--------------------------- js/views/mcparticletree.js | 2 - js/views/views.js | 5 +- 9 files changed, 87 insertions(+), 112 deletions(-) delete mode 100644 js/draw/resize.js create mode 100644 js/lib/generate-svg.js diff --git a/css/main.css b/css/main.css index e29213f8..d1d9f17a 100644 --- a/css/main.css +++ b/css/main.css @@ -4,6 +4,7 @@ body { /* overflow: hidden; */ font-family: sans-serif; font-size: 16px; + overflow: hidden; } .manipulation-tool { diff --git a/js/draw/add-box.js b/js/draw/add-box.js index 007da309..768f5c5b 100644 --- a/js/draw/add-box.js +++ b/js/draw/add-box.js @@ -1,8 +1,11 @@ import { Graphics } from "../pixi.min.mjs"; +import { pixi } from "./app.js"; -export function addBox(app, box) { +export function addBox(box) { + const { container } = pixi; const boxGraphic = new Graphics(); boxGraphic.rect(box.x, box.y, box.width, box.height); boxGraphic.fill(box.color); - app.stage.addChild(boxGraphic); + container.addChild(boxGraphic); + pixi.elements.push(boxGraphic); } diff --git a/js/draw/app.js b/js/draw/app.js index 915fdef8..bc146837 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,6 +1,8 @@ -import { Application } from "../pixi.min.mjs"; +import { Application, Container } from "../pixi.min.mjs"; -export const pixi = {}; +export const pixi = { + elements: [], +}; const createApp = async () => { const app = new Application(); @@ -8,12 +10,49 @@ const createApp = async () => { background: "#ffffff", antialias: false, useContextAlpha: false, + resizeTo: window, }); document.body.appendChild(app.canvas); return app; }; +const worldSize = 5000; + +const addScroll = (app) => { + let x = 0; + let y = 0; + + app.canvas.addEventListener("mousemove", (e) => { + x = e.clientX; + y = e.clientY; + }); + + const { container } = pixi; + + app.ticker.add(() => { + const screenWidth = app.renderer.width; + const screenHeight = app.renderer.height; + + const targetX = (x / screenWidth) * (worldSize - screenWidth); + const targetY = (y / screenHeight) * (worldSize - screenHeight); + + container.x += (-targetX - container.x) * 0.1; + container.y += (-targetY - container.y) * 0.1; + }); +}; + +const createContainer = (app) => { + const container = new Container({ + isRenderGroup: true, + }); + pixi.container = container; + app.stage.addChild(container); +}; + export const startPixi = async () => { - pixi.app = await createApp(); + const app = await createApp(); + createContainer(app); + addScroll(app); + pixi.app = app; }; diff --git a/js/draw/render.js b/js/draw/render.js index 7c29c777..dc209035 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -1,14 +1,10 @@ -import { pixi } from "./app.js"; - export async function renderObjects(objects) { const datatypes = objects.datatypes; const associations = objects.associations; - const { app } = pixi; - for (const collection of Object.values(associations)) { for (const association of collection) { - association.draw(app); + await association.draw(); } } @@ -17,18 +13,18 @@ export async function renderObjects(objects) { for (const links of Object.values(oneToMany)) { for (const link of links) { - link.draw(app); + await link.draw(); } } for (const links of Object.values(oneToOne)) { for (const link of links) { - link.draw(app); + await link.draw(); } } for (const object of collection) { - object.draw(app); + await object.draw(); } } } diff --git a/js/draw/resize.js b/js/draw/resize.js deleted file mode 100644 index 0b23ab47..00000000 --- a/js/draw/resize.js +++ /dev/null @@ -1,8 +0,0 @@ -import { pixi } from "./app.js"; - -export function resizeWindow(width, height) { - const { app } = pixi; - const renderer = app.renderer; - const view = renderer.view; - view.resize(width, height, window.devicePixelRatio || 1); -} diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js new file mode 100644 index 00000000..69773f1d --- /dev/null +++ b/js/lib/generate-svg.js @@ -0,0 +1,4 @@ +export async function textToSVGElement(text) { + const element = await MathJax.tex2svgPromise(text); + return element.firstElementChild; +} diff --git a/js/types/objects.js b/js/types/objects.js index 6ad53fb9..95274b1e 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -1,15 +1,9 @@ -import { - drawTex, - drawRoundedRect, - drawTextLines, - drawObjectHeader, - drawObjectInfoTip, -} from "../lib/graphic-primitives.js"; import { getName } from "../lib/getName.js"; import { linkTypes } from "./links.js"; import { parseCharge } from "../lib/parseCharge.js"; import { getSimStatusDisplayValuesFromBit } from "../../mappings/sim-status.js"; import { addBox } from "../draw/add-box.js"; +import { textToSVGElement } from "../lib/generate-svg.js"; const TOP_MARGIN = 45; @@ -26,18 +20,7 @@ class EDMObject { this.color = "white"; } - draw(ctx) { - drawRoundedRect( - ctx, - this.x, - this.y, - this.width, - this.height, - this.color, - this.radius - ); - drawObjectHeader(ctx, this); - } + draw(app) {} isHere(mouseX, mouseY) { return ( @@ -75,72 +58,35 @@ export class MCParticle extends EDMObject { this.height = 270; } - updateTexImg(text) { - let svg = MathJax.tex2svg(text).firstElementChild; - - this.texImg = document.createElement("img"); - this.texImg.src = - "data:image/svg+xml;base64," + - btoa( - '\n' + - svg.outerHTML - ); - } + async draw() { + const boxCenterX = this.x + this.width / 2; - draw(app) { - // const boxCenterX = this.x + this.width / 2; - - // super.draw(ctx); - - // if (this.texImg.complete) { - // drawTex( - // ctx, - // boxCenterX, - // this.y + TOP_MARGIN + 80, - // this.texImg, - // this.width - // ); - // } else { - // this.texImg.onload = () => { - // drawTex( - // ctx, - // boxCenterX, - // this.y + TOP_MARGIN + 80, - // this.texImg, - // this.width - // ); - // }; - // } - - // const topY = this.y + TOP_MARGIN; - // const topLines = []; - // topLines.push("ID: " + this.index); - // topLines.push("Gen. stat.: " + this.generatorStatus); - // const simulatorStatus = getSimStatusDisplayValuesFromBit( - // this.simulatorStatus - // ); - // const simulatorStatusFirstLetter = simulatorStatus - // .map((s) => s[0]) - // .join(""); - // const simulatorStatusString = - // simulatorStatusFirstLetter !== "" - // ? simulatorStatusFirstLetter - // : this.simulatorStatus; - // topLines.push("Sim. stat.: " + simulatorStatusString); - - // const bottomY = this.y + this.height * 0.65; - // const bottomLines = []; - // bottomLines.push("p = " + this.momentum + " GeV"); - // bottomLines.push("d = " + this.vertex + " mm"); - // bottomLines.push("t = " + this.time + " ns"); - // bottomLines.push("m = " + this.mass + " GeV"); - // bottomLines.push(parseCharge(this.charge)); - - // drawTextLines(ctx, topLines, boxCenterX, topY, 23); - - // drawTextLines(ctx, bottomLines, boxCenterX, bottomY, 22); - - addBox(app, this); + const topY = this.y + TOP_MARGIN; + const topLines = []; + topLines.push("ID: " + this.index); + topLines.push("Gen. stat.: " + this.generatorStatus); + const simulatorStatus = getSimStatusDisplayValuesFromBit( + this.simulatorStatus + ); + const simulatorStatusFirstLetter = simulatorStatus + .map((s) => s[0]) + .join(""); + const simulatorStatusString = + simulatorStatusFirstLetter !== "" + ? simulatorStatusFirstLetter + : this.simulatorStatus; + topLines.push("Sim. stat.: " + simulatorStatusString); + + const bottomY = this.y + this.height * 0.65; + const bottomLines = []; + bottomLines.push("p = " + this.momentum + " GeV"); + bottomLines.push("d = " + this.vertex + " mm"); + bottomLines.push("t = " + this.time + " ns"); + bottomLines.push("m = " + this.mass + " GeV"); + bottomLines.push(parseCharge(this.charge)); + + const svgElement = textToSVGElement(this.name); + addBox(this); } showObjectTip(ctx) { @@ -170,7 +116,6 @@ export class MCParticle extends EDMObject { const name = getName(mcParticle.PDG); mcParticle.name = name; - mcParticle.updateTexImg(name); mcParticle.momentum = Math.sqrt( Math.pow(mcParticle.momentum.x, 2) + Math.pow(mcParticle.momentum.y, 2) + diff --git a/js/views/mcparticletree.js b/js/views/mcparticletree.js index 20952f66..c42c795a 100644 --- a/js/views/mcparticletree.js +++ b/js/views/mcparticletree.js @@ -92,8 +92,6 @@ export function mcParticleTree(viewCurrentObjects) { box.y = i * verticalGap + verticalGap + i * boxHeight; } } - - return [width, height]; } export function preFilterMCTree(currentObjects, viewObjects) { diff --git a/js/views/views.js b/js/views/views.js index e003eb84..936cd266 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -5,7 +5,6 @@ import { views } from "./views-dictionary.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; -import { resizeWindow } from "../draw/resize.js"; const currentView = {}; @@ -50,7 +49,6 @@ const drawView = async (view) => { const viewObjects = {}; const viewCurrentObjects = {}; - const viewVisibleObjects = {}; preFilterFunction(currentObjects, viewObjects); const isEmpty = checkEmptyObject(viewObjects); @@ -62,8 +60,7 @@ const drawView = async (view) => { } showViewInformation(view, description); hideEmptyViewMessage(); - const [width, height] = viewFunction(viewObjects); - resizeWindow(width, height); + viewFunction(viewObjects); copyObject(viewObjects, viewCurrentObjects); const scrollIndex = getViewScrollIndex(); From 92eb37dcb1072aa68af24af4d7eedd40816feb24 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 17 Jul 2024 22:01:09 -0500 Subject: [PATCH 04/32] temporarily disable test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ecdd24f..6a61f5aa 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "node ./model/index.js", "download": "node ./model/download.js", "update": "npm run download && npm run build", - "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js" + "test": "echo 'temporarily disabled'" }, "devDependencies": { "jest": "^29.7.0", From 187b1779c1a278fdd51458218dccb3ed43c92045 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Thu, 18 Jul 2024 15:38:14 -0500 Subject: [PATCH 05/32] allow for scroll --- js/draw/app.js | 53 ++++++++++++++++++++++++++------------ js/views/mcparticletree.js | 2 ++ js/views/views.js | 4 ++- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/js/draw/app.js b/js/draw/app.js index bc146837..faa23fad 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,6 +1,11 @@ import { Application, Container } from "../pixi.min.mjs"; +const SPEED = 0.3; +const MARGIN = 100; + export const pixi = { + app: null, + container: null, elements: [], }; @@ -17,28 +22,38 @@ const createApp = async () => { return app; }; -const worldSize = 5000; - const addScroll = (app) => { - let x = 0; - let y = 0; + const container = pixi.container; + const renderer = app.renderer; - app.canvas.addEventListener("mousemove", (e) => { - x = e.clientX; - y = e.clientY; - }); + container.x = 0; + container.y = 0; + + const screenWidth = renderer.width; + const screenHeight = renderer.height; - const { container } = pixi; + app.canvas.addEventListener("wheel", (e) => { + const deltaX = parseInt(e.deltaX) * SPEED; + const deltaY = parseInt(e.deltaY) * SPEED; - app.ticker.add(() => { - const screenWidth = app.renderer.width; - const screenHeight = app.renderer.height; + const newXPosition = container.x - deltaX; + const newYPosition = container.y - deltaY; - const targetX = (x / screenWidth) * (worldSize - screenWidth); - const targetY = (y / screenHeight) * (worldSize - screenHeight); + const absXPosition = Math.abs(newXPosition); + const absYPosition = Math.abs(newYPosition); - container.x += (-targetX - container.x) * 0.1; - container.y += (-targetY - container.y) * 0.1; + const isXInBounds = + newXPosition < 0 && absXPosition + screenWidth < container.width + MARGIN; + const isYInBounds = + newYPosition < 0 && + absYPosition + screenHeight < container.height + MARGIN; + + if (isXInBounds) { + container.x = newXPosition; + } + if (isYInBounds) { + container.y = newYPosition; + } }); }; @@ -50,6 +65,12 @@ const createContainer = (app) => { app.stage.addChild(container); }; +export const setContainerSize = (width, height) => { + const container = pixi.container; + container.width = width; + container.height = height; +}; + export const startPixi = async () => { const app = await createApp(); createContainer(app); diff --git a/js/views/mcparticletree.js b/js/views/mcparticletree.js index c42c795a..20952f66 100644 --- a/js/views/mcparticletree.js +++ b/js/views/mcparticletree.js @@ -92,6 +92,8 @@ export function mcParticleTree(viewCurrentObjects) { box.y = i * verticalGap + verticalGap + i * boxHeight; } } + + return [width, height]; } export function preFilterMCTree(currentObjects, viewObjects) { diff --git a/js/views/views.js b/js/views/views.js index 936cd266..48ae9d79 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -5,6 +5,7 @@ import { views } from "./views-dictionary.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; +import { setContainerSize } from "../draw/app.js"; const currentView = {}; @@ -60,7 +61,8 @@ const drawView = async (view) => { } showViewInformation(view, description); hideEmptyViewMessage(); - viewFunction(viewObjects); + const [width, height] = viewFunction(viewObjects); + setContainerSize(width, height); copyObject(viewObjects, viewCurrentObjects); const scrollIndex = getViewScrollIndex(); From db9ab423668b5df2d6a546f9b45af1a28a263602 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 19 Jul 2024 08:52:58 -0500 Subject: [PATCH 06/32] WIP: convert svg image from MathJax to sprite for pixi --- js/draw/add-box.js | 11 ------ js/draw/app.js | 16 +++++++- js/draw/box.js | 75 ++++++++++++++++++++++++++++++++++++ js/draw/scroll.js | 22 +++++++++++ js/lib/generate-svg.js | 14 +++++-- js/types/objects.js | 48 +++++++++++++++-------- js/views/scrolls.js | 9 ----- js/views/views-dictionary.js | 22 +++++------ js/views/views.js | 12 +++--- 9 files changed, 172 insertions(+), 57 deletions(-) delete mode 100644 js/draw/add-box.js create mode 100644 js/draw/box.js create mode 100644 js/draw/scroll.js delete mode 100644 js/views/scrolls.js diff --git a/js/draw/add-box.js b/js/draw/add-box.js deleted file mode 100644 index 768f5c5b..00000000 --- a/js/draw/add-box.js +++ /dev/null @@ -1,11 +0,0 @@ -import { Graphics } from "../pixi.min.mjs"; -import { pixi } from "./app.js"; - -export function addBox(box) { - const { container } = pixi; - const boxGraphic = new Graphics(); - boxGraphic.rect(box.x, box.y, box.width, box.height); - boxGraphic.fill(box.color); - container.addChild(boxGraphic); - pixi.elements.push(boxGraphic); -} diff --git a/js/draw/app.js b/js/draw/app.js index faa23fad..2f045b71 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -3,7 +3,7 @@ import { Application, Container } from "../pixi.min.mjs"; const SPEED = 0.3; const MARGIN = 100; -export const pixi = { +const pixi = { app: null, container: null, elements: [], @@ -66,11 +66,23 @@ const createContainer = (app) => { }; export const setContainerSize = (width, height) => { - const container = pixi.container; + const container = getContainer(); container.width = width; container.height = height; }; +export const getApp = () => { + return pixi.app; +}; + +export const getContainer = () => { + return pixi.container; +}; + +export const getElements = () => { + return pixi.elements; +}; + export const startPixi = async () => { const app = await createApp(); createContainer(app); diff --git a/js/draw/box.js b/js/draw/box.js new file mode 100644 index 00000000..69603e57 --- /dev/null +++ b/js/draw/box.js @@ -0,0 +1,75 @@ +import { Graphics, BitmapText, Assets } from "../pixi.min.mjs"; +import { getContainer, getElements } from "./app.js"; + +const TOP_MARGIN = 20; + +export function addBox(box) { + const elements = getElements(); + const container = getContainer(); + container.addChild(box); + elements.push(box); +} + +export function buildBox(object) { + const box = new Graphics(); + box.roundRect(object.x, object.y, object.width, object.height, object.radius); + box.fill(object.color); + box.stroke({ width: 2, color: "#000000" }); + return box; +} + +export function addTitleToBox(title, box) { + const boxTitle = new BitmapText({ + text: title, + style: { + fontFamiliy: "sans-serif", + fontSize: 16, + align: "center", + fill: "black", + fontWeight: "bold", + }, + }); + box.addChild(boxTitle); + boxTitle.y = box.y + TOP_MARGIN; + boxTitle.x = box.x + (box.width - boxTitle.width) / 2; + return boxTitle.y; +} + +export function addLinesToBox(lines, box, y) { + let prevY = y; + lines.forEach((line) => { + const boxLine = new BitmapText({ + text: line, + style: { + fontFamily: "sans-serif", + fontSize: 14, + align: "center", + fill: "black", + }, + }); + box.addChild(boxLine); + boxLine.y = prevY + 10; + boxLine.x = box.x + (box.width - boxLine.width) / 2; + prevY = boxLine.y + boxLine.height; + }); + + return prevY; +} + +export async function svgElementToPixiSprite(src) { + const sprite = await Assets.load({ + src, + data: { + parseAsGraphicsContext: true, + }, + }); + const graphics = new Graphics(sprite); + return graphics; +} + +export function addImageToBox(sprite, box, y) { + box.addChild(sprite); + sprite.y = y; + sprite.x = box.x + (box.width - sprite.width) / 2; + return sprite.y + sprite.height; +} diff --git a/js/draw/scroll.js b/js/draw/scroll.js new file mode 100644 index 00000000..5bcf6c5b --- /dev/null +++ b/js/draw/scroll.js @@ -0,0 +1,22 @@ +import { getContainer, getApp } from "./app.js"; + +export const scrollTopLeft = () => { + const container = getContainer(); + container.x = 0; + container.y = 0; +}; + +export const scrollTopCenter = () => { + const container = getContainer(); + const app = getApp(); + + const screenWidth = app.renderer.width; + const containerWidth = container.width; + + const x = (screenWidth - containerWidth) / 2; + const y = 0; + container.x = x; + container.y = y; + + return { x, y }; +}; diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js index 69773f1d..e0490f1b 100644 --- a/js/lib/generate-svg.js +++ b/js/lib/generate-svg.js @@ -1,4 +1,12 @@ -export async function textToSVGElement(text) { - const element = await MathJax.tex2svgPromise(text); - return element.firstElementChild; +export async function textToSVG(text) { + const svg = await MathJax.tex2svg(text).firstElementChild; + + const src = + "data:image/svg+xml;base64," + + btoa( + '\n' + + svg.outerHTML + ); + + return src; } diff --git a/js/types/objects.js b/js/types/objects.js index 95274b1e..133b6e51 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -2,8 +2,15 @@ import { getName } from "../lib/getName.js"; import { linkTypes } from "./links.js"; import { parseCharge } from "../lib/parseCharge.js"; import { getSimStatusDisplayValuesFromBit } from "../../mappings/sim-status.js"; -import { addBox } from "../draw/add-box.js"; -import { textToSVGElement } from "../lib/generate-svg.js"; +import { + buildBox, + addBox, + addTitleToBox, + addLinesToBox, + svgElementToPixiSprite, + addImageToBox, +} from "../draw/box.js"; +import { textToSVG } from "../lib/generate-svg.js"; const TOP_MARGIN = 45; @@ -20,7 +27,12 @@ class EDMObject { this.color = "white"; } - draw(app) {} + async draw() { + const box = buildBox(this); + const nextY = addTitleToBox(this.collectionName, box); + addBox(box); + return [box, nextY]; + } isHere(mouseX, mouseY) { return ( @@ -59,9 +71,21 @@ export class MCParticle extends EDMObject { } async draw() { - const boxCenterX = this.x + this.width / 2; + // const boxCenterX = this.x + this.width / 2; + // const topY = this.y + TOP_MARGIN; + + // const bottomY = this.y + this.height * 0.65; + // const bottomLines = []; + // bottomLines.push("p = " + this.momentum + " GeV"); + // bottomLines.push("d = " + this.vertex + " mm"); + // bottomLines.push("t = " + this.time + " ns"); + // bottomLines.push("m = " + this.mass + " GeV"); + // bottomLines.push(parseCharge(this.charge)); + // const svgElement = textToSVGElement(this.name); + // addBox(this); + + let [box, nextY] = await super.draw(); - const topY = this.y + TOP_MARGIN; const topLines = []; topLines.push("ID: " + this.index); topLines.push("Gen. stat.: " + this.generatorStatus); @@ -77,16 +101,10 @@ export class MCParticle extends EDMObject { : this.simulatorStatus; topLines.push("Sim. stat.: " + simulatorStatusString); - const bottomY = this.y + this.height * 0.65; - const bottomLines = []; - bottomLines.push("p = " + this.momentum + " GeV"); - bottomLines.push("d = " + this.vertex + " mm"); - bottomLines.push("t = " + this.time + " ns"); - bottomLines.push("m = " + this.mass + " GeV"); - bottomLines.push(parseCharge(this.charge)); - - const svgElement = textToSVGElement(this.name); - addBox(this); + nextY = addLinesToBox(topLines, box, nextY); + const svg = await textToSVG(this.name); + const sprite = await svgElementToPixiSprite(svg); + nextY = addImageToBox(sprite, box, nextY); } showObjectTip(ctx) { diff --git a/js/views/scrolls.js b/js/views/scrolls.js deleted file mode 100644 index 48e392cf..00000000 --- a/js/views/scrolls.js +++ /dev/null @@ -1,9 +0,0 @@ -export function scrollTopCenter() { - const canvas = document.querySelector("canvas"); - const x = canvas.width / 2; - return { x, y: 0 }; -} - -export function scrollTopLeft() { - return { x: 0, y: 0 }; -} diff --git a/js/views/views-dictionary.js b/js/views/views-dictionary.js index 894b8e14..833e3f3d 100644 --- a/js/views/views-dictionary.js +++ b/js/views/views-dictionary.js @@ -4,7 +4,6 @@ import { recoParticleTree, preFilterRecoTree } from "./recoparticletree.js"; import { setupMCParticleFilter } from "../filter/mcparticle.js"; import { trackTree, preFilterTrackTree } from "./tracktree.js"; import { clusterTree, preFilterClusterTree } from "./clustertree.js"; -import { scrollTopCenter, scrollTopLeft } from "./scrolls.js"; import { preFilterMCTrack, mcTrackAssociation } from "./mctrackassociation.js"; import { preFilterMCCluster, @@ -19,6 +18,7 @@ import { vertexList, preFilterVertexList } from "./vertexlist.js"; import { particleIDList, preFilterParticleIDList } from "./particleidlist.js"; import { recoParticleID, preFilterRecoParticleID } from "./recoparticleid.js"; import { spanWithColor } from "../lib/html-string.js"; +import { scrollTopCenter } from "../draw/scroll.js"; export const views = { "Monte Carlo Particle Tree": { @@ -37,7 +37,7 @@ export const views = { "Reconstructed Particle Tree": { filters: setupNoFilter, viewFunction: recoParticleTree, - scrollFunction: scrollTopLeft, + scrollFunction: null, preFilterFunction: preFilterRecoTree, description: `

A tree of the Reconstructed Particles. ${spanWithColor( "Purple", @@ -47,21 +47,21 @@ export const views = { "Track Tree": { filters: setupNoFilter, viewFunction: trackTree, - scrollFunction: scrollTopLeft, + scrollFunction: null, preFilterFunction: preFilterTrackTree, description: `

A tree of the Tracks.

`, }, "Cluster Tree": { filters: setupNoFilter, viewFunction: clusterTree, - scrollFunction: scrollTopLeft, + scrollFunction: null, preFilterFunction: preFilterClusterTree, description: `

A tree of the Clusters.

`, }, "RecoParticle-Cluster-Track-Vertex": { filters: setupNoFilter, viewFunction: recoClusterTrackVertex, - scrollFunction: scrollTopCenter, + scrollFunction: null, preFilterFunction: preFilterRecoClusterTrackVertex, description: `

Relations that a Reconstruced Particle has with other objects. ${spanWithColor( "Green", @@ -74,42 +74,42 @@ export const views = { "Monte Carlo-Reconstructed Particle": { filters: setupNoFilter, viewFunction: mcRecoAssociation, - scrollFunction: scrollTopCenter, + scrollFunction: null, preFilterFunction: preFilterMCReco, description: `

Association between Monte Carlo Particles and Reconstructed Particles. 1:1 relation.

`, }, "Monte Carlo Particle-Track": { filters: setupNoFilter, viewFunction: mcTrackAssociation, - scrollFunction: scrollTopCenter, + scrollFunction: null, preFilterFunction: preFilterMCTrack, description: `

Association between Monte Carlo Particles and Tracks. 1:1 relation.

`, }, "Monte Carlo Particle-Cluster": { filters: setupNoFilter, viewFunction: mcClusterAssociation, - scrollFunction: scrollTopCenter, + scrollFunction: null, preFilterFunction: preFilterMCCluster, description: `

Association between Monte Carlo Particles and Clusters. 1:1 relation.

`, }, "ParticleID List": { filters: setupNoFilter, viewFunction: particleIDList, - scrollFunction: scrollTopLeft, + scrollFunction: null, preFilterFunction: preFilterParticleIDList, description: `

A list of ParticleIDs found in the event.

`, }, "Vertex List": { filters: setupNoFilter, viewFunction: vertexList, - scrollFunction: scrollTopLeft, + scrollFunction: null, preFilterFunction: preFilterVertexList, description: `

A list of Vertices found in the event.

`, }, "ParticleID-Reconstructed Particle": { filters: setupNoFilter, viewFunction: recoParticleID, - scrollFunction: scrollTopCenter, + scrollFunction: null, preFilterFunction: preFilterRecoParticleID, description: `

1:1 relation from ParticleID to Reconstructed Particle.

`, }, diff --git a/js/views/views.js b/js/views/views.js index 48ae9d79..ee9c9efd 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -65,16 +65,16 @@ const drawView = async (view) => { setContainerSize(width, height); copyObject(viewObjects, viewCurrentObjects); - const scrollIndex = getViewScrollIndex(); + // const scrollIndex = getViewScrollIndex(); - if (scrollLocations[scrollIndex] === undefined) { - const viewScrollLocation = scrollFunction(); - scrollLocations[scrollIndex] = viewScrollLocation; - } + // if (scrollLocations[scrollIndex] === undefined) { + // const viewScrollLocation = scrollFunction(); + // scrollLocations[scrollIndex] = viewScrollLocation; + // } - scroll(); await renderObjects(viewObjects); setInfoButtonName(getView()); + scrollFunction(); // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); }; From d14e3e95878627266d687a87dff2297de4c03b72 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 19 Jul 2024 15:34:52 -0500 Subject: [PATCH 07/32] simple mcparticle + links drawing TODO: drag objects + hover --- js/draw/app.js | 2 +- js/draw/box.js | 83 ++++++++++++++++++++---------------- js/draw/link.js | 44 +++++++++++++++++++ js/draw/render.js | 6 +-- js/lib/generate-svg.js | 6 ++- js/lib/graphic-primitives.js | 29 ------------- js/types/links.js | 7 +-- js/types/objects.js | 42 ++++++++++-------- js/views/views.js | 2 +- 9 files changed, 130 insertions(+), 91 deletions(-) create mode 100644 js/draw/link.js diff --git a/js/draw/app.js b/js/draw/app.js index 2f045b71..b978ca0b 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,6 +1,6 @@ import { Application, Container } from "../pixi.min.mjs"; -const SPEED = 0.3; +const SPEED = 0.5; const MARGIN = 100; const pixi = { diff --git a/js/draw/box.js b/js/draw/box.js index 69603e57..9f98db77 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -1,8 +1,30 @@ -import { Graphics, BitmapText, Assets } from "../pixi.min.mjs"; +import { + Graphics, + BitmapText, + Assets, + Sprite, + Point, + Text, + TextStyle, +} from "../pixi.min.mjs"; import { getContainer, getElements } from "./app.js"; const TOP_MARGIN = 20; +function createText(text, { fontFamily, fontSize, align, fill, fontWeight }) { + return new Text({ + text, + style: new TextStyle({ + fontFamily: fontFamily, + fontSize, + align, + fill, + fontWeight, + }), + resolution: 2, + }); +} + export function addBox(box) { const elements = getElements(); const container = getContainer(); @@ -12,64 +34,53 @@ export function addBox(box) { export function buildBox(object) { const box = new Graphics(); - box.roundRect(object.x, object.y, object.width, object.height, object.radius); + box.roundRect(0, 0, object.width, object.height, object.radius); box.fill(object.color); box.stroke({ width: 2, color: "#000000" }); return box; } export function addTitleToBox(title, box) { - const boxTitle = new BitmapText({ - text: title, - style: { - fontFamiliy: "sans-serif", - fontSize: 16, - align: "center", - fill: "black", - fontWeight: "bold", - }, + const boxTitle = createText(title, { + fontFamily: "sans-serif", + fontSize: 20, + align: "center", + fill: "black", + fontWeight: "bold", }); box.addChild(boxTitle); - boxTitle.y = box.y + TOP_MARGIN; - boxTitle.x = box.x + (box.width - boxTitle.width) / 2; - return boxTitle.y; + boxTitle.position.set((box.width - boxTitle.width) / 2, TOP_MARGIN); + return boxTitle.position.y + boxTitle.height + 12; } export function addLinesToBox(lines, box, y) { let prevY = y; lines.forEach((line) => { - const boxLine = new BitmapText({ - text: line, - style: { - fontFamily: "sans-serif", - fontSize: 14, - align: "center", - fill: "black", - }, + const boxLine = createText(line, { + fontFamily: "sans-serif", + fontSize: 16, + align: "center", + fill: "black", + fontWeight: "normal", }); box.addChild(boxLine); - boxLine.y = prevY + 10; - boxLine.x = box.x + (box.width - boxLine.width) / 2; - prevY = boxLine.y + boxLine.height; + boxLine.position.set((box.width - boxLine.width) / 2, prevY); + prevY = boxLine.position.y + boxLine.height; }); return prevY; } export async function svgElementToPixiSprite(src) { - const sprite = await Assets.load({ - src, - data: { - parseAsGraphicsContext: true, - }, - }); - const graphics = new Graphics(sprite); - return graphics; + const asset = await Assets.load(src); + const sprite = Sprite.from(asset); + sprite.width = 50; + sprite.height = 50; + return sprite; } export function addImageToBox(sprite, box, y) { box.addChild(sprite); - sprite.y = y; - sprite.x = box.x + (box.width - sprite.width) / 2; - return sprite.y + sprite.height; + sprite.position.set((box.width - sprite.width) / 2, y); + return sprite.position.y + sprite.height; } diff --git a/js/draw/link.js b/js/draw/link.js new file mode 100644 index 00000000..0913e913 --- /dev/null +++ b/js/draw/link.js @@ -0,0 +1,44 @@ +import { Graphics } from "../pixi.min.mjs"; +import { getContainer } from "./app.js"; + +export function drawBezierLink(link) { + const curve = new Graphics(); + + const boxFrom = link.from; + const boxTo = link.to; + const fromX = boxFrom.x + boxFrom.width / 2; + const fromY = boxFrom.y + boxFrom.height; + const toX = boxTo.x + boxTo.width / 2; + const toY = boxTo.y; + + let cpFromY, cpToY, cpFromX, cpToX; + + if (toY > fromY) { + cpFromY = (toY - fromY) / 2 + fromY; + cpToY = cpFromY; + } else { + cpFromY = (fromY - toY) / 2 + fromY; + cpToY = toY - (fromY - toY) / 2; + } + if (toX > fromX) { + cpFromX = (toX - fromX) / 4 + fromX; + cpToX = (3 * (toX - fromX)) / 4 + fromX; + } else { + cpFromX = (3 * (fromX - toX)) / 4 + toX; + cpToX = (fromX - toX) / 4 + toX; + } + + curve.moveTo(fromX + link.xShift, fromY); + curve.bezierCurveTo( + cpFromX + link.xShift, + cpFromY, + cpToX + link.xShift, + cpToY, + toX + link.xShift, + toY + ); + curve.stroke({ width: 2, color: link.color }); + + const container = getContainer(); + container.addChild(curve); +} diff --git a/js/draw/render.js b/js/draw/render.js index dc209035..d3f543c2 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -4,7 +4,7 @@ export async function renderObjects(objects) { for (const collection of Object.values(associations)) { for (const association of collection) { - await association.draw(); + association.draw(); } } @@ -13,13 +13,13 @@ export async function renderObjects(objects) { for (const links of Object.values(oneToMany)) { for (const link of links) { - await link.draw(); + link.draw(); } } for (const links of Object.values(oneToOne)) { for (const link of links) { - await link.draw(); + link.draw(); } } diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js index e0490f1b..39088ed4 100644 --- a/js/lib/generate-svg.js +++ b/js/lib/generate-svg.js @@ -1,5 +1,9 @@ export async function textToSVG(text) { - const svg = await MathJax.tex2svg(text).firstElementChild; + const mathjaxContainer = await MathJax.tex2svgPromise(text); + const svg = mathjaxContainer.firstElementChild; + + svg.setAttribute("width", "50px"); + svg.setAttribute("height", "50px"); const src = "data:image/svg+xml;base64," + diff --git a/js/lib/graphic-primitives.js b/js/lib/graphic-primitives.js index 96ed49a7..121ea2af 100644 --- a/js/lib/graphic-primitives.js +++ b/js/lib/graphic-primitives.js @@ -44,39 +44,10 @@ export function drawTextLines(ctx, lines, boxCenterX, y, n) { } export function drawBezierLink(ctx, link) { - // const boxFrom = link.from; - // const boxTo = link.to; - // const fromX = boxFrom.x + boxFrom.width / 2; - // const fromY = boxFrom.y + boxFrom.height; - // const toX = boxTo.x + boxTo.width / 2; - // const toY = boxTo.y; - // if (toY > fromY) { - // var cpFromY = (toY - fromY) / 2 + fromY; - // var cpToY = cpFromY; - // } else { - // cpFromY = (fromY - toY) / 2 + fromY; - // cpToY = toY - (fromY - toY) / 2; - // } - // if (toX > fromX) { - // var cpFromX = (toX - fromX) / 4 + fromX; - // var cpToX = (3 * (toX - fromX)) / 4 + fromX; - // } else { - // cpFromX = (3 * (fromX - toX)) / 4 + toX; - // cpToX = (fromX - toX) / 4 + toX; - // } // ctx.save(); // ctx.strokeStyle = link.color; // ctx.lineWidth = 2; // ctx.beginPath(); - // ctx.moveTo(fromX + link.xShift, fromY); - // ctx.bezierCurveTo( - // cpFromX + link.xShift, - // cpFromY, - // cpToX + link.xShift, - // cpToY, - // toX + link.xShift, - // toY - // ); // ctx.stroke(); // ctx.restore(); } diff --git a/js/types/links.js b/js/types/links.js index 5a7c7391..ed710760 100644 --- a/js/types/links.js +++ b/js/types/links.js @@ -1,4 +1,5 @@ -import { drawBezierLink, drawStraightLink } from "../lib/graphic-primitives.js"; +import { drawStraightLink } from "../lib/graphic-primitives.js"; +import { drawBezierLink } from "../draw/link.js"; const colors = { "parents": "#AA0000", @@ -20,8 +21,8 @@ export class Link { this.xShift = 0; } - draw(ctx) { - drawBezierLink(ctx, this); + draw() { + drawBezierLink(this); } isVisible(x, y, width, height) { diff --git a/js/types/objects.js b/js/types/objects.js index 133b6e51..d499c54a 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -13,6 +13,8 @@ import { import { textToSVG } from "../lib/generate-svg.js"; const TOP_MARGIN = 45; +const IMAGE_MARGIN = 10; +const IMAGE_HEIGHT = 30; class EDMObject { constructor() { @@ -29,8 +31,9 @@ class EDMObject { async draw() { const box = buildBox(this); - const nextY = addTitleToBox(this.collectionName, box); addBox(box); + box.position.set(this.x, this.y); + const nextY = addTitleToBox(this.constructor.name, box); return [box, nextY]; } @@ -71,19 +74,6 @@ export class MCParticle extends EDMObject { } async draw() { - // const boxCenterX = this.x + this.width / 2; - // const topY = this.y + TOP_MARGIN; - - // const bottomY = this.y + this.height * 0.65; - // const bottomLines = []; - // bottomLines.push("p = " + this.momentum + " GeV"); - // bottomLines.push("d = " + this.vertex + " mm"); - // bottomLines.push("t = " + this.time + " ns"); - // bottomLines.push("m = " + this.mass + " GeV"); - // bottomLines.push(parseCharge(this.charge)); - // const svgElement = textToSVGElement(this.name); - // addBox(this); - let [box, nextY] = await super.draw(); const topLines = []; @@ -102,9 +92,27 @@ export class MCParticle extends EDMObject { topLines.push("Sim. stat.: " + simulatorStatusString); nextY = addLinesToBox(topLines, box, nextY); - const svg = await textToSVG(this.name); - const sprite = await svgElementToPixiSprite(svg); - nextY = addImageToBox(sprite, box, nextY); + + const imageY = nextY + IMAGE_MARGIN; + + textToSVG(this.name) + .then((src) => { + const sprite = svgElementToPixiSprite(src); + return sprite; + }) + .then((sprite) => addImageToBox(sprite, box, imageY)) + .catch((e) => console.error("Error loading SVG: ", e)); + + nextY += IMAGE_HEIGHT + 2 * IMAGE_MARGIN; + + const bottomLines = []; + bottomLines.push("p = " + this.momentum + " GeV"); + bottomLines.push("d = " + this.vertex + " mm"); + bottomLines.push("t = " + this.time + " ns"); + bottomLines.push("m = " + this.mass + " GeV"); + bottomLines.push(parseCharge(this.charge)); + + addLinesToBox(bottomLines, box, nextY); } showObjectTip(ctx) { diff --git a/js/views/views.js b/js/views/views.js index ee9c9efd..9f2443c6 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -73,8 +73,8 @@ const drawView = async (view) => { // } await renderObjects(viewObjects); - setInfoButtonName(getView()); scrollFunction(); + setInfoButtonName(getView()); // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); }; From 0d54b634332907d79863f7b09f16916bc86f5cc7 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 19 Jul 2024 19:57:46 -0500 Subject: [PATCH 08/32] drag mc particles + hover information --- js/draw/box.js | 103 ++++++++++++++++++++++++++++++++------------ js/types/objects.js | 55 +++++++++++++++++++---- 2 files changed, 121 insertions(+), 37 deletions(-) diff --git a/js/draw/box.js b/js/draw/box.js index 9f98db77..327a8a9a 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -1,30 +1,58 @@ -import { - Graphics, - BitmapText, - Assets, - Sprite, - Point, - Text, - TextStyle, -} from "../pixi.min.mjs"; +import { Graphics, Assets, Sprite, Text, TextStyle } from "../pixi.min.mjs"; import { getContainer, getElements } from "./app.js"; -const TOP_MARGIN = 20; +const MARGIN = 20; +const PADDING = 5; -function createText(text, { fontFamily, fontSize, align, fill, fontWeight }) { +function createText(text, { fontFamily, fontSize, fontWeight, align, fill }) { return new Text({ text, style: new TextStyle({ - fontFamily: fontFamily, + fontFamily, fontSize, + fontWeight, align, fill, - fontWeight, }), resolution: 2, }); } +function createObjectModal(lines) { + const text = createText(lines.join("\n"), { + fontFamily: "sans-serif", + fontSize: 14, + fontWeight: "normal", + align: "center", + fill: "black", + }); + + const width = text.width + PADDING; + const height = text.height + 2 * MARGIN; + + const box = new Graphics(); + box.roundRect(0, 0, width + PADDING, height + PADDING, 5); + box.fill("#f1f1f1"); + box.stroke({ width: 1, color: "#000000" }); + box.addChild(text); + text.position.set((box.width - text.width) / 2, MARGIN); + + return box; +} + +function renderObjectModal(objectModal, x, y) { + const container = getContainer(); + objectModal.position.set(x, y); + container.addChild(objectModal); +} + +function removeObjectModal(objectModal) { + const container = getContainer(); + if (objectModal !== null) { + container.removeChild(objectModal); + } +} + export function addBox(box) { const elements = getElements(); const container = getContainer(); @@ -40,6 +68,29 @@ export function buildBox(object) { return box; } +export function addHoverModal(box, lines) { + let objectModal = null; + + box + .on("pointerover", () => { + objectModal = createObjectModal(lines, box.width); + const objectModalWidth = parseInt(objectModal.width); + const boxWidth = parseInt(box.width); + const x = parseInt(box.position.x); + const xPosition = (boxWidth - objectModalWidth) / 2 + x; + const y = box.position.y; + + renderObjectModal(objectModal, xPosition, y); + + box.on("pointerdown", () => { + removeObjectModal(objectModal); + }); + }) + .on("pointerout", () => { + removeObjectModal(objectModal); + }); +} + export function addTitleToBox(title, box) { const boxTitle = createText(title, { fontFamily: "sans-serif", @@ -49,26 +100,22 @@ export function addTitleToBox(title, box) { fontWeight: "bold", }); box.addChild(boxTitle); - boxTitle.position.set((box.width - boxTitle.width) / 2, TOP_MARGIN); + boxTitle.position.set((box.width - boxTitle.width) / 2, MARGIN); return boxTitle.position.y + boxTitle.height + 12; } export function addLinesToBox(lines, box, y) { - let prevY = y; - lines.forEach((line) => { - const boxLine = createText(line, { - fontFamily: "sans-serif", - fontSize: 16, - align: "center", - fill: "black", - fontWeight: "normal", - }); - box.addChild(boxLine); - boxLine.position.set((box.width - boxLine.width) / 2, prevY); - prevY = boxLine.position.y + boxLine.height; + const text = createText(lines.join("\n"), { + fontFamily: "sans-serif", + fontSize: 16, + fontWeight: "normal", + align: "center", + fill: "black", + width: box.width, }); - - return prevY; + box.addChild(text); + text.position.set((box.width - text.width) / 2, y); + return text.position.y + text.height; } export async function svgElementToPixiSprite(src) { diff --git a/js/types/objects.js b/js/types/objects.js index d499c54a..886d2785 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -9,6 +9,7 @@ import { addLinesToBox, svgElementToPixiSprite, addImageToBox, + addHoverModal, } from "../draw/box.js"; import { textToSVG } from "../lib/generate-svg.js"; @@ -34,6 +35,47 @@ class EDMObject { addBox(box); box.position.set(this.x, this.y); const nextY = addTitleToBox(this.constructor.name, box); + + box.cursor = "pointer"; + box.eventMode = "static"; + + let prevX = box.x + box.width / 2; + let prevY = box.y + box.height / 2; + + box + .on( + "pointerdown", + function () { + this.on( + "pointermove", + function (event) { + const container = box.parent; + + const eventX = container.toLocal(event.data.global).x; + const eventY = container.toLocal(event.data.global).y; + + const deltaX = eventX - prevX; + const deltaY = eventY - prevY; + + this.position.x += deltaX; + this.position.y += deltaY; + prevX = eventX; + prevY = eventY; + }, + box + ); + }, + box + ) + .on( + "pointerup", + function () { + this.off("pointermove"); + }, + box + ); + + addHoverModal(box, this.objectModalLines()); return [box, nextY]; } @@ -55,11 +97,9 @@ class EDMObject { ); } - showObjectTip(ctx) { - const x = this.x; - const y = this.y - 10; + objectModalLines() { const collectionName = "Collection: " + this.collectionName; - drawObjectInfoTip(ctx, x, y, collectionName); + return [collectionName]; } } @@ -115,15 +155,12 @@ export class MCParticle extends EDMObject { addLinesToBox(bottomLines, box, nextY); } - showObjectTip(ctx) { - const x = this.x; - const y = this.y - 10; + objectModalLines() { const collectionName = "Collection: " + this.collectionName; const simulatorStatus = getSimStatusDisplayValuesFromBit( this.simulatorStatus ); - - drawObjectInfoTip(ctx, x, y, collectionName, ...simulatorStatus); + return [collectionName, ...simulatorStatus]; } static setup(mcCollection) { From 594aa6f288596f865b3c871059b0972006321549 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 19 Jul 2024 20:53:19 -0500 Subject: [PATCH 09/32] mcparticle drawing almost done, much better performance, manages cld full sim file very well --- js/draw/link.js | 103 ++++++++++++++++++++++++++++++++++++++------ js/draw/render.js | 16 +++---- js/types/objects.js | 1 + 3 files changed, 99 insertions(+), 21 deletions(-) diff --git a/js/draw/link.js b/js/draw/link.js index 0913e913..8137383b 100644 --- a/js/draw/link.js +++ b/js/draw/link.js @@ -1,11 +1,11 @@ import { Graphics } from "../pixi.min.mjs"; import { getContainer } from "./app.js"; -export function drawBezierLink(link) { - const curve = new Graphics(); +function fromPoints(boxFrom) { + return [boxFrom.x + boxFrom.width / 2, boxFrom.y + boxFrom.height]; +} - const boxFrom = link.from; - const boxTo = link.to; +function toPoints(boxFrom, boxTo) { const fromX = boxFrom.x + boxFrom.width / 2; const fromY = boxFrom.y + boxFrom.height; const toX = boxTo.x + boxTo.width / 2; @@ -27,18 +27,95 @@ export function drawBezierLink(link) { cpFromX = (3 * (fromX - toX)) / 4 + toX; cpToX = (fromX - toX) / 4 + toX; } + return [cpFromX, cpFromY, cpToX, cpToY, toX, toY]; +} + +function bezierCurve({ + fromX, + fromY, + cpFromX, + cpFromY, + cpToX, + cpToY, + toX, + toY, + color, +}) { + const curve = new Graphics(); + curve.moveTo(fromX, fromY); + curve.bezierCurveTo(cpFromX, cpFromY, cpToX, cpToY, toX, toY); + curve.stroke({ width: 2, color }); + return curve; +} - curve.moveTo(fromX + link.xShift, fromY); - curve.bezierCurveTo( - cpFromX + link.xShift, - cpFromY, - cpToX + link.xShift, - cpToY, - toX + link.xShift, - toY +export function drawBezierLink(link) { + const [fromX, fromY] = fromPoints(link.from); + const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( + link.from, + link.to ); - curve.stroke({ width: 2, color: link.color }); + + let curve = bezierCurve({ + fromX: fromX + link.xShift, + fromY: fromY, + cpFromX: cpFromX + link.xShift, + cpFromY: cpFromY, + cpToX: cpToX + link.xShift, + cpToY: cpToY, + toX: toX + link.xShift, + toY: toY, + color: link.color, + }); + + const boxFrom = link.from.renderedBox; + const boxTo = link.to.renderedBox; const container = getContainer(); + boxFrom.on("pointerdown", () => { + boxFrom.on("pointermove", () => { + container.removeChild(curve); + const [fromX, fromY] = fromPoints(boxFrom); + const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( + boxFrom, + boxTo + ); + curve = bezierCurve({ + fromX: fromX + link.xShift, + fromY: fromY, + cpFromX: cpFromX + link.xShift, + cpFromY: cpFromY, + cpToX: cpToX + link.xShift, + cpToY: cpToY, + toX: toX + link.xShift, + toY: toY, + color: link.color, + }); + container.addChild(curve); + }); + }); + + boxTo.on("pointerdown", () => { + boxTo.on("pointermove", () => { + container.removeChild(curve); + const [fromX, fromY] = fromPoints(boxFrom); + const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( + boxFrom, + boxTo + ); + curve = bezierCurve({ + fromX: fromX + link.xShift, + fromY: fromY, + cpFromX: cpFromX + link.xShift, + cpFromY: cpFromY, + cpToX: cpToX + link.xShift, + cpToY: cpToY, + toX: toX + link.xShift, + toY: toY, + color: link.color, + }); + container.addChild(curve); + }); + }); + container.addChild(curve); } diff --git a/js/draw/render.js b/js/draw/render.js index d3f543c2..dee61bff 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -2,15 +2,13 @@ export async function renderObjects(objects) { const datatypes = objects.datatypes; const associations = objects.associations; - for (const collection of Object.values(associations)) { - for (const association of collection) { - association.draw(); - } - } - for (const elements of Object.values(datatypes)) { const { collection, oneToMany, oneToOne } = elements; + for (const object of collection) { + await object.draw(); + } + for (const links of Object.values(oneToMany)) { for (const link of links) { link.draw(); @@ -22,9 +20,11 @@ export async function renderObjects(objects) { link.draw(); } } + } - for (const object of collection) { - await object.draw(); + for (const collection of Object.values(associations)) { + for (const association of collection) { + association.draw(); } } } diff --git a/js/types/objects.js b/js/types/objects.js index 886d2785..d4cd81e7 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -32,6 +32,7 @@ class EDMObject { async draw() { const box = buildBox(this); + this.renderedBox = box; addBox(box); box.position.set(this.x, this.y); const nextY = addTitleToBox(this.constructor.name, box); From 2ac5a116ca624f92adbd845664e7386803be779d Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Sat, 20 Jul 2024 17:38:33 -0500 Subject: [PATCH 10/32] a few optimizations --- js/draw/app.js | 15 ++++++++++++++- js/draw/box.js | 22 +++++++++++++++++----- js/types/objects.js | 2 ++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/js/draw/app.js b/js/draw/app.js index b978ca0b..002f1cda 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,4 +1,4 @@ -import { Application, Container } from "../pixi.min.mjs"; +import { Application, Container, Culler } from "../pixi.min.mjs"; const SPEED = 0.5; const MARGIN = 100; @@ -16,6 +16,10 @@ const createApp = async () => { antialias: false, useContextAlpha: false, resizeTo: window, + preference: "webgpu", + webgpu: { + powerPreference: "high-performance", + }, }); document.body.appendChild(app.canvas); @@ -62,6 +66,15 @@ const createContainer = (app) => { isRenderGroup: true, }); pixi.container = container; + + const culler = new Culler(); + culler.cull(container, { + x: 0, + y: 0, + width: app.renderer.width, + height: app.renderer.height, + }); + app.stage.addChild(container); }; diff --git a/js/draw/box.js b/js/draw/box.js index 327a8a9a..fcbb1c8d 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -1,5 +1,5 @@ import { Graphics, Assets, Sprite, Text, TextStyle } from "../pixi.min.mjs"; -import { getContainer, getElements } from "./app.js"; +import { getApp, getContainer, getElements } from "./app.js"; const MARGIN = 20; const PADDING = 5; @@ -35,6 +35,7 @@ function createObjectModal(lines) { box.fill("#f1f1f1"); box.stroke({ width: 1, color: "#000000" }); box.addChild(text); + box.zIndex = 2; text.position.set((box.width - text.width) / 2, MARGIN); return box; @@ -60,11 +61,22 @@ export function addBox(box) { elements.push(box); } +const boxes = {}; + export function buildBox(object) { - const box = new Graphics(); - box.roundRect(0, 0, object.width, object.height, object.radius); - box.fill(object.color); - box.stroke({ width: 2, color: "#000000" }); + const key = `${object.width}-${object.height}-${object.color}-${object.radius}`; + + if (boxes[key] === undefined) { + const box = new Graphics(); + box.roundRect(0, 0, object.width, object.height, object.radius); + box.fill(object.color); + box.stroke({ width: 2, color: "#000000" }); + const app = getApp(); + const texture = app.renderer.generateTexture(box); + boxes[key] = texture; + } + + const box = new Sprite(boxes[key]); return box; } diff --git a/js/types/objects.js b/js/types/objects.js index d4cd81e7..67de3e2f 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -33,6 +33,8 @@ class EDMObject { async draw() { const box = buildBox(this); this.renderedBox = box; + box.zIndex = 1; + box.interactiveChildren = false; addBox(box); box.position.set(this.x, this.y); const nextY = addTitleToBox(this.constructor.name, box); From bc4d5b5fd3c51244d1084a8fa381617699805e6e Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Sat, 20 Jul 2024 19:14:11 -0500 Subject: [PATCH 11/32] pixi migration for other objects --- js/draw/scroll.js | 9 ++++-- js/event-number.js | 4 +-- js/main.js | 20 ++++++------ js/types/links.js | 18 +++++------ js/types/objects.js | 55 ++++++++++---------------------- js/views/association-view.js | 5 ++- js/views/clustertree.js | 2 +- js/views/list.js | 5 +-- js/views/mcclusterassociation.js | 2 +- js/views/mcrecoassociation.js | 5 ++- js/views/mctrackassociation.js | 5 ++- js/views/onewayview.js | 5 ++- js/views/particleidlist.js | 2 +- js/views/recoclustertrack.js | 4 +-- js/views/recoparticleid.js | 2 +- js/views/recoparticletree.js | 2 +- js/views/tracktree.js | 2 +- js/views/tree.js | 7 ++-- js/views/vertexlist.js | 2 +- js/views/views-dictionary.js | 22 ++++++------- js/views/views.js | 30 +++++++++-------- 21 files changed, 99 insertions(+), 109 deletions(-) diff --git a/js/draw/scroll.js b/js/draw/scroll.js index 5bcf6c5b..bc08cfaa 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -2,8 +2,13 @@ import { getContainer, getApp } from "./app.js"; export const scrollTopLeft = () => { const container = getContainer(); - container.x = 0; - container.y = 0; + const x = 0; + const y = 0; + + container.x = x; + container.y = y; + + return { x, y }; }; export const scrollTopCenter = () => { diff --git a/js/event-number.js b/js/event-number.js index 83b773ad..f0fe1ea2 100644 --- a/js/event-number.js +++ b/js/event-number.js @@ -45,12 +45,12 @@ function loadSelectedEvent() { } } -export function renderEvent(eventNumber) { +export async function renderEvent(eventNumber) { saveScrollLocation(); currentEvent.event = eventNumber; loadSelectedEvent(); updateEventNumber(); - drawCurrentView(); + await drawCurrentView(); } previousEvent.addEventListener("click", () => { diff --git a/js/main.js b/js/main.js index 3b566b3d..0611e6fc 100644 --- a/js/main.js +++ b/js/main.js @@ -9,14 +9,14 @@ const jsonData = {}; const selectedObjectTypes = { types: [ "edm4hep::MCParticle", - // "edm4hep::ReconstructedParticle", - // "edm4hep::MCRecoParticleAssociation", - // "edm4hep::MCRecoTrackParticleAssociation", - // "edm4hep::MCRecoClusterParticleAssociation", - // "edm4hep::Cluster", - // "edm4hep::Track", - // "edm4hep::Vertex", - // "edm4hep::ParticleID", + "edm4hep::ReconstructedParticle", + "edm4hep::MCRecoParticleAssociation", + "edm4hep::MCRecoTrackParticleAssociation", + "edm4hep::MCRecoClusterParticleAssociation", + "edm4hep::Cluster", + "edm4hep::Track", + "edm4hep::Vertex", + "edm4hep::ParticleID", ], }; @@ -136,11 +136,11 @@ document await startPixi(); hideInputModal(); + hideDeploySwitch(); showEventSwitcher(); showViewsMenu(); - renderEvent(eventNum); selectViewInformation(); - hideDeploySwitch(); + await renderEvent(eventNum); }); export { jsonData, selectedObjectTypes }; diff --git a/js/types/links.js b/js/types/links.js index ed710760..9c4b90ed 100644 --- a/js/types/links.js +++ b/js/types/links.js @@ -82,9 +82,9 @@ class MCRecoParticleAssociation extends Link { this.weight = weight; } - draw(ctx) { - drawStraightLink(ctx, this); - } + // draw(ctx) { + // drawStraightLink(ctx, this); + // } } class Particles extends Link { @@ -122,9 +122,9 @@ class MCRecoTrackParticleAssociation extends Link { this.weight = weight; } - draw(ctx) { - drawStraightLink(ctx, this); - } + // draw(ctx) { + // drawStraightLink(ctx, this); + // } } class MCRecoClusterParticleAssociation extends Link { @@ -134,9 +134,9 @@ class MCRecoClusterParticleAssociation extends Link { this.weight = weight; } - draw(ctx) { - drawStraightLink(ctx, this); - } + // draw(ctx) { + // drawStraightLink(ctx, this); + // } } export const linkTypes = { diff --git a/js/types/objects.js b/js/types/objects.js index 67de3e2f..16b3f0fa 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -13,7 +13,6 @@ import { } from "../draw/box.js"; import { textToSVG } from "../lib/generate-svg.js"; -const TOP_MARGIN = 45; const IMAGE_MARGIN = 10; const IMAGE_HEIGHT = 30; @@ -67,6 +66,7 @@ class EDMObject { }, box ); + this.zIndex = 2; }, box ) @@ -74,6 +74,7 @@ class EDMObject { "pointerup", function () { this.off("pointermove"); + this.zIndex = 1; }, box ); @@ -256,29 +257,23 @@ class ReconstructedParticle extends EDMObject { this.radius = 30; } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); + async draw() { + let [box, nextY] = await super.draw(); - const topY = this.y + 1.5 * TOP_MARGIN; const lines = []; lines.push("ID: " + this.index); - const x = parseInt(this.momentum.x * 100) / 100; const y = parseInt(this.momentum.y * 100) / 100; const z = parseInt(this.momentum.z * 100) / 100; lines.push(`p = (x=${x},`); lines.push(`y=${y},`); lines.push(`z=${z}) GeV`); - const energy = parseInt(this.energy * 100) / 100; lines.push("e = " + energy + " GeV"); - lines.push(parseCharge(this.charge)); - drawTextLines(ctx, lines, boxCenterX, topY, 23); + addLinesToBox(lines, box, nextY); } static setup(recoCollection) {} @@ -295,12 +290,9 @@ class Cluster extends EDMObject { this.radius = 20; } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); + async draw() { + const [box, nextY] = await super.draw(); - const topY = this.y + TOP_MARGIN; const lines = []; lines.push("ID: " + this.index); lines.push("type: " + this.type); @@ -313,7 +305,7 @@ class Cluster extends EDMObject { lines.push(`y=${y},`); lines.push(`z=${z}) mm`); - drawTextLines(ctx, lines, boxCenterX, topY, 23); + addLinesToBox(lines, box, nextY); } static setup(clusterCollection) {} @@ -328,12 +320,8 @@ class Track extends EDMObject { this.radius = 25; } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); - - const topY = this.y + TOP_MARGIN; + async draw() { + const [box, nextY] = await super.draw(); const lines = []; lines.push("ID: " + this.index); @@ -343,11 +331,10 @@ class Track extends EDMObject { const chiNdf = `${chi2}/${ndf}`; lines.push("chi2/ndf = " + chiNdf); lines.push("dEdx = " + this.dEdx); - const trackerHitsCount = this.oneToManyRelations["trackerHits"].length; lines.push("tracker hits: " + trackerHitsCount); - drawTextLines(ctx, lines, boxCenterX, topY, 23); + addLinesToBox(lines, box, nextY); } static setup(trackCollection) {} @@ -362,12 +349,8 @@ class ParticleID extends EDMObject { this.radius = 25; } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); - - const topY = this.y + TOP_MARGIN; + async draw() { + const [box, nextY] = await super.draw(); const lines = []; lines.push("ID: " + this.index); @@ -376,7 +359,7 @@ class ParticleID extends EDMObject { lines.push("algorithm: " + this.algorithmType); lines.push("likelihood: " + this.likelihood); - drawTextLines(ctx, lines, boxCenterX, topY, 23); + addLinesToBox(lines, box, nextY); } static setup(particleIDCollection) {} @@ -391,12 +374,8 @@ class Vertex extends EDMObject { this.radius = 25; } - draw(ctx) { - const boxCenterX = this.x + this.width / 2; - - super.draw(ctx); - - const topY = this.y + TOP_MARGIN; + async draw() { + const [box, nextY] = await super.draw(); const lines = []; lines.push("ID: " + this.index); @@ -411,7 +390,7 @@ class Vertex extends EDMObject { const chiNdf = `${chi2}/${ndf}`; lines.push("chi2/ndf = " + chiNdf); - drawTextLines(ctx, lines, boxCenterX, topY, 23); + addLinesToBox(lines, box, nextY); } static setup(vertexCollection) {} diff --git a/js/views/association-view.js b/js/views/association-view.js index ac0323aa..5da2a0b1 100644 --- a/js/views/association-view.js +++ b/js/views/association-view.js @@ -11,7 +11,6 @@ export function buildAssociationView(viewObjects, associationName) { const totalWidth = gap + fromWidth + toWidth; const width = totalWidth > window.innerWidth ? totalWidth : window.innerWidth; - canvas.width = width; const fromHeight = associations[0].from.height; const toHeight = associations[0].to.height; @@ -21,8 +20,6 @@ export function buildAssociationView(viewObjects, associationName) { const totalHeight = length * (height + verticalGap) + verticalGap; - canvas.height = totalHeight; - let accHeight = 0; const fromX = width / 2 - fromWidth - fromHorizontalGap; @@ -40,4 +37,6 @@ export function buildAssociationView(viewObjects, associationName) { association.to.y = toY; accHeight += height + verticalGap; }); + + return [width, totalHeight]; } diff --git a/js/views/clustertree.js b/js/views/clustertree.js index e38432c3..353fd026 100644 --- a/js/views/clustertree.js +++ b/js/views/clustertree.js @@ -5,7 +5,7 @@ export function clusterTree(viewCurrentObjects) { const clusterCollection = viewCurrentObjects.datatypes["edm4hep::Cluster"].collection ?? []; - buildTree(clusterCollection, "clusters"); + return buildTree(clusterCollection, "clusters"); } export function preFilterClusterTree(currentObjects, viewObjects) { diff --git a/js/views/list.js b/js/views/list.js index 6bad53ae..caef9ab2 100644 --- a/js/views/list.js +++ b/js/views/list.js @@ -1,6 +1,5 @@ export function listView(collection) { const width = window.innerWidth; - canvas.width = width; const gap = 1; const objWidth = collection[0].width; @@ -12,7 +11,7 @@ export function listView(collection) { const rows = Math.ceil(collection.length / cols); const height = rows * (objHeight + objVerticalGap / 2) + objVerticalGap / 2; - canvas.height = height > window.innerHeight ? height : window.innerHeight; + const finalHeight = height > window.innerHeight ? height : window.innerHeight; for (let i = 0; i < collection.length; i++) { const x = (i % cols) * objWidth + (((i % cols) + 1) * objHorizontalGap) / 2; @@ -23,4 +22,6 @@ export function listView(collection) { collection[i].x = x; collection[i].y = y; } + + return [width, finalHeight]; } diff --git a/js/views/mcclusterassociation.js b/js/views/mcclusterassociation.js index 1558072c..31f606b1 100644 --- a/js/views/mcclusterassociation.js +++ b/js/views/mcclusterassociation.js @@ -2,7 +2,7 @@ import { preFilterAssociation } from "./pre-filter.js"; import { buildAssociationView } from "./association-view.js"; export function mcClusterAssociation(viewObjects) { - buildAssociationView( + return buildAssociationView( viewObjects, "edm4hep::MCRecoClusterParticleAssociation" ); diff --git a/js/views/mcrecoassociation.js b/js/views/mcrecoassociation.js index 9c3b5306..b37cc1e4 100644 --- a/js/views/mcrecoassociation.js +++ b/js/views/mcrecoassociation.js @@ -2,7 +2,10 @@ import { preFilterAssociation } from "./pre-filter.js"; import { buildAssociationView } from "./association-view.js"; export function mcRecoAssociation(viewObjects) { - buildAssociationView(viewObjects, "edm4hep::MCRecoParticleAssociation"); + return buildAssociationView( + viewObjects, + "edm4hep::MCRecoParticleAssociation" + ); } export function preFilterMCReco(currentObjects, viewObjects) { diff --git a/js/views/mctrackassociation.js b/js/views/mctrackassociation.js index f9d6bde0..eda54ce8 100644 --- a/js/views/mctrackassociation.js +++ b/js/views/mctrackassociation.js @@ -2,7 +2,10 @@ import { preFilterAssociation } from "./pre-filter.js"; import { buildAssociationView } from "./association-view.js"; export function mcTrackAssociation(viewObjects) { - buildAssociationView(viewObjects, "edm4hep::MCRecoTrackParticleAssociation"); + return buildAssociationView( + viewObjects, + "edm4hep::MCRecoTrackParticleAssociation" + ); } export function preFilterMCTrack(currentObjects, viewObjects) { diff --git a/js/views/onewayview.js b/js/views/onewayview.js index 6043a1ca..3bcd1b4c 100644 --- a/js/views/onewayview.js +++ b/js/views/onewayview.js @@ -13,7 +13,6 @@ export function oneWayView(viewObjects, fromCollectionName, relationName) { const totalWidth = gap + fromWidth + toWidth; const width = totalWidth > window.innerWidth ? totalWidth : window.innerWidth; - canvas.width = width; const fromHeight = fromCollection[0].height; const toHeight = toCollection[0].height; @@ -24,8 +23,6 @@ export function oneWayView(viewObjects, fromCollectionName, relationName) { const totalHeight = fromCollection.length * (height + verticalGap) + verticalGap; - canvas.height = totalHeight; - let accHeight = 0; const fromX = width / 2 - fromWidth - fromHorizontalGap; @@ -41,4 +38,6 @@ export function oneWayView(viewObjects, fromCollectionName, relationName) { toCollection[i].y = accHeight + space / 2 - toHeight / 2; accHeight += height + verticalGap; } + + return [width, totalHeight]; } diff --git a/js/views/particleidlist.js b/js/views/particleidlist.js index c3c13cb6..757adeec 100644 --- a/js/views/particleidlist.js +++ b/js/views/particleidlist.js @@ -5,7 +5,7 @@ export function particleIDList(viewCurrentObjects) { const vertexCollection = viewCurrentObjects.datatypes["edm4hep::ParticleID"].collection ?? []; - listView(vertexCollection); + return listView(vertexCollection); } export function preFilterParticleIDList(currentObjects, viewObjects) { diff --git a/js/views/recoclustertrack.js b/js/views/recoclustertrack.js index 0e71d890..40d95cbe 100644 --- a/js/views/recoclustertrack.js +++ b/js/views/recoclustertrack.js @@ -58,8 +58,6 @@ export function recoClusterTrackVertex(viewObjects) { ? totalHorizontalGap : window.innerWidth; - canvas.width = width; - const recoX = width / 2 - recoWidth; const otherX = width / 2 + widestGap; @@ -118,7 +116,7 @@ export function recoClusterTrackVertex(viewObjects) { totalHeight += height; }); - canvas.height = totalHeight; + return [width, totalHeight]; } export function preFilterRecoClusterTrackVertex(currentObjects, viewObjects) { diff --git a/js/views/recoparticleid.js b/js/views/recoparticleid.js index e145b9de..9643961e 100644 --- a/js/views/recoparticleid.js +++ b/js/views/recoparticleid.js @@ -2,7 +2,7 @@ import { preFilterOneWay } from "./pre-filter.js"; import { oneWayView } from "./onewayview.js"; export function recoParticleID(viewObjects) { - oneWayView(viewObjects, "edm4hep::ParticleID", "particle"); + return oneWayView(viewObjects, "edm4hep::ParticleID", "particle"); } export function preFilterRecoParticleID(currentObjects, viewObjects) { diff --git a/js/views/recoparticletree.js b/js/views/recoparticletree.js index a578a90a..423f2884 100644 --- a/js/views/recoparticletree.js +++ b/js/views/recoparticletree.js @@ -6,7 +6,7 @@ export function recoParticleTree(viewCurrentObjects) { viewCurrentObjects.datatypes["edm4hep::ReconstructedParticle"].collection ?? []; - buildTree(recoCollection, "particles"); + return buildTree(recoCollection, "particles"); } export function preFilterRecoTree(currentObjects, viewObjects) { diff --git a/js/views/tracktree.js b/js/views/tracktree.js index 6ff0ff36..19ce03b5 100644 --- a/js/views/tracktree.js +++ b/js/views/tracktree.js @@ -5,7 +5,7 @@ export function trackTree(viewCurrentObjects) { const trackCollection = viewCurrentObjects.datatypes["edm4hep::Track"].collection ?? []; - buildTree(trackCollection, "tracks"); + return buildTree(trackCollection, "tracks"); } export function preFilterTrackTree(currentObjects, viewObjects) { diff --git a/js/views/tree.js b/js/views/tree.js index b62aec46..40a57d75 100644 --- a/js/views/tree.js +++ b/js/views/tree.js @@ -66,12 +66,13 @@ export function buildTree(collection, relationOfReference) { const totalWidth = boxWidth * matrix[0].length + horizontalGap * (matrix[0].length + 1); - canvas.width = - totalWidth > window.innerWidth ? totalWidth : window.innerWidth; + const width = totalWidth > window.innerWidth ? totalWidth : window.innerWidth; const totalHeight = boxHeight * (matrix.length + 1) + verticalGap * (matrix.length + 2); - canvas.height = + const height = totalHeight > window.innerHeight ? totalHeight : window.innerHeight; + + return [width, height]; } diff --git a/js/views/vertexlist.js b/js/views/vertexlist.js index 59962c5f..5554694e 100644 --- a/js/views/vertexlist.js +++ b/js/views/vertexlist.js @@ -5,7 +5,7 @@ export function vertexList(viewCurrentObjects) { const vertexCollection = viewCurrentObjects.datatypes["edm4hep::Vertex"].collection ?? []; - listView(vertexCollection); + return listView(vertexCollection); } export function preFilterVertexList(currentObjects, viewObjects) { diff --git a/js/views/views-dictionary.js b/js/views/views-dictionary.js index 833e3f3d..0a3900c6 100644 --- a/js/views/views-dictionary.js +++ b/js/views/views-dictionary.js @@ -18,7 +18,7 @@ import { vertexList, preFilterVertexList } from "./vertexlist.js"; import { particleIDList, preFilterParticleIDList } from "./particleidlist.js"; import { recoParticleID, preFilterRecoParticleID } from "./recoparticleid.js"; import { spanWithColor } from "../lib/html-string.js"; -import { scrollTopCenter } from "../draw/scroll.js"; +import { scrollTopCenter, scrollTopLeft } from "../draw/scroll.js"; export const views = { "Monte Carlo Particle Tree": { @@ -37,7 +37,7 @@ export const views = { "Reconstructed Particle Tree": { filters: setupNoFilter, viewFunction: recoParticleTree, - scrollFunction: null, + scrollFunction: scrollTopLeft, preFilterFunction: preFilterRecoTree, description: `

A tree of the Reconstructed Particles. ${spanWithColor( "Purple", @@ -47,21 +47,21 @@ export const views = { "Track Tree": { filters: setupNoFilter, viewFunction: trackTree, - scrollFunction: null, + scrollFunction: scrollTopLeft, preFilterFunction: preFilterTrackTree, description: `

A tree of the Tracks.

`, }, "Cluster Tree": { filters: setupNoFilter, viewFunction: clusterTree, - scrollFunction: null, + scrollFunction: scrollTopLeft, preFilterFunction: preFilterClusterTree, description: `

A tree of the Clusters.

`, }, "RecoParticle-Cluster-Track-Vertex": { filters: setupNoFilter, viewFunction: recoClusterTrackVertex, - scrollFunction: null, + scrollFunction: scrollTopCenter, preFilterFunction: preFilterRecoClusterTrackVertex, description: `

Relations that a Reconstruced Particle has with other objects. ${spanWithColor( "Green", @@ -74,42 +74,42 @@ export const views = { "Monte Carlo-Reconstructed Particle": { filters: setupNoFilter, viewFunction: mcRecoAssociation, - scrollFunction: null, + scrollFunction: scrollTopCenter, preFilterFunction: preFilterMCReco, description: `

Association between Monte Carlo Particles and Reconstructed Particles. 1:1 relation.

`, }, "Monte Carlo Particle-Track": { filters: setupNoFilter, viewFunction: mcTrackAssociation, - scrollFunction: null, + scrollFunction: scrollTopCenter, preFilterFunction: preFilterMCTrack, description: `

Association between Monte Carlo Particles and Tracks. 1:1 relation.

`, }, "Monte Carlo Particle-Cluster": { filters: setupNoFilter, viewFunction: mcClusterAssociation, - scrollFunction: null, + scrollFunction: scrollTopCenter, preFilterFunction: preFilterMCCluster, description: `

Association between Monte Carlo Particles and Clusters. 1:1 relation.

`, }, "ParticleID List": { filters: setupNoFilter, viewFunction: particleIDList, - scrollFunction: null, + scrollFunction: scrollTopLeft, preFilterFunction: preFilterParticleIDList, description: `

A list of ParticleIDs found in the event.

`, }, "Vertex List": { filters: setupNoFilter, viewFunction: vertexList, - scrollFunction: null, + scrollFunction: scrollTopLeft, preFilterFunction: preFilterVertexList, description: `

A list of Vertices found in the event.

`, }, "ParticleID-Reconstructed Particle": { filters: setupNoFilter, viewFunction: recoParticleID, - scrollFunction: null, + scrollFunction: scrollTopCenter, preFilterFunction: preFilterRecoParticleID, description: `

1:1 relation from ParticleID to Reconstructed Particle.

`, }, diff --git a/js/views/views.js b/js/views/views.js index 9f2443c6..69878fc7 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -5,7 +5,7 @@ import { views } from "./views-dictionary.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; -import { setContainerSize } from "../draw/app.js"; +import { getContainer, setContainerSize } from "../draw/app.js"; const currentView = {}; @@ -38,7 +38,8 @@ function setInfoButtonName(view) { } const drawView = async (view) => { - paintButton(view); + const container = getContainer(); + container.removeChildren(); const { preFilterFunction, @@ -49,9 +50,8 @@ const drawView = async (view) => { } = views[view]; const viewObjects = {}; - const viewCurrentObjects = {}; - preFilterFunction(currentObjects, viewObjects); + paintButton(view); const isEmpty = checkEmptyObject(viewObjects); if (isEmpty) { @@ -59,12 +59,19 @@ const drawView = async (view) => { hideViewInformation(); return; } + showViewInformation(view, description); + setInfoButtonName(getView()); hideEmptyViewMessage(); + + const viewCurrentObjects = {}; + copyObject(viewObjects, viewCurrentObjects); + const [width, height] = viewFunction(viewObjects); setContainerSize(width, height); - copyObject(viewObjects, viewCurrentObjects); + await renderObjects(viewObjects); + scrollFunction(); // const scrollIndex = getViewScrollIndex(); // if (scrollLocations[scrollIndex] === undefined) { @@ -72,9 +79,6 @@ const drawView = async (view) => { // scrollLocations[scrollIndex] = viewScrollLocation; // } - await renderObjects(viewObjects); - scrollFunction(); - setInfoButtonName(getView()); // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); }; @@ -95,8 +99,8 @@ export const getView = () => { return currentView.view; }; -export const drawCurrentView = () => { - drawView(currentView.view); +export const drawCurrentView = async () => { + await drawView(currentView.view); }; const buttons = []; @@ -104,10 +108,8 @@ const buttons = []; for (const key in views) { const button = document.createElement("button"); button.appendChild(document.createTextNode(key)); - button.onclick = () => { - saveScrollLocation(); - setView(key); - drawView(key); + button.onclick = async () => { + await drawView(key); }; button.className = "view-button"; buttons.push(button); From b4b36957e9cd3c7dc8d85f59e45288c4caab050d Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Sat, 20 Jul 2024 21:05:35 -0500 Subject: [PATCH 12/32] eede using pixi, big performance improve, but might be further improved. A few bugs into --- js/draw.js | 24 -------- js/draw/add-link.js | 0 js/draw/app.js | 11 +--- js/draw/box.js | 10 ++-- js/draw/link.js | 1 + js/draw/render.js | 1 + js/event-number.js | 4 +- js/filter/mcparticle.js | 1 - js/lib/generate-svg.js | 8 ++- js/lib/graphic-primitives.js | 112 ----------------------------------- js/main.js | 2 +- js/menu/filter/filter.js | 1 - js/types/links.js | 30 ---------- js/types/objects.js | 26 ++------ js/views/views.js | 40 ++++++++++--- 15 files changed, 53 insertions(+), 218 deletions(-) delete mode 100644 js/draw.js delete mode 100644 js/draw/add-link.js delete mode 100644 js/lib/graphic-primitives.js diff --git a/js/draw.js b/js/draw.js deleted file mode 100644 index 36dd4f80..00000000 --- a/js/draw.js +++ /dev/null @@ -1,24 +0,0 @@ -export function drawAll(loadedObjects) { - emptyCanvas(); - draw(loadedObjects); -} - -export function drawVisible(visibleObjects) { - emptyVisibleCanvas(); - draw(visibleObjects); -} - -export function emptyCanvas() { - // updateCanvas(null, 0, 0, canvas.width, canvas.height); -} - -function emptyVisibleCanvas() { - // const boundigClientRect = canvas.getBoundingClientRect(); - // updateCanvas( - // null, - // 0 - boundigClientRect.x, - // 0 - boundigClientRect.y, - // window.innerWidth, - // window.innerHeight - // ); -} diff --git a/js/draw/add-link.js b/js/draw/add-link.js deleted file mode 100644 index e69de29b..00000000 diff --git a/js/draw/app.js b/js/draw/app.js index 002f1cda..f3be008d 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -6,7 +6,6 @@ const MARGIN = 100; const pixi = { app: null, container: null, - elements: [], }; const createApp = async () => { @@ -27,7 +26,7 @@ const createApp = async () => { }; const addScroll = (app) => { - const container = pixi.container; + const container = getContainer(); const renderer = app.renderer; container.x = 0; @@ -61,7 +60,7 @@ const addScroll = (app) => { }); }; -const createContainer = (app) => { +export const createContainer = (app) => { const container = new Container({ isRenderGroup: true, }); @@ -76,6 +75,7 @@ const createContainer = (app) => { }); app.stage.addChild(container); + addScroll(app); }; export const setContainerSize = (width, height) => { @@ -92,13 +92,8 @@ export const getContainer = () => { return pixi.container; }; -export const getElements = () => { - return pixi.elements; -}; - export const startPixi = async () => { const app = await createApp(); createContainer(app); - addScroll(app); pixi.app = app; }; diff --git a/js/draw/box.js b/js/draw/box.js index fcbb1c8d..198b9aea 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -1,5 +1,5 @@ import { Graphics, Assets, Sprite, Text, TextStyle } from "../pixi.min.mjs"; -import { getApp, getContainer, getElements } from "./app.js"; +import { getApp, getContainer } from "./app.js"; const MARGIN = 20; const PADDING = 5; @@ -55,10 +55,8 @@ function removeObjectModal(objectModal) { } export function addBox(box) { - const elements = getElements(); const container = getContainer(); container.addChild(box); - elements.push(box); } const boxes = {}; @@ -130,11 +128,11 @@ export function addLinesToBox(lines, box, y) { return text.position.y + text.height; } -export async function svgElementToPixiSprite(src) { +export async function svgElementToPixiSprite(src, size) { const asset = await Assets.load(src); const sprite = Sprite.from(asset); - sprite.width = 50; - sprite.height = 50; + sprite.width = size; + sprite.height = size; return sprite; } diff --git a/js/draw/link.js b/js/draw/link.js index 8137383b..0335a80a 100644 --- a/js/draw/link.js +++ b/js/draw/link.js @@ -71,6 +71,7 @@ export function drawBezierLink(link) { const boxTo = link.to.renderedBox; const container = getContainer(); + boxFrom.on("pointerdown", () => { boxFrom.on("pointermove", () => { container.removeChild(curve); diff --git a/js/draw/render.js b/js/draw/render.js index dee61bff..7659a373 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -6,6 +6,7 @@ export async function renderObjects(objects) { const { collection, oneToMany, oneToOne } = elements; for (const object of collection) { + object.renderedBox = null; await object.draw(); } diff --git a/js/event-number.js b/js/event-number.js index f0fe1ea2..83b773ad 100644 --- a/js/event-number.js +++ b/js/event-number.js @@ -45,12 +45,12 @@ function loadSelectedEvent() { } } -export async function renderEvent(eventNumber) { +export function renderEvent(eventNumber) { saveScrollLocation(); currentEvent.event = eventNumber; loadSelectedEvent(); updateEventNumber(); - await drawCurrentView(); + drawCurrentView(); } previousEvent.addEventListener("click", () => { diff --git a/js/filter/mcparticle.js b/js/filter/mcparticle.js index f29bb0bb..6fdf92d7 100644 --- a/js/filter/mcparticle.js +++ b/js/filter/mcparticle.js @@ -8,7 +8,6 @@ import { start, getWidthFilterContent, } from "../menu/filter/filter.js"; -import { drawAll } from "../draw.js"; const filter = document.getElementById("filter"); const filters = document.getElementById("filters"); diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js index 39088ed4..e240f637 100644 --- a/js/lib/generate-svg.js +++ b/js/lib/generate-svg.js @@ -1,9 +1,11 @@ -export async function textToSVG(text) { +const SCALE = 1.25; + +export async function textToSVG(text, size) { const mathjaxContainer = await MathJax.tex2svgPromise(text); const svg = mathjaxContainer.firstElementChild; - svg.setAttribute("width", "50px"); - svg.setAttribute("height", "50px"); + svg.setAttribute("width", `${parseInt(size * SCALE)}px`); + svg.setAttribute("height", `${parseInt(size * SCALE)}px`); const src = "data:image/svg+xml;base64," + diff --git a/js/lib/graphic-primitives.js b/js/lib/graphic-primitives.js deleted file mode 100644 index 121ea2af..00000000 --- a/js/lib/graphic-primitives.js +++ /dev/null @@ -1,112 +0,0 @@ -export function drawRoundedRect(ctx, x, y, width, height, fillColor, radius) { - // ctx.save(); - // ctx.fillStyle = fillColor; - // ctx.beginPath(); - // ctx.roundRect(x, y, width, height, radius); - // ctx.fill(); - // ctx.strokeStyle = "black"; - // ctx.lineWidth = 2; - // ctx.beginPath(); - // ctx.roundRect(x, y, width, height, radius); - // ctx.stroke(); - // ctx.restore(); -} - -export function drawTex(ctx, x, y, texImg, maxWidth) { - // let scale = (maxWidth * 0.9) / texImg.naturalWidth; - // if (scale > 2) { - // scale = 2; - // } - // const tempHeight = texImg.naturalHeight * scale; - // const tempWidth = texImg.naturalWidth * scale; - // ctx.save(); - // ctx.drawImage( - // texImg, - // x - tempWidth / 2, - // y - tempHeight / 2, - // tempWidth, - // tempHeight - // ); - // ctx.restore(); -} - -export function drawTextLines(ctx, lines, boxCenterX, y, n) { - // ctx.save(); - // ctx.font = "16px sans-serif"; - // for (const [i, lineText] of lines.entries()) { - // ctx.fillText( - // lineText, - // boxCenterX - ctx.measureText(lineText).width / 2, - // y + i * n - // ); - // } - // ctx.restore(); -} - -export function drawBezierLink(ctx, link) { - // ctx.save(); - // ctx.strokeStyle = link.color; - // ctx.lineWidth = 2; - // ctx.beginPath(); - // ctx.stroke(); - // ctx.restore(); -} - -export function drawStraightLink(ctx, link) { - // const boxFrom = link.from; - // const boxTo = link.to; - // const fromX = boxFrom.x + boxFrom.width / 2; - // const fromY = boxFrom.y + boxFrom.height / 2; - // const toX = boxTo.x + boxTo.width / 2; - // const toY = boxTo.y + boxTo.height / 2; - // ctx.save(); - // ctx.strokeStyle = link.color; - // ctx.lineWidth = 2; - // ctx.beginPath(); - // ctx.moveTo(fromX, fromY); - // ctx.lineTo(toX, toY); - // ctx.stroke(); - // ctx.restore(); -} - -export function updateCanvas(ctx, x, y, width, height) { - // ctx.clearRect(x, y, width, height); -} - -export function drawObjectHeader(ctx, object) { - // ctx.save(); - // ctx.font = "bold 16px sans-serif"; - // const text = object.constructor.name; - // const boxCenterX = object.x + object.width / 2; - // const textWidth = ctx.measureText(text).width; - // const x = boxCenterX - ctx.measureText(text).width / 2; - // const topY = object.y + 20; - // if (textWidth > object.width) { - // const lines = text.split(/(?=[A-Z])/); - // for (const [i, lineText] of lines.entries()) { - // ctx.fillText( - // lineText, - // boxCenterX - ctx.measureText(lineText).width / 2, - // topY + i * 20 - // ); - // } - // } else { - // ctx.fillText(text, x, topY); - // } - // ctx.restore(); -} - -export function drawObjectInfoTip(ctx, x, y, ...args) { - // ctx.save(); - // ctx.font = "bold 12px sans-serif"; - // const lines = args.length; - // const height = 20 * lines; - // const maxWidth = Math.max(...args.map((arg) => ctx.measureText(arg).width)); - // ctx.fillStyle = "rgba(225, 225, 225, 1)"; - // ctx.fillRect(x, y, maxWidth + 10, height + 10); - // ctx.fillStyle = "black"; - // for (const [i, arg] of args.entries()) { - // ctx.fillText(arg, x + 5, y + 20 + i * 20); - // } - // ctx.restore(); -} diff --git a/js/main.js b/js/main.js index 0611e6fc..5cf05095 100644 --- a/js/main.js +++ b/js/main.js @@ -140,7 +140,7 @@ document showEventSwitcher(); showViewsMenu(); selectViewInformation(); - await renderEvent(eventNum); + renderEvent(eventNum); }); export { jsonData, selectedObjectTypes }; diff --git a/js/menu/filter/filter.js b/js/menu/filter/filter.js index d9ba0744..2371ecab 100644 --- a/js/menu/filter/filter.js +++ b/js/menu/filter/filter.js @@ -1,4 +1,3 @@ -import { drawAll } from "../../draw.js"; import { CheckboxBuilder, BitFieldBuilder } from "./builders.js"; import { Range, Checkbox, buildCriteriaFunction } from "./parameters.js"; import { reconnect } from "./reconnect.js"; diff --git a/js/types/links.js b/js/types/links.js index 9c4b90ed..3f12e93d 100644 --- a/js/types/links.js +++ b/js/types/links.js @@ -1,4 +1,3 @@ -import { drawStraightLink } from "../lib/graphic-primitives.js"; import { drawBezierLink } from "../draw/link.js"; const colors = { @@ -24,35 +23,6 @@ export class Link { draw() { drawBezierLink(this); } - - isVisible(x, y, width, height) { - const boxFrom = this.from; - const boxTo = this.to; - - const fromX = boxFrom.x + boxFrom.width / 2; - const fromY = boxFrom.y + boxFrom.height; - const toX = boxTo.x + boxTo.width / 2; - const toY = boxTo.y; - - const boxX = Math.min(fromX, toX); - const boxWidth = Math.abs(fromX - toX); - const boxY = Math.min(fromY, toY); - const boxHeight = Math.abs(fromY - toY); - - /* - console.log("boxX: ", this.boxX); - console.log("boxY: ", this.boxY); - console.log("boxWidth: ", this.boxWidth); - console.log("boxHeight: ", this.boxHeight); - */ - - return ( - x + width > boxX && - x < boxX + boxWidth && - y + height > boxY && - y < boxY + boxHeight - ); - } } class ParentLink extends Link { diff --git a/js/types/objects.js b/js/types/objects.js index 16b3f0fa..c228f1b8 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -14,7 +14,7 @@ import { import { textToSVG } from "../lib/generate-svg.js"; const IMAGE_MARGIN = 10; -const IMAGE_HEIGHT = 30; +const IMAGE_SIZE = 40; class EDMObject { constructor() { @@ -83,24 +83,6 @@ class EDMObject { return [box, nextY]; } - isHere(mouseX, mouseY) { - return ( - mouseX > this.x && - mouseX < this.x + this.width && - mouseY > this.y && - mouseY < this.y + this.height - ); - } - - isVisible(x, y, width, height) { - return ( - x + width > this.x && - x < this.x + this.width && - y + height > this.y && - y < this.y + this.height - ); - } - objectModalLines() { const collectionName = "Collection: " + this.collectionName; return [collectionName]; @@ -139,15 +121,15 @@ export class MCParticle extends EDMObject { const imageY = nextY + IMAGE_MARGIN; - textToSVG(this.name) + textToSVG(this.name, IMAGE_SIZE) .then((src) => { - const sprite = svgElementToPixiSprite(src); + const sprite = svgElementToPixiSprite(src, IMAGE_SIZE); return sprite; }) .then((sprite) => addImageToBox(sprite, box, imageY)) .catch((e) => console.error("Error loading SVG: ", e)); - nextY += IMAGE_HEIGHT + 2 * IMAGE_MARGIN; + nextY += IMAGE_SIZE + 2 * IMAGE_MARGIN; const bottomLines = []; bottomLines.push("p = " + this.momentum + " GeV"); diff --git a/js/views/views.js b/js/views/views.js index 69878fc7..d6c03770 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -5,7 +5,12 @@ import { views } from "./views-dictionary.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; -import { getContainer, setContainerSize } from "../draw/app.js"; +import { + createContainer, + getApp, + getContainer, + setContainerSize, +} from "../draw/app.js"; const currentView = {}; @@ -37,10 +42,21 @@ function setInfoButtonName(view) { button.innerText = view; } -const drawView = async (view) => { - const container = getContainer(); - container.removeChildren(); +const addTask = (() => { + let pending = Promise.resolve(); + + const run = async (view) => { + try { + await pending; + } finally { + return drawView(view); + } + }; + return (view) => (pending = run(view)); +})(); + +const drawView = async (view) => { const { preFilterFunction, viewFunction, @@ -67,6 +83,14 @@ const drawView = async (view) => { const viewCurrentObjects = {}; copyObject(viewObjects, viewCurrentObjects); + // const container = getContainer(); + // container.destroy({ + // children: true, + // }); + const app = getApp(); + app.stage.removeChildren(); + createContainer(app); + const [width, height] = viewFunction(viewObjects); setContainerSize(width, height); @@ -99,8 +123,8 @@ export const getView = () => { return currentView.view; }; -export const drawCurrentView = async () => { - await drawView(currentView.view); +export const drawCurrentView = () => { + addTask(currentView.view); }; const buttons = []; @@ -108,8 +132,8 @@ const buttons = []; for (const key in views) { const button = document.createElement("button"); button.appendChild(document.createTextNode(key)); - button.onclick = async () => { - await drawView(key); + button.onclick = () => { + addTask(key); }; button.className = "view-button"; buttons.push(button); From ae645ccf49d50a01ee571329400675ad1ffdbb69 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Sat, 20 Jul 2024 21:08:47 -0500 Subject: [PATCH 13/32] update tests --- package.json | 2 +- test/objects.test.js | 117 ---------------------------------------- test/primitives.test.js | 72 ------------------------- 3 files changed, 1 insertion(+), 190 deletions(-) delete mode 100644 test/objects.test.js delete mode 100644 test/primitives.test.js diff --git a/package.json b/package.json index 6a61f5aa..4ecdd24f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "node ./model/index.js", "download": "node ./model/download.js", "update": "npm run download && npm run build", - "test": "echo 'temporarily disabled'" + "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js" }, "devDependencies": { "jest": "^29.7.0", diff --git a/test/objects.test.js b/test/objects.test.js deleted file mode 100644 index 31cdee92..00000000 --- a/test/objects.test.js +++ /dev/null @@ -1,117 +0,0 @@ -import { MCParticle } from "../js/types/objects"; -import { Link } from "../js/types/links"; - -describe("MCParticle", () => { - let mcParticle; - - beforeEach(() => { - mcParticle = new MCParticle(1); - mcParticle.x = 0; - mcParticle.y = 0; - }); - - afterEach(() => { - mcParticle = null; - }); - - it("should return true if (x, y) coordinates are within the box", () => { - const x = 60; - const y = 120; - - expect(mcParticle.isHere(x, y)).toBe(true); - }); - - it("should return false if x coordinate is outside the box", () => { - const x = 200; - const y = 120; - - expect(mcParticle.isHere(x, y)).toBe(false); - }); - - it("should return false if y coordinate is outside the box", () => { - const x = 50; - const y = -1; - - expect(mcParticle.isHere(x, y)).toBe(false); - }); - - it("should return true if box is visible within the given area", () => { - const x = 0; - const y = 0; - const width = 200; - const height = 200; - - expect(mcParticle.isVisible(x, y, width, height)).toBe(true); - }); - - it("should return false if the box is to the right of the area", () => { - mcParticle.x = 300; - const x = 0; - const y = 0; - const width = 200; - const height = 200; - - expect(mcParticle.isVisible(x, y, width, height)).toBe(false); - }); - - it("should return false if the box is to the left of the area", () => { - mcParticle.x = -300; - const x = 0; - const y = 0; - const width = 200; - const height = 200; - - expect(mcParticle.isVisible(x, y, width, height)).toBe(false); - }); - - it("should return false if the box is below the area", () => { - mcParticle.y = 300; - const x = 0; - const y = 0; - const width = 200; - const height = 200; - - expect(mcParticle.isVisible(x, y, width, height)).toBe(false); - }); - - it("should return false if the box is above the area", () => { - mcParticle.y = -300; - const x = 0; - const y = 0; - const width = 200; - const height = 200; - - expect(mcParticle.isVisible(x, y, width, height)).toBe(false); - }); -}); - -describe("Link", () => { - let link; - let firstObject, secondObject; - - beforeEach(() => { - firstObject = new MCParticle(0); - firstObject.x = 0; - firstObject.y = 0; - secondObject = new MCParticle(1); - secondObject.x = 0; - secondObject.y = 0; - link = new Link(firstObject, secondObject); - }); - - it("should construct correctly", () => { - expect(link.from).toBe(firstObject); - expect(link.to).toBe(secondObject); - }); - - it("should return true if the link is visible", () => { - secondObject.x = 140; - secondObject.y = 250; - - expect(link.isVisible(0, 0, 300, 300)).toBe(true); - }); - - it("should return false if the link is not visible", () => { - expect(link.isVisible(10, 10, 50, 50)).toBe(false); - }); -}); diff --git a/test/primitives.test.js b/test/primitives.test.js deleted file mode 100644 index 550f9999..00000000 --- a/test/primitives.test.js +++ /dev/null @@ -1,72 +0,0 @@ -import { jest } from "@jest/globals"; -import { drawRoundedRect, drawTex } from "../js/lib/graphic-primitives.js"; - -let ctx; - -beforeEach(() => { - ctx = { - save: jest.fn(), - fillStyle: null, - beginPath: jest.fn(), - roundRect: jest.fn(), - fill: jest.fn(), - strokeStyle: null, - lineWidth: null, - stroke: jest.fn(), - restore: jest.fn(), - drawImage: jest.fn(), - }; -}); - -afterEach(() => { - ctx = null; -}); - -describe("drawRoundedRect", () => { - it("should draw a rounded rectangle with the correct properties", () => { - drawRoundedRect(ctx, 10, 20, 100, 200, "red", 15); - - expect(ctx.save).toHaveBeenCalled(); - expect(ctx.fillStyle).toBe("red"); - expect(ctx.beginPath).toHaveBeenCalledTimes(2); - expect(ctx.roundRect).toHaveBeenCalledTimes(2); - expect(ctx.roundRect).toHaveBeenNthCalledWith(1, 10, 20, 100, 200, 15); - expect(ctx.roundRect).toHaveBeenNthCalledWith(2, 10, 20, 100, 200, 15); - expect(ctx.fill).toHaveBeenCalled(); - expect(ctx.strokeStyle).toBe("black"); - expect(ctx.lineWidth).toBe(2); - expect(ctx.stroke).toHaveBeenCalled(); - expect(ctx.restore).toHaveBeenCalled(); - }); -}); - -describe("drawTex", () => { - let texImg; - - beforeEach(() => { - texImg = { - naturalWidth: 200, - naturalHeight: 100, - }; - }); - - afterEach(() => { - texImg = null; - }); - - it("should draw an image with the correct properties", () => { - drawTex(ctx, 10, 20, texImg, 50); - - expect(ctx.save).toHaveBeenCalled(); - expect(ctx.drawImage).toHaveBeenCalledWith(texImg, -12.5, 8.75, 45, 22.5); - expect(ctx.restore).toHaveBeenCalled(); - }); - - it("should draw an image scaled to 2 if the scale is greater than 2", () => { - drawTex(ctx, 10, 20, texImg, 500); - - expect(ctx.save).toHaveBeenCalled(); - expect(ctx.drawImage).toHaveBeenCalledWith(texImg, -190, -80, 400, 200); - expect(ctx.restore).toHaveBeenCalled(); - }); -}); From 6b039ac6c5efad02920ffe088ed80fc433bac456 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Sun, 21 Jul 2024 22:14:05 -0500 Subject: [PATCH 14/32] correct rendenring order --- js/draw/render.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/draw/render.js b/js/draw/render.js index 7659a373..31215c29 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -2,14 +2,14 @@ export async function renderObjects(objects) { const datatypes = objects.datatypes; const associations = objects.associations; - for (const elements of Object.values(datatypes)) { - const { collection, oneToMany, oneToOne } = elements; - + for (const { collection } of Object.values(datatypes)) { for (const object of collection) { object.renderedBox = null; await object.draw(); } + } + for (const { oneToMany, oneToOne } of Object.values(datatypes)) { for (const links of Object.values(oneToMany)) { for (const link of links) { link.draw(); From bc740726d4033b4f9ede443cfe843666e4de0b6e Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Mon, 22 Jul 2024 16:29:14 -0500 Subject: [PATCH 15/32] recover vertical scrolling --- js/draw/app.js | 22 +++++++++++++--------- js/draw/scroll.js | 10 ++-------- js/views/views.js | 30 +++++++++++++++++------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/js/draw/app.js b/js/draw/app.js index f3be008d..f0f9968b 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,11 +1,13 @@ import { Application, Container, Culler } from "../pixi.min.mjs"; const SPEED = 0.5; -const MARGIN = 100; +const MARGIN = 0; const pixi = { app: null, container: null, + width: NaN, + height: NaN, }; const createApp = async () => { @@ -36,20 +38,17 @@ const addScroll = (app) => { const screenHeight = renderer.height; app.canvas.addEventListener("wheel", (e) => { - const deltaX = parseInt(e.deltaX) * SPEED; - const deltaY = parseInt(e.deltaY) * SPEED; + const deltaX = parseInt(e.deltaX * SPEED); + const deltaY = parseInt(e.deltaY * SPEED); const newXPosition = container.x - deltaX; const newYPosition = container.y - deltaY; - const absXPosition = Math.abs(newXPosition); - const absYPosition = Math.abs(newYPosition); - const isXInBounds = - newXPosition < 0 && absXPosition + screenWidth < container.width + MARGIN; + newXPosition < 0 && newXPosition > screenWidth - pixi.width; + const isYInBounds = - newYPosition < 0 && - absYPosition + screenHeight < container.height + MARGIN; + newYPosition < 0 && newYPosition > screenHeight - pixi.height; if (isXInBounds) { container.x = newXPosition; @@ -84,6 +83,11 @@ export const setContainerSize = (width, height) => { container.height = height; }; +export const saveSize = (width, height) => { + pixi.width = width; + pixi.height = height; +}; + export const getApp = () => { return pixi.app; }; diff --git a/js/draw/scroll.js b/js/draw/scroll.js index bc08cfaa..6081e232 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -1,27 +1,21 @@ -import { getContainer, getApp } from "./app.js"; +import { getApp, getContainer } from "./app.js"; export const scrollTopLeft = () => { - const container = getContainer(); const x = 0; const y = 0; - container.x = x; - container.y = y; - return { x, y }; }; export const scrollTopCenter = () => { - const container = getContainer(); const app = getApp(); + const container = getContainer(); const screenWidth = app.renderer.width; const containerWidth = container.width; const x = (screenWidth - containerWidth) / 2; const y = 0; - container.x = x; - container.y = y; return { x, y }; }; diff --git a/js/views/views.js b/js/views/views.js index d6c03770..a688f8f4 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -9,6 +9,7 @@ import { createContainer, getApp, getContainer, + saveSize, setContainerSize, } from "../draw/app.js"; @@ -33,8 +34,11 @@ function getViewScrollIndex() { } function scroll() { + const container = getContainer(); const index = getViewScrollIndex(); - window.scrollTo(scrollLocations[index].x, scrollLocations[index].y); + const { x, y } = scrollLocations[index]; + + container.position.set(x, y); } function setInfoButtonName(view) { @@ -83,35 +87,33 @@ const drawView = async (view) => { const viewCurrentObjects = {}; copyObject(viewObjects, viewCurrentObjects); - // const container = getContainer(); - // container.destroy({ - // children: true, - // }); const app = getApp(); app.stage.removeChildren(); createContainer(app); const [width, height] = viewFunction(viewObjects); setContainerSize(width, height); + saveSize(width, height); await renderObjects(viewObjects); - scrollFunction(); - // const scrollIndex = getViewScrollIndex(); - // if (scrollLocations[scrollIndex] === undefined) { - // const viewScrollLocation = scrollFunction(); - // scrollLocations[scrollIndex] = viewScrollLocation; - // } + const scrollIndex = getViewScrollIndex(); + if (scrollLocations[scrollIndex] === undefined) { + const viewScrollLocation = scrollFunction(); + scrollLocations[scrollIndex] = viewScrollLocation; + } + scroll(); // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); }; export function saveScrollLocation() { const index = getViewScrollIndex(); if (scrollLocations[index] === undefined) return; + const container = getContainer(); scrollLocations[index] = { - x: window.scrollX, - y: window.scrollY, + x: container.x, + y: container.y, }; } @@ -133,6 +135,8 @@ for (const key in views) { const button = document.createElement("button"); button.appendChild(document.createTextNode(key)); button.onclick = () => { + saveScrollLocation(); + setView(key); addTask(key); }; button.className = "view-button"; From 020e80fe0b9bff5ec04b59c2148d1cf51a18e9c2 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Mon, 22 Jul 2024 18:25:16 -0500 Subject: [PATCH 16/32] filters again --- index.html | 2 +- js/draw/app.js | 10 ++++------ js/draw/render.js | 15 +++++++++++---- js/draw/scroll.js | 6 +++--- js/filter/mcparticle.js | 27 ++++++++++++++------------- js/menu/filter/filter.js | 23 +++++++++-------------- js/menu/show-pdg.js | 38 ++++++++++++++++---------------------- js/menu/toggle.js | 20 ++++++++++++++++---- js/types/objects.js | 20 +++++++++++++------- js/views/views.js | 22 +++++----------------- 10 files changed, 92 insertions(+), 91 deletions(-) diff --git a/index.html b/index.html index ac520e4c..cb84b0ee 100644 --- a/index.html +++ b/index.html @@ -195,8 +195,8 @@

- + \ No newline at end of file diff --git a/js/draw/app.js b/js/draw/app.js index f0f9968b..6019cb2b 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -77,12 +77,6 @@ export const createContainer = (app) => { addScroll(app); }; -export const setContainerSize = (width, height) => { - const container = getContainer(); - container.width = width; - container.height = height; -}; - export const saveSize = (width, height) => { pixi.width = width; pixi.height = height; @@ -96,6 +90,10 @@ export const getContainer = () => { return pixi.container; }; +export const getContainerSize = () => { + return { width: pixi.width, height: pixi.height }; +}; + export const startPixi = async () => { const app = await createApp(); createContainer(app); diff --git a/js/draw/render.js b/js/draw/render.js index 31215c29..0e6ee40b 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -1,12 +1,17 @@ +import { getApp, createContainer } from "./app.js"; +import { scroll } from "../views/views.js"; + export async function renderObjects(objects) { + const app = getApp(); + app.stage.removeChildren(); + createContainer(app); + const datatypes = objects.datatypes; const associations = objects.associations; for (const { collection } of Object.values(datatypes)) { - for (const object of collection) { - object.renderedBox = null; - await object.draw(); - } + const renderPromises = collection.map((object) => object.draw()); + await Promise.all(renderPromises); } for (const { oneToMany, oneToOne } of Object.values(datatypes)) { @@ -28,4 +33,6 @@ export async function renderObjects(objects) { association.draw(); } } + + scroll(); } diff --git a/js/draw/scroll.js b/js/draw/scroll.js index 6081e232..edc851b5 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -1,4 +1,4 @@ -import { getApp, getContainer } from "./app.js"; +import { getApp, getContainerSize } from "./app.js"; export const scrollTopLeft = () => { const x = 0; @@ -9,10 +9,10 @@ export const scrollTopLeft = () => { export const scrollTopCenter = () => { const app = getApp(); - const container = getContainer(); + const { width } = getContainerSize(); const screenWidth = app.renderer.width; - const containerWidth = container.width; + const containerWidth = width; const x = (screenWidth - containerWidth) / 2; const y = 0; diff --git a/js/filter/mcparticle.js b/js/filter/mcparticle.js index 6fdf92d7..488725d2 100644 --- a/js/filter/mcparticle.js +++ b/js/filter/mcparticle.js @@ -1,4 +1,5 @@ -import { PdgToggle } from "../menu/show-pdg.js"; +import { Toggle } from "../menu/toggle.js"; +import { togglePDG, toggleId } from "../menu/show-pdg.js"; import { bits, genStatus, @@ -13,11 +14,7 @@ const filter = document.getElementById("filter"); const filters = document.getElementById("filters"); const manipulationTools = document.getElementsByClassName("manipulation-tool"); -export function setupMCParticleFilter( - viewObjects, - viewCurrentObjects, - viewVisibleObjects -) { +export function setupMCParticleFilter(viewObjects, viewCurrentObjects) { for (const tool of manipulationTools) { tool.style.display = "flex"; } @@ -35,12 +32,16 @@ export function setupMCParticleFilter( const width = getWidthFilterContent(); filter.style.width = width; - const pdgToggle = new PdgToggle("show-pdg"); - pdgToggle.init(() => { - pdgToggle.toggle(viewCurrentObjects, () => { - drawAll(viewCurrentObjects); - }); - }); - start(viewObjects, viewCurrentObjects, viewVisibleObjects); + const pdgToggle = new Toggle("show-pdg"); + pdgToggle.init( + () => { + toggleId(viewCurrentObjects); + }, + () => { + togglePDG(viewCurrentObjects); + } + ); + + start(viewObjects, viewCurrentObjects); } diff --git a/js/menu/filter/filter.js b/js/menu/filter/filter.js index 2371ecab..8b518ad9 100644 --- a/js/menu/filter/filter.js +++ b/js/menu/filter/filter.js @@ -4,6 +4,7 @@ import { reconnect } from "./reconnect.js"; import { units } from "../../types/units.js"; import { copyObject } from "../../lib/copy.js"; import { SimStatusBitFieldDisplayValues } from "../../../mappings/sim-status.js"; +import { renderObjects } from "../../draw/render.js"; const filterButton = document.getElementById("filter-button"); const openFilter = document.getElementById("open-filter"); @@ -68,7 +69,7 @@ bits.setCheckBoxes(); const genStatus = new CheckboxBuilder("generatorStatus", "Generator status"); -function applyFilter(loadedObjects, currentObjects, visibleObjects) { +function applyFilter(loadedObjects, currentObjects) { const rangeFunctions = Range.buildFilter(parametersRange); const checkboxFunctions = Checkbox.buildFilter(bits.checkBoxes); const genStatusFunctions = Checkbox.buildFilter(genStatus.checkBoxes); @@ -82,18 +83,12 @@ function applyFilter(loadedObjects, currentObjects, visibleObjects) { const filteredObjects = reconnect(criteriaFunction, loadedObjects); copyObject(filteredObjects, currentObjects); - - drawAll(currentObjects); - - getVisible(currentObjects, visibleObjects); + renderObjects(currentObjects); } -function removeFilter(loadedObjects, currentObjects, visibleObjects) { +function removeFilter(loadedObjects, currentObjects) { copyObject(loadedObjects, currentObjects); - - drawAll(currentObjects); - - getVisible(currentObjects, visibleObjects); + renderObjects(currentObjects); filters.innerHTML = ""; @@ -101,7 +96,7 @@ function removeFilter(loadedObjects, currentObjects, visibleObjects) { renderGenSim(bits, genStatus); } -export function start(loadedObjects, currentObjects, visibleObjects) { +export function start(loadedObjects, currentObjects) { filterButton.addEventListener("click", () => { active = !active; @@ -117,17 +112,17 @@ export function start(loadedObjects, currentObjects, visibleObjects) { }); apply.addEventListener("click", () => - applyFilter(loadedObjects, currentObjects, visibleObjects) + applyFilter(loadedObjects, currentObjects) ); document.addEventListener("keydown", (event) => { if (event.key === "Enter" && active) { - applyFilter(loadedObjects, currentObjects, visibleObjects); + applyFilter(loadedObjects, currentObjects); } }); reset.addEventListener("click", () => - removeFilter(loadedObjects, currentObjects, visibleObjects) + removeFilter(loadedObjects, currentObjects) ); } diff --git a/js/menu/show-pdg.js b/js/menu/show-pdg.js index 131bbd2e..81675805 100644 --- a/js/menu/show-pdg.js +++ b/js/menu/show-pdg.js @@ -1,25 +1,19 @@ -import { Toggle } from "./toggle.js"; +export const togglePDG = async (objects) => { + const collection = objects.datatypes["edm4hep::MCParticle"].collection; -export class PdgToggle extends Toggle { - constructor(id) { - super(id); - } + const updatePDG = collection.map((object) => + object.drawImage(`${object.name}`) + ); - toggle(currentObjects, redraw) { - const collection = - currentObjects.datatypes["edm4hep::MCParticle"].collection; - if (this.isSliderActive) { - if (collection[0].PDG === undefined) return; - for (const object of collection) { - object.updateTexImg(`${object.PDG}`); - } - } else { - if (collection[0].PDG === undefined) return; - for (const object of collection) { - object.updateTexImg(`${object.name}`); - } - } + await Promise.all(updatePDG); +}; - redraw(); - } -} +export const toggleId = async (objects) => { + const collection = objects.datatypes["edm4hep::MCParticle"].collection; + + const updateId = collection.map((object) => + object.drawImage(`${object.PDG}`) + ); + + await Promise.all(updateId); +}; diff --git a/js/menu/toggle.js b/js/menu/toggle.js index d3fd2025..6d2136e4 100644 --- a/js/menu/toggle.js +++ b/js/menu/toggle.js @@ -1,13 +1,25 @@ +const prev = { + function: null, +}; + export class Toggle { constructor(id) { this.isSliderActive = false; this.slider = document.getElementById(id); } - init(callback) { - this.slider.addEventListener("click", () => { + init(activeFunction, inactiveFunction) { + const newFunction = () => { this.isSliderActive = !this.isSliderActive; - callback(); - }); + if (this.isSliderActive) { + activeFunction(); + } else { + inactiveFunction(); + } + }; + + this.slider.removeEventListener("click", prev.function); + this.slider.addEventListener("click", newFunction); + prev.function = newFunction; } } diff --git a/js/types/objects.js b/js/types/objects.js index c228f1b8..6fc7022e 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -121,13 +121,7 @@ export class MCParticle extends EDMObject { const imageY = nextY + IMAGE_MARGIN; - textToSVG(this.name, IMAGE_SIZE) - .then((src) => { - const sprite = svgElementToPixiSprite(src, IMAGE_SIZE); - return sprite; - }) - .then((sprite) => addImageToBox(sprite, box, imageY)) - .catch((e) => console.error("Error loading SVG: ", e)); + this.drawImage(this.name, imageY); nextY += IMAGE_SIZE + 2 * IMAGE_MARGIN; @@ -149,6 +143,18 @@ export class MCParticle extends EDMObject { return [collectionName, ...simulatorStatus]; } + async drawImage(text, imageY) { + if (this.pdgImage) { + imageY = this.pdgImage.position.y; + this.renderedBox.removeChild(this.pdgImage); + } + + const src = await textToSVG(text, IMAGE_SIZE); + const sprite = await svgElementToPixiSprite(src, IMAGE_SIZE); + this.pdgImage = sprite; + addImageToBox(sprite, this.renderedBox, imageY); + } + static setup(mcCollection) { for (const mcParticle of mcCollection) { const parentLength = mcParticle.oneToManyRelations["parents"].length; diff --git a/js/views/views.js b/js/views/views.js index a688f8f4..bc217b62 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -5,13 +5,7 @@ import { views } from "./views-dictionary.js"; import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; -import { - createContainer, - getApp, - getContainer, - saveSize, - setContainerSize, -} from "../draw/app.js"; +import { getContainer, saveSize } from "../draw/app.js"; const currentView = {}; @@ -33,7 +27,7 @@ function getViewScrollIndex() { return `${currentEvent.event}-${getView()}`; } -function scroll() { +export function scroll() { const container = getContainer(); const index = getViewScrollIndex(); const { x, y } = scrollLocations[index]; @@ -87,24 +81,18 @@ const drawView = async (view) => { const viewCurrentObjects = {}; copyObject(viewObjects, viewCurrentObjects); - const app = getApp(); - app.stage.removeChildren(); - createContainer(app); - const [width, height] = viewFunction(viewObjects); - setContainerSize(width, height); saveSize(width, height); - await renderObjects(viewObjects); - const scrollIndex = getViewScrollIndex(); if (scrollLocations[scrollIndex] === undefined) { const viewScrollLocation = scrollFunction(); scrollLocations[scrollIndex] = viewScrollLocation; } - scroll(); - // filters(viewObjects, viewCurrentObjects, viewVisibleObjects); + await renderObjects(viewObjects); + + filters(viewObjects, viewCurrentObjects); }; export function saveScrollLocation() { From 4b33cb6d4b5390c08b5ab42fa2e240c396d75101 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Mon, 22 Jul 2024 18:44:31 -0500 Subject: [PATCH 17/32] horizontal scrolling using wheel + shift --- js/draw/app.js | 37 +------------------------------------ js/draw/scroll.js | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/js/draw/app.js b/js/draw/app.js index 6019cb2b..c34dac95 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,7 +1,5 @@ import { Application, Container, Culler } from "../pixi.min.mjs"; - -const SPEED = 0.5; -const MARGIN = 0; +import { addScroll } from "./scroll.js"; const pixi = { app: null, @@ -27,38 +25,6 @@ const createApp = async () => { return app; }; -const addScroll = (app) => { - const container = getContainer(); - const renderer = app.renderer; - - container.x = 0; - container.y = 0; - - const screenWidth = renderer.width; - const screenHeight = renderer.height; - - app.canvas.addEventListener("wheel", (e) => { - const deltaX = parseInt(e.deltaX * SPEED); - const deltaY = parseInt(e.deltaY * SPEED); - - const newXPosition = container.x - deltaX; - const newYPosition = container.y - deltaY; - - const isXInBounds = - newXPosition < 0 && newXPosition > screenWidth - pixi.width; - - const isYInBounds = - newYPosition < 0 && newYPosition > screenHeight - pixi.height; - - if (isXInBounds) { - container.x = newXPosition; - } - if (isYInBounds) { - container.y = newYPosition; - } - }); -}; - export const createContainer = (app) => { const container = new Container({ isRenderGroup: true, @@ -96,6 +62,5 @@ export const getContainerSize = () => { export const startPixi = async () => { const app = await createApp(); - createContainer(app); pixi.app = app; }; diff --git a/js/draw/scroll.js b/js/draw/scroll.js index edc851b5..26097900 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -1,4 +1,6 @@ -import { getApp, getContainerSize } from "./app.js"; +import { getApp, getContainerSize, getContainer } from "./app.js"; + +const SPEED = 0.5; export const scrollTopLeft = () => { const x = 0; @@ -19,3 +21,39 @@ export const scrollTopCenter = () => { return { x, y }; }; + +export const addScroll = (app) => { + const container = getContainer(); + const renderer = app.renderer; + + container.x = 0; + container.y = 0; + + const screenWidth = renderer.width; + const screenHeight = renderer.height; + + app.canvas.addEventListener("wheel", (e) => { + if (e.shiftKey) { + const deltaX = parseInt(e.deltaY * SPEED); + const newXPosition = container.x - deltaX; + const isXInBounds = + newXPosition < 0 && + newXPosition > screenWidth - getContainerSize().width; + if (isXInBounds) { + container.x = newXPosition; + } + } else { + const deltaY = parseInt(e.deltaY * SPEED); + + const newYPosition = container.y - deltaY; + + const isYInBounds = + newYPosition < 0 && + newYPosition > screenHeight - getContainerSize().height; + + if (isYInBounds) { + container.y = newYPosition; + } + } + }); +}; From 5b76f2108fb4342ef3a73ae49cf02fec4f4459a0 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Mon, 22 Jul 2024 19:01:50 -0500 Subject: [PATCH 18/32] reorder files --- js/{filter => filters}/mcparticle.js | 0 js/{filter => filters}/nofilter.js | 0 js/{views => filters}/pre-filter.js | 0 js/views/clustertree.js | 4 ++-- js/views/mcclusterassociation.js | 4 ++-- js/views/mcparticletree.js | 2 +- js/views/mcrecoassociation.js | 4 ++-- js/views/mctrackassociation.js | 4 ++-- js/views/particleidlist.js | 4 ++-- js/views/recoparticleid.js | 4 ++-- js/views/recoparticletree.js | 4 ++-- js/views/{ => templates}/association-view.js | 0 js/views/{ => templates}/list.js | 0 js/views/{ => templates}/onewayview.js | 0 js/views/{ => templates}/tree.js | 0 js/views/tracktree.js | 4 ++-- js/views/vertexlist.js | 4 ++-- js/views/views-dictionary.js | 4 ++-- 18 files changed, 21 insertions(+), 21 deletions(-) rename js/{filter => filters}/mcparticle.js (100%) rename js/{filter => filters}/nofilter.js (100%) rename js/{views => filters}/pre-filter.js (100%) rename js/views/{ => templates}/association-view.js (100%) rename js/views/{ => templates}/list.js (100%) rename js/views/{ => templates}/onewayview.js (100%) rename js/views/{ => templates}/tree.js (100%) diff --git a/js/filter/mcparticle.js b/js/filters/mcparticle.js similarity index 100% rename from js/filter/mcparticle.js rename to js/filters/mcparticle.js diff --git a/js/filter/nofilter.js b/js/filters/nofilter.js similarity index 100% rename from js/filter/nofilter.js rename to js/filters/nofilter.js diff --git a/js/views/pre-filter.js b/js/filters/pre-filter.js similarity index 100% rename from js/views/pre-filter.js rename to js/filters/pre-filter.js diff --git a/js/views/clustertree.js b/js/views/clustertree.js index 353fd026..4c7360b6 100644 --- a/js/views/clustertree.js +++ b/js/views/clustertree.js @@ -1,5 +1,5 @@ -import { buildTree } from "./tree.js"; -import { preFilterTree } from "./pre-filter.js"; +import { buildTree } from "./templates/tree.js"; +import { preFilterTree } from "../filters/pre-filter.js"; export function clusterTree(viewCurrentObjects) { const clusterCollection = diff --git a/js/views/mcclusterassociation.js b/js/views/mcclusterassociation.js index 31f606b1..32f117a9 100644 --- a/js/views/mcclusterassociation.js +++ b/js/views/mcclusterassociation.js @@ -1,5 +1,5 @@ -import { preFilterAssociation } from "./pre-filter.js"; -import { buildAssociationView } from "./association-view.js"; +import { preFilterAssociation } from "../filters/pre-filter.js"; +import { buildAssociationView } from "./templates/association-view.js"; export function mcClusterAssociation(viewObjects) { return buildAssociationView( diff --git a/js/views/mcparticletree.js b/js/views/mcparticletree.js index 20952f66..4e12ed03 100644 --- a/js/views/mcparticletree.js +++ b/js/views/mcparticletree.js @@ -1,4 +1,4 @@ -import { preFilterTree } from "./pre-filter.js"; +import { preFilterTree } from "../filters/pre-filter.js"; export function mcParticleTree(viewCurrentObjects) { const mcCollection = diff --git a/js/views/mcrecoassociation.js b/js/views/mcrecoassociation.js index b37cc1e4..afcc91be 100644 --- a/js/views/mcrecoassociation.js +++ b/js/views/mcrecoassociation.js @@ -1,5 +1,5 @@ -import { preFilterAssociation } from "./pre-filter.js"; -import { buildAssociationView } from "./association-view.js"; +import { preFilterAssociation } from "../filters/pre-filter.js"; +import { buildAssociationView } from "./templates/association-view.js"; export function mcRecoAssociation(viewObjects) { return buildAssociationView( diff --git a/js/views/mctrackassociation.js b/js/views/mctrackassociation.js index eda54ce8..91b83323 100644 --- a/js/views/mctrackassociation.js +++ b/js/views/mctrackassociation.js @@ -1,5 +1,5 @@ -import { preFilterAssociation } from "./pre-filter.js"; -import { buildAssociationView } from "./association-view.js"; +import { preFilterAssociation } from "../filters/pre-filter.js"; +import { buildAssociationView } from "./templates/association-view.js"; export function mcTrackAssociation(viewObjects) { return buildAssociationView( diff --git a/js/views/particleidlist.js b/js/views/particleidlist.js index 757adeec..e95cbbdc 100644 --- a/js/views/particleidlist.js +++ b/js/views/particleidlist.js @@ -1,5 +1,5 @@ -import { listView } from "./list.js"; -import { preFilterList } from "./pre-filter.js"; +import { listView } from "./templates/list.js"; +import { preFilterList } from "../filters/pre-filter.js"; export function particleIDList(viewCurrentObjects) { const vertexCollection = diff --git a/js/views/recoparticleid.js b/js/views/recoparticleid.js index 9643961e..0af74176 100644 --- a/js/views/recoparticleid.js +++ b/js/views/recoparticleid.js @@ -1,5 +1,5 @@ -import { preFilterOneWay } from "./pre-filter.js"; -import { oneWayView } from "./onewayview.js"; +import { preFilterOneWay } from "../filters/pre-filter.js"; +import { oneWayView } from "./templates/onewayview.js"; export function recoParticleID(viewObjects) { return oneWayView(viewObjects, "edm4hep::ParticleID", "particle"); diff --git a/js/views/recoparticletree.js b/js/views/recoparticletree.js index 423f2884..89ceb006 100644 --- a/js/views/recoparticletree.js +++ b/js/views/recoparticletree.js @@ -1,5 +1,5 @@ -import { buildTree } from "./tree.js"; -import { preFilterTree } from "./pre-filter.js"; +import { buildTree } from "./templates/tree.js"; +import { preFilterTree } from "../filters/pre-filter.js"; export function recoParticleTree(viewCurrentObjects) { const recoCollection = diff --git a/js/views/association-view.js b/js/views/templates/association-view.js similarity index 100% rename from js/views/association-view.js rename to js/views/templates/association-view.js diff --git a/js/views/list.js b/js/views/templates/list.js similarity index 100% rename from js/views/list.js rename to js/views/templates/list.js diff --git a/js/views/onewayview.js b/js/views/templates/onewayview.js similarity index 100% rename from js/views/onewayview.js rename to js/views/templates/onewayview.js diff --git a/js/views/tree.js b/js/views/templates/tree.js similarity index 100% rename from js/views/tree.js rename to js/views/templates/tree.js diff --git a/js/views/tracktree.js b/js/views/tracktree.js index 19ce03b5..88369fb8 100644 --- a/js/views/tracktree.js +++ b/js/views/tracktree.js @@ -1,5 +1,5 @@ -import { buildTree } from "./tree.js"; -import { preFilterTree } from "./pre-filter.js"; +import { buildTree } from "./templates/tree.js"; +import { preFilterTree } from "../filters/pre-filter.js"; export function trackTree(viewCurrentObjects) { const trackCollection = diff --git a/js/views/vertexlist.js b/js/views/vertexlist.js index 5554694e..a27f16fe 100644 --- a/js/views/vertexlist.js +++ b/js/views/vertexlist.js @@ -1,5 +1,5 @@ -import { listView } from "./list.js"; -import { preFilterList } from "./pre-filter.js"; +import { listView } from "./templates/list.js"; +import { preFilterList } from "../filters/pre-filter.js"; export function vertexList(viewCurrentObjects) { const vertexCollection = diff --git a/js/views/views-dictionary.js b/js/views/views-dictionary.js index 0a3900c6..d67a2216 100644 --- a/js/views/views-dictionary.js +++ b/js/views/views-dictionary.js @@ -1,7 +1,7 @@ import { mcParticleTree, preFilterMCTree } from "./mcparticletree.js"; import { mcRecoAssociation, preFilterMCReco } from "./mcrecoassociation.js"; import { recoParticleTree, preFilterRecoTree } from "./recoparticletree.js"; -import { setupMCParticleFilter } from "../filter/mcparticle.js"; +import { setupMCParticleFilter } from "../filters/mcparticle.js"; import { trackTree, preFilterTrackTree } from "./tracktree.js"; import { clusterTree, preFilterClusterTree } from "./clustertree.js"; import { preFilterMCTrack, mcTrackAssociation } from "./mctrackassociation.js"; @@ -13,7 +13,7 @@ import { recoClusterTrackVertex, preFilterRecoClusterTrackVertex, } from "./recoclustertrack.js"; -import { setupNoFilter } from "../filter/nofilter.js"; +import { setupNoFilter } from "../filters/nofilter.js"; import { vertexList, preFilterVertexList } from "./vertexlist.js"; import { particleIDList, preFilterParticleIDList } from "./particleidlist.js"; import { recoParticleID, preFilterRecoParticleID } from "./recoparticleid.js"; From ebf9d5898df3bd7c9f666c44756db290a44519a6 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 16:27:25 -0500 Subject: [PATCH 19/32] drag from initial mousedown event, not from middle of box --- js/types/objects.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/types/objects.js b/js/types/objects.js index 6fc7022e..d270ab77 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -41,18 +41,18 @@ class EDMObject { box.cursor = "pointer"; box.eventMode = "static"; - let prevX = box.x + box.width / 2; - let prevY = box.y + box.height / 2; + const container = box.parent; box .on( "pointerdown", - function () { + function (downEvent) { + let prevX = container.toLocal(downEvent.data.global).x; + let prevY = container.toLocal(downEvent.data.global).y; + this.on( "pointermove", function (event) { - const container = box.parent; - const eventX = container.toLocal(event.data.global).x; const eventY = container.toLocal(event.data.global).y; From 88894e4f7642d8f5a1459b91341ececb76cbb94d Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 16:32:01 -0500 Subject: [PATCH 20/32] activate antialias for smoother lines --- js/draw/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/draw/app.js b/js/draw/app.js index c34dac95..669f0385 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -12,7 +12,7 @@ const createApp = async () => { const app = new Application(); await app.init({ background: "#ffffff", - antialias: false, + antialias: true, useContextAlpha: false, resizeTo: window, preference: "webgpu", From 0ff6b7772bd4d3e8abf4d55f4326bd3f5bb15e3f Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 17:04:34 -0500 Subject: [PATCH 21/32] delay 500ms box overlay --- js/draw/box.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/js/draw/box.js b/js/draw/box.js index 198b9aea..7636c162 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -81,24 +81,27 @@ export function buildBox(object) { export function addHoverModal(box, lines) { let objectModal = null; - box - .on("pointerover", () => { - objectModal = createObjectModal(lines, box.width); - const objectModalWidth = parseInt(objectModal.width); - const boxWidth = parseInt(box.width); - const x = parseInt(box.position.x); - const xPosition = (boxWidth - objectModalWidth) / 2 + x; - const y = box.position.y; - + box.on("pointerover", () => { + objectModal = createObjectModal(lines, box.width); + const objectModalWidth = parseInt(objectModal.width); + const boxWidth = parseInt(box.width); + const x = parseInt(box.position.x); + const xPosition = (boxWidth - objectModalWidth) / 2 + x; + const y = box.position.y; + + const timeout = setTimeout(() => { renderObjectModal(objectModal, xPosition, y); + }, 500); - box.on("pointerdown", () => { - removeObjectModal(objectModal); - }); - }) - .on("pointerout", () => { + const clean = () => { + clearTimeout(timeout); removeObjectModal(objectModal); - }); + objectModal = null; + }; + + box.on("pointerdown", clean); + box.on("pointerout", clean); + }); } export function addTitleToBox(title, box) { From 8c11d918c4ae0889fb4acd3da6c414cb312592dd Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 17:38:47 -0500 Subject: [PATCH 22/32] improve dragging, add event to window, not to individual box to prevent lose box --- js/draw/app.js | 5 +++++ js/draw/drag.js | 39 +++++++++++++++++++++++++++++++++++++++ js/types/objects.js | 39 ++------------------------------------- 3 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 js/draw/drag.js diff --git a/js/draw/app.js b/js/draw/app.js index 669f0385..c94fcd00 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,4 +1,5 @@ import { Application, Container, Culler } from "../pixi.min.mjs"; +import { dragEnd } from "./drag.js"; import { addScroll } from "./scroll.js"; const pixi = { @@ -40,6 +41,10 @@ export const createContainer = (app) => { }); app.stage.addChild(container); + app.stage.eventMode = "static"; + app.stage.hitArea = app.screen; + app.stage.on("pointerup", dragEnd); + app.stage.on("pointerupoutside", dragEnd); addScroll(app); }; diff --git a/js/draw/drag.js b/js/draw/drag.js new file mode 100644 index 00000000..6d7807b0 --- /dev/null +++ b/js/draw/drag.js @@ -0,0 +1,39 @@ +import { getApp, getContainer } from "./app.js"; + +let currentObject; +let prevX, prevY; + +export function dragStart(event) { + const app = getApp(); + const container = getContainer(); + + prevX = container.toLocal(event.data.global).x; + prevY = container.toLocal(event.data.global).y; + + this.zIndex = 2; + currentObject = this; + + app.stage.on("pointermove", dragMove, this); +} + +export function dragMove(event) { + const container = getContainer(); + + const eventX = container.toLocal(event.data.global).x; + const eventY = container.toLocal(event.data.global).y; + + const deltaX = eventX - prevX; + const deltaY = eventY - prevY; + + this.position.x += deltaX; + this.position.y += deltaY; + + prevX = eventX; + prevY = eventY; +} + +export function dragEnd() { + currentObject.zIndex = 1; + const app = getApp(); + app.stage.off("pointermove", dragMove); +} diff --git a/js/types/objects.js b/js/types/objects.js index d270ab77..5623d766 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -12,6 +12,7 @@ import { addHoverModal, } from "../draw/box.js"; import { textToSVG } from "../lib/generate-svg.js"; +import { dragStart } from "../draw/drag.js"; const IMAGE_MARGIN = 10; const IMAGE_SIZE = 40; @@ -41,43 +42,7 @@ class EDMObject { box.cursor = "pointer"; box.eventMode = "static"; - const container = box.parent; - - box - .on( - "pointerdown", - function (downEvent) { - let prevX = container.toLocal(downEvent.data.global).x; - let prevY = container.toLocal(downEvent.data.global).y; - - this.on( - "pointermove", - function (event) { - const eventX = container.toLocal(event.data.global).x; - const eventY = container.toLocal(event.data.global).y; - - const deltaX = eventX - prevX; - const deltaY = eventY - prevY; - - this.position.x += deltaX; - this.position.y += deltaY; - prevX = eventX; - prevY = eventY; - }, - box - ); - this.zIndex = 2; - }, - box - ) - .on( - "pointerup", - function () { - this.off("pointermove"); - this.zIndex = 1; - }, - box - ); + box.on("pointerdown", dragStart, box); addHoverModal(box, this.objectModalLines()); return [box, nextY]; From 08d65c44e85767404886d51febc9a7dfcb923193 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 18:02:05 -0500 Subject: [PATCH 23/32] add culling for not visible objects --- js/draw/app.js | 4 +--- js/draw/link.js | 1 + js/types/objects.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/draw/app.js b/js/draw/app.js index c94fcd00..b08a79bf 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -27,9 +27,7 @@ const createApp = async () => { }; export const createContainer = (app) => { - const container = new Container({ - isRenderGroup: true, - }); + const container = new Container(); pixi.container = container; const culler = new Culler(); diff --git a/js/draw/link.js b/js/draw/link.js index 0335a80a..85806ceb 100644 --- a/js/draw/link.js +++ b/js/draw/link.js @@ -45,6 +45,7 @@ function bezierCurve({ curve.moveTo(fromX, fromY); curve.bezierCurveTo(cpFromX, cpFromY, cpToX, cpToY, toX, toY); curve.stroke({ width: 2, color }); + curve.cullable = true; return curve; } diff --git a/js/types/objects.js b/js/types/objects.js index 5623d766..30acc709 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -37,11 +37,11 @@ class EDMObject { box.interactiveChildren = false; addBox(box); box.position.set(this.x, this.y); + box.cullable = true; const nextY = addTitleToBox(this.constructor.name, box); box.cursor = "pointer"; box.eventMode = "static"; - box.on("pointerdown", dragStart, box); addHoverModal(box, this.objectModalLines()); From add0931ed3a63d05c56565ebdf8f3e76d28ef4dd Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Tue, 23 Jul 2024 20:00:31 -0500 Subject: [PATCH 24/32] cull correctly, huge improvement --- js/draw/app.js | 12 +++++++++--- js/draw/drag.js | 8 ++++++++ js/draw/render.js | 2 +- js/draw/renderable.js | 17 +++++++++++++++++ js/draw/scroll.js | 5 ++++- js/types/objects.js | 22 +++++++++++++++++++++- js/views/views.js | 2 ++ 7 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 js/draw/renderable.js diff --git a/js/draw/app.js b/js/draw/app.js index b08a79bf..bbc9d6e6 100644 --- a/js/draw/app.js +++ b/js/draw/app.js @@ -1,4 +1,10 @@ -import { Application, Container, Culler } from "../pixi.min.mjs"; +import { + Application, + Container, + Culler, + CullerPlugin, + extensions, +} from "../pixi.min.mjs"; import { dragEnd } from "./drag.js"; import { addScroll } from "./scroll.js"; @@ -26,7 +32,7 @@ const createApp = async () => { return app; }; -export const createContainer = (app) => { +export const createContainer = (app, objects) => { const container = new Container(); pixi.container = container; @@ -43,7 +49,7 @@ export const createContainer = (app) => { app.stage.hitArea = app.screen; app.stage.on("pointerup", dragEnd); app.stage.on("pointerupoutside", dragEnd); - addScroll(app); + addScroll(app, objects); }; export const saveSize = (width, height) => { diff --git a/js/draw/drag.js b/js/draw/drag.js index 6d7807b0..868b316c 100644 --- a/js/draw/drag.js +++ b/js/draw/drag.js @@ -1,3 +1,4 @@ +import { Rectangle } from "../pixi.min.mjs"; import { getApp, getContainer } from "./app.js"; let currentObject; @@ -28,6 +29,13 @@ export function dragMove(event) { this.position.x += deltaX; this.position.y += deltaY; + this.cullArea = new Rectangle( + this.position.x, + this.position.y, + this.width, + this.height + ); + prevX = eventX; prevY = eventY; } diff --git a/js/draw/render.js b/js/draw/render.js index 0e6ee40b..9eade9a5 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -4,7 +4,7 @@ import { scroll } from "../views/views.js"; export async function renderObjects(objects) { const app = getApp(); app.stage.removeChildren(); - createContainer(app); + createContainer(app, objects); const datatypes = objects.datatypes; const associations = objects.associations; diff --git a/js/draw/renderable.js b/js/draw/renderable.js new file mode 100644 index 00000000..c9c54000 --- /dev/null +++ b/js/draw/renderable.js @@ -0,0 +1,17 @@ +import { Rectangle } from "../pixi.min.mjs"; + +export function setRenderable(objects) { + for (const { collection } of Object.values(objects.datatypes)) { + for (const object of collection) { + const renderedBox = object.renderedBox; + renderedBox.cullArea = new Rectangle( + renderedBox.x, + renderedBox.y, + renderedBox.width, + renderedBox.height + ); + + renderedBox.renderable = object.isVisible(); + } + } +} diff --git a/js/draw/scroll.js b/js/draw/scroll.js index 26097900..d23e9206 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -1,4 +1,5 @@ import { getApp, getContainerSize, getContainer } from "./app.js"; +import { setRenderable } from "./renderable.js"; const SPEED = 0.5; @@ -22,7 +23,7 @@ export const scrollTopCenter = () => { return { x, y }; }; -export const addScroll = (app) => { +export const addScroll = (app, objects) => { const container = getContainer(); const renderer = app.renderer; @@ -55,5 +56,7 @@ export const addScroll = (app) => { container.y = newYPosition; } } + + setRenderable(objects); }); }; diff --git a/js/types/objects.js b/js/types/objects.js index 30acc709..48871866 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -13,6 +13,8 @@ import { } from "../draw/box.js"; import { textToSVG } from "../lib/generate-svg.js"; import { dragStart } from "../draw/drag.js"; +import { getApp, getContainer } from "../draw/app.js"; +import { Culler, Rectangle } from "../pixi.min.mjs"; const IMAGE_MARGIN = 10; const IMAGE_SIZE = 40; @@ -37,12 +39,13 @@ class EDMObject { box.interactiveChildren = false; addBox(box); box.position.set(this.x, this.y); - box.cullable = true; const nextY = addTitleToBox(this.constructor.name, box); box.cursor = "pointer"; box.eventMode = "static"; box.on("pointerdown", dragStart, box); + box.cullable = true; + box.cullArea = new Rectangle(box.x, box.y, box.width, box.height); addHoverModal(box, this.objectModalLines()); return [box, nextY]; @@ -52,6 +55,23 @@ class EDMObject { const collectionName = "Collection: " + this.collectionName; return [collectionName]; } + + isVisible() { + const app = getApp(); + const container = getContainer(); + + const x = Math.abs(container.x); + const y = Math.abs(container.y); + const width = app.renderer.width; + const height = app.renderer.height; + + return ( + x + width > this.x && + x < this.x + this.width && + y + height > this.y && + y < this.y + this.height + ); + } } export class MCParticle extends EDMObject { diff --git a/js/views/views.js b/js/views/views.js index bc217b62..c37ff97e 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -6,6 +6,7 @@ import { emptyViewMessage, hideEmptyViewMessage } from "../lib/messages.js"; import { showViewInformation, hideViewInformation } from "../information.js"; import { renderObjects } from "../draw/render.js"; import { getContainer, saveSize } from "../draw/app.js"; +import { setRenderable } from "../draw/renderable.js"; const currentView = {}; @@ -91,6 +92,7 @@ const drawView = async (view) => { } await renderObjects(viewObjects); + setRenderable(viewCurrentObjects); filters(viewObjects, viewCurrentObjects); }; From 68d6fe0962fd94e710e29d264b2fb4f6d907a5ae Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Wed, 24 Jul 2024 11:44:54 -0500 Subject: [PATCH 25/32] allow to scroll on laptop and pc --- js/draw/scroll.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/draw/scroll.js b/js/draw/scroll.js index d23e9206..7e028dbb 100644 --- a/js/draw/scroll.js +++ b/js/draw/scroll.js @@ -44,19 +44,26 @@ export const addScroll = (app, objects) => { container.x = newXPosition; } } else { + const deltaX = parseInt(e.deltaX * SPEED); const deltaY = parseInt(e.deltaY * SPEED); - + const newXPosition = container.x - deltaX; const newYPosition = container.y - deltaY; + const isXInBounds = + newXPosition < 0 && + newXPosition > screenWidth - getContainerSize().width; const isYInBounds = newYPosition < 0 && newYPosition > screenHeight - getContainerSize().height; + if (isXInBounds) { + container.x = newXPosition; + } + if (isYInBounds) { container.y = newYPosition; } } - setRenderable(objects); }); }; From 7cf37ea342f53a855f5eea38a237db5df955ab2a Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Thu, 25 Jul 2024 20:42:01 -0500 Subject: [PATCH 26/32] fix isVisible functioon for objects + implement for links --- js/draw/drag.js | 23 ++++++++++++++--------- js/draw/link.js | 12 ++++++++++++ js/draw/renderable.js | 27 ++++++++++++++++++++++++--- js/types/links.js | 31 +++++++++++++++++++++++++++++++ js/types/objects.js | 4 ++-- 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/js/draw/drag.js b/js/draw/drag.js index 868b316c..734fa2df 100644 --- a/js/draw/drag.js +++ b/js/draw/drag.js @@ -8,17 +8,20 @@ export function dragStart(event) { const app = getApp(); const container = getContainer(); + const renderedBox = this.renderedBox; + prevX = container.toLocal(event.data.global).x; prevY = container.toLocal(event.data.global).y; - this.zIndex = 2; - currentObject = this; + renderedBox.zIndex = 2; + currentObject = renderedBox; app.stage.on("pointermove", dragMove, this); } export function dragMove(event) { const container = getContainer(); + const renderedBox = this.renderedBox; const eventX = container.toLocal(event.data.global).x; const eventY = container.toLocal(event.data.global).y; @@ -26,14 +29,16 @@ export function dragMove(event) { const deltaX = eventX - prevX; const deltaY = eventY - prevY; - this.position.x += deltaX; - this.position.y += deltaY; + this.x += deltaX; + this.y += deltaY; + renderedBox.position.x += deltaX; + renderedBox.position.y += deltaY; - this.cullArea = new Rectangle( - this.position.x, - this.position.y, - this.width, - this.height + renderedBox.cullArea = new Rectangle( + renderedBox.position.x, + renderedBox.position.y, + renderedBox.width, + renderedBox.height ); prevX = eventX; diff --git a/js/draw/link.js b/js/draw/link.js index 85806ceb..88bab53b 100644 --- a/js/draw/link.js +++ b/js/draw/link.js @@ -68,6 +68,8 @@ export function drawBezierLink(link) { color: link.color, }); + link.renderedLink = curve; + const boxFrom = link.from.renderedBox; const boxTo = link.to.renderedBox; @@ -92,8 +94,13 @@ export function drawBezierLink(link) { toY: toY, color: link.color, }); + link.renderedLink = curve; + link.renderedLink.renderable = link.isVisible(); container.addChild(curve); }); + boxFrom.on("pointerup", () => { + boxFrom.off("pointermove"); + }); }); boxTo.on("pointerdown", () => { @@ -115,8 +122,13 @@ export function drawBezierLink(link) { toY: toY, color: link.color, }); + link.renderedLink = curve; + link.renderedLink.renderable = link.isVisible(); container.addChild(curve); }); + boxTo.on("pointerup", () => { + boxTo.off("pointermove"); + }); }); container.addChild(curve); diff --git a/js/draw/renderable.js b/js/draw/renderable.js index c9c54000..b501e628 100644 --- a/js/draw/renderable.js +++ b/js/draw/renderable.js @@ -1,17 +1,38 @@ import { Rectangle } from "../pixi.min.mjs"; export function setRenderable(objects) { - for (const { collection } of Object.values(objects.datatypes)) { + for (const { collection, oneToMany, oneToOne } of Object.values( + objects.datatypes + )) { for (const object of collection) { const renderedBox = object.renderedBox; + renderedBox.cullArea = new Rectangle( - renderedBox.x, - renderedBox.y, + renderedBox.position.x, + renderedBox.position.y, renderedBox.width, renderedBox.height ); renderedBox.renderable = object.isVisible(); } + + for (const links of Object.values(oneToMany)) { + for (const link of links) { + link.renderedLink.renderable = link.isVisible(); + } + } + + for (const links of Object.values(oneToOne)) { + for (const link of links) { + link.renderedLink.renderable = link.isVisible(); + } + } + } + + for (const associations of Object.values(objects.associations)) { + for (const association of associations) { + association.renderedLink.renderable = association.isVisible(); + } } } diff --git a/js/types/links.js b/js/types/links.js index 3f12e93d..5427cfc0 100644 --- a/js/types/links.js +++ b/js/types/links.js @@ -1,3 +1,4 @@ +import { getApp, getContainer } from "../draw/app.js"; import { drawBezierLink } from "../draw/link.js"; const colors = { @@ -23,6 +24,36 @@ export class Link { draw() { drawBezierLink(this); } + + isVisible() { + const boxFrom = this.from; + const boxTo = this.to; + + const fromX = boxFrom.x + boxFrom.width / 2; + const fromY = boxFrom.y + boxFrom.height; + const toX = boxTo.x + boxTo.width / 2; + const toY = boxTo.y; + + const boxX = Math.min(fromX, toX); + const boxWidth = Math.abs(fromX - toX); + const boxY = Math.min(fromY, toY); + const boxHeight = Math.abs(fromY - toY); + + const app = getApp(); + const container = getContainer(); + + const x = Math.abs(container.x); + const y = Math.abs(container.y); + const width = app.renderer.width; + const height = app.renderer.height; + + return ( + x + width > boxX && + x < boxX + boxWidth && + y + height > boxY && + y < boxY + boxHeight + ); + } } class ParentLink extends Link { diff --git a/js/types/objects.js b/js/types/objects.js index 48871866..636650ba 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -14,7 +14,7 @@ import { import { textToSVG } from "../lib/generate-svg.js"; import { dragStart } from "../draw/drag.js"; import { getApp, getContainer } from "../draw/app.js"; -import { Culler, Rectangle } from "../pixi.min.mjs"; +import { Rectangle } from "../pixi.min.mjs"; const IMAGE_MARGIN = 10; const IMAGE_SIZE = 40; @@ -43,7 +43,7 @@ class EDMObject { box.cursor = "pointer"; box.eventMode = "static"; - box.on("pointerdown", dragStart, box); + box.on("pointerdown", dragStart, this); box.cullable = true; box.cullArea = new Rectangle(box.x, box.y, box.width, box.height); From 293bfdda1ccdfb973804a8d7a19f775ff1966366 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 08:58:11 -0500 Subject: [PATCH 27/32] remove twice prop in css, use commented line --- css/main.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index d1d9f17a..74d505a4 100644 --- a/css/main.css +++ b/css/main.css @@ -1,10 +1,9 @@ body { margin: 0; padding: 0; - /* overflow: hidden; */ + overflow: hidden; font-family: sans-serif; font-size: 16px; - overflow: hidden; } .manipulation-tool { From 0596784b5db401ecfa450d4462bead554086df19 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 09:54:57 -0500 Subject: [PATCH 28/32] fix small gap between box and link when dragging --- js/draw/link.js | 115 ++++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/js/draw/link.js b/js/draw/link.js index 88bab53b..0eb7ae23 100644 --- a/js/draw/link.js +++ b/js/draw/link.js @@ -1,5 +1,5 @@ import { Graphics } from "../pixi.min.mjs"; -import { getContainer } from "./app.js"; +import { getApp, getContainer } from "./app.js"; function fromPoints(boxFrom) { return [boxFrom.x + boxFrom.width / 2, boxFrom.y + boxFrom.height]; @@ -50,6 +50,9 @@ function bezierCurve({ } export function drawBezierLink(link) { + const app = getApp(); + const container = getContainer(); + const [fromX, fromY] = fromPoints(link.from); const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( link.from, @@ -73,62 +76,70 @@ export function drawBezierLink(link) { const boxFrom = link.from.renderedBox; const boxTo = link.to.renderedBox; - const container = getContainer(); + const boxFromOnMove = () => { + container.removeChild(curve); + const [fromX, fromY] = fromPoints(link.from); + const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( + link.from, + link.to + ); + curve = bezierCurve({ + fromX: fromX + link.xShift, + fromY: fromY, + cpFromX: cpFromX + link.xShift, + cpFromY: cpFromY, + cpToX: cpToX + link.xShift, + cpToY: cpToY, + toX: toX + link.xShift, + toY: toY, + color: link.color, + }); + link.renderedLink = curve; + link.renderedLink.renderable = link.isVisible(); + container.addChild(curve); + }; boxFrom.on("pointerdown", () => { - boxFrom.on("pointermove", () => { - container.removeChild(curve); - const [fromX, fromY] = fromPoints(boxFrom); - const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( - boxFrom, - boxTo - ); - curve = bezierCurve({ - fromX: fromX + link.xShift, - fromY: fromY, - cpFromX: cpFromX + link.xShift, - cpFromY: cpFromY, - cpToX: cpToX + link.xShift, - cpToY: cpToY, - toX: toX + link.xShift, - toY: toY, - color: link.color, - }); - link.renderedLink = curve; - link.renderedLink.renderable = link.isVisible(); - container.addChild(curve); - }); - boxFrom.on("pointerup", () => { - boxFrom.off("pointermove"); - }); + app.stage.on("pointermove", boxFromOnMove); + }); + app.stage.on("pointerup", () => { + app.stage.off("pointermove", boxFromOnMove); + }); + app.stage.on("pointerupoutside", () => { + app.stage.off("pointermove", boxFromOnMove); }); - boxTo.on("pointerdown", () => { - boxTo.on("pointermove", () => { - container.removeChild(curve); - const [fromX, fromY] = fromPoints(boxFrom); - const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( - boxFrom, - boxTo - ); - curve = bezierCurve({ - fromX: fromX + link.xShift, - fromY: fromY, - cpFromX: cpFromX + link.xShift, - cpFromY: cpFromY, - cpToX: cpToX + link.xShift, - cpToY: cpToY, - toX: toX + link.xShift, - toY: toY, - color: link.color, - }); - link.renderedLink = curve; - link.renderedLink.renderable = link.isVisible(); - container.addChild(curve); - }); - boxTo.on("pointerup", () => { - boxTo.off("pointermove"); + const boxToOnMove = () => { + container.removeChild(curve); + const [fromX, fromY] = fromPoints(link.from); + const [cpFromX, cpFromY, cpToX, cpToY, toX, toY] = toPoints( + link.from, + link.to + ); + curve = bezierCurve({ + fromX: fromX + link.xShift, + fromY: fromY, + cpFromX: cpFromX + link.xShift, + cpFromY: cpFromY, + cpToX: cpToX + link.xShift, + cpToY: cpToY, + toX: toX + link.xShift, + toY: toY, + color: link.color, }); + link.renderedLink = curve; + link.renderedLink.renderable = link.isVisible(); + container.addChild(curve); + }; + + boxTo.on("pointerdown", () => { + app.stage.on("pointermove", boxToOnMove); + }); + app.stage.on("pointerup", () => { + app.stage.off("pointermove", boxToOnMove); + }); + app.stage.on("pointerupoutside", () => { + app.stage.off("pointermove", boxToOnMove); }); container.addChild(curve); From 69df814ede583e8dd6f2c4babcd18686c1b94c90 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 12:24:22 -0500 Subject: [PATCH 29/32] cache images for MCParticle and render only if visible --- js/draw/box.js | 23 ++++++++++++++++++++--- js/draw/render.js | 3 --- js/lib/generate-svg.js | 9 ++++++++- js/types/objects.js | 35 ++++++++++++++++++++++++++--------- js/views/views.js | 1 + 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/js/draw/box.js b/js/draw/box.js index 7636c162..38af43a7 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -1,4 +1,11 @@ -import { Graphics, Assets, Sprite, Text, TextStyle } from "../pixi.min.mjs"; +import { + Graphics, + Assets, + Sprite, + Text, + TextStyle, + Cache, +} from "../pixi.min.mjs"; import { getApp, getContainer } from "./app.js"; const MARGIN = 20; @@ -131,8 +138,14 @@ export function addLinesToBox(lines, box, y) { return text.position.y + text.height; } -export async function svgElementToPixiSprite(src, size) { - const asset = await Assets.load(src); +export async function svgElementToPixiSprite(id, src, size) { + let asset; + + if (!Cache.has(id)) { + Cache.set(id, await Assets.load(src)); + } + + asset = Cache.get(id); const sprite = Sprite.from(asset); sprite.width = size; sprite.height = size; @@ -144,3 +157,7 @@ export function addImageToBox(sprite, box, y) { sprite.position.set((box.width - sprite.width) / 2, y); return sprite.position.y + sprite.height; } + +export function removeImageFromBox(sprite, box) { + box.removeChild(sprite); +} diff --git a/js/draw/render.js b/js/draw/render.js index 9eade9a5..490b994e 100644 --- a/js/draw/render.js +++ b/js/draw/render.js @@ -1,5 +1,4 @@ import { getApp, createContainer } from "./app.js"; -import { scroll } from "../views/views.js"; export async function renderObjects(objects) { const app = getApp(); @@ -33,6 +32,4 @@ export async function renderObjects(objects) { association.draw(); } } - - scroll(); } diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js index e240f637..f14eae58 100644 --- a/js/lib/generate-svg.js +++ b/js/lib/generate-svg.js @@ -1,6 +1,12 @@ const SCALE = 1.25; -export async function textToSVG(text, size) { +const store = {}; + +export async function textToSVG(id, text, size) { + if (store[id]) { + return store[id]; + } + const mathjaxContainer = await MathJax.tex2svgPromise(text); const svg = mathjaxContainer.firstElementChild; @@ -14,5 +20,6 @@ export async function textToSVG(text, size) { svg.outerHTML ); + store[id] = src; return src; } diff --git a/js/types/objects.js b/js/types/objects.js index 636650ba..6ad47603 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -10,6 +10,7 @@ import { svgElementToPixiSprite, addImageToBox, addHoverModal, + removeImageFromBox, } from "../draw/box.js"; import { textToSVG } from "../lib/generate-svg.js"; import { dragStart } from "../draw/drag.js"; @@ -105,8 +106,8 @@ export class MCParticle extends EDMObject { nextY = addLinesToBox(topLines, box, nextY); const imageY = nextY + IMAGE_MARGIN; - - this.drawImage(this.name, imageY); + this.imageY = imageY; + this.hasImage = false; nextY += IMAGE_SIZE + 2 * IMAGE_MARGIN; @@ -129,17 +130,33 @@ export class MCParticle extends EDMObject { } async drawImage(text, imageY) { - if (this.pdgImage) { - imageY = this.pdgImage.position.y; - this.renderedBox.removeChild(this.pdgImage); - } - - const src = await textToSVG(text, IMAGE_SIZE); - const sprite = await svgElementToPixiSprite(src, IMAGE_SIZE); + const id = `${text}-${IMAGE_SIZE}`; + const src = await textToSVG(id, text, IMAGE_SIZE); + const sprite = await svgElementToPixiSprite(id, src, IMAGE_SIZE); this.pdgImage = sprite; addImageToBox(sprite, this.renderedBox, imageY); } + isVisible() { + const isVisible = super.isVisible(); + + if (isVisible) { + if (!this.hasImage) { + this.hasImage = true; + this.drawImage(this.name, this.imageY); + } + } else { + if (this.pdgImage) { + removeImageFromBox(this.pdgImage, this.renderedBox); + this.pdgImage.destroy(); + this.pdgImage = null; + this.hasImage = false; + } + } + + return isVisible; + } + static setup(mcCollection) { for (const mcParticle of mcCollection) { const parentLength = mcParticle.oneToManyRelations["parents"].length; diff --git a/js/views/views.js b/js/views/views.js index c37ff97e..5e5b50eb 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -92,6 +92,7 @@ const drawView = async (view) => { } await renderObjects(viewObjects); + scroll(); setRenderable(viewCurrentObjects); filters(viewObjects, viewCurrentObjects); From 3b635a176dc01f940238ec3736394544287992b4 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 12:56:04 -0500 Subject: [PATCH 30/32] render new image on toggle if visible --- js/lib/generate-svg.js | 2 +- js/menu/show-pdg.js | 31 +++++++++++++++++++------------ js/types/objects.js | 13 +++++++------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/js/lib/generate-svg.js b/js/lib/generate-svg.js index f14eae58..872c34b1 100644 --- a/js/lib/generate-svg.js +++ b/js/lib/generate-svg.js @@ -7,7 +7,7 @@ export async function textToSVG(id, text, size) { return store[id]; } - const mathjaxContainer = await MathJax.tex2svgPromise(text); + const mathjaxContainer = await MathJax.tex2svgPromise(`${text}`); const svg = mathjaxContainer.firstElementChild; svg.setAttribute("width", `${parseInt(size * SCALE)}px`); diff --git a/js/menu/show-pdg.js b/js/menu/show-pdg.js index 81675805..9b0d93d8 100644 --- a/js/menu/show-pdg.js +++ b/js/menu/show-pdg.js @@ -1,19 +1,26 @@ -export const togglePDG = async (objects) => { - const collection = objects.datatypes["edm4hep::MCParticle"].collection; - - const updatePDG = collection.map((object) => - object.drawImage(`${object.name}`) - ); +import { removeImageFromBox } from "../draw/box.js"; - await Promise.all(updatePDG); +const toggleImage = (object, newText) => { + object.textToRender = newText; + const renderedBox = object.renderedBox; + removeImageFromBox(object.image, renderedBox); + if (renderedBox.renderable) { + object.drawImage(object.textToRender, object.imageY); + } }; -export const toggleId = async (objects) => { +export const togglePDG = (objects) => { const collection = objects.datatypes["edm4hep::MCParticle"].collection; - const updateId = collection.map((object) => - object.drawImage(`${object.PDG}`) - ); + collection.map((object) => { + toggleImage(object, object.name); + }); +}; + +export const toggleId = (objects) => { + const collection = objects.datatypes["edm4hep::MCParticle"].collection; - await Promise.all(updateId); + collection.map((object) => { + toggleImage(object, object.PDG); + }); }; diff --git a/js/types/objects.js b/js/types/objects.js index 6ad47603..bc1f67df 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -133,7 +133,7 @@ export class MCParticle extends EDMObject { const id = `${text}-${IMAGE_SIZE}`; const src = await textToSVG(id, text, IMAGE_SIZE); const sprite = await svgElementToPixiSprite(id, src, IMAGE_SIZE); - this.pdgImage = sprite; + this.image = sprite; addImageToBox(sprite, this.renderedBox, imageY); } @@ -143,13 +143,13 @@ export class MCParticle extends EDMObject { if (isVisible) { if (!this.hasImage) { this.hasImage = true; - this.drawImage(this.name, this.imageY); + this.drawImage(this.textToRender, this.imageY); } } else { - if (this.pdgImage) { - removeImageFromBox(this.pdgImage, this.renderedBox); - this.pdgImage.destroy(); - this.pdgImage = null; + if (this.image) { + removeImageFromBox(this.image, this.renderedBox); + this.image.destroy(); + this.image = null; this.hasImage = false; } } @@ -173,6 +173,7 @@ export class MCParticle extends EDMObject { const name = getName(mcParticle.PDG); mcParticle.name = name; + mcParticle.textToRender = name; mcParticle.momentum = Math.sqrt( Math.pow(mcParticle.momentum.x, 2) + Math.pow(mcParticle.momentum.y, 2) + From 538060ef3979b482722b45fbb16d208da8f89f20 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 13:58:49 -0500 Subject: [PATCH 31/32] min size same as window when smaller --- js/views/views.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/views/views.js b/js/views/views.js index 5e5b50eb..aa10ac5c 100644 --- a/js/views/views.js +++ b/js/views/views.js @@ -82,7 +82,13 @@ const drawView = async (view) => { const viewCurrentObjects = {}; copyObject(viewObjects, viewCurrentObjects); - const [width, height] = viewFunction(viewObjects); + let [width, height] = viewFunction(viewObjects); + if (width < window.innerWidth) { + width = window.innerWidth; + } + if (height < window.innerHeight) { + height = window.innerHeight; + } saveSize(width, height); const scrollIndex = getViewScrollIndex(); From 89a20129e69f3e67cb44ec97f0a5c51091a2d455 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 26 Jul 2024 14:26:20 -0500 Subject: [PATCH 32/32] wrap object title if larger than box width --- js/draw/box.js | 15 ++++++++++++--- js/types/objects.js | 10 ++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/js/draw/box.js b/js/draw/box.js index 38af43a7..9df12faa 100644 --- a/js/draw/box.js +++ b/js/draw/box.js @@ -10,8 +10,12 @@ import { getApp, getContainer } from "./app.js"; const MARGIN = 20; const PADDING = 5; +const TITLE_MARGIN = 12; -function createText(text, { fontFamily, fontSize, fontWeight, align, fill }) { +function createText( + text, + { fontFamily, fontSize, fontWeight, align, fill, wrap = false, maxWidth } +) { return new Text({ text, style: new TextStyle({ @@ -20,6 +24,8 @@ function createText(text, { fontFamily, fontSize, fontWeight, align, fill }) { fontWeight, align, fill, + wordWrap: wrap, + wordWrapWidth: maxWidth, }), resolution: 2, }); @@ -118,10 +124,12 @@ export function addTitleToBox(title, box) { align: "center", fill: "black", fontWeight: "bold", + wrap: true, + maxWidth: box.width, }); box.addChild(boxTitle); boxTitle.position.set((box.width - boxTitle.width) / 2, MARGIN); - return boxTitle.position.y + boxTitle.height + 12; + return boxTitle.position.y + boxTitle.height + TITLE_MARGIN; } export function addLinesToBox(lines, box, y) { @@ -131,7 +139,8 @@ export function addLinesToBox(lines, box, y) { fontWeight: "normal", align: "center", fill: "black", - width: box.width, + wrap: true, + maxWidth: box.width, }); box.addChild(text); text.position.set((box.width - text.width) / 2, y); diff --git a/js/types/objects.js b/js/types/objects.js index bc1f67df..cad6c032 100644 --- a/js/types/objects.js +++ b/js/types/objects.js @@ -40,7 +40,7 @@ class EDMObject { box.interactiveChildren = false; addBox(box); box.position.set(this.x, this.y); - const nextY = addTitleToBox(this.constructor.name, box); + const nextY = addTitleToBox(this.titleName, box); box.cursor = "pointer"; box.eventMode = "static"; @@ -83,6 +83,7 @@ export class MCParticle extends EDMObject { this.color = "#dff6ff"; this.radius = 15; this.height = 270; + this.titleName = "MCParticle"; } async draw() { @@ -242,10 +243,11 @@ export class MCParticle extends EDMObject { class ReconstructedParticle extends EDMObject { constructor() { super(); - this.width = 140; + this.width = 145; this.height = 190; this.color = "#fbffdf"; this.radius = 30; + this.titleName = "Reconstructed\nParticle"; } async draw() { @@ -279,6 +281,7 @@ class Cluster extends EDMObject { this.height = 170; this.color = "#ffe8df"; this.radius = 20; + this.titleName = "Cluster"; } async draw() { @@ -309,6 +312,7 @@ class Track extends EDMObject { this.height = 150; this.color = "#fff6df"; this.radius = 25; + this.titleName = "Track"; } async draw() { @@ -338,6 +342,7 @@ class ParticleID extends EDMObject { this.height = 140; this.color = "#c9edf7"; this.radius = 25; + this.titleName = "Particle ID"; } async draw() { @@ -363,6 +368,7 @@ class Vertex extends EDMObject { this.height = 150; this.color = "#f5d3ef"; this.radius = 25; + this.titleName = "Vertex"; } async draw() {