summaryrefslogtreecommitdiff
path: root/dist/assets/index-DB6B0XuI.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/assets/index-DB6B0XuI.js')
-rw-r--r--dist/assets/index-DB6B0XuI.js451
1 files changed, 451 insertions, 0 deletions
diff --git a/dist/assets/index-DB6B0XuI.js b/dist/assets/index-DB6B0XuI.js
new file mode 100644
index 0000000..09ed45c
--- /dev/null
+++ b/dist/assets/index-DB6B0XuI.js
@@ -0,0 +1,451 @@
+const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-BytxDfn1.js","assets/webworkerAll-J8ccMaq4.js","assets/colorToUniform-DmtBy-2V.js","assets/WebGPURenderer-CtyVoQqf.js","assets/SharedSystems-DVK37F7d.js","assets/WebGLRenderer-BVO0qznQ.js"])))=>i.map(i=>d[i]);
+(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();class Wn{constructor(){this.listeners=new Map}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set);const i=this.listeners.get(t);return i.add(e),()=>{i.delete(e),i.size===0&&this.listeners.delete(t)}}emit(t,e){const i=this.listeners.get(t);if(i)for(const r of i)r(e)}}const _r="timeplot.app-state.v1";function Ns(s){return Object.fromEntries(Object.entries(s).map(([t,e])=>[t,{...e}]))}function Us(s){return Object.fromEntries(Object.entries(s).map(([t,e])=>[t,{...e}]))}function Yn(s){return{type:s.type,preset:s.preset,sampleRateHz:s.sampleRateHz,amplitude:s.amplitude,noise:s.noise,replayRate:s.replayRate,dataFileName:s.dataFileName,wsUrl:s.wsUrl,wsReconnectMs:s.wsReconnectMs}}function Xn(s){return{plot:{showGrid:s.plot.showGrid,showPoints:s.plot.showPoints,windowDurationMs:s.plot.windowDurationMs,maxPoints:s.plot.maxPoints},time:{speed:s.time.speed},panels:Ns(s.panels),graphs:Us(s.graphs),sources:Object.fromEntries(Object.entries(s.sources).map(([t,e])=>[t,Yn(e)]))}}function jn(s,t){return!t||typeof t!="object"?s:{...s,time:t.time?{...s.time,speed:t.time.speed??s.time.speed,paused:!1}:s.time,plot:t.plot?{...s.plot,...t.plot,valueRange:s.plot.valueRange,hoveredPoint:null,tooltip:{...s.plot.tooltip}}:s.plot,panels:t.panels?Ns(Object.fromEntries(Object.entries(s.panels).map(([i,r])=>[i,{...r,...t.panels[i]??{}}]))):s.panels,graphs:t.graphs?Us(Object.fromEntries(Object.entries(s.graphs).map(([i,r])=>[i,{...r,...t.graphs[i]??{}}]))):s.graphs,sources:t.sources?Object.fromEntries(Object.entries(s.sources).map(([i,r])=>{const n=t.sources[i]??{},o=n.type??r.type;return[i,{...r,...n,type:o,dataset:[],datasetPointCount:0,datasetDurationMs:0,loadError:o==="csv-replay"&&n.dataFileName?`Reload ${n.dataFileName} to restore replay data`:"",wsStatus:"idle",wsStatusDetail:""}]})):s.sources}}function qn(){if(typeof localStorage>"u")return null;try{const s=localStorage.getItem(_r);return s?JSON.parse(s):null}catch(s){return console.warn("[timeplot] failed to load persisted state",s),null}}function Zn(s){if(!(typeof localStorage>"u"))try{localStorage.setItem(_r,JSON.stringify(Xn(s)))}catch(t){console.warn("[timeplot] failed to persist state",t)}}function br(){return{app:{title:"TimePlot",renderer:"pending"},time:{realNowMs:Date.now(),realElapsedMs:0,plotTimeMs:0,speed:1,paused:!1},plot:{showGrid:!0,showPoints:!0,windowDurationMs:2e4,maxPoints:1600,valueRange:{min:-1.6,max:1.6},hoveredPoint:null,tooltip:{visible:!1,x:0,y:0,point:null}},sources:{signalA:{id:"signal-a",label:"Signal A",type:"synthetic-wave",preset:"telemetry",sampleRateHz:60,amplitude:1,noise:.08,replayRate:1,dataset:[],dataFileName:"",datasetPointCount:0,datasetDurationMs:0,loadError:"",wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,wsStatus:"idle",wsStatusDetail:""},signalB:{id:"signal-b",label:"Signal B",type:"synthetic-wave",preset:"chirp",sampleRateHz:48,amplitude:.8,noise:.04,replayRate:1,dataset:[],dataFileName:"",datasetPointCount:0,datasetDurationMs:0,loadError:"",wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,wsStatus:"idle",wsStatusDetail:""}},graphs:{primary:{sourceKey:"signalA",transform:"raw",title:"Primary signal"},secondary:{sourceKey:"signalB",transform:"delta",title:"Secondary signal"}},panels:{status:{title:"Status",visible:!0},source:{title:"Data Source",visible:!0},config:{title:"Config",visible:!0},help:{title:"Help",visible:!1}}}}class Kn{constructor(t=br()){this.state=jn(t,qn()),this.listeners=new Set}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}setState(t){const e=typeof t=="function"?t(this.state):t;this.state=e,Zn(this.state);for(const i of this.listeners)i(this.state)}patch(t){this.setState(e=>({...e,...t,time:t.time?{...e.time,...t.time}:e.time,plot:t.plot?{...e.plot,...t.plot,valueRange:t.plot.valueRange?{...e.plot.valueRange,...t.plot.valueRange}:e.plot.valueRange,tooltip:t.plot.tooltip?{...e.plot.tooltip,...t.plot.tooltip}:e.plot.tooltip}:e.plot,sources:t.sources?Object.fromEntries(Object.entries({...e.sources,...t.sources}).map(([i,r])=>[i,{...e.sources[i],...r}])):e.sources,graphs:t.graphs?Us(Object.fromEntries(Object.entries({...e.graphs,...t.graphs}).map(([i,r])=>[i,{...e.graphs[i],...r}]))):e.graphs,panels:t.panels?Ns({...e.panels,...t.panels}):e.panels}))}}class Qn{constructor(t){this.store=t,this.lastFrameTime=performance.now()}tick(t=performance.now()){const e=t-this.lastFrameTime;return this.lastFrameTime=t,this.store.setState(i=>{const r=i.time.realElapsedMs+e,n=i.time.paused?0:e*i.time.speed;return{...i,time:{...i.time,realNowMs:Date.now(),realElapsedMs:r,plotTimeMs:Math.max(0,i.time.plotTimeMs+n)}}}),e}togglePause(){this.store.setState(t=>({...t,time:{...t.time,paused:!t.time.paused}}))}setPaused(t){this.store.setState(e=>({...e,time:{...e.time,paused:t}}))}setSpeed(t){const e=Math.max(.1,Math.min(12,t));this.store.setState(i=>({...i,time:{...i.time,speed:e}}))}reset(){this.store.setState(t=>({...t,time:{...t.time,realElapsedMs:0,plotTimeMs:0},plot:{...t.plot,hoveredPoint:null,tooltip:{...t.plot.tooltip,visible:!1,point:null}}})),this.lastFrameTime=performance.now()}}class ni{constructor(t=1600){this.maxPoints=t,this.points=[]}addPoint(t){this.points.push(t),this.points.length>this.maxPoints&&this.points.splice(0,this.points.length-this.maxPoints)}clear(){this.points=[]}getVisiblePoints(t,e){const i=t-e;return this.points.filter(r=>r.timeMs>=i&&r.timeMs<=t)}}const Jn="modulepreload",to=function(s){return"/"+s},oi={},Ne=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(e.map(h=>{if(h=to(h),h in oi)return;oi[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":Jn,l||(u.as="script"),u.crossOrigin="",u.href=h,a&&u.setAttribute("nonce",a),document.head.appendChild(u),l)return new Promise((p,d)=>{u.addEventListener("load",p),u.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return t().catch(n)})};var L=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(L||{});const ys=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},ve=(s,t)=>ys(s).priority??t,rt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(ys).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(ys).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,r=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var o;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((o=n[s])==null||o.forEach(a=>t(a)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>ve(o.value,e)-ve(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>ve(n,e)-ve(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}},eo={extension:{type:L.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Ne(()=>import("./browserAll-BytxDfn1.js"),__vite__mapDeps([0,1,2]))}},so={extension:{type:L.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Ne(()=>import("./webworkerAll-J8ccMaq4.js"),__vite__mapDeps([1,2]))}};class q{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new q(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}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}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))}}function wr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Sr={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new r(c,u||h,p),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],d]:h._events[m].push(d):(h._events[m]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var p=0,d=u.length,m=new Array(d);p<d;p++)m[p]=u[p].fn;return m},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,p,d,m){var g=e?e+l:l;if(!this._events[g])return!1;var f=this._events[g],x=arguments.length,y,_;if(f.fn){switch(f.once&&this.removeListener(l,f.fn,void 0,!0),x){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,c),!0;case 3:return f.fn.call(f.context,c,u),!0;case 4:return f.fn.call(f.context,c,u,p),!0;case 5:return f.fn.call(f.context,c,u,p,d),!0;case 6:return f.fn.call(f.context,c,u,p,d,m),!0}for(_=1,y=new Array(x-1);_<x;_++)y[_-1]=arguments[_];f.fn.apply(f.context,y)}else{var b=f.length,v;for(_=0;_<b;_++)switch(f[_].once&&this.removeListener(l,f[_].fn,void 0,!0),x){case 1:f[_].fn.call(f[_].context);break;case 2:f[_].fn.call(f[_].context,c);break;case 3:f[_].fn.call(f[_].context,c,u);break;case 4:f[_].fn.call(f[_].context,c,u,p);break;default:if(!y)for(v=1,y=new Array(x-1);v<x;v++)y[v-1]=arguments[v];f[_].fn.apply(f[_].context,y)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,p){var d=e?e+l:l;if(!this._events[d])return this;if(!c)return o(this,d),this;var m=this._events[d];if(m.fn)m.fn===c&&(!p||m.once)&&(!u||m.context===u)&&o(this,d);else{for(var g=0,f=[],x=m.length;g<x;g++)(m[g].fn!==c||p&&!m[g].once||u&&m[g].context!==u)&&f.push(m[g]);f.length?this._events[d]=f.length===1?f[0]:f:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,s.exports=a})(Sr);var io=Sr.exports;const pt=wr(io),ro=Math.PI*2,no=180/Math.PI,oo=Math.PI/180;class Z{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new Z(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}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Ze.x=0,Ze.y=0,Ze}}const Ze=new Z;class I{constructor(t=1,e=0,i=0,r=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,n,o){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new Z;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new Z;const i=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-r),c=t.x,u=t.y;return e.x=o*l*c+-n*l*u+(h*n-a*o)*l,e.y=i*l*u+-r*l*c+(-h*i+a*r)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,o=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,u=e.c,p=e.d;return this.a=i*l+r*u,this.b=i*c+r*p,this.c=n*l+o*u,this.d=n*c+o*p,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*p+e.ty,this}setTransform(t,e,i,r,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(ro-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(o.x*e+o.y*r),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,o=t*r-e*i;return this.a=r/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-r*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 I;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}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return ho.identity()}static get shared(){return ao.identity()}}const ao=new I,ho=new I,kt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Et=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Rt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],It=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],_s=[],vr=[],Pe=Math.sign;function lo(){for(let s=0;s<16;s++){const t=[];_s.push(t);for(let e=0;e<16;e++){const i=Pe(kt[s]*kt[e]+Rt[s]*Et[e]),r=Pe(Et[s]*kt[e]+It[s]*Et[e]),n=Pe(kt[s]*Rt[e]+Rt[s]*It[e]),o=Pe(Et[s]*Rt[e]+It[s]*It[e]);for(let a=0;a<16;a++)if(kt[a]===i&&Et[a]===r&&Rt[a]===n&&It[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){const t=new I;t.set(kt[s],Et[s],Rt[s],It[s],0,0),vr.push(t)}}lo();const z={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:s=>kt[s],uY:s=>Et[s],vX:s=>Rt[s],vY:s=>It[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>_s[s][t],sub:(s,t)=>_s[s][z.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?z.S:z.N:Math.abs(t)*2<=Math.abs(s)?s>0?z.E:z.W:t>0?s>0?z.SE:z.SW:s>0?z.NE:z.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=vr[z.inv(t)];r.tx=e,r.ty=i,s.append(r)},transformRectCoords:(s,t,e,i)=>{const{x:r,y:n,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===z.E?(i.set(r+h,n+l,o,a),i):e===z.S?i.set(c-n-a+h,r+l,a,o):e===z.W?i.set(c-r-o+h,u-n-a+l,o,a):e===z.N?i.set(n+h,u-r-o+l,a,o):i.set(r+h,n+l,o,a)}},Me=[new Z,new Z,new Z,new Z];class W{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new W(0,0,0,0)}clone(){return new W(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-r),c=i-l,u=a-l,p=a+n+l,d=h-l,m=h+o+l,g=a+c,f=a+n-c,x=h+c,y=h+o-c;return t>=u&&t<=p&&e>=d&&e<=m&&!(t>g&&t<f&&e>x&&e<y)}intersects(t,e){if(!e){const R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=Me[0].set(t.left,t.top),h=Me[1].set(t.left,t.bottom),l=Me[2].set(t.right,t.top),c=Me[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const p=u*(h.y-a.y),d=u*(a.x-h.x),m=p*i+d*n,g=p*r+d*n,f=p*i+d*o,x=p*r+d*o;if(Math.max(m,g,f,x)<=p*a.x+d*a.y||Math.min(m,g,f,x)>=p*c.x+d*c.y)return!1;const y=u*(a.y-l.y),_=u*(l.x-a.x),b=y*i+_*n,v=y*r+_*n,S=y*i+_*o,w=y*r+_*o;return!(Math.max(b,v,S,w)<=y*a.x+_*a.y||Math.min(b,v,S,w)>=y*c.x+_*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t||(t=new W),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,r=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,r){return this.x=t,this.y=e,this.width=i,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ke={default:-1};function V(s="default"){return Ke[s]===void 0&&(Ke[s]=-1),++Ke[s]}const ai=new Set,O="8.0.0",co="8.3.4",$t={quiet:!1,noColor:!1},F=(s,t,e=3)=>{if($t.quiet||ai.has(t))return;let i=new Error().stack;const r=`${t}
+Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!$t.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(`
+`).splice(e).join(`
+`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),ai.add(t)};Object.defineProperties(F,{quiet:{get:()=>$t.quiet,set:s=>{$t.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>$t.noColor,set:s=>{$t.noColor=s},enumerable:!0,configurable:!1}});const Pr=()=>{};function Vt(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function hi(s){return!(s&s-1)&&!!s}function Mr(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const li=Object.create(null);function uo(s){const t=li[s];return t===void 0&&(li[s]=V("resource")),t}const Cr=class Tr extends pt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Tr.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){F(O,"TextureStyle.wrapMode is now TextureStyle.addressMode"),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=uo(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Cr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ue=Cr;const Ar=class kr extends pt{constructor(t={}){super(),this.options=t,this.uid=V("textureSource"),this._resourceType="textureSource",this._resourceId=V("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={...kr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1: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 Ue(Mr(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.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=V("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=V("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=hi(this.pixelWidth)&&hi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Ar.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ht=Ar;class $s extends ht{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}$s.extension=L.TextureSource;const ci=new I;class fo{constructor(t,e){this.mapCoord=new I,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*i.a+o*i.c+i.tx,e[r+1]=n*i.b+o*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(ci.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(ci));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class D extends pt{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=V("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new W,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new ht,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=r||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new fo(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,o=e.y/r,a=e.width/i,h=e.height/r;let l=this.rotate;if(l){const c=a/2,u=h/2,p=n+c,d=o+u;l=z.add(l,z.NW),t.x0=p+c*z.uX(l),t.y0=d+u*z.uY(l),l=z.add(l,2),t.x1=p+c*z.uX(l),t.y1=d+u*z.uY(l),l=z.add(l,2),t.x2=p+c*z.uX(l),t.y2=d+u*z.uY(l),l=z.add(l,2),t.x3=p+c*z.uX(l),t.y3=d+u*z.uY(l)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+h,t.x3=n,t.y3=o+h}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return F(O,"Texture.baseTexture is now Texture.source"),this._source}}D.EMPTY=new D({label:"EMPTY",source:new ht({label:"EMPTY"})});D.EMPTY.destroy=Pr;D.WHITE=new D({source:new $s({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});D.WHITE.destroy=Pr;function po(s,t,e){const{width:i,height:r}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;s.minX=n.x-t._x*i,s.maxX=s.minX+o,s.minY=n.y-t._y*r,s.maxY=s.minY+a}else s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*r,s.maxY=s.minY+r}const ui=new I;class at{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ui,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new W);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=ui,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty;let p=this.minX,d=this.minY,m=this.maxX,g=this.maxY,f=o*t+h*e+c,x=a*t+l*e+u;f<p&&(p=f),x<d&&(d=x),f>m&&(m=f),x>g&&(g=x),f=o*i+h*e+c,x=a*i+l*e+u,f<p&&(p=f),x<d&&(d=x),f>m&&(m=f),x>g&&(g=x),f=o*t+h*r+c,x=a*t+l*r+u,f<p&&(p=f),x<d&&(d=x),f>m&&(m=f),x>g&&(g=x),f=o*i+h*r+c,x=a*i+l*r+u,f<p&&(p=f),x<d&&(d=x),f>m&&(m=f),x>g&&(g=x),this.minX=p,this.minY=d,this.maxX=m,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:u}=t;let p=o*e+h*i+c,d=a*e+l*i+u;this.minX=p,this.minY=d,this.maxX=p,this.maxY=d,p=o*r+h*i+c,d=a*r+l*i+u,this.minX=p<this.minX?p:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY,p=o*e+h*n+c,d=a*e+l*n+u,this.minX=p<this.minX?p:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY,p=o*r+h*n+c,d=a*r+l*n+u,this.minX=p<this.minX?p:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),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 at(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,c=r.b,u=r.c,p=r.d,d=r.tx,m=r.ty;for(let g=e;g<i;g+=2){const f=t[g],x=t[g+1],y=l*f+u*x+d,_=c*f+p*x+m;n=y<n?y:n,o=_<o?_:o,a=y>a?y:a,h=_>h?_:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var mo={grad:.9,turn:360,rad:360/(2*Math.PI)},mt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},X=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},st=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Er=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},di=function(s){return{r:st(s.r,0,255),g:st(s.g,0,255),b:st(s.b,0,255),a:st(s.a)}},Qe=function(s){return{r:X(s.r),g:X(s.g),b:X(s.b),a:X(s.a,3)}},go=/^#([0-9a-f]{3,8})$/i,Ce=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Rr=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Ir=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},fi=function(s){return{h:Er(s.h),s:st(s.s,0,100),l:st(s.l,0,100),a:st(s.a)}},pi=function(s){return{h:X(s.h),s:X(s.s),l:X(s.l),a:X(s.a,3)}},mi=function(s){return Ir((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},he=function(s){return{h:(t=Rr(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},xo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_o=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bs={string:[[function(s){var t=go.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?X(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?X(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=_o.exec(s)||bo.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:di({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(s){var t=xo.exec(s)||yo.exec(s);if(!t)return null;var e,i,r=fi({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(mo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return mi(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return mt(t)&&mt(e)&&mt(i)?di({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!mt(t)||!mt(e)||!mt(i))return null;var o=fi({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return mi(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!mt(t)||!mt(e)||!mt(i))return null;var o=function(a){return{h:Er(a.h),s:st(a.s,0,100),v:st(a.v,0,100),a:st(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Ir(o)},"hsv"]]},gi=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},wo=function(s){return typeof s=="string"?gi(s.trim(),bs.string):typeof s=="object"&&s!==null?gi(s,bs.object):[null,void 0]},Je=function(s,t){var e=he(s);return{h:e.h,s:st(e.s+100*t,0,100),l:e.l,a:e.a}},ts=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},xi=function(s,t){var e=he(s);return{h:e.h,s:e.s,l:st(e.l+100*t,0,100),a:e.a}},ws=function(){function s(t){this.parsed=wo(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return X(ts(this.rgba),2)},s.prototype.isDark=function(){return ts(this.rgba)<.5},s.prototype.isLight=function(){return ts(this.rgba)>=.5},s.prototype.toHex=function(){return t=Qe(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?Ce(X(255*n)):"","#"+Ce(e)+Ce(i)+Ce(r)+o;var t,e,i,r,n,o},s.prototype.toRgb=function(){return Qe(this.rgba)},s.prototype.toRgbString=function(){return t=Qe(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return pi(he(this.rgba))},s.prototype.toHslString=function(){return t=pi(he(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Rr(this.rgba),{h:X(t.h),s:X(t.s),v:X(t.v),a:X(t.a,3)};var t},s.prototype.invert=function(){return ct({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),ct(Je(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),ct(Je(this.rgba,-t))},s.prototype.grayscale=function(){return ct(Je(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),ct(xi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),ct(xi(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?ct({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):X(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=he(this.rgba);return typeof t=="number"?ct({h:t,s:e.s,l:e.l,a:e.a}):X(e.h)},s.prototype.isEqual=function(t){return this.toHex()===ct(t).toHex()},s}(),ct=function(s){return s instanceof ws?s:new ws(s)},yi=[],So=function(s){s.forEach(function(t){yi.indexOf(t)<0&&(t(ws,bs),yi.push(t))})};function vo(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,p="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var m in e){var g=(a=c,h=n[m],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));g<u&&(u=g,p=m)}return p}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new s(h).toRgb():null},"name"])}So([vo]);const Wt=class re{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 re)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,o)=>n===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=re._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=re.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=ct(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof re||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}};Wt.shared=new Wt;Wt._temp=new Wt;Wt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=Wt;const Po={cullArea:null,cullable:!1,cullableChildren:!0};let es=0;const _i=500;function Q(...s){es!==_i&&(es++,es===_i?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const _e={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)},release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}};class Mo{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var i;let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class Co{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 Mo(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const it=new Co;_e.register(it);const To={get isCachedAsTexture(){var s;return!!((s=this.renderGroup)!=null&&s.isCachedAsTexture)},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){var s;(s=this.renderGroup)==null||s.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){F("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function Ao(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}const ko={allowChildren:!0,removeChildren(s=0,t){var n;const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let a=e-1;a>=s;a--){const h=this.children[a];h&&(r.push(h),h.parent=null)}Ao(this.children,s,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(r);for(let a=0;a<r.length;++a){const h=r[a];(n=h.parentRenderLayer)==null||n.detach(h),this.emit("childRemoved",h,this,a),r[a].emit("removed",this)}return r.length>0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||F(O,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s)}},Eo={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e))},collectRenderablesSimple(s,t,e){const i=this.children,r=i.length;for(let n=0;n<r;n++)i[n].collectRenderables(s,t,e)},collectRenderablesWithEffects(s,t,e){const{renderPipes:i}=t;for(let r=0;r<this.effects.length;r++){const n=this.effects[r];i[n.pipe].push(n,this,s)}this.collectRenderablesSimple(s,t,e);for(let r=this.effects.length-1;r>=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,s)}}};class bi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Ro{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return it.get(i.maskClass,t)}return t}returnMaskEffect(t){it.return(t)}}const Ss=new Ro;rt.handleByList(L.MaskEffect,Ss._effectClasses);const Io={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)},addEffect(s){this.effects.indexOf(s)===-1&&(this.effects.push(s),this.effects.sort((e,i)=>e.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Ss.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ss.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new bi);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new bi),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Bo={label:null,get name(){return F(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){F(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,!0,e);return e}},K=it.getPool(I),xt=it.getPool(at),Fo=new I,Go={getFastGlobalBounds(s,t){t||(t=new at),t.clear(),this._getGlobalBoundsRecursive(!!s,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(s,t,e){let i=t;if(s&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(i=xt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(s,i,e)}if(r){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(Fo).invert()),t.addBounds(i),xt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),xt.return(i))}};function Br(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=K.get().identity(),i=Os(s,r)):i=I.IDENTITY,Fr(s,e,i,t),r&&K.return(r),e.isValid||e.set(0,0,0,0),e}function Fr(s,t,e,i){var a,h;if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=K.get(),r.appendFrom(s.localTransform,e));const n=t,o=!!s.effects.length;if(o&&(t=xt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{const l=s.bounds;l&&!l.isEmpty()&&(t.matrix=r,t.addBounds(l));for(let c=0;c<s.children.length;c++)Fr(s.children[c],t,r,i)}if(o){for(let l=0;l<s.effects.length;l++)(h=(a=s.effects[l]).addBounds)==null||h.call(a,t);n.addBounds(t,I.IDENTITY),xt.return(t)}i||K.return(r)}function Os(s,t){const e=s.parent;return e&&(Os(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Gr(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=r*a/255|0;return(h<<16)+(l<<8)+c}const wi=16777215;function Si(s,t){return s===wi?t:t===wi?s:Gr(s,t)}function ze(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const Lo={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(s=new I,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Os(this,K.get().identity());return s.appendFrom(this.localTransform,e),K.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?ze(this.renderGroup.worldColor):this.parentRenderGroup?ze(Si(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Si(t,e.localColor),e=e.parent;return ze(t)}};function Lr(s,t,e){return t.clear(),e||(e=I.IDENTITY),Dr(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function Dr(s,t,e,i,r){var h,l;let n;if(r)n=K.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const c=s.localTransform;n=K.get(),n.appendFrom(c,e)}const o=t,a=!!s.effects.length;if(a&&(t=xt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));const c=s.children;for(let u=0;u<c.length;u++)Dr(c[u],t,n,i,!1)}if(a){for(let c=0;c<s.effects.length;c++)(l=(h=s.effects[c]).addLocalBounds)==null||l.call(h,t,i);o.addBounds(t,I.IDENTITY),xt.return(t)}K.return(n)}function zr(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,r.children.length&&zr(r,t)}return t.didChange}const Do=new I,zo={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new at});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),zr(this,s),s.didChange&&Lr(this,s.localBounds,Do),s.localBounds},getBounds(s,t){return Br(this,s,t||new at)}},Ho={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},No={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,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(Uo))}};function Uo(s,t){return s._zIndex-t._zIndex}const $o={getGlobalPosition(s=new Z,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){const i=this.getGlobalTransform(K.get(),e);return t=i.apply(s,t),K.return(i),t},toLocal(s,t,e,i){t&&(s=t.toGlobal(s,e,i));const r=this.getGlobalTransform(K.get(),i);return e=r.applyInverse(s,e),K.return(r),e}};class Hr{constructor(){this.uid=V("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Oo=0;class Vo{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Ue(this.textureOptions)}createTexture(t,e,i){const r=new ht({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new D({source:r,label:`texturePool_${Oo++}`})}getOptimalTexture(t,e,i=1,r){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=Vt(n),o=Vt(o);const a=(n<<17)+(o<<1)+(r?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,r)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this._texturePool={}}}const Nr=new Vo;_e.register(Nr);class Wo{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new I,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Hr,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const r=e[i];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Nr.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new I),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new I),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new I),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Yo(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const ss=new q(null),Te=new q(null),is=new q(null,1,1),Ae=new q(null),vi=1,Xo=2,rs=4;class ft extends pt{constructor(t={}){var e,i;super(),this.uid=V("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new I,this.relativeGroupTransform=new I,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new q(this,0,0),this._scale=is,this._pivot=Te,this._origin=Ae,this._skew=ss,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Yo(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(r=>this.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){F("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),rt.mixin(ft,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||F(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=it.get(Wo,this),this.groupTransform=I.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),it.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 I),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*no}set angle(t){this.rotation=t*oo}get pivot(){return this._pivot===Te&&(this._pivot=new q(this,0,0)),this._pivot}set pivot(t){this._pivot===Te&&(this._pivot=new q(this,0,0),this._origin!==Ae&&Q("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ss&&(this._skew=new q(this,0,0)),this._skew}set skew(t){this._skew===ss&&(this._skew=new q(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===is&&(this._scale=new q(this,1,1)),this._scale}set scale(t){this._scale===is&&(this._scale=new q(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Ae&&(this._origin=new q(this,0,0)),this._origin}set origin(t){this._origin===Ae&&(this._origin=new q(this,0,0),this._pivot!==Te&&Q("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,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.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=r._x,c=r._y,u=-n._x,p=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+p*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=vi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Y.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=vi,this._onUpdate())}get tint(){return ze(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Xo,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|=rs,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|=rs,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|=rs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&e)for(let n=0;n<e.length;++n)e[n].destroy(t);(r=this.renderGroup)==null||r.destroy(),this.renderGroup=null}}rt.mixin(ft,ko,Go,$o,Ho,zo,Io,Bo,No,Po,To,Lo,Eo);class Vs extends ft{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new at(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:r}=t;return i>=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const r in this._gpuData)(i=(e=this._gpuData[r]).destroy)==null||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:r}=e;r.blendMode.pushBlendMode(this,this.groupBlendMode,t),r[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const o=this.children,a=o.length;for(let h=0;h<a;h++)o[h].collectRenderables(t,e,i);r.blendMode.popBlendMode(t)}}class de extends Vs{constructor(t=D.EMPTY){t instanceof D&&(t={texture:t});const{texture:e=D.EMPTY,anchor:i,roundPixels:r,width:n,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof D?new de(t):new de(D.from(t,e))}set texture(t){t||(t=D.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return po(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return F("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:r,height:n}=e.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const jo=new at;function Ur(s,t,e){const i=jo;s.measurable=!0,Br(s,e,i),t.addBoundsMask(i),s.measurable=!1}function $r(s,t,e){const i=xt.get();s.measurable=!0;const r=K.get().identity(),n=Or(s,e,r);Lr(s,i,n),s.measurable=!1,t.addBoundsMask(i),K.return(r),xt.return(i)}function Or(s,t,e){return s?(s!==t&&(Or(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(Q("Mask bounds, renderable is not inside the root container"),e)}class Vr{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof de),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Ur(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof de}}Vr.extension=L.MaskEffect;class Wr{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"}}Wr.extension=L.MaskEffect;class Yr{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){Ur(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof ft}}Yr.extension=L.MaskEffect;const qo={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Pi=qo;const et={get(){return Pi},set(s){Pi=s}};class Xr extends ht{constructor(t){t.resource||(t.resource=et.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Xr.extension=L.TextureSource;class $e extends ht{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}$e.extension=L.TextureSource;var vs=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(vs||{});class ns{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}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 jr=class tt{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 ns(null,null,1/0),this.deltaMS=1/tt.targetFPMS,this.elapsedMS=1/tt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=vs.NORMAL){return this._addListener(new ns(t,e,i))}addOnce(t,e,i=vs.NORMAL){return this._addListener(new ns(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*tt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,tt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!tt._shared){const t=tt._shared=new tt;t.autoStart=!0,t._protected=!0}return tt._shared}static get system(){if(!tt._system){const t=tt._system=new tt;t.autoStart=!0,t._protected=!0}return tt._system}};jr.targetFPMS=.06;let ke=jr,os;async function Zo(){return os??(os=(async()=>{var o;const t=et.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),os}const We=class qr extends ht{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...qr.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"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=ke.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 Zo(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,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&&(ke.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||(ke.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ke.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};We.extension=L.TextureSource;We.defaultOptions={...ht.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};We.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ko=We;const zt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Qo{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){const e=this._cache.get(t);return e||Q(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=zt(t);let r;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){r=l.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&Q("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){Q(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Ht=new Qo,Ps=[];rt.handleByList(L.TextureSource,Ps);function Zr(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<Ps.length;r++){const n=Ps[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Jo(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&Ht.has(i))return Ht.get(i);const n=new D({source:Zr(r)});return n.on("destroy",()=>{Ht.has(i)&&Ht.remove(i)}),t||Ht.set(i,n),n}function ta(s,t=!1){return typeof s=="string"?Ht.get(s):s instanceof ht?new D({source:s}):Jo(s,t)}D.from=ta;ht.from=Zr;rt.add(Vr,Wr,Yr,Ko,$e,Xr,$s);var Kr=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Kr||{});function nt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Qt(s){return s.split("?")[0].split("#")[0]}function ea(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sa(s,t,e){return s.replace(new RegExp(ea(t),"g"),e)}function ia(s,t){let e="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const fe={toPosix(s){return sa(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){nt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(nt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Qt(this.toPosix(t??et.get().getBaseUrl())),r=Qt(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?fe.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(nt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=ia(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return nt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(nt(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(nt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=!1;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){nt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){nt(s),t&&nt(t),s=Qt(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){nt(s),s=Qt(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){nt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Qt(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Qr(s,t,e,i,r){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Qr(s.replace(i[e],a),t,e+1,i,r):r.push(s.replace(i[e],a))}}function ra(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),Qr(s,r,0,e,i)}else i.push(s);return i}const Mi=s=>!Array.isArray(s);class Jr{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){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return zt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&Q("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&Q(`[Resolver] already has key: ${n} overwriting`)},zt(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=zt(o).map(m=>typeof m=="string"?ra(m):Array.isArray(m)?m:[m]),p=this.getAlias(n);Array.isArray(p)?p.forEach(i):i(p);const d=[];u.forEach(m=>{m.forEach(g=>{let f={};if(typeof g!="object"){f.src=g;for(let x=0;x<this._parsers.length;x++){const y=this._parsers[x];if(y.test(g)){f=y.parse(g);break}}}else a=g.data??a,h=g.format??h,(g.loadParser||g.parser)&&(l=g.loadParser??l,c=g.parser??c),f={...f,...g};if(!p)throw new Error(`[Resolver] alias is undefined for this asset: ${f.src}`);f=this._buildResolvedAsset(f,{aliases:p,data:a,format:h,loadParser:l,parser:c}),d.push(f)})}),p.forEach(m=>{this._assetMap[m]=d})})}resolveBundle(t){const e=Mi(t);t=zt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}i[r]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Mi(t);t=zt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,parser:o,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=fe.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??na(t.src),t}}Jr.RETINA_PREFIX=/@([0-9\.]+)x/;function na(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Ci=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},tn=class ne{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof ht&&(i={texture:t,data:e});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof D?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ne.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ne.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],o=n.frame;if(o){let a=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new W(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new W(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new W(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new W(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new D({source:this.textureSource,frame:a,orig:c,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ne.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ne.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};tn.BATCH_SIZE=1e3;let Ti=tn;const oa=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function en(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=fe.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=en([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const aa={extension:L.Asset,cache:{test:s=>s instanceof Ti,getCacheableAssets:(s,t)=>en(s,t,!1)},resolver:{extension:{type:L.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&oa.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=Jr.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:L.LoadParser,priority:Kr.Normal,name:"spritesheetLoader"},async testParse(s,t){return fe.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,p;const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=fe.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof D)h=i;else{const d=Ci(a+(r??s.meta.image),t.src);h=(await e.load([{src:d,data:n}]))[d]}const l=new Ti({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(c)){const d=[];for(const g of c){if(typeof g!="string")continue;let f=a+g;(p=t.data)!=null&&p.ignoreMultiPack||(f=Ci(f,t.src),d.push(e.load({src:f,data:{textureOptions:n,ignoreMultiPack:!0}})))}const m=await Promise.all(d);l.linkedSheets=m,m.forEach(g=>{g.linkedSheets=[l].concat(l.linkedSheets.filter(f=>f!==g))})}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};rt.add(aa);const as=Object.create(null),Ai=Object.create(null);function Ws(s,t){let e=Ai[s];return e===void 0&&(as[t]===void 0&&(as[t]=1),Ai[s]=e=as[t]++),e}let Gt;function sn(){return(!Gt||Gt!=null&&Gt.isContextLost())&&(Gt=et.get().createCanvas().getContext("webgl",{})),Gt}let Ee;function ha(){if(!Ee){Ee="mediump";const s=sn();s&&s.getShaderPrecisionFormat&&(Ee=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Ee}function la(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
+
+ #ifdef GL_ES // This checks if it is WebGL1
+ #define in varying
+ #define finalColor gl_FragColor
+ #define texture texture2D
+ #endif
+ ${s}
+ `):`
+
+ #ifdef GL_ES // This checks if it is WebGL1
+ #define in attribute
+ #define out varying
+ #endif
+ ${s}
+ `}function ca(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float;
+${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function ua(s,t){return t?`#version 300 es
+${s}`:s}const da={},fa={};function pa(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?da:fa;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
+${s}`}function ma(s,t){return t?s.replace("#version 300 es",""):s}const hs={stripVersion:ma,ensurePrecision:ca,addProgramDefines:la,setProgramName:pa,insertVersion:ua},Jt=Object.create(null),rn=class Ms{constructor(t){t={...Ms.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ha()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(hs).forEach(o=>{const a=i[o];r=hs[o](r,a,!0),n=hs[o](n,a,!1)}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ws(`${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,Jt[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Jt[e]||(Jt[e]=new Ms(t),Jt[e]._cacheKey=e),Jt[e]}};rn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let nn=rn;const ki={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 ga(s){return ki[s]??ki.float32}const xa={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function ya({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;(a=o.exec(n))!==null;){const h=xa[a[3]]??"float32";e[a[2]]={location:parseInt(a[1],10),format:h,stride:ga(h).stride,offset:0,instance:!1,start:0}}}}return e}function ls(s){var u,p;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(u=s.match(t))==null?void 0:u.map(d=>({group:parseInt(d.match(e)[1],10),binding:parseInt(d.match(i)[1],10),name:d.match(r)[2],isUniform:d.match(r)[1]==="<uniform>",type:d.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((p=s.match(o))==null?void 0:p.map(d=>{const m=d.match(h)[1],g=d.match(a).reduce((f,x)=>{const[y,_]=x.split(":");return f[y.trim()]=_.trim(),f},{});return g?{name:m,members:g}:null}).filter(({name:d})=>l.some(m=>m.type===d)))??[];return{groups:l,structs:c}}var oe=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(oe||{});function _a({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:oe.VERTEX|oe.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:oe.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:oe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function ba({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function wa(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:r,groups:n}}const te=Object.create(null);class Ye{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=ls(e.source);this.structsAndGroups=l}else{const l=ls(i.source),c=ls(e.source);this.structsAndGroups=wa(l,c)}this.layout=r??ba(this.structsAndGroups),this.gpuLayout=n??_a(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ws(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=ya(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,te[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return te[e]||(te[e]=new Ye(t),te[e]._cacheKey=e),te[e]}}const on=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Sa=on.reduce((s,t)=>(s[t]=!0,s),{});function va(s,t){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const an=class hn{constructor(t,e){this._touched=0,this.uid=V("uniform"),this._resourceType="uniformGroup",this._resourceId=V("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...hn.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Sa[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${on.join(", ")}`)}n.value??(n.value=va(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ws(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};an.defaultOptions={ubo:!1,isStatic:!1};let ln=an;class He{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r==null?void 0:r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Cs=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Cs||{});class Ys extends pt{constructor(t){super(),this.uid=V("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Cs.WEBGPU),i&&(o|=Cs.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in n)h[c]||(r[99]||(r[99]=new He,this._ownedBindGroups.push(r[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let p=n[c];!p.source&&!p._resourceType&&(p=new ln(p));const d=h[u];d&&(r[d.group]||(r[d.group]=new He,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(p,d.binding))}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new He,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=Ye.from(e)),i&&(o=nn.from(i)),new Ys({gpuProgram:n,glProgram:o,...r})}}const Ts=[];rt.handleByNamedList(L.Environment,Ts);async function Pa(s){if(!s)for(let t=0;t<Ts.length;t++){const e=Ts[t];if(e.value.test()){await e.value.load();return}}}let ee;function Ma(){if(typeof ee=="boolean")return ee;try{ee=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ee=!1}return ee}function Ei(s,t,e=2){const i=t&&t.length,r=i?t[0]*e:s.length;let n=cn(s,0,r,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=Ea(s,t,n,e)),s.length>80*e){a=s[0],h=s[1];let c=a,u=h;for(let p=e;p<r;p+=e){const d=s[p],m=s[p+1];d<a&&(a=d),m<h&&(h=m),d>c&&(c=d),m>u&&(u=m)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return pe(n,o,e,a,h,l,0),o}function cn(s,t,e,i,r){let n;if(r===Ua(s,t,e,i)>0)for(let o=t;o<e;o+=i)n=Ri(o/i|0,s[o],s[o+1],n);else for(let o=e-i;o>=t;o-=i)n=Ri(o/i|0,s[o],s[o+1],n);return n&&Yt(n,n.next)&&(ge(n),n=n.next),n}function Ft(s,t){if(!s)return s;t||(t=s);let e=s,i;do if(i=!1,!e.steiner&&(Yt(e,e.next)||U(e.prev,e,e.next)===0)){if(ge(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function pe(s,t,e,i,r,n,o){if(!s)return;!o&&n&&Ga(s,i,r,n);let a=s;for(;s.prev!==s.next;){const h=s.prev,l=s.next;if(n?Ta(s,i,r,n):Ca(s)){t.push(h.i,s.i,l.i),ge(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=Aa(Ft(s),t),pe(s,t,e,i,r,n,2)):o===2&&ka(s,t,e,i,r,n):pe(Ft(s),t,e,i,r,n,1);break}}}function Ca(s){const t=s.prev,e=s,i=s.next;if(U(t,e,i)>=0)return!1;const r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(r,n,o),u=Math.min(a,h,l),p=Math.max(r,n,o),d=Math.max(a,h,l);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=u&&m.y<=d&&ae(r,a,n,h,o,l,m.x,m.y)&&U(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ta(s,t,e,i){const r=s.prev,n=s,o=s.next;if(U(r,n,o)>=0)return!1;const a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,p=o.y,d=Math.min(a,h,l),m=Math.min(c,u,p),g=Math.max(a,h,l),f=Math.max(c,u,p),x=As(d,m,t,e,i),y=As(g,f,t,e,i);let _=s.prevZ,b=s.nextZ;for(;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=d&&_.x<=g&&_.y>=m&&_.y<=f&&_!==r&&_!==o&&ae(a,c,h,u,l,p,_.x,_.y)&&U(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=d&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&ae(a,c,h,u,l,p,b.x,b.y)&&U(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=d&&_.x<=g&&_.y>=m&&_.y<=f&&_!==r&&_!==o&&ae(a,c,h,u,l,p,_.x,_.y)&&U(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&ae(a,c,h,u,l,p,b.x,b.y)&&U(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Aa(s,t){let e=s;do{const i=e.prev,r=e.next.next;!Yt(i,r)&&dn(i,e,e.next,r)&&me(i,r)&&me(r,i)&&(t.push(i.i,e.i,r.i),ge(e),ge(e.next),e=s=r),e=e.next}while(e!==s);return Ft(e)}function ka(s,t,e,i,r,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&za(o,a)){let h=fn(o,a);o=Ft(o,o.next),h=Ft(h,h.next),pe(o,t,e,i,r,n,0),pe(h,t,e,i,r,n,0);return}a=a.next}o=o.next}while(o!==s)}function Ea(s,t,e,i){const r=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,h=n<o-1?t[n+1]*i:s.length,l=cn(s,a,h,i,!1);l===l.next&&(l.steiner=!0),r.push(Da(l))}r.sort(Ra);for(let n=0;n<r.length;n++)e=Ia(r[n],e);return e}function Ra(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=i-r}return e}function Ia(s,t){const e=Ba(s,t);if(!e)return t;const i=fn(e,s);return Ft(i,i.next),Ft(e,e.next)}function Ba(s,t){let e=t;const i=s.x,r=s.y;let n=-1/0,o;if(Yt(s,e))return e;do{if(Yt(s,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const u=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>n&&(n=u,o=e.x<e.next.x?e:e.next,u===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=h&&i!==e.x&&un(r<l?i:n,r,h,l,r<l?n:i,r,e.x,e.y)){const u=Math.abs(r-e.y)/(i-e.x);me(e,s)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&Fa(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function Fa(s,t){return U(s.prev,s,t.prev)<0&&U(t.next,s,s.next)<0}function Ga(s,t,e,i){let r=s;do r.z===0&&(r.z=As(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,La(r)}function La(s){let t,e=1;do{let i=s,r;s=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=o}n.nextZ=null,e*=2}while(t>1);return s}function As(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Da(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function un(s,t,e,i,r,n,o,a){return(r-o)*(t-a)>=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function ae(s,t,e,i,r,n,o,a){return!(s===o&&t===a)&&un(s,t,e,i,r,n,o,a)}function za(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Ha(s,t)&&(me(s,t)&&me(t,s)&&Na(s,t)&&(U(s.prev,s,t.prev)||U(s,t.prev,t))||Yt(s,t)&&U(s.prev,s,s.next)>0&&U(t.prev,t,t.next)>0)}function U(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Yt(s,t){return s.x===t.x&&s.y===t.y}function dn(s,t,e,i){const r=Ie(U(s,t,e)),n=Ie(U(s,t,i)),o=Ie(U(e,i,s)),a=Ie(U(e,i,t));return!!(r!==n&&o!==a||r===0&&Re(s,e,t)||n===0&&Re(s,i,t)||o===0&&Re(e,s,i)||a===0&&Re(e,t,i))}function Re(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Ie(s){return s>0?1:s<0?-1:0}function Ha(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&dn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function me(s,t){return U(s.prev,s,s.next)<0?U(s,t,s.next)>=0&&U(s,s.prev,t)>=0:U(s,t,s.prev)<0||U(s,s.next,t)<0}function Na(s,t){let e=s,i=!1;const r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function fn(s,t){const e=ks(s.i,s.x,s.y),i=ks(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Ri(s,t,e,i){const r=ks(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ge(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function ks(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ua(s,t,e,i){let r=0;for(let n=t,o=e-i;n<e;n+=i)r+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return r}const $a=Ei.default||Ei;var pn=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(pn||{});class Oa{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,o,a,h){const{name:l,items:c}=this;for(let u=0,p=c.length;u<p;u++)c[u][l](t,e,i,r,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Va=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],mn=class gn extends pt{constructor(t){super(),this.uid=V("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Va,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Pa(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...gn.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){let i=t;if(i instanceof ft&&(i={container:i},e&&(F(O,"passing a second argument is deprecated, please use render options instead"),i.target=e.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:Y.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i))}resize(t,e,i){const r=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=pn.ALL);const{clear:i,clearColor:r,target:n}=t;Y.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,Y.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Oa(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&_e.release(),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ma())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};mn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let xn=mn,Be;function Wa(s){return Be!==void 0||(Be=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??xn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!et.get().getWebGLRenderingContext())return!1;let r=et.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const o=r.getExtension("WEBGL_lose_context");o&&o.loseContext()}return r=null,n}catch{return!1}})()),Be}let Fe;async function Ya(s={}){return Fe!==void 0||(Fe=await(async()=>{const t=et.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Fe}const Ii=["webgl","webgpu","canvas"];async function Xa(s){let t=[];s.preference?(t.push(s.preference),Ii.forEach(n=>{n!==s.preference&&t.push(n)})):t=Ii.slice();let e,i={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await Ya()){const{WebGPURenderer:a}=await Ne(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-CtyVoQqf.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&Wa(s.failIfMajorPerformanceCaveat??xn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Ne(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-BVO0qznQ.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=a,i={...s,...s.webgl};break}else if(o==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const yn="8.13.2";class _n{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,yn)}static destroy(){}}_n.extension=L.Application;class ja{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,yn)}destroy(){this._renderer=null}}ja.extension={type:[L.WebGLSystem,L.WebGPUSystem],name:"initHook",priority:-10};const bn=class Es{constructor(...t){this.stage=new ft,t[0]!==void 0&&F(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Xa(t),Es._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return F(O,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Es._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};bn._plugins=[];let wn=bn;rt.handleByList(L.Application,wn._plugins);rt.add(_n);/**
+ * tiny-lru
+ *
+ * @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
+ * @license BSD-3-Clause
+ * @version 11.4.5
+ */class qa{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(e=>[e,this.get(e)])}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=[];let e=this.first;for(;e!==null;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let r=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(t,e,i=!1,r=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(e=>this.get(e))}}function Za(s=1e3,t=0,e=!1){if(isNaN(s)||s<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new qa(s,t,e)}const Ka=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Sn(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Ka.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const cs={willReadFrequently:!0},lt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t===void 0){const e=et.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}-${e.styleKey}-wordWrap-${r}`;if(T._measurementCache.has(n))return T._measurementCache.get(n);const o=Sn(e),a=T.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const h=T.__context;h.font=o;const c=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let p=0;for(let _=0;_<c.length;_++){const b=T._measureText(c[_],e.letterSpacing,h);u[_]=b,p=Math.max(p,b)}const d=((y=e._stroke)==null?void 0:y.width)||0;let m=p+d;e.dropShadow&&(m+=e.dropShadow.distance);const g=e.lineHeight||a.fontSize;let f=Math.max(g,a.fontSize+d)+(c.length-1)*(g+e.leading);e.dropShadow&&(f+=e.dropShadow.distance);const x=new T(t,e,m,f,c,u,g+e.leading,p,a);return T._measurementCache.set(n,x),x}static _measureText(t,e,i){let r=!1;T.experimentalLetterSpacingSupported&&(T.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(r)o-=e,l-=e;else{const c=(T.graphemeSegmenter(t).length-1)*e;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",cs);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=T._collapseSpaces(c),p=T._collapseNewlines(c);let d=!u;const m=e.wordWrapWidth+l,g=T._tokenize(t);for(let f=0;f<g.length;f++){let x=g[f];if(T._isNewline(x)){if(!p){a+=T._addLine(o),d=!u,o="",n=0;continue}x=" "}if(u){const _=T.isBreakingSpace(x),b=T.isBreakingSpace(o[o.length-1]);if(_&&b)continue}const y=T._getFromCache(x,l,h,r);if(y>m)if(o!==""&&(a+=T._addLine(o),o="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let b=0;b<_.length;b++){let v=_[b],S=v,w=1;for(;_[b+w];){const k=_[b+w];if(!T.canBreakChars(S,k,x,b,e.breakWords))v+=k;else break;S=k,w++}b+=w-1;const R=T._getFromCache(v,l,h,r);R+n>m&&(a+=T._addLine(o),d=!1,o="",n=0),o+=v,n+=R}}else{o.length>0&&(a+=T._addLine(o),o="",n=0);const _=f===g.length-1;a+=T._addLine(x,!_),d=!1,o="",n=0}else y+n>m&&(d=!1,a+=T._addLine(o),o="",n=0),(o.length>0||!T.isBreakingSpace(x)||d)&&(o+=x,n+=y)}return a+=T._addLine(o,!1),a}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t}
+`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(T.isBreakingSpace(n,o)||T._isNewline(n)){i!==""&&(e.push(i),i=""),n==="\r"&&o===`
+`?(e.push(`\r
+`),r++):e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return T.graphemeSegmenter(t)}static measureFont(t){if(T._fonts[t])return T._fonts[t];const e=T._context;e.font=t;const i=e.measureText(T.METRICS_STRING+T.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return T._fonts[t]=r,r}static clearMetrics(t=""){t?delete T._fonts[t]:T._fonts={}}static get _canvas(){if(!T.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",cs);if(i!=null&&i.measureText)return T.__canvas=e,e;t=et.get().createCanvas()}catch{t=et.get().createCanvas()}t.width=t.height=10,T.__canvas=t}return T.__canvas}static get _context(){return T.__context||(T.__context=T._canvas.getContext("2d",cs)),T.__context}};lt.METRICS_STRING="|ÉqÅ";lt.BASELINE_SYMBOL="M";lt.BASELINE_MULTIPLIER=1.4;lt.HEIGHT_MULTIPLIER=2;lt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let r=0;for(const n of e)i[r++]=n.segment;return i}}return s=>[...s]})();lt.experimentalLetterSpacing=!1;lt._fonts={};lt._newlines=[10,13];lt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];lt._measurementCache=Za(1e3);let Nt=lt;const Bi=[{offset:0,color:"white"},{offset:1,color:"black"}],Xs=class Rs{constructor(...t){this.uid=V("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Qa(t);e={...e.type==="radial"?Rs.defaultRadialOptions:Rs.defaultLinearOptions,...Mr(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:r}=this.end,n=i-t,o=r-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const f=t;t=i,i=f,n*=-1}if(o<0){const f=e;e=r,r=f,o*=-1}}const h=this.colorStops.length?this.colorStops:Bi,l=this._textureSize,{canvas:c,context:u}=Gi(l,1),p=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Fi(p,h),u.fillStyle=p,u.fillRect(0,0,l,1),this.texture=new D({source:new $e({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),g=new I;g.scale(d/l,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Bi,e=this._textureSize,{canvas:i,context:r}=Gi(e,e),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,p=h-c,d=e/(c*2),m=(n-u)*d,g=(o-p)*d,f=r.createRadialGradient(m,g,l*d,(a-u)*d,(h-p)*d,c*d);Fi(f,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,e,e),r.fillStyle=f,r.translate(m,g),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-m,-g),r.fillRect(0,0,e,e),this.texture=new D({source:new $e({resource:i,addressMode:this._wrapMode})});const x=new I;x.scale(1/d,1/d),x.translate(u,p),this.textureSpace==="local"&&x.scale(e,e),this.transform=x}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Xs.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Xs.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let _t=Xs;function Fi(s,t){for(let e=0;e<t.length;e++){const i=t[e];s.addColorStop(i.offset,i.color)}}function Gi(s,t){const e=et.get().createCanvas(s,t),i=e.getContext("2d");return{canvas:e,context:i}}function Qa(s){let t=s[0]??{};return(typeof t=="number"||s[1])&&(F("8.5.2","use options object instead"),t={type:"linear",start:{x:s[0],y:s[1]},end:{x:s[2],y:s[3]},textureSpace:s[4],textureSize:s[5]??_t.defaultLinearOptions.textureSize}),t}const Li={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 Xe{constructor(t,e){this.uid=V("fillPattern"),this._tick=0,this.transform=new I,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Li[e].addressModeU,t.source.style.addressModeV=Li[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var Ja=eh,us={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},th=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function eh(s){var t=[];return s.replace(th,function(e,i,r){var n=i.toLowerCase();for(r=ih(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==us[n])return r.unshift(i),t.push(r);if(r.length<us[n])throw new Error("malformed path data");t.push([i].concat(r.splice(0,us[n])))}}),t}var sh=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function ih(s){var t=s.match(sh);return t?t.map(Number):[]}const rh=wr(Ja);function nh(s,t){const e=rh(s),i=[];let r=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:Q(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r))}return t}class js{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new js(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i,r=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-r)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new W),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}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class qs{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new qs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-r),h=i-a,l=n-h,c=o-h,u=n+a,p=o+a,d=t-this.x,m=e-this.y,g=d*d/(l*l)+m*m/(c*c),f=d*d/(u*u)+m*m/(p*p);return g>1&&f<=1}getBounds(t){return t||(t=new W),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}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function oh(s,t,e,i,r,n){const o=s-e,a=t-i,h=r-e,l=n-i,c=o*h+a*l,u=h*h+l*l;let p=-1;u!==0&&(p=c/u);let d,m;p<0?(d=e,m=i):p>1?(d=r,m=n):(d=e+p*h,m=i+p*l);const g=s-d,f=t-m;return g*g+f*f}let ah,hh;class le{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let r=0;r<i;r+=2){const n=e[r],o=e[r+1],a=e[(r+2)%i],h=e[(r+3)%i];t+=(a-n)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(ah),i=t.getBounds(hh);if(!e.containsRect(i))return!1;const r=t.points;for(let n=0;n<r.length;n+=2){const o=r[n],a=r[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new le(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}strokeContains(t,e,i,r=.5){const n=i*i,o=n*(1-r),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const u=h[c],p=h[c+1],d=h[(c+2)%h.length],m=h[(c+3)%h.length],g=oh(t,e,u,p,d,m),f=Math.sign((d-u)*(e-p)-(m-p)*(t-u));if(g<=(f<0?a:o))return!0}return!1}getBounds(t){t||(t=new W);const e=this.points;let i=1/0,r=-1/0,n=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];i=l<i?l:i,r=l>r?l:r,n=c<n?c:n,o=c>o?c:o}return t.x=i,t.width=r-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return F("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return F("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Ge=(s,t,e,i,r,n,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=r-n&&l<=r+o};class Zs{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t||(t=new W),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Zs(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return!0}return!1}strokeContains(t,e,i,r=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-r),u=i-c,p=n+l,d=o+l,m=a-l*2,g=h-l*2,f=n+a,x=o+h;return(t>=n-c&&t<=n+u||t>=f-u&&t<=f+c)&&e>=d&&e<=d+g||(e>=o-c&&e<=o+u||e>=x-u&&e<=x+c)&&t>=p&&t<=p+m?!0:t<p&&e<d&&Ge(t,e,p,d,l,u,c)||t>f-l&&e<d&&Ge(t,e,f-l,d,l,u,c)||t>f-l&&e>x-l&&Ge(t,e,f-l,x-l,l,u,c)||t<p&&e>x-l&&Ge(t,e,p,x-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const vn={};function lh(s,t,e){let i=2166136261;for(let r=0;r<t;r++)i^=s[r].uid,i=Math.imul(i,16777619),i>>>=0;return vn[i]||ch(s,t,i,e)}function ch(s,t,e,i){const r={};let n=0;for(let a=0;a<i;a++){const h=a<t?s[a]:D.EMPTY.source;r[n++]=h.source,r[n++]=h.style}const o=new He(r);return vn[e]=o,o}class Di{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function zi(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const o=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(o)}}const uh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var dh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(dh||{});function Hi(s,t){return t.alphaMode==="no-premultiply-alpha"&&uh[s]||s}const fh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
+`);function ph(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
+else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function mh(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=fh.replace(/%forloop%/gi,ph(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e)}return s}let Lt=null;function gh(){var t;if(Lt)return Lt;const s=sn();return Lt=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Lt=mh(Lt,s),(t=s.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Lt}class xh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class yh{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new xh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const ce=[];let Oe=0;_e.register({clear:()=>{if(ce.length>0)for(const s of ce)s&&s.destroy();ce.length=0,Oe=0}});function Ni(){return Oe>0?ce[--Oe]:new yh}function Ui(s){ce[Oe++]=s}let se=0;const Pn=class Mn{constructor(t){this.uid=V("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...Mn.defaultOptions,...t},t.maxTextures||(F("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=gh());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new Di(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Ui(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=Ni(),r=i.textures;r.clear();const n=e[this.elementStart];let o=Hi(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,p=this._batchIndexStart,d="startBatch";const m=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const f=e[g];e[g]=null;const y=f.texture._source,_=Hi(f.blendMode,y),b=o!==_||a!==f.topology;if(y._batchTick===se&&!b){f._textureId=y._textureBindLocation,u+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,h,l,f._attributeStart,f._textureId),this.packQuadIndex(c,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,h,l,f._attributeStart,f._textureId),this.packIndex(f,c,f._indexStart,f._attributeStart/this.vertexSize)),f._batch=i;continue}y._batchTick=se,(r.count>=m||b)&&(this._finishBatch(i,p,u-p,r,o,a,t,d),d="renderBatch",p=u,o=_,a=f.topology,i=Ni(),r=i.textures,r.clear(),++se),f._textureId=y._textureBindLocation=r.count,r.ids[y.uid]=r.count,r.textures[r.count++]=y,f._batch=i,u+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,h,l,f._attributeStart,f._textureId),this.packQuadIndex(c,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,h,l,f._attributeStart,f._textureId),this.packIndex(f,c,f._indexStart,f._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,p,u-p,r,o,a,t,d),p=u,++se),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=u}_finishBatch(t,e,i,r,n,o,a,h){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=r,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++se,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Di(e);zi(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else zi(e.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,r){const n=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[i++]=r+n[l+a]-h}destroy(){if(this.batches!==null){for(let t=0;t<this.batches.length;t++)Ui(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]&&(this._elements[t]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Pn.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let _h=Pn;var J=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(J||{});class xe extends pt{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this.uid=V("buffer"),this._resourceType="buffer",this._resourceId=V("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&J.STATIC)}set static(t){t?this.descriptor.usage|=J.STATIC:this.descriptor.usage&=~J.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=V("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Cn(s,t){if(!(s instanceof xe)){let e=t?J.INDEX:J.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=J.INDEX|J.COPY_DST):(s=new Float32Array(s),e=J.VERTEX|J.COPY_DST)),s=new xe({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function bh(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=r.BYTES_PER_ELEMENT,c=(i.offset||0)/l,u=(i.stride||2*4)/l;for(let p=c;p<r.length;p+=u){const d=r[p],m=r[p+1];d>a&&(a=d),m>h&&(h=m),d<n&&(n=d),m<o&&(o=m)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function wh(s){return(s instanceof xe||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Cn(s.buffer,!1),s}class Sh extends pt{constructor(t={}){super(),this.uid=V("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new at,this._boundsDirty=!0;const{attributes:e,indexBuffer:i,topology:r}=t;if(this.buffers=[],this.attributes={},e)for(const n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=wh(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=Cn(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,bh(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const vh=new Float32Array(1),Ph=new Uint32Array(1);class Mh extends Sh{constructor(){const e=new xe({data:vh,label:"attribute-batch-buffer",usage:J.VERTEX|J.COPY_DST,shrinkToFit:!1}),i=new xe({data:Ph,label:"index-batch-buffer",usage:J.INDEX|J.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:i})}}function $i(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else Q(`${i} placement hook does not exist in shader`)}}const Ch=/\{\{(.*?)\}\}/g;function Oi(s){var i;const t={};return(((i=s.match(Ch))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function Vi(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Wi(s,t,e=!1){const i=[];Vi(t,i),s.forEach(a=>{a.header&&Vi(a.header,i)});const r=i;e&&r.sort();const n=r.map((a,h)=>` @location(${h}) ${a},`).join(`
+`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
+${n}
+`),o}function Yi(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Th(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Ah(s){const t=/@.*?\s+/g;return s.replace(t,"")}function kh(s,t){const e=[];Yi(t,e),s.forEach(h=>{h.header&&Yi(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`,
+`),n=e.sort().map(h=>` var ${Ah(h)};`).join(`
+`),o=`return VSOutput(
+ ${e.sort().map(h=>` ${Th(h)}`).join(`,
+`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
+${r}
+`),a=a.replace("{{start}}",`
+${n}
+`),a=a.replace("{{return}}",`
+${o}
+`),a}function Xi(s,t){let e=s;for(const i in t){const r=t[i];r.join(`
+`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
+${r.join(`
+`)}
+//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const St=Object.create(null),ds=new Map;let Eh=0;function Rh({template:s,bits:t}){const e=Tn(s,t);if(St[e])return St[e];const{vertex:i,fragment:r}=Bh(s,t);return St[e]=An(i,r,t),St[e]}function Ih({template:s,bits:t}){const e=Tn(s,t);return St[e]||(St[e]=An(s.vertex,s.fragment,t)),St[e]}function Bh(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let r=Wi(e,s.vertex,!0);r=kh(e,r);const n=Wi(i,s.fragment,!0);return{vertex:r,fragment:n}}function Tn(s,t){return t.map(e=>(ds.has(e)||ds.set(e,Eh++),ds.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function An(s,t,e){const i=Oi(s),r=Oi(t);return e.forEach(n=>{$i(n.vertex,i,n.name),$i(n.fragment,r,n.name)}),{vertex:Xi(s,i),fragment:Xi(t,r)}}const Fh=`
+ @in aPosition: vec2<f32>;
+ @in aUV: vec2<f32>;
+
+ @out @builtin(position) vPosition: vec4<f32>;
+ @out vUV : vec2<f32>;
+ @out vColor : vec4<f32>;
+
+ {{header}}
+
+ struct VSOutput {
+ {{struct}}
+ };
+
+ @vertex
+ fn main( {{in}} ) -> VSOutput {
+
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
+ var modelMatrix = mat3x3<f32>(
+ 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0
+ );
+ var position = aPosition;
+ var uv = aUV;
+
+ {{start}}
+
+ vColor = vec4<f32>(1., 1., 1., 1.);
+
+ {{main}}
+
+ vUV = uv;
+
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
+
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
+
+ vColor *= globalUniforms.uWorldColorAlpha;
+
+ {{end}}
+
+ {{return}}
+ };
+`,Gh=`
+ @in vUV : vec2<f32>;
+ @in vColor : vec4<f32>;
+
+ {{header}}
+
+ @fragment
+ fn main(
+ {{in}}
+ ) -> @location(0) vec4<f32> {
+
+ {{start}}
+
+ var outColor:vec4<f32>;
+
+ {{main}}
+
+ var finalColor:vec4<f32> = outColor * vColor;
+
+ {{end}}
+
+ return finalColor;
+ };
+`,Lh=`
+ 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}}
+ }
+`,Dh=`
+
+ in vec4 vColor;
+ in vec2 vUV;
+
+ out vec4 finalColor;
+
+ {{header}}
+
+ void main(void) {
+
+ {{start}}
+
+ vec4 outColor;
+
+ {{main}}
+
+ finalColor = outColor * vColor;
+
+ {{end}}
+ }
+`,zh={name:"global-uniforms-bit",vertex:{header:`
+ struct GlobalUniforms {
+ uProjectionMatrix:mat3x3<f32>,
+ uWorldTransformMatrix:mat3x3<f32>,
+ uWorldColorAlpha: vec4<f32>,
+ uResolution: vec2<f32>,
+ }
+
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
+ `}},Hh={name:"global-uniforms-bit",vertex:{header:`
+ uniform mat3 uProjectionMatrix;
+ uniform mat3 uWorldTransformMatrix;
+ uniform vec4 uWorldColorAlpha;
+ uniform vec2 uResolution;
+ `}};function Nh({bits:s,name:t}){const e=Rh({template:{fragment:Gh,vertex:Fh},bits:[zh,...s]});return Ye.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Uh({bits:s,name:t}){return new nn({name:t,...Ih({template:{vertex:Lh,fragment:Dh},bits:[Hh,...s]})})}const $h={name:"color-bit",vertex:{header:`
+ @in aColor: vec4<f32>;
+ `,main:`
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
+ `}},Oh={name:"color-bit",vertex:{header:`
+ in vec4 aColor;
+ `,main:`
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
+ `}},fs={};function Vh(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
+`)}function Wh(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
+`)}function Yh(s){return fs[s]||(fs[s]={name:"texture-batch-bit",vertex:{header:`
+ @in aTextureIdAndRound: vec2<u32>;
+ @out @interpolate(flat) vTextureId : u32;
+ `,main:`
+ vTextureId = aTextureIdAndRound.y;
+ `,end:`
+ if(aTextureIdAndRound.x == 1)
+ {
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
+ }
+ `},fragment:{header:`
+ @in @interpolate(flat) vTextureId: u32;
+
+ ${Vh(s)}
+ `,main:`
+ var uvDx = dpdx(vUV);
+ var uvDy = dpdy(vUV);
+
+ ${Wh(s)}
+ `}}),fs[s]}const ps={};function Xh(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
+`)}function jh(s){return ps[s]||(ps[s]={name:"texture-batch-bit",vertex:{header:`
+ in vec2 aTextureIdAndRound;
+ out float vTextureId;
+
+ `,main:`
+ vTextureId = aTextureIdAndRound.y;
+ `,end:`
+ if(aTextureIdAndRound.x == 1.)
+ {
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
+ }
+ `},fragment:{header:`
+ in float vTextureId;
+
+ uniform sampler2D uTextures[${s}];
+
+ `,main:`
+
+ ${Xh(s)}
+ `}}),ps[s]}const qh={name:"round-pixels-bit",vertex:{header:`
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
+ {
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
+ }
+ `}},Zh={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;
+ }
+ `}},ji={};function Kh(s){let t=ji[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=ji[s]=new ln({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class Qh extends Ys{constructor(t){const e=Uh({name:"batch",bits:[Oh,jh(t),Zh]}),i=Nh({name:"batch",bits:[$h,Yh(t),qh]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Kh(t)}})}}let ms=null;const kn=class En extends _h{constructor(t){super(t),this.geometry=new Mh,this.name=En.extension.name,this.vertexSize=6,ms??(ms=new Qh(t.maxTextures)),this.shader=ms}packAttributes(t,e,i,r,n){const o=n<<16|t.roundPixels&65535,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,p=a.tx,d=a.ty,{positions:m,uvs:g}=t,f=t.color,x=t.attributeOffset,y=x+t.attributeSize;for(let _=x;_<y;_++){const b=_*2,v=m[b],S=m[b+1];e[r++]=h*v+c*S+p,e[r++]=u*S+l*v+d,e[r++]=g[b],e[r++]=g[b+1],i[r++]=f,i[r++]=o}}packQuadAttributes(t,e,i,r,n){const o=t.texture,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,p=a.tx,d=a.ty,m=t.bounds,g=m.maxX,f=m.minX,x=m.maxY,y=m.minY,_=o.uvs,b=t.color,v=n<<16|t.roundPixels&65535;e[r+0]=h*f+c*y+p,e[r+1]=u*y+l*f+d,e[r+2]=_.x0,e[r+3]=_.y0,i[r+4]=b,i[r+5]=v,e[r+6]=h*g+c*y+p,e[r+7]=u*y+l*g+d,e[r+8]=_.x1,e[r+9]=_.y1,i[r+10]=b,i[r+11]=v,e[r+12]=h*g+c*x+p,e[r+13]=u*x+l*g+d,e[r+14]=_.x2,e[r+15]=_.y2,i[r+16]=b,i[r+17]=v,e[r+18]=h*f+c*x+p,e[r+19]=u*x+l*f+d,e[r+20]=_.x3,e[r+21]=_.y3,i[r+22]=b,i[r+23]=v}};kn.extension={type:[L.Batcher],name:"default"};let Jh=kn;function tl(s,t,e,i,r,n,o,a=null){let h=0;e*=t,r*=n;const l=a.a,c=a.b,u=a.c,p=a.d,d=a.tx,m=a.ty;for(;h<o;){const g=s[e],f=s[e+1];i[r]=l*g+u*f+d,i[r+1]=c*g+p*f+m,r+=n,e+=t,h++}}function el(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++}function Rn(s,t,e,i,r){const n=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),i||(i=2),r||(r=s.length/i-e);let u=e*i;for(let p=0;p<r;p++){const d=s[u],m=s[u+1];s[u]=n*d+a*m+l,s[u+1]=o*d+h*m+c,u+=i}}const sl=new I;class In{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?Gr(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||sl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const ye={extension:{type:L.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,o,a;if(s.type==="circle"){const b=s;if(o=a=b.radius,o<=0)return!1;e=b.x,i=b.y,r=n=0}else if(s.type==="ellipse"){const b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,i=b.y,r=n=0}else{const b=s,v=b.width/2,S=b.height/2;e=b.x+v,i=b.y+S,o=a=Math.max(0,Math.min(b.radius,Math.min(v,S))),r=v-o,n=S-a}if(r<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,!0;let c=0,u=h*4+(r?2:0)+2,p=u,d=l,m=r+o,g=n,f=e+m,x=e-m,y=i+g;if(t[c++]=f,t[c++]=y,t[--u]=y,t[--u]=x,n){const b=i-g;t[p++]=x,t[p++]=b,t[--d]=b,t[--d]=f}for(let b=1;b<h;b++){const v=Math.PI/2*(b/h),S=r+Math.cos(v)*o,w=n+Math.sin(v)*a,R=e+S,k=e-S,P=i+w,M=i-w;t[c++]=R,t[c++]=P,t[--u]=P,t[--u]=k,t[p++]=k,t[p++]=M,t[--d]=M,t[--d]=R}m=r,g=n+a,f=e+m,x=e-m,y=i+g;const _=i-g;return t[c++]=f,t[c++]=y,t[--d]=_,t[--d]=f,r&&(t[c++]=x,t[c++]=y,t[--d]=_,t[--d]=x),!0},triangulate(s,t,e,i,r,n){if(s.length===0)return;let o=0,a=0;for(let c=0;c<s.length;c+=2)o+=s[c],a+=s[c+1];o/=s.length/2,a/=s.length/2;let h=i;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<s.length;c+=2)t[h*e]=s[c],t[h*e+1]=s[c+1],c>0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1}},il={...ye,extension:{...ye.extension,name:"ellipse"}},rl={...ye,extension:{...ye.extension,name:"roundedRectangle"}},Bn=1e-4,qi=1e-4;function nl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const o=s[i],a=s[i+1];e+=(o-r)*(a+n),r=o,n=a}return e<0?-1:1}function Zi(s,t,e,i,r,n,o,a){const h=s-e*r,l=t-i*r,c=s+e*n,u=t+i*n;let p,d;o?(p=i,d=-e):(p=-i,d=e);const m=h+p,g=l+d,f=c+p,x=u+d;return a.push(m,g),a.push(f,x),2}function Tt(s,t,e,i,r,n,o,a){const h=e-s,l=i-t;let c=Math.atan2(h,l),u=Math.atan2(r-s,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let p=c;const d=u-c,m=Math.abs(d),g=Math.sqrt(h*h+l*l),f=(15*m*Math.sqrt(g)/Math.PI>>0)+1,x=d/f;if(p+=x,a){o.push(s,t),o.push(e,i);for(let y=1,_=p;y<f;y++,_+=x)o.push(s,t),o.push(s+Math.sin(_)*g,t+Math.cos(_)*g);o.push(s,t),o.push(r,n)}else{o.push(e,i),o.push(s,t);for(let y=1,_=p;y<f;y++,_+=x)o.push(s+Math.sin(_)*g,t+Math.cos(_)*g),o.push(s,t);o.push(r,n),o.push(s,t)}return f*2}function ol(s,t,e,i,r,n){const o=Bn;if(s.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let B=nl(s);h=(h-.5)*B+.5}const l=new Z(s[0],s[1]),c=new Z(s[s.length-2],s[s.length-1]),u=i,p=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){s=s.slice(),p&&(s.pop(),s.pop(),c.set(s[s.length-2],s[s.length-1]));const B=(l.x+c.x)*.5,wt=(c.y+l.y)*.5;s.unshift(B,wt),s.push(B,wt)}const d=r,m=s.length/2;let g=s.length;const f=d.length/2,x=a.width/2,y=x*x,_=a.miterLimit*a.miterLimit;let b=s[0],v=s[1],S=s[2],w=s[3],R=0,k=0,P=-(v-w),M=b-S,G=0,E=0,N=Math.sqrt(P*P+M*M);P/=N,M/=N,P*=x,M*=x;const bt=h,C=(1-bt)*2,A=bt*2;u||(a.cap==="round"?g+=Tt(b-P*(C-A)*.5,v-M*(C-A)*.5,b-P*C,v-M*C,b+P*A,v+M*A,d,!0)+2:a.cap==="square"&&(g+=Zi(b,v,P,M,C,A,!0,d))),d.push(b-P*C,v-M*C),d.push(b+P*A,v+M*A);for(let B=1;B<m-1;++B){b=s[(B-1)*2],v=s[(B-1)*2+1],S=s[B*2],w=s[B*2+1],R=s[(B+1)*2],k=s[(B+1)*2+1],P=-(v-w),M=b-S,N=Math.sqrt(P*P+M*M),P/=N,M/=N,P*=x,M*=x,G=-(w-k),E=S-R,N=Math.sqrt(G*G+E*E),G/=N,E/=N,G*=x,E*=x;const wt=S-b,jt=v-w,qt=S-R,Zt=k-w,ei=wt*qt+jt*Zt,be=jt*qt-Zt*wt,Kt=be<0;if(Math.abs(be)<.001*Math.abs(ei)){d.push(S-P*C,w-M*C),d.push(S+P*A,w+M*A),ei>=0&&(a.join==="round"?g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+4:g+=2,d.push(S-G*A,w-E*A),d.push(S+G*C,w+E*C));continue}const si=(-P+b)*(-M+w)-(-P+S)*(-M+v),ii=(-G+R)*(-E+w)-(-G+S)*(-E+k),we=(wt*ii-qt*si)/be,Se=(Zt*si-jt*ii)/be,qe=(we-S)*(we-S)+(Se-w)*(Se-w),vt=S+(we-S)*C,Pt=w+(Se-w)*C,Mt=S-(we-S)*A,Ct=w-(Se-w)*A,On=Math.min(wt*wt+jt*jt,qt*qt+Zt*Zt),ri=Kt?C:A,Vn=On+ri*ri*y;qe<=Vn?a.join==="bevel"||qe/y>_?(Kt?(d.push(vt,Pt),d.push(S+P*A,w+M*A),d.push(vt,Pt),d.push(S+G*A,w+E*A)):(d.push(S-P*C,w-M*C),d.push(Mt,Ct),d.push(S-G*C,w-E*C),d.push(Mt,Ct)),g+=2):a.join==="round"?Kt?(d.push(vt,Pt),d.push(S+P*A,w+M*A),g+=Tt(S,w,S+P*A,w+M*A,S+G*A,w+E*A,d,!0)+4,d.push(vt,Pt),d.push(S+G*A,w+E*A)):(d.push(S-P*C,w-M*C),d.push(Mt,Ct),g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+4,d.push(S-G*C,w-E*C),d.push(Mt,Ct)):(d.push(vt,Pt),d.push(Mt,Ct)):(d.push(S-P*C,w-M*C),d.push(S+P*A,w+M*A),a.join==="round"?Kt?g+=Tt(S,w,S+P*A,w+M*A,S+G*A,w+E*A,d,!0)+2:g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+2:a.join==="miter"&&qe/y<=_&&(Kt?(d.push(Mt,Ct),d.push(Mt,Ct)):(d.push(vt,Pt),d.push(vt,Pt)),g+=2),d.push(S-G*C,w-E*C),d.push(S+G*A,w+E*A),g+=2)}b=s[(m-2)*2],v=s[(m-2)*2+1],S=s[(m-1)*2],w=s[(m-1)*2+1],P=-(v-w),M=b-S,N=Math.sqrt(P*P+M*M),P/=N,M/=N,P*=x,M*=x,d.push(S-P*C,w-M*C),d.push(S+P*A,w+M*A),u||(a.cap==="round"?g+=Tt(S-P*(C-A)*.5,w-M*(C-A)*.5,S-P*C,w-M*C,S+P*A,w+M*A,d,!1)+2:a.cap==="square"&&(g+=Zi(S,w,P,M,C,A,!1,d)));const Xt=qi*qi;for(let B=f;B<g+f-2;++B)b=d[B*2],v=d[B*2+1],S=d[(B+1)*2],w=d[(B+1)*2+1],R=d[(B+2)*2],k=d[(B+2)*2+1],!(Math.abs(b*(w-k)+S*(k-v)+R*(v-w))<Xt)&&n.push(B,B+1,B+2)}function al(s,t,e,i){const r=Bn;if(s.length===0)return;const n=s[0],o=s[1],a=s[s.length-2],h=s[s.length-1],l=t||Math.abs(n-a)<r&&Math.abs(o-h)<r,c=e,u=s.length/2,p=c.length/2;for(let d=0;d<u;d++)c.push(s[d*2]),c.push(s[d*2+1]);for(let d=0;d<u-1;d++)i.push(p+d,p+d+1);l&&i.push(p+u-1,p)}function Fn(s,t,e,i,r,n,o){const a=$a(s,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+r,n[o++]=a[l+1]+r,n[o++]=a[l+2]+r;let h=r*i;for(let l=0;l<s.length;l+=2)e[h]=s[l],e[h+1]=s[l+1],h+=i}const hl=[],ll={extension:{type:L.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return!0},triangulate(s,t,e,i,r,n){Fn(s,hl,t,e,i,r,n)}},cl={extension:{type:L.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,r=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+o,t[6]=i,t[7]=r+o,!0):!1},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[6],t[i+o+1]=s[7],o+=e,t[i+o]=s[4],t[i+o+1]=s[5],o+=e;const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},ul={extension:{type:L.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,!0},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[4],t[i+o+1]=s[5];const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},dl=new I,fl=new W;function pl(s,t,e,i){const r=t.matrix?s.copyFrom(t.matrix).invert():s.identity();if(t.textureSpace==="local"){const o=e.getBounds(fl);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,p=-h*c,d=r.a,m=r.b,g=r.c,f=r.d;r.a*=l,r.b*=l,r.c*=c,r.d*=c,r.tx=u*d+p*g+r.tx,r.ty=u*m+p*f+r.ty}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof _t)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&r.append(dl.copyFrom(i).invert()),r}const je={};rt.handleByMap(L.ShapeBuilder,je);rt.add(cl,ll,ul,ye,il,rl);const ml=new W,gl=new I;function xl(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")yl(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&Ki(l.shapePath,h,!0,i,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),Ki(a,h,o,i,e)}}}function yl(s,t,e){const i=[],r=je.rectangle,n=ml;n.x=s.dx,n.y=s.dy,n.width=s.dw,n.height=s.dh;const o=s.transform;if(!r.build(n,i))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&Rn(i,o),r.triangulate(i,a,2,u,l,c);const p=s.image,d=p.uvs;h.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);const m=it.get(In);m.indexOffset=c,m.indexSize=l.length-c,m.attributeOffset=u,m.attributeSize=a.length/2-u,m.baseColor=s.style,m.alpha=s.alpha,m.texture=p,m.geometryData=e,t.push(m)}function Ki(s,t,e,i,r){const{vertices:n,uvs:o,indices:a}=r;s.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],p=je[h.type];if(!p.build(h,u))return;const d=a.length,m=n.length/2;let g="triangle-list";if(l&&Rn(u,l),e){const _=h.closePath??!0,b=t;b.pixelLine?(al(u,_,n,a),g="line-list"):ol(u,b,!1,_,n,a)}else if(c){const _=[],b=u.slice();_l(c).forEach(S=>{_.push(b.length/2),b.push(...S)}),Fn(b,_,n,2,m,a,d)}else p.triangulate(u,n,2,m,a,d);const f=o.length/2,x=t.texture;if(x!==D.WHITE){const _=pl(gl,t,h,l);tl(n,2,m,o,f,2,n.length/2-m,_)}else el(o,f,2,n.length/2-m);const y=it.get(In);y.indexOffset=d,y.indexSize=a.length-d,y.attributeOffset=m,y.attributeSize=n.length/2-m,y.baseColor=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=r,y.topology=g,i.push(y)})}function _l(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e].shape,r=[];je[i.type].build(i,r)&&t.push(r)}return t}class bl{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class wl{constructor(){this.instructions=new Hr}init(t){this.batcher=new Jh({maxTextures:t}),this.instructions.reset()}get geometry(){return F(co,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Ks=class Is{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(t){Is.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Is.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),xl(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"?e.isBatchable=e.geometryData.vertices.length<400:e.isBatchable=!0,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=it.get(wl,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:r}=this._gpuContextHash[t.uid],n=r.vertices.length,o=r.indices.length;for(let c=0;c<i.length;c++)i[c].applyTransform=!1;const a=e.batcher;a.ensureAttributeBuffer(n),a.ensureIndexBuffer(o),a.begin();for(let c=0;c<i.length;c++){const u=i[c];a.add(u)}a.finish(e.instructions);const h=a.geometry;h.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),h.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);const l=a.batches;for(let c=0;c<l.length;c++){const u=l[c];u.bindGroup=lh(u.textures.textures,u.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new bl;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(it.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{it.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ks.extension={type:[L.WebGLSystem,L.WebGPUSystem,L.CanvasSystem],name:"graphicsContext"};Ks.defaultOptions={bezierSmoothness:.5};let Gn=Ks;const Sl=8,Le=11920929e-14,vl=1;function Ln(s,t,e,i,r,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Gn.defaultOptions.bezierSmoothness));let p=(vl-u)/1;return p*=p,Pl(t,e,i,r,n,o,a,h,s,p),s}function Pl(s,t,e,i,r,n,o,a,h,l){Bs(s,t,e,i,r,n,o,a,h,l,0),h.push(o,a)}function Bs(s,t,e,i,r,n,o,a,h,l,c){if(c>Sl)return;const u=(s+e)/2,p=(t+i)/2,d=(e+r)/2,m=(i+n)/2,g=(r+o)/2,f=(n+a)/2,x=(u+d)/2,y=(p+m)/2,_=(d+g)/2,b=(m+f)/2,v=(x+_)/2,S=(y+b)/2;if(c>0){let w=o-s,R=a-t;const k=Math.abs((e-o)*R-(i-a)*w),P=Math.abs((r-o)*R-(n-a)*w);if(k>Le&&P>Le){if((k+P)*(k+P)<=l*(w*w+R*R)){h.push(v,S);return}}else if(k>Le){if(k*k<=l*(w*w+R*R)){h.push(v,S);return}}else if(P>Le){if(P*P<=l*(w*w+R*R)){h.push(v,S);return}}else if(w=v-(s+o)/2,R=S-(t+a)/2,w*w+R*R<=l){h.push(v,S);return}}Bs(s,t,u,p,x,y,v,S,h,l,c+1),Bs(v,S,_,b,g,f,o,a,h,l,c+1)}const Ml=8,Cl=11920929e-14,Tl=1;function Al(s,t,e,i,r,n,o,a){const l=Math.min(.99,Math.max(0,a??Gn.defaultOptions.bezierSmoothness));let c=(Tl-l)/1;return c*=c,kl(t,e,i,r,n,o,s,c),s}function kl(s,t,e,i,r,n,o,a){Fs(o,s,t,e,i,r,n,a,0),o.push(r,n)}function Fs(s,t,e,i,r,n,o,a,h){if(h>Ml)return;const l=(t+i)/2,c=(e+r)/2,u=(i+n)/2,p=(r+o)/2,d=(l+u)/2,m=(c+p)/2;let g=n-t,f=o-e;const x=Math.abs((i-n)*f-(r-o)*g);if(x>Cl){if(x*x<=a*(g*g+f*f)){s.push(d,m);return}}else if(g=d-(t+n)/2,f=m-(e+o)/2,g*g+f*f<=a){s.push(d,m);return}Fs(s,t,e,l,c,d,m,a,h+1),Fs(s,d,m,u,p,n,o,a,h+1)}function Dn(s,t,e,i,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=r;l*=o?-1:1;for(let u=0;u<a+1;u++){const p=Math.cos(c),d=Math.sin(c),m=t+p*i,g=e+d*i;s.push(m,g),c+=l}}function El(s,t,e,i,r,n){const o=s[s.length-2],h=s[s.length-1]-e,l=o-t,c=r-e,u=i-t,p=Math.abs(h*u-l*c);if(p<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const d=h*h+l*l,m=c*c+u*u,g=h*c+l*u,f=n*Math.sqrt(d)/p,x=n*Math.sqrt(m)/p,y=f*g/d,_=x*g/m,b=f*u+x*l,v=f*c+x*h,S=l*(x+y),w=h*(x+y),R=u*(f+_),k=c*(f+_),P=Math.atan2(w-v,S-b),M=Math.atan2(k-v,R-b);Dn(s,b+t,v+e,n,P,M,l*c>u*h)}const ue=Math.PI*2,gs={centerX:0,centerY:0,ang1:0,ang2:0},xs=({x:s,y:t},e,i,r,n,o,a,h)=>{s*=e,t*=i;const l=r*s-n*t,c=n*s+r*t;return h.x=l+o,h.y=c+a,h};function Rl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Qi=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Il=(s,t,e,i,r,n,o,a,h,l,c,u,p)=>{const d=Math.pow(r,2),m=Math.pow(n,2),g=Math.pow(c,2),f=Math.pow(u,2);let x=d*m-d*f-m*g;x<0&&(x=0),x/=d*f+m*g,x=Math.sqrt(x)*(o===a?-1:1);const y=x*r/n*u,_=x*-n/r*c,b=l*y-h*_+(s+e)/2,v=h*y+l*_+(t+i)/2,S=(c-y)/r,w=(u-_)/n,R=(-c-y)/r,k=(-u-_)/n,P=Qi(1,0,S,w);let M=Qi(S,w,R,k);a===0&&M>0&&(M-=ue),a===1&&M<0&&(M+=ue),p.centerX=b,p.centerY=v,p.ang1=P,p.ang2=M};function Bl(s,t,e,i,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*ue/360),u=Math.cos(a*ue/360),p=u*(t-i)/2+c*(e-r)/2,d=-c*(t-i)/2+u*(e-r)/2;if(p===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),Il(t,e,i,r,n,o,h,l,c,u,p,d,gs);let{ang1:g,ang2:f}=gs;const{centerX:x,centerY:y}=gs;let _=Math.abs(f)/(ue/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);f/=b;let v=s[s.length-2],S=s[s.length-1];const w={x:0,y:0};for(let R=0;R<b;R++){const k=Rl(g,f),{x:P,y:M}=xs(k[0],n,o,u,c,x,y,w),{x:G,y:E}=xs(k[1],n,o,u,c,x,y,w),{x:N,y:bt}=xs(k[2],n,o,u,c,x,y,w);Ln(s,v,S,P,M,G,E,N,bt),v=N,S=bt,g+=f}}function Fl(s,t,e){const i=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,p=l/c;return{len:c,nx:u,ny:p}},r=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let n=t[t.length-1];for(let o=0;o<t.length;o++){const a=t[o%t.length],h=a.radius??e;if(h<=0){r(o,a),n=a;continue}const l=t[(o+1)%t.length],c=i(a,n),u=i(a,l);if(c.len<1e-4||u.len<1e-4){r(o,a),n=a;continue}let p=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,m=!1;c.nx*u.nx-c.ny*-u.ny<0?p<0?p=Math.PI+p:(p=Math.PI-p,d=-1,m=!0):p>0&&(d=-1,m=!0);const g=p/2;let f,x=Math.abs(Math.cos(g)*h/Math.sin(g));x>Math.min(c.len/2,u.len/2)?(x=Math.min(c.len/2,u.len/2),f=Math.abs(x*Math.sin(g)/Math.cos(g))):f=h;const y=a.x+u.nx*x+-u.ny*f*d,_=a.y+u.ny*x+u.nx*f*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,v=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(y+Math.cos(b)*f,_+Math.sin(b)*f),s.arc(y,_,f,b,v,m),n=a}}function Gl(s,t,e,i){const r=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a<o;a++){const h=t[(a+1)%o],l=h.radius??e;if(l<=0){a===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],p=r(c,h);let d;if(p<1e-4)d=h;else{const f=Math.min(p/2,l);d=n(h,c,f/p)}const m=r(u,h);let g;if(m<1e-4)g=h;else{const f=Math.min(m/2,l);g=n(h,u,f/m)}a===0?s.moveTo(d.x,d.y):s.lineTo(d.x,d.y),s.quadraticCurveTo(h.x,h.y,g.x,g.y,i)}}const Ll=new W;class Dl{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new at,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Dn(a,t,e,i,r,n,o),this}arcTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly.points;return El(o,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,o,a){const h=this._currentPoly.points;return Bl(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,o,a){this._ensurePoly();const h=this._currentPoly;return Ln(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,o,a),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly;return Al(this._currentPoly.points,o.lastX,o.lastY,t,e,i,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const i=this.shapePrimitives,r=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&i.length-r>1){let n=null;for(let o=r;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=n==null?void 0:n.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,r,n){return this.drawShape(new W(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new js(t,e,i),r),this}poly(t,e,i){const r=new le(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/r,l=[];for(let c=0;c<r;c++){const u=a-c*h;l.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(l,!0,o),this}roundPoly(t,e,i,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,o);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let p=0;p<r;p++){const d=p*c+l,m=t+i*Math.cos(d),g=e+i*Math.sin(d),f=d+Math.PI+u,x=d-Math.PI-u,y=m+n*Math.cos(f),_=g+n*Math.sin(f),b=m+n*Math.cos(x),v=g+n*Math.sin(x);p===0?this.moveTo(y,_):this.lineTo(y,_),this.quadraticCurveTo(m,g,b,v,a)}return this.closePath()}roundShape(t,e,i=!1,r){return t.length<3?this:(i?Gl(this,t,e,r):Fl(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const o=Math.min(i,r)/2,a=Math.min(o,Math.max(-o,n)),h=t+i,l=e+r,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(h-u,e).arcTo(h-c,e+c,h,e+u,u).lineTo(h,l-u).arcTo(h-c,l-c,t+i-u,l,u).lineTo(t+u,l).arcTo(t+c,l-c,t,l-u,u).closePath()}chamferRect(t,e,i,r,n,o){if(n<=0)return this.rect(t,e,i,r);const a=Math.min(n,Math.min(i,r)/2),h=t+i,l=e+r,c=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,r,n){return this.drawShape(new qs(t,e,i,r),n),this}roundRect(t,e,i,r,n,o){return this.drawShape(new Zs(t,e,i,r,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new le,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new le,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(Ll);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class yt{constructor(t,e=!1){this.instructions=[],this.uid=V("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?nh(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Dl(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(Z.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else{h=o.data[2],l=o.data[3];const c=a.x,u=a.y;h=c+(c-h),l=u+(u-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,i,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(Z.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=!0,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,r]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,r,n,o,a){n||(n=r/2);const h=-1*Math.PI/2+o,l=i*2,c=Math.PI*2/l,u=[];for(let p=0;p<l;p++){const d=p%2?n:r,m=p*c+h;u.push(t+d*Math.cos(m),e+d*Math.sin(m))}return this.poly(u,!0,a),this}clone(t=!1){const e=new yt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,p=0,d=0,m=0,g=0;for(let f=0;f<this.instructions.length;f++){const x=this.instructions[f],y=x.data;switch(x.action){case"moveTo":case"lineTo":h=y[0],l=y[1],y[0]=e*h+r*l+o,y[1]=i*h+n*l+a;break;case"bezierCurveTo":c=y[0],u=y[1],p=y[2],d=y[3],h=y[4],l=y[5],y[0]=e*c+r*u+o,y[1]=i*c+n*u+a,y[2]=e*p+r*d+o,y[3]=i*p+n*d+a,y[4]=e*h+r*l+o,y[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=y[0],u=y[1],h=y[2],l=y[3],y[0]=e*c+r*u+o,y[1]=i*c+n*u+a,y[2]=e*h+r*l+o,y[3]=i*h+n*l+a;break;case"arcToSvg":h=y[5],l=y[6],m=y[0],g=y[1],y[0]=e*m+r*g,y[1]=i*m+n*g,y[5]=e*h+r*l+o,y[6]=i*h+n*l+a;break;case"circle":y[4]=ie(y[3],t);break;case"rect":y[4]=ie(y[4],t);break;case"ellipse":y[8]=ie(y[8],t);break;case"roundRect":y[5]=ie(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=ie(y[2],t);break;default:Q("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function ie(s,t){return s?s.prepend(t):t.clone()}function $(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function zl(s,t){const e=s.querySelectorAll("defs");for(let i=0;i<e.length;i++){const r=e[i];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=Hl(o);break;case"radialgradient":t.defs[o.id]=Nl();break}}}}function Hl(s){const t=$(s,"x1",0),e=$(s,"y1",0),i=$(s,"x2",1),r=$(s,"y2",0),n=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new _t(t,e,i,r,n==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){const h=s.children[a],l=$(h,"offset",0),c=Y.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function Nl(s){return Q("[SVG Parser] Radial gradients are not yet supported"),new _t(0,0,1,0)}function Ji(s){const t=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const tr={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function zn(s,t){const e=s.getAttribute("style"),i={},r={},n={strokeStyle:i,fillStyle:r,useFill:!1,useStroke:!1};for(const o in tr){const a=s.getAttribute(o);a&&er(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");tr[l]&&er(t,n,l,c.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function er(s,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const r=Ji(i);t.strokeStyle.fill=s.defs[r]}else t.strokeStyle.color=Y.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const r=Ji(i);t.fillStyle.fill=s.defs[r]}else t.fillStyle.color=Y.shared.setValue(i).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(i);break;case"stroke-opacity":t.strokeStyle.alpha=Number(i);break;case"opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i);break}}function Ul(s){if(s.length<=2)return!0;const t=s.map(a=>a.area).sort((a,h)=>h-a),[e,i]=t,r=t[t.length-1],n=e/i,o=i/r;return!(n>3&&o<2)}function $l(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function Ol(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],r=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(i.push(e[c]),r.push(e[c+1]));if(i.length===0||r.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...r),h=Math.max(...r);return(o-n)*(h-a)}function sr(s,t){const e=new yt(s,!1);for(const i of e.instructions)t.instructions.push(i)}function Vl(s,t){if(typeof s=="string"){const o=document.createElement("div");o.innerHTML=s.trim(),s=o.querySelector("svg")}const e={context:t,defs:{},path:new yt};zl(s,e);const i=s.children,{fillStyle:r,strokeStyle:n}=zn(s,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&Hn(a,e,r,n)}return t}function Hn(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:o}=zn(s,t);n&&e?e={...e,...n}:n&&(e=n),o&&i?i={...i,...o}:o&&(i=o);const a=!e&&!i;a&&(e={color:0});let h,l,c,u,p,d,m,g,f,x,y,_,b,v,S,w,R;switch(s.nodeName.toLowerCase()){case"path":{v=s.getAttribute("d");const k=s.getAttribute("fill-rule"),P=$l(v),M=k==="evenodd",G=P.length>1;if(M&&G){const N=P.map(C=>({path:C,area:Ol(C)}));if(N.sort((C,A)=>A.area-C.area),P.length>3||!Ul(N))for(let C=0;C<N.length;C++){const A=N[C],Xt=C===0;t.context.beginPath();const B=new yt(void 0,!0);sr(A.path,B),t.context.path(B),Xt?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let C=0;C<N.length;C++){const A=N[C],Xt=C%2===1;t.context.beginPath();const B=new yt(void 0,!0);sr(A.path,B),t.context.path(B),Xt?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const N=k?k==="evenodd":!0;S=new yt(v,N),t.context.path(S),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":m=$(s,"cx",0),g=$(s,"cy",0),f=$(s,"r",0),t.context.ellipse(m,g,f,f),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":h=$(s,"x",0),l=$(s,"y",0),w=$(s,"width",0),R=$(s,"height",0),x=$(s,"rx",0),y=$(s,"ry",0),x||y?t.context.roundRect(h,l,w,R,x||y):t.context.rect(h,l,w,R),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=$(s,"cx",0),g=$(s,"cy",0),x=$(s,"rx",0),y=$(s,"ry",0),t.context.beginPath(),t.context.ellipse(m,g,x,y),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=$(s,"x1",0),u=$(s,"y1",0),p=$(s,"x2",0),d=$(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(p,d),i&&t.context.stroke(i);break;case"polygon":b=s.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":b=s.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Q(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let k=0;k<r.length;k++)Hn(r[k],t,e,i)}function Wl(s){return Y.isColorLike(s)}function ir(s){return s instanceof Xe}function rr(s){return s instanceof _t}function Yl(s){return s instanceof D}function Xl(s,t,e){const i=Y.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=D.WHITE,{...e,...s}}function jl(s,t,e){return s.texture=t,{...e,...s}}function nr(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function or(s,t,e){return t.buildGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace=t.textureSpace,{...e,...s}}function ql(s,t){const e={...t,...s},i=Y.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function Bt(s,t){if(s==null)return null;const e={},i=s;return Wl(s)?Xl(e,s,t):Yl(s)?jl(e,s,t):ir(s)?nr(e,s,t):rr(s)?or(e,s,t):i.fill&&ir(i.fill)?nr(i,i.fill,t):i.fill&&rr(i.fill)?or(i,i.fill,t):ql(i,t)}function Ve(s,t){const{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...h}=t,l=Bt(s,h);return l?{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...l}:null}const Zl=new Z,ar=new I,Qs=class ut extends pt{constructor(){super(...arguments),this.uid=V("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new yt,this._transform=new I,this._fillStyle={...ut.defaultFillStyle},this._strokeStyle={...ut.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new at,this._boundsDirty=!0}clone(){const t=new ut;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...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=Bt(t,ut.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Ve(t,ut.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Bt(t,ut.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Bt(t,ut.defaultStrokeStyle),this}texture(t,e,i,r,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Y.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new yt,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r&&r.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(F(O,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Bt(t,ut.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(Z.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Ve(t,ut.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,r,n,o),this}arcTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}arcToSvg(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,o),this}roundPoly(t,e,i,r,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,o),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,o),this}star(t,e,i,r,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,r,n,o,this._transform.clone()),this}svg(t){return this._tick++,Vl(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:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,o){return t instanceof I?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,o),this)}transform(t,e,i,r,n,o){return t instanceof I?(this._transform.append(t),this):(ar.set(t,e,i,r,n,o),this._transform.append(ar),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),h=n.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return t}containsPoint(t){var r;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let n=0;n<e.length;n++){const o=e[n],a=o.data,h=a.path;if(!o.action||!h)continue;const l=a.style,c=h.shapePath.shapePrimitives;for(let u=0;u<c.length;u++){const p=c[u].shape;if(!l||!p)continue;const d=c[u].transform,m=d?d.applyInverse(t,Zl):t;if(o.action==="fill")i=p.contains(m.x,m.y);else{const f=l;i=p.strokeContains(m.x,m.y,f.width,f.alignment)}const g=a.hole;if(g){const f=(r=g.shapePath)==null?void 0:r.shapePrimitives;if(f)for(let x=0;x<f.length;x++)f[x].shape.contains(m.x,m.y)&&(i=!1)}if(i)return!0}}return i}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(i)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(i))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Qs.defaultFillStyle={color:16777215,alpha:1,texture:D.WHITE,matrix:null,fill:null,textureSpace:"local"};Qs.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:D.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let ot=Qs;const Js=class Ut extends pt{constructor(t={}){super(),this.uid=V("textStyle"),this._tick=0,Kl(t);const e={...Ut.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i]}this.update(),this._tick=0}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({...Ut.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Ut.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get filters(){return this._filters}set filters(t){this._filters=Object.freeze(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({...ot.defaultFillStyle,...t},()=>{this._fill=Bt({...this._originalFill},ot.defaultFillStyle)})),this._fill=Bt(t===0?"black":t,ot.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ot.defaultStrokeStyle,...t},()=>{this._stroke=Ve({...this._originalStroke},ot.defaultStrokeStyle)})),this._stroke=Ve(t,ot.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=Ut.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new Ut({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var i,r,n,o;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const a=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(a),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(a),(n=this._stroke)!=null&&n.texture&&this._stroke.texture.destroy(a),(o=this._originalStroke)!=null&&o.texture&&this._originalStroke.texture.destroy(a)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,r,n)=>(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof _t||t instanceof Xe)}};Js.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Js.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 Nn=Js;function Kl(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Nn.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){F(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Y.isColorLike(e))i.color=e;else if(e instanceof _t||e instanceof Xe)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(F(O,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&Q("The number of fill colors must match the number of fill gradient stops.");const e=new _t({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),r=t.fill.map(n=>Y.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,r[o])}),s.fill={fill:e}}}class Ql{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=et.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Vt(t),e=Vt(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,r),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Gs=new Ql;_e.register(Gs);const hr=1e5;function lr(s,t,e,i=0){if(s.texture===D.WHITE&&!s.fill)return Y.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Xe){const r=s.fill,n=t.createPattern(r.texture.source.resource,"repeat"),o=r.transform.copyTo(I.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}else if(s.fill instanceof _t){const r=s.fill,n=r.type==="linear",o=r.textureSpace==="local";let a=1,h=1;o&&e&&(a=e.width+i,h=e.height+i);let l,c=!1;if(n){const{start:u,end:p}=r;l=t.createLinearGradient(u.x*a,u.y*h,p.x*a,p.y*h),c=Math.abs(p.x-u.x)<Math.abs((p.y-u.y)*.1)}else{const{center:u,innerRadius:p,outerCenter:d,outerRadius:m}=r;l=t.createRadialGradient(u.x*a,u.y*h,p*a,d.x*a,d.y*h,m*a)}if(c&&o&&e){const u=e.lineHeight/h;for(let p=0;p<e.lines.length;p++){const d=(p*e.lineHeight+i/2)/h;r.colorStops.forEach(m=>{const g=d+m.offset*u;l.addColorStop(Math.floor(g*hr)/hr,Y.shared.setValue(m.color).toHex())})}}else r.colorStops.forEach(u=>{l.addColorStop(u.offset,Y.shared.setValue(u.color).toHex())});return l}}else{const r=t.createPattern(s.texture.source.resource,"repeat"),n=s.matrix.copyTo(I.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),r.setTransform(n),r}return Q("FillStyle not recognised",s),"red"}class dt extends Vs{constructor(t){t instanceof ot&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ot,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=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}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new dt(this._context.clone()):(this._ownedContext=null,new dt(this._context))}lineStyle(t,e,i){F(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){F(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){F(O,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==ot.defaultStrokeStyle.width||t.color!==ot.defaultStrokeStyle.color||t.alpha!==ot.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return F(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return F(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return F(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return F(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return F(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return F(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Jl extends Vs{constructor(t,e){const{text:i,resolution:r,style:n,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function tc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(F(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}let At=null,gt=null;function ec(s,t){At||(At=et.get().createCanvas(256,128),gt=At.getContext("2d",{willReadFrequently:!0}),gt.globalCompositeOperation="copy",gt.globalAlpha=1),(At.width<s||At.height<t)&&(At.width=Vt(s),At.height=Vt(t))}function cr(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function ur(s,t,e,i,r){const n=4*t;for(let o=i,a=i*n+4*e;o<=r;++o,a+=n)if(s[a+3]!==0)return!1;return!0}function sc(...s){let t=s[0];t.canvas||(t={canvas:s[0],resolution:s[1]});const{canvas:e}=t,i=Math.min(t.resolution??1,1),r=t.width??e.width,n=t.height??e.height;let o=t.output;if(ec(r,n),!gt)throw new TypeError("Failed to get canvas 2D context");gt.drawImage(e,0,0,r,n,0,0,r*i,n*i);const h=gt.getImageData(0,0,r,n).data;let l=0,c=0,u=r-1,p=n-1;for(;c<n&&cr(h,r,c);)++c;if(c===n)return W.EMPTY;for(;cr(h,r,p);)--p;for(;ur(h,r,l,c,p);)++l;for(;ur(h,r,u,c,p);)--u;return++u,++p,gt.globalCompositeOperation="source-over",gt.strokeRect(l,c,u-l,p-c),gt.globalCompositeOperation="copy",o??(o=new W),o.set(l/i,c/i,(u-l)/i,(p-c)/i),o}const dr=new W;class ic{getCanvasAndContext(t){const{text:e,style:i,resolution:r=1}=t,n=i._getFinalPadding(),o=Nt.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*r),h=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*r),l=Gs.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(e,i,n,r,l);const c=i.trim?sc({canvas:l.canvas,width:a,height:h,resolution:1,output:dr}):dr.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){Gs.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,r,n){var _,b,v,S;const{canvas:o,context:a}=n,h=Sn(e),l=Nt.measureText(t||" ",e),c=l.lines,u=l.lineHeight,p=l.lineWidths,d=l.maxLineWidth,m=l.fontProperties,g=o.height;if(a.resetTransform(),a.scale(r,r),a.textBaseline=e.textBaseline,(_=e._stroke)!=null&&_.width){const w=e._stroke;a.lineWidth=w.width,a.miterLimit=w.miterLimit,a.lineJoin=w.join,a.lineCap=w.cap}a.font=h;let f,x;const y=e.dropShadow?2:1;for(let w=0;w<y;++w){const R=e.dropShadow&&w===0,k=R?Math.ceil(Math.max(1,g)+i*2):0,P=k*r;if(R){a.fillStyle="black",a.strokeStyle="black";const E=e.dropShadow,N=E.color,bt=E.alpha;a.shadowColor=Y.shared.setValue(N).setAlpha(bt).toRgbaString();const C=E.blur*r,A=E.distance*r;a.shadowBlur=C,a.shadowOffsetX=Math.cos(E.angle)*A,a.shadowOffsetY=Math.sin(E.angle)*A+P}else{if(a.fillStyle=e._fill?lr(e._fill,a,l,i*2):null,(b=e._stroke)!=null&&b.width){const E=e._stroke.width*.5+i*2;a.strokeStyle=lr(e._stroke,a,l,E)}a.shadowColor="black"}let M=(u-m.fontSize)/2;u-m.fontSize<0&&(M=0);const G=((v=e._stroke)==null?void 0:v.width)??0;for(let E=0;E<c.length;E++)f=G/2,x=G/2+E*u+m.ascent+M,e.align==="right"?f+=d-p[E]:e.align==="center"&&(f+=(d-p[E])/2),(S=e._stroke)!=null&&S.width&&this._drawLetterSpacing(c[E],e,n,f+i,x+i-k,!0),e._fill!==void 0&&this._drawLetterSpacing(c[E],e,n,f+i,x+i-k)}}_drawLetterSpacing(t,e,i,r,n,o=!1){const{context:a}=i,h=e.letterSpacing;let l=!1;if(Nt.experimentalLetterSpacingSupported&&(Nt.experimentalLetterSpacing?(a.letterSpacing=`${h}px`,a.textLetterSpacing=`${h}px`,l=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),h===0||l){o?a.strokeText(t,r,n):a.fillText(t,r,n);return}let c=r;const u=Nt.graphemeSegmenter(t);let p=a.measureText(t).width,d=0;for(let m=0;m<u.length;++m){const g=u[m];o?a.strokeText(g,c,n):a.fillText(g,c,n);let f="";for(let x=m+1;x<u.length;++x)f+=u[x];d=a.measureText(f).width,c+=p-d+h,p=d}}}const fr=new ic;class Dt extends Jl{constructor(...t){const e=tc(t,"Text");super(e,Nn),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Ue?e.textureStyle:new Ue(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,r=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=fr.getCanvasAndContext({text:this.text,style:this._style,resolution:1});fr.returnCanvasAndContext(o),i=n.width,r=n.height}else{const n=Nt.measureText(this._text,this._style);i=n.width,r=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*r,t.maxY=t.minY+r}}rt.add(eo,so);function Ot(s){const t=Math.max(0,s/1e3);if(t<60)return`${t.toFixed(2)}s`;const e=Math.floor(t/60),i=t%60;return`${e}m ${i.toFixed(1)}s`}function Un(s){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(s))}function Ls(s){return Number.isFinite(s)?s.toFixed(3):"—"}function De(s,t,e){return Math.min(e,Math.max(t,s))}function rc(s,t,e,i,r,n,o,a){s.roundRect(t,e,i,r,n),s.fill(o),s.stroke(a)}class pr{constructor({host:t,panelId:e="primary",title:i="Vertical plot",subtitle:r=null,showReadouts:n=!0,lineColor:o=10473983,pointColor:a=15201023}){this.host=t,this.panelId=e,this.panelTitle=i,this.panelSubtitle=r,this.showReadouts=n,this.lineColor=o,this.pointColor=a,this.app=new wn,this.container=new ft,this.background=new dt,this.grid=new dt,this.axes=new dt,this.line=new dt,this.points=new dt,this.crosshair=new dt,this.overlay=new ft,this.readoutBackground=new dt,this.axisLabelLayer=new ft,this.titleText=new Dt({text:"Plot viewport",style:{fill:15660287,fontFamily:"Inter, sans-serif",fontSize:16}}),this.subtitleText=new Dt({text:"Synthetic data stream",style:{fill:9216967,fontFamily:"Inter, sans-serif",fontSize:12}}),this.realTimeText=new Dt({text:"",style:{fill:15265527,fontFamily:"IBM Plex Mono, monospace",fontSize:11}}),this.plotTimeText=new Dt({text:"",style:{fill:15265527,fontFamily:"IBM Plex Mono, monospace",fontSize:11}}),this.axisTitleText=new Dt({text:"",style:{fill:9478327,fontFamily:"Inter, sans-serif",fontSize:10,fontWeight:"600",letterSpacing:1.5}}),this.screenPoints=[],this.bounds={width:100,height:100},this.hoverRadiusPx=20,this.pointer=null,this.lastPointerEventAt=0,this.axisLabels=[]}async init(){const t=navigator.gpu?"webgpu":"webgl";return await this.app.init({preference:t,resizeTo:this.host,antialias:!0,backgroundAlpha:0,resolution:Math.min(window.devicePixelRatio||1,2)}),this.app.stage.addChild(this.container),this.container.addChild(this.background),this.container.addChild(this.grid),this.container.addChild(this.axes),this.container.addChild(this.line),this.container.addChild(this.points),this.container.addChild(this.crosshair),this.container.addChild(this.overlay),this.overlay.addChild(this.readoutBackground),this.overlay.addChild(this.axisLabelLayer),this.overlay.addChild(this.titleText),this.overlay.addChild(this.subtitleText),this.overlay.addChild(this.realTimeText),this.overlay.addChild(this.plotTimeText),this.overlay.addChild(this.axisTitleText),this.host.appendChild(this.app.canvas),this.attachPointerListeners(),t}attachPointerListeners(){this.host.addEventListener("pointerleave",()=>{this.pointer=null,this.lastPointerEventAt=performance.now()}),this.host.addEventListener("pointermove",t=>{const e=this.host.getBoundingClientRect();this.pointer={x:t.clientX-e.left,y:t.clientY-e.top},this.lastPointerEventAt=performance.now()})}resize(){this.bounds={width:this.host.clientWidth,height:this.host.clientHeight}}render(t,e){this.resize(),this.renderFrame(t,e),this.clearHover()}clearHover(){this.crosshair.clear()}getHoverCandidate(){if(!this.pointer||this.screenPoints.length===0)return null;let t=null,e=1/0;for(const i of this.screenPoints){const r=i.x-this.pointer.x,n=i.y-this.pointer.y,o=Math.sqrt(r*r+n*n);o<e&&(t=i,e=o)}return!t||e>this.hoverRadiusPx?null:{panelId:this.panelId,point:t,x:De(t.x,0,this.bounds.width),y:De(t.y,0,this.bounds.height),pointerX:this.pointer.x,pointerY:this.pointer.y,distance:e,lastPointerEventAt:this.lastPointerEventAt}}hasPointer(){return this.pointer!==null}findNearestScreenPointByTime(t){if(this.screenPoints.length===0)return null;let e=null,i=1/0;for(const r of this.screenPoints){const n=Math.abs(r.timeMs-t);n<i&&(e=r,i=n)}return e}renderLinkedHover(t){if(this.crosshair.clear(),!t)return;const e=De(t.x,0,this.bounds.width),i=De(t.y,0,this.bounds.height);this.crosshair.moveTo(e,0),this.crosshair.lineTo(e,this.bounds.height),this.crosshair.moveTo(0,i),this.crosshair.lineTo(this.bounds.width,i),this.crosshair.stroke({color:9222399,width:1,alpha:.24}),this.crosshair.rect(e-4,i-4,8,8),this.crosshair.stroke({color:16777215,width:1.5,alpha:.95})}ensureAxisLabelCount(t){for(;this.axisLabels.length<t;){const e=new Dt({text:"",style:{fill:9478327,fontFamily:"IBM Plex Mono, monospace",fontSize:10}});this.axisLabels.push(e),this.axisLabelLayer.addChild(e)}for(;this.axisLabels.length>t;){const e=this.axisLabels.pop();this.axisLabelLayer.removeChild(e),e.destroy()}}renderAxes({padding:t,plotWidth:e,plotHeight:i,minTime:r,maxTime:n,minValue:o,maxValue:a,width:h}){const d=[];this.axes.clear(),this.axes.moveTo(t.left,t.top),this.axes.lineTo(t.left,t.top+i),this.axes.lineTo(t.left+e,t.top+i),this.axes.stroke({color:4082783,width:1,alpha:1});for(let m=0;m<5;m+=1){const g=m/4,f=t.top+g*i,x=r+g*(n-r);this.axes.moveTo(t.left-8,f),this.axes.lineTo(t.left,f),this.axes.stroke({color:5202554,width:1,alpha:1}),d.push({text:Ot(x),x:14,y:f-7,anchorX:0})}for(let m=0;m<5;m+=1){const g=m/4,f=t.left+g*e,x=o+g*(a-o);this.axes.moveTo(f,t.top+i),this.axes.lineTo(f,t.top+i+8),this.axes.stroke({color:5202554,width:1,alpha:1}),d.push({text:Ls(x),x:f,y:t.top+i+10,anchorX:.5})}this.ensureAxisLabelCount(d.length),d.forEach((m,g)=>{const f=this.axisLabels[g];f.text=m.text,f.x=m.x,f.y=m.y,f.anchor.set(m.anchorX,0)}),this.axisTitleText.text="TIME",this.axisTitleText.x=18,this.axisTitleText.y=t.top-18,this.axisTitleText.rotation=0,this.axes.moveTo(t.left+e,t.top+i),this.axes.lineTo(h-14,t.top+i),this.axes.stroke({color:2107957,width:1,alpha:1})}renderReadouts(t,e){if(!this.showReadouts){this.readoutBackground.clear(),this.realTimeText.text="",this.plotTimeText.text="";return}const i=168,r=22,n=6,o=e-i-18,a=14;this.readoutBackground.clear(),this.readoutBackground.rect(o,a,i,r),this.readoutBackground.fill({color:1054237,alpha:1}),this.readoutBackground.stroke({color:3095629,width:1,alpha:1}),this.readoutBackground.rect(o,a+r+n,i,r),this.readoutBackground.fill({color:1054237,alpha:1}),this.readoutBackground.stroke({color:3095629,width:1,alpha:1}),this.realTimeText.text=`REAL ${Un(t.time.realNowMs)}`,this.realTimeText.x=o+10,this.realTimeText.y=a+5,this.plotTimeText.text=`PLOT ${Ot(t.time.plotTimeMs)}`,this.plotTimeText.x=o+10,this.plotTimeText.y=a+r+n+5}renderFrame(t,e){const i=this.bounds.width,r=this.bounds.height,n={top:72,right:28,bottom:46,left:88},o=Math.max(10,i-n.left-n.right),a=Math.max(10,r-n.top-n.bottom),h=t.time.plotTimeMs-t.plot.windowDurationMs,l=Math.max(t.time.plotTimeMs,h+1),{min:c,max:u}=t.plot.valueRange,p=Math.max(.001,u-c);if(this.background.clear(),rc(this.background,0,0,i,r,6,{color:329483,alpha:1},{color:2898765,width:1}),this.grid.clear(),t.plot.showGrid){for(let m=0;m<=6;m+=1){const g=n.left+o*m/6;this.grid.moveTo(g,n.top),this.grid.lineTo(g,n.top+a),this.grid.stroke({color:2176074,width:1,alpha:.85})}for(let m=0;m<=8;m+=1){const g=n.top+a*m/8;this.grid.moveTo(n.left,g),this.grid.lineTo(n.left+o,g),this.grid.stroke({color:2176074,width:1,alpha:.85})}}if(this.renderAxes({padding:n,plotWidth:o,plotHeight:a,minTime:h,maxTime:l,minValue:c,maxValue:u,width:i}),this.line.clear(),this.points.clear(),this.screenPoints=[],e.length>0&&(e.forEach((d,m)=>{const g=n.left+(d.value-c)/p*o,f=n.top+(d.timeMs-h)/(l-h)*a;this.screenPoints.push({...d,x:g,y:f}),m===0?this.line.moveTo(g,f):this.line.lineTo(g,f)}),this.line.stroke({color:this.lineColor,width:2,alpha:.96,cap:"square",join:"miter"}),t.plot.showPoints))for(const d of this.screenPoints)this.points.rect(d.x-2,d.y-2,4,4),this.points.fill({color:this.pointColor,alpha:.92});this.titleText.text=this.panelTitle,this.titleText.x=20,this.titleText.y=14,this.subtitleText.text=this.panelSubtitle??`value → ${t.source.preset} · ${t.source.sampleRateHz} hz · time ↓`,this.subtitleText.x=20,this.subtitleText.y=36,this.renderReadouts(t,i)}destroy(){this.app.destroy(!0,{children:!0})}}class ti{constructor(t={}){this.config={...t},this.running=!1}start(){this.running=!0}stop(){this.running=!1}updateConfig(t){this.config={...this.config,...t}}}function nc(s,t,e){return Math.min(e,Math.max(t,s))}class oc extends ti{constructor(t={}){super({replayRate:1,dataset:[],...t}),this.sourceType="csv-replay",this.nextPointIndex=0}start(t=0){super.start(),this.reset(t)}reset(){this.nextPointIndex=0}updateConfig(t){const e=t.dataset!==this.config.dataset;super.updateConfig(t),e&&this.reset()}update(t){if(!this.running||!Array.isArray(this.config.dataset)||this.config.dataset.length===0)return[];const e=nc(this.config.replayRate??1,.1,8),i=t*e,r=[];for(;this.nextPointIndex<this.config.dataset.length;){const n=this.config.dataset[this.nextPointIndex];if(n.timeMs>i)break;r.push({timeMs:n.timeMs/e,value:n.value,sourceId:this.config.id??"csv-replay"}),this.nextPointIndex+=1}return r}}function ac(s,t,e){return Math.min(e,Math.max(t,s))}function hc(s){const t=Math.sin(s*12.9898)*43758.5453;return t-Math.floor(t)}class lc extends ti{constructor(t={}){super({sampleRateHz:60,preset:"telemetry",amplitude:1,noise:.08,...t}),this.sourceType="synthetic-wave",this.lastEmittedPlotTimeMs=0}start(t=0){super.start(),this.lastEmittedPlotTimeMs=t}stop(){super.stop()}reset(t=0){this.lastEmittedPlotTimeMs=t}sampleValue(t){const e=t/1e3,i=this.config.amplitude,r=this.config.noise,n=(hc(t*.017)-.5)*2*r;switch(this.config.preset){case"chirp":{const o=Math.sin(e*e*1.4);return i*(.7*o+.3*Math.sin(e*7.5))+n}case"burst":{const o=e%6-1.5,a=Math.sin(e*9.5)*Math.exp(-(o**2)*.8);return i*(.45*Math.sin(e*2.1)+a)+n}case"telemetry":default:{const o=Math.sin(e*2.2),a=.35*Math.cos(e*6.4+Math.sin(e*.8)),h=.15*Math.sin(e*.33);return i*(o+a+h)+n}}}update(t){if(!this.running)return[];const e=1e3/ac(this.config.sampleRateHz,1,240);if(t<this.lastEmittedPlotTimeMs)return this.lastEmittedPlotTimeMs=t,[];const i=[];for(;this.lastEmittedPlotTimeMs+e<=t;)this.lastEmittedPlotTimeMs+=e,i.push({timeMs:this.lastEmittedPlotTimeMs,value:this.sampleValue(this.lastEmittedPlotTimeMs),sourceId:"synthetic-wave"});return i}}function cc(s,t,e){return Math.min(e,Math.max(t,s))}function $n(s){return typeof s=="number"&&Number.isFinite(s)}function Ds(s){if(Array.isArray(s))return s.flatMap(t=>Ds(t));if($n(s))return[{value:s,timestampMs:null}];if(typeof s=="string"){const t=s.trim();if(!t)return[];const e=Number(t);if(Number.isFinite(e))return[{value:e,timestampMs:null}];try{return Ds(JSON.parse(t))}catch{return[]}}if(s&&typeof s=="object"){const t=[s.value,s.y,s.signal,s.data].find(i=>Number.isFinite(Number(i)));if(t===void 0)return[];const e=[s.timeMs,s.timestampMs,s.timestamp,s.t].find(i=>Number.isFinite(Number(i)));return[{value:Number(t),timestampMs:e===void 0?null:Number(e)}]}return[]}class uc extends ti{constructor(t={},{onStatusChange:e}={}){super({wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,...t}),this.sourceType="websocket",this.onStatusChange=e,this.socket=null,this.queue=[],this.lastPlotTimeMs=0,this.reconnectTimer=null,this.shouldReconnect=!1,this.firstSourceTimestampMs=null,this.basePlotTimeMs=0}start(t=0){super.start(),this.lastPlotTimeMs=t,this.basePlotTimeMs=t,this.shouldReconnect=!0,this.connect()}stop(){super.stop(),this.shouldReconnect=!1,this.clearReconnectTimer(),this.socket&&(this.socket.close(),this.socket=null),this.setStatus("disconnected","socket closed")}reset(t=0){this.queue=[],this.lastPlotTimeMs=t,this.basePlotTimeMs=t,this.firstSourceTimestampMs=null}updateConfig(t){const e=this.config.wsUrl,i=this.config.wsReconnectMs;super.updateConfig(t),(e!==this.config.wsUrl||i!==this.config.wsReconnectMs)&&this.running&&this.reconnect()}update(t){if(this.lastPlotTimeMs=t,this.queue.length===0)return[];const e=[];for(;this.queue.length>0;){const i=this.queue.shift();let r=t;$n(i.timestampMs)&&(this.firstSourceTimestampMs===null&&(this.firstSourceTimestampMs=i.timestampMs,this.basePlotTimeMs=t),r=this.basePlotTimeMs+(i.timestampMs-this.firstSourceTimestampMs)),e.push({timeMs:r,value:i.value,sourceId:this.config.id??"websocket"})}return e}reconnect(){this.running&&(this.clearReconnectTimer(),this.socket&&(this.socket.close(),this.socket=null),this.connect())}connect(){var e;const t=(e=this.config.wsUrl)==null?void 0:e.trim();if(!t){this.setStatus("idle","enter a websocket url");return}this.clearReconnectTimer(),this.setStatus("connecting",t);try{this.socket=new WebSocket(t)}catch(i){this.setStatus("error",i instanceof Error?i.message:String(i)),this.scheduleReconnect();return}this.socket.addEventListener("open",()=>{this.setStatus("connected",t)}),this.socket.addEventListener("message",i=>{const r=Ds(i.data);r.length!==0&&this.queue.push(...r)}),this.socket.addEventListener("error",()=>{this.setStatus("error","socket error")}),this.socket.addEventListener("close",()=>{this.socket=null,this.running&&(this.setStatus("disconnected","retrying"),this.scheduleReconnect())})}scheduleReconnect(){if(!this.shouldReconnect||!this.running)return;const t=cc(Number(this.config.wsReconnectMs)||2e3,250,3e4);this.clearReconnectTimer(),this.reconnectTimer=window.setTimeout(()=>{this.connect()},t)}clearReconnectTimer(){this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}setStatus(t,e=""){var i;(i=this.onStatusChange)==null||i.call(this,{wsStatus:t,wsStatusDetail:e})}}class dc{constructor(t,e){this.store=t,this.bus=e,this.sources=new Map,this.syncFromState()}syncFromState(){const t=this.store.getState(),e=Object.entries(t.sources),i=new Set(e.map(([r])=>r));for(const[r,n]of e){const o=this.sources.get(r);if(!o){const a=this.createSource(r,n);this.sources.set(r,a),a.start(t.time.plotTimeMs);continue}if(o.sourceType!==n.type){o.stop();const a=this.createSource(r,n);this.sources.set(r,a),a.start(t.time.plotTimeMs);continue}o.updateConfig(n)}for(const[r,n]of this.sources.entries())i.has(r)||(n.stop(),this.sources.delete(r))}createSource(t,e){switch(e.type){case"csv-replay":return new oc(e);case"websocket":return new uc(e,{onStatusChange:i=>{this.store.setState(r=>({...r,sources:{...r.sources,[t]:{...r.sources[t],...i}}}))}});case"synthetic-wave":default:return new lc(e)}}update(t){for(const[e,i]of this.sources.entries()){const r=i.update(t);for(const n of r)this.bus.emit("data:point",{...n,sourceId:e})}}reset(){const t=this.store.getState().time.plotTimeMs;for(const e of this.sources.values())e.reset(t)}}function fc(s){return s.split(/[;,\t]/).map(t=>t.trim())}function zs(s){return s!==""&&Number.isFinite(Number(s))}function pc(s){if(s.length===0)return{hasHeader:!1,headers:[]};const[t]=s,e=t.some(i=>!zs(i));return{hasHeader:e,headers:e?t.map(i=>i.toLowerCase()):[]}}function mc(s){const t=s.find(e=>e.includes("time")||e.includes("timestamp"));return t&&t.includes("sec")&&!t.includes("msec")&&!t.includes("ms")?1e3:1}function gc(s,t){if(s.length===0)return{timeIndex:t>1?0:-1,valueIndex:t>1?1:0};const e=s.findIndex(r=>r.includes("time")||r.includes("timestamp")),i=s.findIndex(r=>r.includes("value")||r.includes("signal")||r.includes("y"));return{timeIndex:e,valueIndex:i>=0?i:s.length>1?1:0}}function xc(s,{sampleRateHz:t=60}={}){var m;const e=s.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).map(fc).filter(g=>g.some(f=>f!==""));if(e.length===0)throw new Error("CSV file is empty");const{hasHeader:i,headers:r}=pc(e),n=i?e.slice(1):e,o=e[0].length,{timeIndex:a,valueIndex:h}=gc(r,o),l=mc(r),c=1e3/Math.max(1,t),u=n.map((g,f)=>{const x=g[h];if(!zs(x))return null;const y=Number(x);return{timeMs:a>=0&&zs(g[a])?Number(g[a])*l:f*c,value:y}}).filter(Boolean).sort((g,f)=>g.timeMs-f.timeMs);if(u.length===0)throw new Error("CSV file did not contain any numeric data points");const p=u[0].timeMs,d=u.map(g=>({timeMs:g.timeMs-p,value:g.value}));return{points:d,metadata:{pointCount:d.length,durationMs:((m=d.at(-1))==null?void 0:m.timeMs)??0}}}function H(s,t,e){const i=document.createElement(s);return t&&(i.className=t),e&&(i.textContent=e),i}function mr(s,t){s.dataset.active=String(t)}function gr(s){return s.tagName==="SELECT"?s.value:s instanceof HTMLInputElement?s.type==="checkbox"?s.checked:s.type==="number"||s.type==="range"?Number(s.value):s.value:s.value}function j(s,t){if(!(!s||document.activeElement===s)){if(s instanceof HTMLInputElement&&s.type==="checkbox"){s.checked=!!t;return}s.value=String(t??"")}}class yc{constructor({root:t,store:e,actions:i}){this.root=t,this.store=e,this.actions=i,this.elements={}}mount(){const t=H("div","timeplot-shell"),e=H("header","timeplot-topbar"),i=H("section","timeplot-viewport"),r=H("div","timeplot-plot-grid"),n=H("section","timeplot-plot-panel"),o=H("section","timeplot-plot-panel"),a=H("div","timeplot-canvas-host"),h=H("div","timeplot-canvas-host"),l=H("aside","timeplot-sidebar"),c=H("div","timeplot-tooltip"),u=H("div","timeplot-tooltip");c.hidden=!0,u.hidden=!0;const p=H("div","timeplot-brand"),d=H("h1","timeplot-title","TimePlot"),m=H("div","timeplot-subtitle","Dual synchronized signal monitor");p.append(d,m);const g=H("div","timeplot-toolbar");return g.append(this.createTransportControls(),this.createPanelToggles()),e.append(p,g),n.append(a,c),o.append(h,u),r.append(n,o),i.append(r),t.append(e,i,l),this.root.replaceChildren(t),this.elements={...this.elements,shell:t,topbar:e,viewport:i,plotGrid:r,primaryPlotPanel:n,secondaryPlotPanel:o,primaryCanvasHost:a,secondaryCanvasHost:h,sidebar:l,primaryTooltip:c,secondaryTooltip:u,title:d,subtitle:m,statusPanel:this.createStatusPanel(),sourcePanel:this.createSourcePanel(),configPanel:this.createConfigPanel(),helpPanel:this.createHelpPanel()},l.append(this.elements.statusPanel,this.elements.sourcePanel,this.elements.configPanel,this.elements.helpPanel),this.elements}createTransportControls(){const t=H("div","control-group"),e=H("button","control-button","Pause"),i=H("button","control-button","Reset"),r=H("span",null,"Speed"),n=document.createElement("input");n.type="range",n.min="0.1",n.max="6",n.step="0.1";const o=H("span",null,"1.0×");return e.addEventListener("click",()=>this.actions.togglePause()),i.addEventListener("click",()=>this.actions.resetScene()),n.addEventListener("input",a=>this.actions.setSpeed(Number(a.target.value))),t.append(e,i,r,n,o),this.elements.pauseButton=e,this.elements.resetButton=i,this.elements.speedInput=n,this.elements.speedValue=o,t}createPanelToggles(){const t=H("div","control-group"),e=["status","source","config","help"];this.elements.panelButtons={};for(const i of e){const r=H("button","panel-toggle",i);r.addEventListener("click",()=>this.actions.togglePanel(i)),this.elements.panelButtons[i]=r,t.append(r)}return t}createStatusPanel(){const t=H("section","panel");return t.innerHTML=`
+ <h2>Status</h2>
+ <dl class="kv-list">
+ <dt>Renderer</dt><dd data-field="renderer">—</dd>
+ <dt>Real time</dt><dd data-field="realTime">—</dd>
+ <dt>Real elapsed</dt><dd data-field="realElapsed">—</dd>
+ <dt>Plot time</dt><dd data-field="plotTime">—</dd>
+ <dt>Playback</dt><dd data-field="playback">—</dd>
+ <dt>Points</dt><dd data-field="points">—</dd>
+ </dl>
+ `,t}createSourcePanel(){const t=H("section","panel");return t.innerHTML=`
+ <h2>Data Source</h2>
+ <div class="panel-subsection" data-source-config="signalA">
+ <div class="panel-section-title">Signal A</div>
+ <div class="field-grid">
+ <label>
+ Source type
+ <select data-source-key="signalA" data-source-field="type">
+ <option value="synthetic-wave">Synthetic wave</option>
+ <option value="csv-replay">CSV replay</option>
+ <option value="websocket">WebSocket</option>
+ </select>
+ </label>
+ </div>
+ <div class="field-grid" data-source-mode="synthetic-wave">
+ <label>
+ Preset
+ <select data-source-key="signalA" data-source-field="preset">
+ <option value="telemetry">Telemetry</option>
+ <option value="chirp">Chirp</option>
+ <option value="burst">Burst</option>
+ </select>
+ </label>
+ <label>
+ Sample rate (Hz)
+ <input data-source-key="signalA" data-source-field="sampleRateHz" type="number" min="1" max="240" step="1" />
+ </label>
+ <label>
+ Amplitude
+ <input data-source-key="signalA" data-source-field="amplitude" type="number" min="0.1" max="3" step="0.1" />
+ </label>
+ <label>
+ Noise
+ <input data-source-key="signalA" data-source-field="noise" type="number" min="0" max="0.5" step="0.01" />
+ </label>
+ </div>
+ <div class="field-grid" data-source-mode="csv-replay">
+ <label>
+ CSV file
+ <input data-source-key="signalA" data-source-file="dataset" type="file" accept=".csv,text/csv" />
+ </label>
+ <label>
+ Replay rate
+ <input data-source-key="signalA" data-source-field="replayRate" type="number" min="0.1" max="8" step="0.1" />
+ </label>
+ <div class="source-meta" data-source-key="signalA" data-source-meta></div>
+ </div>
+ <div class="field-grid" data-source-mode="websocket">
+ <label>
+ WebSocket URL
+ <input data-source-key="signalA" data-source-field="wsUrl" type="url" placeholder="ws://localhost:8080" />
+ </label>
+ <label>
+ Reconnect (ms)
+ <input data-source-key="signalA" data-source-field="wsReconnectMs" type="number" min="250" max="30000" step="250" />
+ </label>
+ <div class="source-meta" data-source-key="signalA" data-source-ws-meta></div>
+ </div>
+ </div>
+ <div class="panel-subsection" data-source-config="signalB">
+ <div class="panel-section-title">Signal B</div>
+ <div class="field-grid">
+ <label>
+ Source type
+ <select data-source-key="signalB" data-source-field="type">
+ <option value="synthetic-wave">Synthetic wave</option>
+ <option value="csv-replay">CSV replay</option>
+ <option value="websocket">WebSocket</option>
+ </select>
+ </label>
+ </div>
+ <div class="field-grid" data-source-mode="synthetic-wave">
+ <label>
+ Preset
+ <select data-source-key="signalB" data-source-field="preset">
+ <option value="telemetry">Telemetry</option>
+ <option value="chirp">Chirp</option>
+ <option value="burst">Burst</option>
+ </select>
+ </label>
+ <label>
+ Sample rate (Hz)
+ <input data-source-key="signalB" data-source-field="sampleRateHz" type="number" min="1" max="240" step="1" />
+ </label>
+ <label>
+ Amplitude
+ <input data-source-key="signalB" data-source-field="amplitude" type="number" min="0.1" max="3" step="0.1" />
+ </label>
+ <label>
+ Noise
+ <input data-source-key="signalB" data-source-field="noise" type="number" min="0" max="0.5" step="0.01" />
+ </label>
+ </div>
+ <div class="field-grid" data-source-mode="csv-replay">
+ <label>
+ CSV file
+ <input data-source-key="signalB" data-source-file="dataset" type="file" accept=".csv,text/csv" />
+ </label>
+ <label>
+ Replay rate
+ <input data-source-key="signalB" data-source-field="replayRate" type="number" min="0.1" max="8" step="0.1" />
+ </label>
+ <div class="source-meta" data-source-key="signalB" data-source-meta></div>
+ </div>
+ <div class="field-grid" data-source-mode="websocket">
+ <label>
+ WebSocket URL
+ <input data-source-key="signalB" data-source-field="wsUrl" type="url" placeholder="ws://localhost:8080" />
+ </label>
+ <label>
+ Reconnect (ms)
+ <input data-source-key="signalB" data-source-field="wsReconnectMs" type="number" min="250" max="30000" step="250" />
+ </label>
+ <div class="source-meta" data-source-key="signalB" data-source-ws-meta></div>
+ </div>
+ </div>
+ `,t.querySelectorAll("[data-source-field]").forEach(e=>{const i=e.tagName==="SELECT"?"change":"input";e.addEventListener(i,()=>{const r=e.getAttribute("data-source-key"),n=e.getAttribute("data-source-field"),o=gr(e);this.actions.updateSource(r,n,o)})}),t.querySelectorAll("[data-source-file]").forEach(e=>{e.addEventListener("change",async()=>{var n;const i=e.getAttribute("data-source-key"),r=(n=e.files)==null?void 0:n[0];r&&(await this.actions.loadSourceFile(i,r),e.value="")})}),t}createConfigPanel(){const t=H("section","panel");return t.innerHTML=`
+ <h2>Config</h2>
+ <div class="field-grid">
+ <label>
+ Visible window (ms)
+ <input data-plot-field="windowDurationMs" type="number" min="2000" max="120000" step="1000" />
+ </label>
+ <label>
+ Max points
+ <input data-plot-field="maxPoints" type="number" min="200" max="4000" step="100" />
+ </label>
+ <div class="panel-row">
+ <span>Show grid</span>
+ <input data-plot-field="showGrid" type="checkbox" />
+ </div>
+ <div class="panel-row">
+ <span>Show points</span>
+ <input data-plot-field="showPoints" type="checkbox" />
+ </div>
+ </div>
+ <div class="panel-subsection">
+ <div class="panel-section-title">Graph routing</div>
+ <div class="field-grid">
+ <label>
+ Primary graph source
+ <select data-graph-id="primary" data-graph-field="sourceKey">
+ <option value="signalA">Signal A</option>
+ <option value="signalB">Signal B</option>
+ </select>
+ </label>
+ <label>
+ Primary graph transform
+ <select data-graph-id="primary" data-graph-field="transform">
+ <option value="raw">Raw</option>
+ <option value="delta">Delta</option>
+ <option value="smooth">Smooth</option>
+ </select>
+ </label>
+ <label>
+ Secondary graph source
+ <select data-graph-id="secondary" data-graph-field="sourceKey">
+ <option value="signalA">Signal A</option>
+ <option value="signalB">Signal B</option>
+ </select>
+ </label>
+ <label>
+ Secondary graph transform
+ <select data-graph-id="secondary" data-graph-field="transform">
+ <option value="raw">Raw</option>
+ <option value="delta">Delta</option>
+ <option value="smooth">Smooth</option>
+ </select>
+ </label>
+ </div>
+ </div>
+ `,t.querySelectorAll("[data-plot-field]").forEach(e=>{const i=e instanceof HTMLInputElement&&e.type==="checkbox"?"change":"input";e.addEventListener(i,()=>{const r=e.getAttribute("data-plot-field"),n=gr(e);this.actions.updatePlot(r,n)})}),t.querySelectorAll("[data-graph-field]").forEach(e=>{e.addEventListener("change",()=>{const i=e.getAttribute("data-graph-id"),r=e.getAttribute("data-graph-field");this.actions.updateGraph(i,r,e.value)})}),t}createHelpPanel(){const t=H("section","panel");return t.innerHTML=`
+ <h2>Help</h2>
+ <ol class="help-list">
+ <li>Each signal can be synthetic or file-backed CSV replay.</li>
+ <li>Each graph can target Signal A or Signal B independently.</li>
+ <li>Each graph can render raw, delta, or smoothed data.</li>
+ <li>Hover either trace to inspect the nearest synchronized sample.</li>
+ <li>Use pause and speed controls to inspect timing behavior.</li>
+ </ol>
+ `,t}sync(t,e){this.elements.title.textContent=t.app.title,this.elements.subtitle.textContent="Dual synchronized signal monitor",this.elements.pauseButton.textContent=t.time.paused?"Resume":"Pause",mr(this.elements.pauseButton,t.time.paused),j(this.elements.speedInput,t.time.speed),this.elements.speedValue.textContent=`${t.time.speed.toFixed(1)}×`;const i=this.elements.statusPanel.querySelectorAll("[data-field]"),r=Object.fromEntries(Array.from(i).map(n=>[n.getAttribute("data-field"),n]));r.renderer.textContent=t.app.renderer,r.realTime.textContent=Un(t.time.realNowMs),r.realElapsed.textContent=Ot(t.time.realElapsedMs),r.plotTime.textContent=Ot(t.time.plotTimeMs),r.playback.textContent=t.time.paused?"Paused":`${t.time.speed.toFixed(1)}×`,r.points.textContent=typeof e=="object"?`${e.primary} / ${e.secondary}`:`${e}`,this.syncSourcePanel(t),this.syncConfigPanel(t),this.syncPanels(t),this.syncTooltip(t)}syncSourcePanel(t){Object.entries(t.sources).forEach(([e,i])=>{j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="type"]`),i.type),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="preset"]`),i.preset),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="sampleRateHz"]`),i.sampleRateHz),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="amplitude"]`),i.amplitude),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="noise"]`),i.noise);const r=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="replayRate"]`);r&&j(r,i.replayRate??1),this.elements.sourcePanel.querySelector(`[data-source-config="${e}"]`).querySelectorAll("[data-source-mode]").forEach(c=>{c.hidden=c.getAttribute("data-source-mode")!==i.type});const o=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-meta]`);o&&(i.type==="csv-replay"?o.innerHTML=i.loadError?`<span class="source-meta-error">${i.loadError}</span>`:`${i.dataFileName||"No file loaded"}${i.datasetPointCount?` · ${i.datasetPointCount} pts · ${Ot(i.datasetDurationMs||0)}`:""}`:i.type==="websocket"?o.textContent="":o.textContent="Generates data procedurally in-browser");const a=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="wsUrl"]`),h=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="wsReconnectMs"]`),l=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-ws-meta]`);a&&j(a,i.wsUrl??""),h&&j(h,i.wsReconnectMs??2e3),l&&(l.innerHTML=i.type==="websocket"?`status: <span class="source-meta-status source-meta-status-${i.wsStatus||"idle"}">${i.wsStatus||"idle"}</span>${i.wsStatusDetail?` · ${i.wsStatusDetail}`:""}`:"")})}syncConfigPanel(t){j(this.elements.configPanel.querySelector('[data-plot-field="windowDurationMs"]'),t.plot.windowDurationMs),j(this.elements.configPanel.querySelector('[data-plot-field="maxPoints"]'),t.plot.maxPoints),j(this.elements.configPanel.querySelector('[data-plot-field="showGrid"]'),t.plot.showGrid),j(this.elements.configPanel.querySelector('[data-plot-field="showPoints"]'),t.plot.showPoints),j(this.elements.configPanel.querySelector('[data-graph-id="primary"][data-graph-field="sourceKey"]'),t.graphs.primary.sourceKey),j(this.elements.configPanel.querySelector('[data-graph-id="primary"][data-graph-field="transform"]'),t.graphs.primary.transform),j(this.elements.configPanel.querySelector('[data-graph-id="secondary"][data-graph-field="sourceKey"]'),t.graphs.secondary.sourceKey),j(this.elements.configPanel.querySelector('[data-graph-id="secondary"][data-graph-field="transform"]'),t.graphs.secondary.transform)}syncPanels(t){const e={status:this.elements.statusPanel,source:this.elements.sourcePanel,config:this.elements.configPanel,help:this.elements.helpPanel};for(const[i,r]of Object.entries(t.panels))e[i].hidden=!r.visible,mr(this.elements.panelButtons[i],r.visible)}syncTooltip(t){const e=t.plot.tooltip;if(this.elements.primaryTooltip.hidden=!0,this.elements.secondaryTooltip.hidden=!0,!e.visible||!e.point)return;const i=e.panelId==="secondary"?this.elements.secondaryTooltip:this.elements.primaryTooltip;i.hidden=!1,i.style.left=`${e.x}px`,i.style.top=`${e.y}px`,i.innerHTML=`
+ <div class="timeplot-tooltip-title">Hovered sample</div>
+ <div class="timeplot-tooltip-row"><span class="muted">Panel</span><span>${e.panelLabel??"Primary"}</span></div>
+ <div class="timeplot-tooltip-row"><span class="muted">Plot time</span><span>${Ot(e.point.timeMs)}</span></div>
+ <div class="timeplot-tooltip-row"><span class="muted">Value</span><span>${Ls(e.point.value)}</span></div>
+ <div class="timeplot-tooltip-row"><span class="muted">Source</span><span>${e.point.sourceId}</span></div>
+ ${e.linkedPoint?`<div class="timeplot-tooltip-row"><span class="muted">Linked panel</span><span>${e.linkedPanelLabel??"Linked"}</span></div>`:""}
+ ${e.linkedPoint?`<div class="timeplot-tooltip-row"><span class="muted">Linked value</span><span>${Ls(e.linkedPoint.value)}</span></div>`:""}
+ `}}function xr(s,t,e){return Math.min(e,Math.max(t,s))}function _c(s){if(s.length<2)return[];const t=[];for(let e=1;e<s.length;e+=1){const i=s[e-1],r=s[e],n=Math.max(1,r.timeMs-i.timeMs);t.push({...r,value:(r.value-i.value)/n*1e3,sourceId:`${r.sourceId}:delta`})}return t}function bc(s,t=5){if(s.length===0)return[];const e=[];for(let i=0;i<s.length;i+=1){const r=Math.max(0,i-t+1),n=s.slice(r,i+1),o=n.reduce((a,h)=>a+h.value,0)/n.length;e.push({...s[i],value:o,sourceId:`${s[i].sourceId}:smooth`})}return e}function wc(s,t){switch(t){case"delta":return _c(s);case"smooth":return bc(s);case"raw":default:return s}}function yr(s){switch(s){case"delta":return"Δvalue / second";case"smooth":return"moving average";case"raw":default:return"raw signal"}}function Sc(s,t){if(s.length===0)return t;let e=1/0,i=-1/0;for(const n of s)e=Math.min(e,n.value),i=Math.max(i,n.value);const r=Math.max(Math.abs(e),Math.abs(i),.1);return{min:-r,max:r}}function vc(s,t){return!s&&!t?null:s&&!t?s:!s&&t?t:s.lastPointerEventAt>=t.lastPointerEventAt?s:t}async function Pc(s){const t=new Wn,e=new Kn(br()),i=new Qn(e),r=new Map(Object.keys(e.getState().sources).map(f=>[f,new ni(e.getState().plot.maxPoints)]));let n;const o=()=>{const f=e.getState();for(const x of Object.keys(f.sources))r.has(x)||r.set(x,new ni(f.plot.maxPoints)),r.get(x).maxPoints=f.plot.maxPoints;for(const x of Array.from(r.keys()))f.sources[x]||r.delete(x)},a=f=>{var x;(x=r.get(f))==null||x.clear()},h=(f,x)=>{const y=f.graphs[x],_=r.get(y.sourceKey),b=_?_.getVisiblePoints(f.time.plotTimeMs,f.plot.windowDurationMs):[],v=wc(b,y.transform);return{graphConfig:y,points:v,range:Sc(v,f.plot.valueRange)}},l={togglePause:()=>i.togglePause(),setSpeed:f=>i.setSpeed(f),resetScene:()=>{i.reset(),r.forEach(f=>f.clear()),n.reset()},togglePanel:f=>{e.setState(x=>({...x,panels:{...x.panels,[f]:{...x.panels[f],visible:!x.panels[f].visible}}}))},updateSource:(f,x,y)=>{e.setState(_=>({..._,sources:{..._.sources,[f]:{..._.sources[f],[x]:y,...x==="type"?{loadError:y==="csv-replay"&&_.sources[f].dataset.length===0?_.sources[f].dataFileName?`Reload ${_.sources[f].dataFileName} to restore replay data`:"Load a CSV file to begin replay":"",wsStatus:y==="websocket"?_.sources[f].wsStatus:"idle",wsStatusDetail:y==="websocket"?_.sources[f].wsStatusDetail:""}:{}}}})),n.syncFromState(),o(),(x==="type"||x==="wsUrl"||x==="wsReconnectMs")&&(a(f),n.reset())},loadSourceFile:async(f,x)=>{var y;try{const b=((y=e.getState().sources[f])==null?void 0:y.sampleRateHz)??60,v=await x.text(),{points:S,metadata:w}=xc(v,{sampleRateHz:b});a(f),e.setState(R=>({...R,sources:{...R.sources,[f]:{...R.sources[f],type:"csv-replay",dataset:S,dataFileName:x.name,datasetPointCount:w.pointCount,datasetDurationMs:w.durationMs,loadError:"",wsStatus:"idle",wsStatusDetail:""}}})),n.syncFromState(),n.reset()}catch(_){e.setState(b=>({...b,sources:{...b.sources,[f]:{...b.sources[f],loadError:_ instanceof Error?_.message:String(_)}}}))}},updatePlot:(f,x)=>{e.setState(y=>({...y,plot:{...y.plot,[f]:x}})),f==="maxPoints"&&(buffer.maxPoints=xr(x,200,4e3),r.forEach(y=>{y.maxPoints=xr(x,200,4e3)}))},updateGraph:(f,x,y)=>{e.setState(_=>({..._,graphs:{..._.graphs,[f]:{..._.graphs[f],[x]:y}}}))}},c=new yc({root:s,store:e,actions:l}),u=c.mount(),p=new pr({host:u.primaryCanvasHost,panelId:"primary",title:"Primary signal",subtitle:null,showReadouts:!0,lineColor:10473983,pointColor:15201023}),d=new pr({host:u.secondaryCanvasHost,panelId:"secondary",title:"Secondary signal",subtitle:null,showReadouts:!1,lineColor:16761963,pointColor:16769456}),m=await p.init();await d.init(),e.patch({app:{...e.getState().app,renderer:m}}),n=new dc(e,t),t.on("data:point",f=>{var x;(x=r.get(f.sourceId))==null||x.addPoint(f)});const g=f=>{if(!(f.target instanceof HTMLInputElement||f.target instanceof HTMLSelectElement)){if(f.code==="Space"){f.preventDefault(),l.togglePause();return}if(f.key==="["){l.setSpeed(e.getState().time.speed-.1);return}if(f.key==="]"){l.setSpeed(e.getState().time.speed+.1);return}f.key.toLowerCase()==="g"&&l.updatePlot("showGrid",!e.getState().plot.showGrid)}};return window.addEventListener("keydown",g),p.app.ticker.add(()=>{i.tick(),n.syncFromState(),o(),n.update(e.getState().time.plotTimeMs);const f=e.getState(),x=h(f,"primary"),y=h(f,"secondary");p.panelTitle=f.graphs.primary.title,p.panelSubtitle=`${f.sources[f.graphs.primary.sourceKey].label} · ${yr(f.graphs.primary.transform)} · time ↓`,d.panelTitle=f.graphs.secondary.title,d.panelSubtitle=`${f.sources[f.graphs.secondary.sourceKey].label} · ${yr(f.graphs.secondary.transform)} · time ↓`;const _={...f,plot:{...f.plot,valueRange:x.range}},b={...f,plot:{...f.plot,valueRange:y.range}};p.render(_,x.points),d.render(b,y.points);const v=p.getHoverCandidate(),S=d.getHoverCandidate(),w=vc(v,S);if(!w){p.clearHover(),d.clearHover(),e.setState(E=>({...E,plot:{...E.plot,hoveredPoint:null,tooltip:{...E.plot.tooltip,visible:!1,point:null,linkedPoint:null}}})),c.sync(e.getState(),{primary:x.points.length,secondary:y.points.length});return}const R=p.findNearestScreenPointByTime(w.point.timeMs),k=d.findNearestScreenPointByTime(w.point.timeMs);p.renderLinkedHover(R),d.renderLinkedHover(k);const P=w.panelId==="secondary"?f.graphs.secondary.title:f.graphs.primary.title,M=w.panelId==="secondary"?R:k,G=w.panelId==="secondary"?f.graphs.primary.title:f.graphs.secondary.title;e.setState(E=>({...E,plot:{...E.plot,hoveredPoint:w.point,tooltip:{...E.plot.tooltip,visible:!0,panelId:w.panelId,panelLabel:P,x:w.x,y:w.y,point:w.point,linkedPoint:M,linkedPanelLabel:G}}})),c.sync(e.getState(),{primary:x.points.length,secondary:y.points.length})}),{destroy(){window.removeEventListener("keydown",g),p.destroy(),d.destroy()}}}const Hs=document.getElementById("app");if(!Hs)throw new Error("App root not found");Pc(Hs).catch(s=>{console.error("Failed to start TimePlot",s),Hs.innerHTML=`
+ <div style="padding: 24px; color: #fff; font-family: sans-serif;">
+ <h1>TimePlot failed to start</h1>
+ <pre>${String(s)}</pre>
+ </div>
+ `});export{Wo as $,xn as A,J as B,ft as C,et as D,L as E,Nr as F,Ye as G,bi as H,de as I,ga as J,Ma as K,_e as L,I as M,V as N,W as O,Z as P,Oa as Q,Cs as R,dh as S,ke as T,vs as U,Si as V,rs as W,vi as X,Xo as Y,Ue as Z,Y as _,pt as a,Lr as a0,yn as a1,F as a2,O as a3,ja as a4,Sh as a5,mh as a6,Uh as a7,Oh as a8,jh as a9,Zh as aa,Kh as ab,Sn as ac,Nt as ad,$e as ae,lr as af,Nn as ag,Za as ah,Ht as ai,In as aj,Hi as ak,Di as al,dt as am,po as an,fr as ao,Gn as ap,xe as b,He as c,Ws as d,rt as e,zi as f,lh as g,pn as h,Xr as i,ht as j,ln as k,Gs as l,Nh as m,$h as n,Yh as o,qh as p,Ys as q,Ao as r,D as s,nn as t,fo as u,Jh as v,Q as w,it as x,Br as y,at as z};