modern-canvas 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,17 +1,869 @@
1
- (function(I,P){typeof exports=="object"&&typeof module<"u"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(I=typeof globalThis<"u"?globalThis:I||self,P(I.modernCanvas={}))})(this,function(I){"use strict";function P(o){return typeof o=="function"?o():o}class x extends Float32Array{static identity(){return new x([1,0,0,0,1,0,0,0,1])}static translation(r,c){return new x([1,0,0,0,1,0,r,c,1])}static rotation(r){const c=Math.cos(r),t=Math.sin(r);return new x([c,-t,0,t,c,0,0,0,1])}static scaling(r,c){return new x([r,0,0,0,c,0,0,0,1])}multiply(r){const c=this[0],t=this[1],n=this[2],d=this[3],m=this[4],a=this[5],s=this[6],e=this[7],i=this[8],u=r[0],l=r[1],h=r[2],E=r[3],T=r[4],f=r[5],g=r[6],R=r[7],p=r[8];return this[0]=u*c+l*d+h*s,this[1]=u*t+l*m+h*e,this[2]=u*n+l*a+h*i,this[3]=E*c+T*d+f*s,this[4]=E*t+T*m+f*e,this[5]=E*n+T*a+f*i,this[6]=g*c+R*d+p*s,this[7]=g*t+R*m+p*e,this[8]=g*n+R*a+p*i,this}}function L(o){const r=[];for(let c=o.length,t=0;t<c;t++){const n=o[t],d=~~(n/16);for(let m=0;m<=d;m++)m in r||(r[m]=0);r[d]|=1<<n%16}return r}function C(o){const r=document.createElement("video");return r.playsInline=!0,r.muted=!0,r.loop=!0,r.src=o,r}function M(o){const r=new Image;return r.decoding="sync",r.loading="eager",r.crossOrigin="anonymous",r.src=o,r}let b;const U=new Map;function S(){var o;return b||(b=document.createElement("iframe"),b.id=`__SANDBOX__${Math.random()}`,b.width="0",b.height="0",b.style.visibility="hidden",b.style.position="fixed",document.body.appendChild(b),(o=b.contentWindow)==null||o.document.write('<!DOCTYPE html><meta charset="UTF-8"><title></title><body>')),b}function D(o){switch(!0){case(o.startsWith("#")&&o.length===7):return o=o.substring(1),[parseInt(`${o[0]}${o[1]}`,16)/255,parseInt(`${o[2]}${o[3]}`,16)/255,parseInt(`${o[4]}${o[5]}`,16)/255,1];case(o.startsWith("#")&&o.length===9):return o=o.substring(1),[parseInt(`${o[0]}${o[1]}`,16)/255,parseInt(`${o[2]}${o[3]}`,16)/255,parseInt(`${o[4]}${o[5]}`,16)/255,parseInt(`${o[6]}${o[7]}`,16)/255];case o.startsWith("rgb("):return[...o.replace(/rgb\((.+?)\)/,"$1").split(",").slice(0,3).map(r=>Number(r.trim())/255),1];case o.startsWith("rgba("):return o.replace(/rgba\((.+?)\)/,"$1").split(",").slice(0,4).map(r=>Number(r.trim())/255)}}function F(o,r=[0,0,0,0]){if(U.has(o))return U.get(o);let c=D(o);if(!c){const t=S();if(t){const n=t.contentWindow;if(n){const d=n.document,m=d.createElement("div");d.body.appendChild(m),m.textContent=" ",m.style.color=o,c=D(n.getComputedStyle(m).color),d.body.removeChild(m)}}}return c&&U.set(o,c),c??r}const w=P({name:"renderer2d",register(o){o.registerShape("rectangle",{type:"2d",mode:"triangles",buffer:new Float32Array([-1,1,-1,-1,1,-1,1,-1,1,1,-1,1])}),o.registerMaterial("material2d",{vertexShader:`attribute vec2 aPosition;
2
- varying vec2 vTextureCoord;
3
- uniform mat3 uModelMatrix;
4
- void main() {
5
- vTextureCoord = step(0.0, aPosition);
6
- vec2 position = aPosition;
7
- gl_Position = vec4((uModelMatrix * vec3(position, 1)).xy, 0, 1);
8
- }`,fragmentShader:`uniform sampler2D uSampler;
9
- varying vec2 vTextureCoord;
10
- uniform vec4 uBackgroundColor;
11
- void main() {
12
- vec4 color = texture2D(uSampler, vTextureCoord);
13
- gl_FragColor = mix(uBackgroundColor, color, color.a);
14
- }`});const r=document.createElement("canvas").getContext("2d");o.registerSystem({update(c=0){var d;const{textures:t}=o,n=o.query("type");for(let m=n.length,a=0;a<m;a++){const s=n[a],{type:e}=s;if(e==="image"&&s.src)t.has(s.id)||o.registerTexture(s.id,M(s.src));else if(e==="video")if(!t.has(s.id))o.registerTexture(s.id,C(s.src));else{const i=(d=t.get(s.id))==null?void 0:d.source;i.duration&&(i.currentTime=c%i.duration)}else if(e==="text"){const{width:i,height:u,color:l="black",fontSize:h=14,fontWeight:E=400,direction:T="inherit",fontFamily:f="monospace",fontKerning:g="normal",textAlign:R="center",textBaseline:p="middle"}=s.style??{};if(!t.has(s.id)){const _=`${E} ${h}px ${f}`;r.font=_;const A=r.measureText(s.content),v=u??A.actualBoundingBoxAscent+A.actualBoundingBoxDescent,y=i??A.width;s.style.width=y,s.style.height=v,r.canvas.width=y,r.canvas.height=v,r.fillStyle=l,r.direction=T,r.font=_,r.fontKerning=g,r.textAlign=R,r.textBaseline=p,r.clearRect(0,0,y,v),r.fillText(s.content,y/2,v/2),o.registerTexture(s.id,r.canvas)}}}}}),o.registerSystem({update(){var m;const{width:c,height:t,textures:n}=o,d=o.query();for(let a=d.length,s=0;s<a;s++){const e=d[s],{shape:i="rectangle",material:u="material2d",filters:l=[]}=e,{left:h=0,top:E=0,width:T=0,height:f=0,rotation:g=0,background:R}=e.style??{},p=h/c,_=E/t,A=T/c,v=f/t,y=g/180*Math.PI,k=R!=null&&R.color?F(R.color):[0,0,0,0];o.renderNode({shape:i,material:u,uniforms:{uSampler:(m=n.get(e.id))==null?void 0:m.value,uBackgroundColor:k,uModelMatrix:x.identity().multiply(x.translation(2*p-(1-A),1-v-2*_)).multiply(x.scaling(A,v)).multiply(x.rotation(y))},extraRenderers:l==null?void 0:l.map(j=>{const{shape:q,material:K,type:z,...J}=j;return{shape:q??i,material:K??z??u,uniforms:J}})})}}})}});function B(o,r){const{width:c,height:t,context:n,shapes:d,materials:m,framebuffers:a,lastState:s}=o,{extraRenderers:e=[]}=r,i=[r,...e].filter(u=>d.has(u.shape)&&m.has(u.material));for(let u=i.length,l=0;l<u;l++){const h=i[l],{shape:E,material:T,uniforms:f}=h,g=d.get(E),R=m.get(T);(s==null?void 0:s.material)!==T&&(s==null?void 0:s.shape)!==E&&R.setupAttributes({aPosition:g.buffer});const p=l<u-1?a[l%2]:null;n.bindFramebuffer(n.FRAMEBUFFER,(p==null?void 0:p.buffer)??null),n.viewport(0,0,c,t),p&&n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),(s==null?void 0:s.material)!==T&&n.useProgram(R.program),f&&R.setupUniforms(f),n.drawArrays(g.mode,0,g.count),p&&n.bindTexture(n.TEXTURE_2D,p.texture),o.lastState={material:T,shape:E}}}function N(o,r=0){var d,m;const{context:c,systems:t,framebuffers:n}=o;n.forEach(a=>a.resize()),c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);for(let a=t.length,s=0;s<a;s++)(m=(d=t[s]).update)==null||m.call(d,r);c.flush()}function O(){const o=new Map,r=new Map;function c(a){if(o.has(a))return o.get(a);if(r.has(a)){const{value:s,shared:e}=r.get(a),i=s();return e&&n(a,i),i}}function t(a){return o.has(a)||r.has(a)}function n(a,s){o.set(a,s)}function d(a,s){m(a,s,!0)}function m(a,s,e=!1){r.set(a,{value:s,shared:e})}return new Proxy({instances:o,bindings:r,get:c,has:t,set:n,bind:m,singleton:d},{get(a,s,e){return typeof s=="symbol"||s in a?Reflect.get(a,s,e):a.get(s)},has(a,s){return typeof s=="symbol"||s in a?Reflect.has(a,s):a.has(s)},set(a,s,e,i){return typeof s=="symbol"||s in a?Reflect.set(a,s,e,i):(a.set(s,e),!0)}})}function X(o,r,c){const{context:t,materials:n,slTypes:d}=o,{vertexShader:m,fragmentShader:a,uniforms:s}=c;if(n.has(r))return;const e=[{type:t.VERTEX_SHADER,source:m},{type:t.FRAGMENT_SHADER,source:a.includes("precision")?a:`precision mediump float;
15
- ${a}`}].map(({type:E,source:T})=>{const f=t.createShader(E);if(!f)throw new Error("failed to create shader");if(t.shaderSource(f,T),t.compileShader(f),!t.getShaderParameter(f,t.COMPILE_STATUS))throw new Error(`failed to compiling shader:
16
- ${T}
17
- ${t.getShaderInfoLog(f)}`);return f}),i=t.createProgram();if(!i)throw new Error("failed to create program");if(e.forEach(E=>t.attachShader(i,E)),t.linkProgram(i),e.forEach(E=>t.deleteShader(E)),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error(`failed to initing program: ${t.getProgramInfoLog(i)}`);const u={};for(let E=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES),T=0;T<E;T++){const f=t.getActiveAttrib(i,T);if(!f)continue;const g=f.name.replace(/\[.*?]$/,"");u[g]={type:d[f.type],isArray:g!==f.name,location:t.getAttribLocation(i,g)}}const l={};for(let E=t.getProgramParameter(i,t.ACTIVE_UNIFORMS),T=0;T<E;T++){const f=t.getActiveUniform(i,T);if(!f)continue;const g=f.name.replace(/\[.*?]$/,"");l[g]={type:d[f.type],isArray:g!==f.name,location:t.getUniformLocation(i,g)}}const h={...c,program:i,attributes:u,uniforms:l,setupAttributes(E){for(const[T,f]of Object.entries(E)){const g=u[T];if(!g)continue;const{type:R,isArray:p,location:_}=g;if(f instanceof WebGLBuffer){t.bindBuffer(t.ARRAY_BUFFER,f);const A=t.getAttribLocation(i,T);switch(R){case"vec2":t.vertexAttribPointer(A,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(A);break;case"vec3":t.vertexAttribPointer(A,3,t.FLOAT,!1,0,0),t.enableVertexAttribArray(A);break}}else switch(R){case"float":p?t.vertexAttrib1fv(_,f):t.vertexAttrib1f(_,f);break;case"vec2":t.vertexAttrib2fv(_,f);break;case"vec3":t.vertexAttrib3fv(_,f);break;case"vec4":t.vertexAttrib4fv(_,f);break}}},setupUniforms(E){for(const[T,f]of Object.entries(E)){const g=l[T];if(!g)continue;const{type:R,isArray:p,location:_}=g;switch(R){case"float":p?t.uniform1fv(_,f):t.uniform1f(_,f);break;case"bool":case"int":p?t.uniform1iv(_,f):t.uniform1i(_,f);break;case"vec2":t.uniform2fv(_,f);break;case"vec3":t.uniform3fv(_,f);break;case"vec4":t.uniform4fv(_,f);break;case"mat2":t.uniformMatrix2fv(_,!1,f);break;case"mat3":t.uniformMatrix3fv(_,!1,f);break;case"mat4":t.uniformMatrix4fv(_,!1,f);break;case"sampler2D":t.bindTexture(t.TEXTURE_2D,f??o.defaultTexture),t.uniform1i(_,0);break}}}};s&&h.setupUniforms(s),n.set(r,h)}function G(o,r,c){const{context:t,shapes:n,drawModes:d}=o,{type:m="2d",mode:a="triangles",buffer:s=new Float32Array([])}=c,e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW),n.set(r,{mode:d[a],count:s.byteLength/s.BYTES_PER_ELEMENT/(m==="2d"?2:3),buffer:e})}function $(o){const{entities:r,children:c,components:t,archetypes:n}=o;r.clear(),t.clear(),n.clear();const d=function(){let e=0;return()=>++e}(),m=function(){let e=0;return()=>++e}();function a(e,i){var R,p;e.id||(e.id=d());const u=e.id,l=[];for(const _ in e){let A=t.get(_);A||(A=m(),t.set(_,A)),l.push(A)}const h=L(l),E=h.map(_=>String.fromCharCode(_)).join(""),T=r.get(u);T&&((p=(R=n.get(T.archetypeId))==null?void 0:R.entityIds)==null||p.delete(u));const f=n.get(E);let g=f==null?void 0:f.entityIds;f||(g=new Set,n.set(E,{entityIds:g,codePoints:h})),g.add(u),r.set(u,{path:i,archetypeId:E})}function s(e,i){for(let u=e.length,l=0;l<u;l++){const h=e[l],E=[...i,l];a(h,E),h.children&&s(h.children,E)}}s(c,[])}function W(o,r){const{entities:c,components:t,children:n,archetypes:d}=o;if(!r)return n.flatMap(function i(u){var l;return[u,(l=u.children)==null?void 0:l.flatMap(i)].filter(Boolean)});const m=typeof r=="string"?[r]:r,a=[];for(let i=m.length,u=0;u<i;u++){const l=t.get(m[u]);l&&a.push(l)}const s=L(a),e=[];for(const[,{entityIds:i,codePoints:u}]of d.entries())if(u.some(l=>s.some(h=>h&l)))for(const[l]of i.entries()){const{path:h}=c.get(l);if(!h||!h.length)continue;let E=n[h[0]];for(let T=h.length,f=1;f<T;f++)E=E[f];e.push(E)}return e}function V(o,r,c){const{context:t,textures:n}=o,d={loading:!0,value:null,source:c};return n.set(r,d),new Promise(m=>{c instanceof HTMLImageElement?c.addEventListener("load",a,{once:!0}):c instanceof HTMLVideoElement?(c.addEventListener("canplay",a,{once:!0}),c.addEventListener("timeupdate",()=>{t.bindTexture(t.TEXTURE_2D,d.value),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,c)})):a();function a(){d.value=t.createTexture(),d.value&&(t.bindTexture(t.TEXTURE_2D,d.value),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,c)),d.loading=!1,c instanceof HTMLVideoElement&&(c.currentTime=.01),m()}})}function H(o,r){const{systems:c}=o;c.push(r)}function Y(o={}){var a,s;const{view:r=document.createElement("canvas"),children:c=[],plugins:t=[]}=o,n=O();n.view=r,n.singleton("context",()=>{const{view:e}=n,i=e.getContext("webgl",o)||e.getContext("experimental-webgl",o);if(!i)throw new Error("failed to getContext for webgl");const u=i.drawingBufferWidth,l=i.drawingBufferHeight;return i.viewport(0,0,u,l),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),i.clearColor(0,0,0,0),i.enable(i.DEPTH_TEST),i.enable(i.CULL_FACE),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),i.depthMask(!1),i}),n.singleton("defaultTexture",()=>{const{context:e,width:i,height:u}=n,l=e.createTexture();return e.bindTexture(e.TEXTURE_2D,l),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,i,u,0,e.RGBA,e.UNSIGNED_BYTE,null),l}),n.singleton("framebuffers",()=>{const{context:e}=n;return Array.from({length:2},()=>{const i=e.createTexture(),u=e.createFramebuffer(),l=e.createRenderbuffer();function h(){const{width:E,height:T}=n;e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,E,T,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindRenderbuffer(e.RENDERBUFFER,l),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,E,T)}return h(),e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindFramebuffer(e.FRAMEBUFFER,u),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.bindRenderbuffer(e.RENDERBUFFER,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l),{buffer:u,depthBuffer:l,texture:i,resize:h}})}),n.singleton("drawModes",()=>{const{context:e}=n;return{points:e.POINTS,linear:e.LINEAR,triangles:e.TRIANGLES,triangleStrip:e.TRIANGLE_STRIP,triangleFan:e.TRIANGLE_FAN}}),n.singleton("slTypes",()=>{const{context:e}=n;return{[e.FLOAT]:"float",[e.FLOAT_VEC2]:"vec2",[e.FLOAT_VEC3]:"vec3",[e.FLOAT_VEC4]:"vec4",[e.INT]:"int",[e.INT_VEC2]:"ivec2",[e.INT_VEC3]:"ivec3",[e.INT_VEC4]:"ivec4",[e.UNSIGNED_INT]:"uint",[e.UNSIGNED_INT_VEC2??-1]:"uvec2",[e.UNSIGNED_INT_VEC3??-1]:"uvec3",[e.UNSIGNED_INT_VEC4??-1]:"uvec4",[e.BOOL]:"bool",[e.BOOL_VEC2]:"bvec2",[e.BOOL_VEC3]:"bvec3",[e.BOOL_VEC4]:"bvec4",[e.FLOAT_MAT2]:"mat2",[e.FLOAT_MAT3]:"mat3",[e.FLOAT_MAT4]:"mat4",[e.SAMPLER_2D]:"sampler2D",[e.INT_SAMPLER_2D??-1]:"sampler2D",[e.UNSIGNED_INT_SAMPLER_2D??-1]:"sampler2D",[e.SAMPLER_CUBE]:"samplerCube",[e.INT_SAMPLER_CUBE??-1]:"samplerCube",[e.UNSIGNED_INT_SAMPLER_CUBE??-1]:"samplerCube",[e.SAMPLER_2D_ARRAY??-1]:"sampler2DArray",[e.INT_SAMPLER_2D_ARRAY??-1]:"sampler2DArray",[e.UNSIGNED_INT_SAMPLER_2D_ARRAY??-1]:"sampler2DArray"}}),n.singleton("extensions",()=>({loseContext:n.context.getExtension("WEBGL_lose_context")})),n.bind("width",()=>n.context.drawingBufferWidth),n.bind("height",()=>n.context.drawingBufferHeight),n.plugins=new Map,n.children=c,n.shapes=new Map,n.registerShape=(e,i)=>G(n,e,i),n.materials=new Map,n.registerMaterial=(e,i)=>X(n,e,i),n.textures=new Map,n.registerTexture=(e,i)=>V(n,e,i),n.entities=new Map,n.components=new Map,n.archetypes=new Map,n.systems=[],n.registerSystem=e=>H(n,e),n.query=e=>W(n,e),n.setup=()=>$(n),n.load=async()=>{var u,l;const{systems:e,textures:i}=n;for(let h=e.length,E=0;E<h;E++)(l=(u=e[E]).update)==null||l.call(u,0);for(;Array.from(i.values()).some(h=>h.loading);)await new Promise(h=>setTimeout(h,100))},n.renderNode=e=>B(n,e),n.render=e=>N(n,e),n.start=()=>{let e=0,i=0;u(0);function u(l){requestAnimationFrame(u),N(n,i),l*=.001,i+=l-e,e=l}};function d(e){e.preventDefault(),setTimeout(()=>{var i;n.context.isContextLost()&&((i=n.extensions.loseContext)==null||i.restoreContext())},0)}function m(){}return(a=r.addEventListener)==null||a.call(r,"webglcontextlost",d,!1),(s=r.addEventListener)==null||s.call(r,"webglcontextrestored",m,!1),n.destroy=()=>{var e,i,u;(e=r.removeEventListener)==null||e.call(r,"webglcontextlost",d),(i=r.removeEventListener)==null||i.call(r,"webglcontextrestored",m),n.context.useProgram(null),(u=n.extensions.loseContext)==null||u.loseContext()},t.forEach(e=>{var i;(i=e.register)==null||i.call(e,n),n.plugins.set(e.name,e)}),n.setup(),n}I.Renderer2d=w,I.createApp=Y,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,Et){typeof exports=="object"&&typeof module<"u"?Et(exports):typeof define=="function"&&define.amd?define(["exports"],Et):(g=typeof globalThis<"u"?globalThis:g||self,Et(g.modernCanvas={}))})(this,function(g){"use strict";var zp=Object.defineProperty;var Vp=(g,Et,at)=>Et in g?zp(g,Et,{enumerable:!0,configurable:!0,writable:!0,value:at}):g[Et]=at;var d=(g,Et,at)=>Vp(g,typeof Et!="symbol"?Et+"":Et,at);var er,ke;const Et=Math.PI,at=Et*2;let kl=0;function Dn(n){var e;return((e=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:e.id)??++kl}function ns(n){return!(n&n-1)&&!!n}const Nl=/([\w-]+)\((.+?)\)/g,Fl=/[^,]+/g,$l=/([-e.\d]+)(.*)/;function os(n){return Array.isArray(n)?n.map(e=>({name:e.name,args:e.args.map(t=>({...t,normalizedIntValue:t.normalizedDefaultIntValue}))})):{...n,normalizedIntValue:n.normalizedDefaultIntValue}}function xr(n,e,t={}){const r=wr(e,t);return r.length?r:Rn(n,e,t)}function wr(n,e={}){const t=[];let r;for(;(r=Nl.exec(n))!==null;){const[,i,s]=r;i&&t.push({name:i,args:zl(i,s,e)})}return t}function zl(n,e,t={}){const r=[];let i,s=0;for(;(i=Fl.exec(e))!==null;)r.push(Rn(n,i[0],{...t,index:s++}));return r}function Rn(n,e,t={}){const{width:r=1,height:i=1,index:s=0}=t,o=e.match($l),a={unit:(o==null?void 0:o[2])??null,value:e,intValue:Number(o==null?void 0:o[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(n){case"scale":case"scaleX":case"scaleY":case"scale3d":a.normalizedDefaultIntValue=1;break}switch(a.unit){case"%":a.normalizedIntValue=a.intValue/100;break;case"rad":a.normalizedIntValue=a.intValue/at;break;case"deg":a.normalizedIntValue=a.intValue/360;break;case"px":switch(s){case 0:a.normalizedIntValue=a.intValue/r;break;case 1:a.normalizedIntValue=a.intValue/i;break}break;case"turn":case"em":case"rem":default:a.normalizedIntValue=a.intValue;break}return a}const Bn="WebGL2RenderingContext"in globalThis,Ln="ImageBitmap"in globalThis,kn="ResizeObserver"in globalThis,sr="PointerEvent"in globalThis,Nn="WheelEvent"in globalThis,Vl="MouseEvent"in globalThis,_e="ontouchstart"in globalThis,Fn="onclick"in globalThis,as="createImageBitmap"in globalThis,ls="AudioContext"in globalThis,hs="webkitAudioContext"in globalThis,cs="OfflineAudioContext"in globalThis,$n="webkitOfflineAudioContext"in globalThis,zn=ls||hs,Pr=typeof window<"u",us=globalThis.devicePixelRatio||1,fs=n=>n!==null&&typeof n=="object"&&n.nodeType===1,Vn=n=>fs(n)&&n.tagName==="VIDEO",Xl=n=>fs(n)&&n.tagName==="IMG";function Xn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function jn(n){return Bn&&n instanceof globalThis.WebGL2RenderingContext}function Gn(){if(Pr)return globalThis.document.createElement("canvas")}function qn(n,e=globalThis.location){if(n.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(n,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Yn(n,e,t){t===null&&!e.startsWith("data:")?n.crossOrigin=qn(e):t!==!1&&(n.crossOrigin=typeof t=="string"?t:"anonymous")}let ve=class{constructor(){d(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}on(e,t,r){const i={value:t,options:r},s=this.eventListeners.get(e);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(e,[s,i]):this.eventListeners.set(e,i),this}once(e,t){return this.on(e,t,{once:!0})}off(e,t,r){var s,o;if(!t)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==t||typeof r=="object"&&(r!=null&&r.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===t&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(e);return this}emit(e,...t){var i,s;const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let o=r.length,a=0;a<o;a++){const l=r[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(e,l.value,l.options),l.value.apply(this,t)}else typeof r.options=="object"&&((s=r.options)!=null&&s.once)&&this.off(e,r.value,r.options),r.value.apply(this,t);return!0}else return!1}};const oi=new Map;function Z(n){let e,t;return typeof n=="string"?e=n:{tag:e,renderable:t}=n,function(r){Object.defineProperty(r.prototype,"tag",{value:e,enumerable:!0,configurable:!0}),typeof t<"u"&&Object.defineProperty(r,"renderable",{value:t,enumerable:!1,configurable:!1}),oi.set(e,r)}}const Wn=new WeakMap;function ai(n){let e=Wn.get(n);if(!e){const t=Object.getPrototypeOf(n);e=new Map(t?ai(t):void 0),Wn.set(n,e)}return e}function W(n,e,t={}){ai(n).set(e,t);const{default:r,alias:i}=t;let s=Object.getOwnPropertyDescriptor(n.prototype,e);if(!s){const o=i??Symbol.for(String(e));s={get(){return this[o]},set(a){this[o]=a}}}Object.defineProperty(n.prototype,e,{get(){var o;return((o=s.get)==null?void 0:o.call(this))??r},set(o){var l,h,c;const a=((l=s.get)==null?void 0:l.call(this))??r;(h=s.set)==null||h.call(this,o),(c=this.requestUpdate)==null||c.call(this,e,a,t)},configurable:!0,enumerable:!0})}function U(n){return function(e,t){W(e.constructor,t,n)}}function nt(n){return U({...n,protected:!0})}function jl(n="node",e={}){const t=oi.get(n);if(!t)throw new Error(`Failed to createNode, tag: ${n}`);return new t().setProperties(e)}class ft{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(e,t={}){const{sort:r=0,once:i=!1}=t;this._queue[r]||(this._queue[r]=[]),this._queue[r].push({cb:e,once:i})}static off(e,t={}){const{sort:r=0}=t,i=this._queue[r];if(!i)return;const s=[];for(let o=i.length,a=0;a<o;a++){const l=i[a];l.cb!==e&&s.push(l)}s.length?this._queue[r]=s:this._queue.splice(r,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(e=>this._update(e)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(e){this._elapsed=e-this._currentTime,this._currentTime=e,this._requestId=requestAnimationFrame(t=>this._update(t)),this._performUpdate()}static _performUpdate(){const e=this._queue,t=[];for(let r=e.length,i=r;i>=0;i--){const s=e[i];if(!s)continue;const o=[];for(let a=s.length,l=0;l<a;l++){const h=s[l];try{h.cb()}catch(c){console.warn(c)}h.once||o.push(h)}o.length&&(t[i]=o)}this._queue=t}}d(ft,"_queue",[]),d(ft,"_currentTime",0),d(ft,"_elapsed",0),d(ft,"_requestId"),ft.start();async function ds(n){return new Promise(e=>{ft.on(()=>{n==null||n(),e()},{sort:1,once:!0})})}let Gl=0;class li extends ve{constructor(){super(...arguments);d(this,"instanceId",++Gl);d(this,"_defaultProperties");d(this,"_updatedProperties",new Map);d(this,"_changedProperties",new Set);d(this,"_updatePending",Promise.resolve());d(this,"_isUpdatePending",!1)}async _enqueueUpdate(){this._isUpdatePending=!0;try{await this._updatePending}catch(t){Promise.reject(t)}await ds(),this._performUpdate()}_performUpdate(){this._isUpdatePending&&(this._onUpdate(this._updatedProperties),this._updatedProperties=new Map,this._isUpdatePending=!1)}_onUpdate(t){}_onUpdateProperty(t,r,i,s){}isDirty(t){return this._updatedProperties.has(t)}getPropertyDeclarations(){return ai(this.constructor)}getPropertyDeclaration(t){return this.getPropertyDeclarations().get(t)}getDefaultProperties(){if(!this._defaultProperties){this._defaultProperties={};for(const[t,r]of this.getPropertyDeclarations())!r.protected&&!r.alias&&(this._defaultProperties[t]=r.default)}return this._defaultProperties}getProperty(t){return this[t]}setProperty(t,r){return this[t]=r,this}getProperties(t){const r={};for(const[i,s]of this.getPropertyDeclarations())!s.protected&&!s.alias&&(!t||t.includes(i))&&(r[i]=this.getProperty(i));return r}setProperties(t){if(t)for(const[r]of this.getPropertyDeclarations())r in t&&this.setProperty(r,t[r]);return this}requestUpdate(t,r,i){if(t!==void 0){const s=this[t];if(!Object.is(s,r))this._updatedProperties.set(t,r),this._changedProperties.add(t),i??(i=this.getPropertyDeclaration(t)),this._onUpdateProperty(t,s,r,i),this.emit("updateProperty",t,s,r,i);else return}this._isUpdatePending||(this._updatePending=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}destroy(){}}class ps extends li{constructor(){super(...arguments);d(this,"_refCount",0)}}class Ee extends ps{}class hi extends Ee{constructor(t={}){super();d(this,"vertexAttributes");d(this,"indexBuffer");d(this,"instanceCount");d(this,"mode");d(this,"_materialWeakMap",new WeakMap);this.vertexAttributes=new Map(Object.entries((t==null?void 0:t.vertexAttributes)??{})),this.indexBuffer=t==null?void 0:t.indexBuffer,this.instanceCount=t==null?void 0:t.instanceCount,this.mode=(t==null?void 0:t.mode)??"triangles"}_glVertexArray(t){var r;return{attributes:Object.fromEntries(Array.from(this.vertexAttributes).map(([i,s])=>[i,{buffer:s.buffer._glBuffer(t),size:s.size,type:s.type,normalized:s.normalized,stride:s.stride,offset:s.offset,divisor:s.divisor}])),elementArrayBuffer:(r=this.indexBuffer)==null?void 0:r._glBuffer(t)}}_glVertexArrayObject(t,r){let i=this._materialWeakMap.get(r);return i||(i={material:r.instanceId,geometry:this.instanceId},this._materialWeakMap.set(r,i)),t.getRelated(i,()=>t.vertexArray.create(r._glProgram(t),this._glVertexArray(t)))}draw(t,r,i){var l;t.flush(),r.activate(t,i);const s=this._glVertexArrayObject(t,r);let o=!1,a;this.vertexAttributes.forEach(h=>{(a==null?void 0:a.instanceId)!==h.buffer.instanceId&&(a=h.buffer,a.upload(t)&&(o=!0)),h.upload()&&(o=!0)}),(l=this.indexBuffer)!=null&&l.upload(t)&&(o=!0),o&&s&&t.vertexArray.update(r._glProgram(t),s,this._glVertexArray(t)),t.vertexArray.bind(s??this._glVertexArray(t)),t.draw({mode:this.mode,instanceCount:this.instanceCount}),t.vertexArray.unbind()}}var ql=Object.defineProperty,Hn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ql(e,t,i),i};class nr extends Ee{constructor(t){super();d(this,"needsUpload",!1);this.setProperties(t)}_glBufferOptions(){return{target:"element_array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(t){return t.getRelated(this,()=>t.buffer.create(this._glBufferOptions()))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"data":case"dynamic":this.needsUpload=!0;break}}upload(t){const r=this.needsUpload;return r&&(this.needsUpload=!1,t.buffer.update(this._glBuffer(t),this._glBufferOptions())),r}}Hn([nt({default:null})],nr.prototype,"data"),Hn([nt({default:!1})],nr.prototype,"dynamic");var Yl=Object.defineProperty,Zn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Yl(e,t,i),i};class be extends Ee{constructor(t){super();d(this,"needsUpload",!1);this.setProperties(t)}_glBufferOptions(){return{target:"array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(t){return t.getRelated(this,()=>t.buffer.create(this._glBufferOptions()))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"data":case"dynamic":this.needsUpload=!0;break}}upload(t){const r=this.needsUpload;return r&&(this.needsUpload=!1,t.buffer.update(this._glBuffer(t),this._glBufferOptions())),r}}Zn([nt({default:null})],be.prototype,"data"),Zn([nt({default:!1})],be.prototype,"dynamic");var Wl=Object.defineProperty,Ne=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Wl(e,t,i),i};class jt extends Ee{constructor(t){super();d(this,"stride");d(this,"offset");d(this,"divisor");d(this,"needsUpload",!1);this.setProperties({buffer:new be,...t})}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"buffer":case"size":case"normalized":case"type":case"stride":case"offset":case"divisor":this.needsUpload=!0;break}}upload(){const t=this.needsUpload;return t&&(this.needsUpload=!1),t}}Ne([nt()],jt.prototype,"buffer"),Ne([nt({default:0})],jt.prototype,"size"),Ne([nt({default:!1})],jt.prototype,"normalized"),Ne([nt({default:"float"})],jt.prototype,"type"),Ne([nt()],jt.prototype,"stride"),Ne([nt()],jt.prototype,"offset"),Ne([nt()],jt.prototype,"divisor");class Hl extends hi{constructor(){super({vertexAttributes:{position:new jt({buffer:new be({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const Qi=class Qi extends Ee{constructor(t={}){super();d(this,"vert");d(this,"frag");d(this,"uniforms");this.vert=t.vert??`precision highp float;
2
+ attribute vec2 position;
3
+ uniform mat3 projectionMatrix;
4
+ uniform mat3 modelViewMatrix;
5
+ void main(void) {
6
+ gl_Position = vec4((projectionMatrix * modelViewMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
7
+ }`,this.frag=t.frag??`uniform vec4 tint;
8
+ void main(void) {
9
+ gl_FragColor = tint;
10
+ }`,this.uniforms=new Map(Object.entries(t.uniforms??{projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}))}_glProgram(t){return t.getRelated(this,()=>{let r=this.vert,i=this.frag;return i.includes("precision")||(i=`precision mediump float;
11
+ ${i}`),r.includes("precision")||(r=`precision mediump float;
12
+ ${r}`),t.program.create({vert:r,frag:i})})}activate(t,r){t.program.bind(this._glProgram(t)),(r||this.uniforms.size>0)&&t.program.updateUniforms({...Object.fromEntries(this.uniforms.entries()),...r})}};d(Qi,"instance",new Qi);let lt=Qi;class ci extends lt{static get instance(){return this._instance??(this._instance=new this)}constructor(){super({vert:`precision highp float;
13
+ attribute vec2 position;
14
+ attribute vec2 uv;
15
+ uniform mat3 projectionMatrix;
16
+ uniform mat3 modelViewMatrix;
17
+ varying vec2 vUv;
18
+ void main(void) {
19
+ gl_Position = vec4((projectionMatrix * modelViewMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
20
+ vUv = uv;
21
+ }`,frag:`varying vec2 vUv;
22
+ uniform sampler2D sampler;
23
+ uniform vec4 tint;
24
+ void main(void) {
25
+ gl_FragColor = texture2D(sampler, vUv) * tint;
26
+ }`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}d(ci,"_instance");class et extends hi{static get instance(){return this._instance??(this._instance=new this)}static draw(e,t=ci.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new jt({buffer:new be({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new jt({buffer:new be({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}d(et,"_instance");class Zl extends hi{constructor(){const t=new be({data:new Float32Array,dynamic:!0}),r=new be({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new jt({buffer:t,size:2,normalized:!1,type:"float"}),uv:new jt({buffer:r,size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array,dynamic:!0})});d(this,"positionBuffer");d(this,"uvBuffer");this.positionBuffer=t,this.uvBuffer=r}update(t,r,i){return this.positionBuffer.data=t,this.uvBuffer.data=r,this.indexBuffer.data=i,this}}var Kl=Object.defineProperty,Kn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Kl(e,t,i),i};class ui extends li{constructor(){super();d(this,"_starting",!1);d(this,"_nextDeltaTime",0);this._onNextTick=this._onNextTick.bind(this)}get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}start(t){return this._starting||(this._starting=!0,this.removeAllListeners(),this.on("process",t),ft.on(this._onNextTick,{sort:0})),this}stop(){return this._starting&&(this._starting=!1,ft.off(this._onNextTick,{sort:0})),this}_onNextTick(){const t=ft.elapsed*this.speed;if((this._nextDeltaTime-=t)<=0){const i=(this._nextDeltaTime=this.spf)||t;this.emit("process",i)}}}Kn([U({default:24})],ui.prototype,"fps"),Kn([U({default:1})],ui.prototype,"speed");const Ql=8,fi=11920929e-14,Jl=1;function gs(n,e,t,r,i,s,o,a,l,h=.5){const u=Math.min(.99,Math.max(0,h));let f=(Jl-u)/1;return f*=f,th(e,t,r,i,s,o,a,l,n,f),n}function th(n,e,t,r,i,s,o,a,l,h){ms(n,e,t,r,i,s,o,a,l,h,0),l.push(o,a)}function ms(n,e,t,r,i,s,o,a,l,h,c){if(c>Ql)return;const u=(n+t)/2,f=(e+r)/2,p=(t+i)/2,y=(r+s)/2,_=(i+o)/2,m=(s+a)/2,b=(u+p)/2,w=(f+y)/2,x=(p+_)/2,C=(y+m)/2,P=(b+x)/2,E=(w+C)/2;if(c>0){let A=o-n,S=a-e;const T=Math.abs((t-o)*S-(r-a)*A),O=Math.abs((i-o)*S-(s-a)*A);if(T>fi&&O>fi){if((T+O)*(T+O)<=h*(A*A+S*S)){l.push(P,E);return}}else if(T>fi){if(T*T<=h*(A*A+S*S)){l.push(P,E);return}}else if(O>fi){if(O*O<=h*(A*A+S*S)){l.push(P,E);return}}else if(A=P-(n+o)/2,S=E-(e+a)/2,A*A+S*S<=h){l.push(P,E);return}}ms(n,e,u,f,b,w,P,E,l,h,c+1),ms(P,E,x,C,_,m,o,a,l,h,c+1)}const eh=8,rh=11920929e-14,ih=1;function Qn(n,e,t,r,i,s,o,a=.5){const h=Math.min(.99,Math.max(0,a));let c=(ih-h)/1;return c*=c,sh(e,t,r,i,s,o,n,c),n}function sh(n,e,t,r,i,s,o,a){ys(o,n,e,t,r,i,s,a,0),o.push(i,s)}function ys(n,e,t,r,i,s,o,a,l){if(l>eh)return;const h=(e+r)/2,c=(t+i)/2,u=(r+s)/2,f=(i+o)/2,p=(h+u)/2,y=(c+f)/2;let _=s-e,m=o-t;const b=Math.abs((r-s)*m-(i-o)*_);if(b>rh){if(b*b<=a*(_*_+m*m)){n.push(p,y);return}}else if(_=p-(e+s)/2,m=y-(t+o)/2,_*_+m*m<=a){n.push(p,y);return}ys(n,e,t,h,c,p,y,a,l+1),ys(n,p,y,u,f,s,o,a,l+1)}function _s(n,e,t,r,i,s,o,a){let l=Math.abs(i-s);(!o&&i>s||o&&s>i)&&(l=2*Math.PI-l),a=a||Math.max(6,Math.floor(6*r**(1/3)*(l/Math.PI))),a=Math.max(a,3);let h=l/a,c=i;h*=o?-1:1;for(let u=0;u<a+1;u++){const f=Math.cos(c),p=Math.sin(c),y=e+f*r,_=t+p*r;n.push(y,_),c+=h}}function nh(n,e,t,r,i,s){const o=n[n.length-2],l=n[n.length-1]-t,h=o-e,c=i-t,u=r-e,f=Math.abs(l*u-h*c);if(f<1e-8||s===0){(n[n.length-2]!==e||n[n.length-1]!==t)&&n.push(e,t);return}const p=l*l+h*h,y=c*c+u*u,_=l*c+h*u,m=s*Math.sqrt(p)/f,b=s*Math.sqrt(y)/f,w=m*_/p,x=b*_/y,C=m*u+b*h,P=m*c+b*l,E=h*(b+w),A=l*(b+w),S=u*(m+x),T=c*(m+x),O=Math.atan2(A-P,E-C),$=Math.atan2(T-P,S-C);_s(n,C+e,P+t,s,O,$,h*c>u*l)}const Cr=Math.PI*2,vs={centerX:0,centerY:0,ang1:0,ang2:0};function bs({x:n,y:e},t,r,i,s,o,a,l){n*=t,e*=r;const h=i*n-s*e,c=s*n+i*e;return l.x=h+o,l.y=c+a,l}function oh(n,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=e===1.5707963267948966?.551915024494:t,i=Math.cos(n),s=Math.sin(n),o=Math.cos(n+e),a=Math.sin(n+e);return[{x:i-s*r,y:s+i*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}function Jn(n,e,t,r){const i=n*r-e*t<0?-1:1;let s=n*t+e*r;return s>1&&(s=1),s<-1&&(s=-1),i*Math.acos(s)}function ah(n,e,t,r,i,s,o,a,l,h,c,u,f){const p=i**2,y=s**2,_=c**2,m=u**2;let b=p*y-p*m-y*_;b<0&&(b=0),b/=p*m+y*_,b=Math.sqrt(b)*(o===a?-1:1);const w=b*i/s*u,x=b*-s/i*c,C=h*w-l*x+(n+t)/2,P=l*w+h*x+(e+r)/2,E=(c-w)/i,A=(u-x)/s,S=(-c-w)/i,T=(-u-x)/s,O=Jn(1,0,E,A);let $=Jn(E,A,S,T);a===0&&$>0&&($-=Cr),a===1&&$<0&&($+=Cr),f.centerX=C,f.centerY=P,f.ang1=O,f.ang2=$}function to(n,e,t,r,i,s,o,a=0,l=0,h=0){if(s===0||o===0)return;const c=Math.sin(a*Cr/360),u=Math.cos(a*Cr/360),f=u*(e-r)/2+c*(t-i)/2,p=-c*(e-r)/2+u*(t-i)/2;if(f===0&&p===0)return;s=Math.abs(s),o=Math.abs(o);const y=f**2/s**2+p**2/o**2;y>1&&(s*=Math.sqrt(y),o*=Math.sqrt(y)),ah(e,t,r,i,s,o,l,h,c,u,f,p,vs);let{ang1:_,ang2:m}=vs;const{centerX:b,centerY:w}=vs;let x=Math.abs(m)/(Cr/4);Math.abs(1-x)<1e-7&&(x=1);const C=Math.max(Math.ceil(x),1);m/=C;let P=n[n.length-2],E=n[n.length-1];const A={x:0,y:0};for(let S=0;S<C;S++){const T=oh(_,m),{x:O,y:$}=bs(T[0],s,o,u,c,b,w,A),{x:N,y:B}=bs(T[1],s,o,u,c,b,w,A),{x:M,y:L}=bs(T[2],s,o,u,c,b,w,A);gs(n,P,E,O,$,N,B,M,L),P=M,E=L,_+=m}}class di{constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.radius=r}contains(e,t){if(this.radius<=0)return!1;const r=this.radius*this.radius;let i=this.x-e,s=this.y-t;return i*=i,s*=s,i+s<=r}strokeContains(e,t,r){if(this.radius===0)return!1;const i=this.x-e,s=this.y-t,o=this.radius,a=r/2,l=Math.sqrt(i*i+s*s);return l<o+a&&l>o-a}clone(){return new di(this.x,this.y,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){return e=e||new Gt,e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}class Tr{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.halfWidth=r,this.halfHeight=i}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(e-this.x)/this.halfWidth,i=(t-this.y)/this.halfHeight;return r*=r,i*=i,r+i<=1}strokeContains(e,t,r){const{halfWidth:i,halfHeight:s}=this;if(i<=0||s<=0)return!1;const o=r/2,a=i-o,l=s-o,h=i+o,c=s+o,u=e-this.x,f=t-this.y,p=u*u/(a*a)+f*f/(l*l),y=u*u/(h*h)+f*f/(c*c);return p>1&&y<=1}clone(){return new Tr(this.x,this.y,this.halfWidth,this.halfHeight)}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}getBounds(){return new Gt(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}function Er(n,e,t,r,i,s){const o=n-t,a=e-r,l=i-t,h=s-r,c=o*l+a*h,u=l*l+h*h;let f=-1;u!==0&&(f=c/u);let p,y;f<0?(p=t,y=r):f>1?(p=i,y=s):(p=t+f*l,y=r+f*h);const _=n-p,m=e-y;return _*_+m*m}class xs{constructor(e=0,t=0,r=0,i=0,s=0,o=0){this.x=e,this.y=t,this.x2=r,this.y2=i,this.x3=s,this.y3=o}contains(e,t){const r=(this.x-this.x3)*(t-this.y3)-(this.y-this.y3)*(e-this.x3),i=(this.x2-this.x)*(t-this.y)-(this.y2-this.y)*(e-this.x);if(r<0!=i<0&&r!==0&&i!==0)return!1;const s=(this.x3-this.x2)*(t-this.y2)-(this.y3-this.y2)*(e-this.x2);return s===0||s<0==r+i<=0}strokeContains(e,t,r){const i=r/2,s=i*i,{x:o,x2:a,x3:l,y:h,y2:c,y3:u}=this;return Er(e,t,o,h,a,u)<=s||Er(e,t,a,c,l,u)<=s||Er(e,t,l,u,o,h)<=s}clone(){return new xs(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(e){return this.x=e.x,this.y=e.y,this.x2=e.x2,this.y2=e.y2,this.x3=e.x3,this.y3=e.y3,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){e=e||new Gt;const t=Math.min(this.x,this.x2,this.x3),r=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),s=Math.max(this.y,this.y2,this.y3);return e.x=t,e.y=i,e.width=r-t,e.height=s-i,e}buildOutline(e){Ms.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Ms.triangulate(r,e,2,0,t,0)}}class Fe{constructor(...e){d(this,"points");d(this,"closed");let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const r=[];for(let i=0,s=t.length;i<s;i++)r.push(t[i].x,t[i].y);t=r}this.points=t,this.closed=!0}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}reset(){return this.points.length=0,this}contains(e,t){let r=!1;const i=this.points.length/2;for(let s=0,o=i-1;s<i;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],c=this.points[o*2+1];l>t!=c>t&&e<(h-a)*((t-l)/(c-l))+a&&(r=!r)}return r}strokeContains(e,t,r){const i=r/2,s=i*i,{points:o}=this,a=o.length-(this.closed?0:2);for(let l=0;l<a;l+=2){const h=o[l],c=o[l+1],u=o[(l+2)%o.length],f=o[(l+3)%o.length];if(Er(e,t,h,c,u,f)<=s)return!0}return!1}clone(){const e=this.points.slice(),t=new Fe(e);return t.closed=this.closed,t}copyFrom(e){return this.points=e.points.slice(),this.closed=e.closed,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){e=e||new Gt;const t=this.points;let r=1/0,i=-1/0,s=1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=2){const h=t[a],c=t[a+1];r=h<r?h:r,i=h>i?h:i,s=c<s?c:s,o=c>o?c:o}return e.x=r,e.width=i-r,e.y=s,e.height=o-s,e}buildOutline(e){Ts.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Ts.triangulate(r,e,2,0,t,0)}}function pi(n,e,t,r,i,s){const o=n-t,a=e-r,l=Math.sqrt(o*o+a*a);return l>=i-s&&l<=i+s}class gi{constructor(e=0,t=0,r=0,i=0,s=r/4){this.x=e,this.y=t,this.width=r,this.height=i,this.radius=s}getBounds(e){return e=e||new Gt,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new gi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+r&&t<=this.y+this.height-r||e>=this.x+r&&e<=this.x+this.width-r)return!0;let i=e-(this.x+r),s=t-(this.y+r);const o=r*r;if(i*i+s*s<=o||(i=e-(this.x+this.width-r),i*i+s*s<=o)||(s=t-(this.y+this.height-r),i*i+s*s<=o)||(i=e-(this.x+r),i*i+s*s<=o))return!0}return!1}strokeContains(e,t,r){const{x:i,y:s,width:o,height:a,radius:l}=this,h=r/2,c=i+l,u=s+l,f=o-l*2,p=a-l*2,y=i+o,_=s+a;return(e>=i-h&&e<=i+h||e>=y-h&&e<=y+h)&&t>=u&&t<=u+p||(t>=s-h&&t<=s+h||t>=_-h&&t<=_+h)&&e>=c&&e<=c+f?!0:e<c&&t<u&&pi(e,t,c,u,l,h)||e>y-l&&t<u&&pi(e,t,y-l,u,l,h)||e>y-l&&t>_-l&&pi(e,t,y-l,_-l,l,h)||e<c&&t>_-l&&pi(e,t,c,_-l,l,h)}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}class lh extends Fe{constructor(e=0,t=0,r=5,i=1,s,o=0){s=s||i/2;const a=-1*Math.PI/2+o,l=r*2,h=at/l,c=[];for(let u=0;u<l;u++){const f=u%2?s:i,p=u*h+a;c.push(e+f*Math.cos(p),t+f*Math.sin(p))}super(c)}}const $e={build(n,e){let t,r,i,s,o,a;if(n instanceof di)t=n.x,r=n.y,o=a=n.radius,i=s=0;else if(n instanceof Tr)t=n.x,r=n.y,o=n.halfWidth,a=n.halfHeight,i=s=0;else{const C=n,P=C.width/2,E=C.height/2;t=C.x+P,r=C.y+E,o=a=Math.max(0,Math.min(C.radius,Math.min(P,E))),i=P-o,s=E-a}if(!(o>=0&&a>=0&&i>=0&&s>=0))return e;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(i?4:0)+(s?4:0);if(h===0)return e;if(l===0)return e[0]=e[6]=t+i,e[1]=e[3]=r+s,e[2]=e[4]=t-i,e[5]=e[7]=r-s,e;let c=0,u=l*4+(i?2:0)+2,f=u,p=h,y=i+o,_=s,m=t+y,b=t-y,w=r+_;if(e[c++]=m,e[c++]=w,e[--u]=w,e[--u]=b,s){const C=r-_;e[f++]=b,e[f++]=C,e[--p]=C,e[--p]=m}for(let C=1;C<l;C++){const P=Math.PI/2*(C/l),E=i+Math.cos(P)*o,A=s+Math.sin(P)*a,S=t+E,T=t-E,O=r+A,$=r-A;e[c++]=S,e[c++]=O,e[--u]=O,e[--u]=T,e[f++]=T,e[f++]=$,e[--p]=$,e[--p]=S}y=i,_=s+a,m=t+y,b=t-y,w=r+_;const x=r-_;return e[c++]=m,e[c++]=w,e[--p]=x,e[--p]=m,i&&(e[c++]=b,e[c++]=w,e[--p]=x,e[--p]=b),e},triangulate(n,e,t,r,i,s){if(n.length===0)return;let o=0,a=0;for(let c=0;c<n.length;c+=2)o+=n[c],a+=n[c+1];o/=n.length/2,a/=n.length/2;let l=r;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<n.length;c+=2)e[l*t]=n[c],e[l*t+1]=n[c+1],c>0&&(i[s++]=l,i[s++]=h,i[s++]=l-1),l++;i[s++]=h+1,i[s++]=h,i[s++]=l-1}},Ji=class Ji{constructor(e=0,t=0){this.x=e,this.y=t}static get shared(){const e=this._shared??new Ji;return e.x=0,e.y=0,e}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}};d(Ji,"_shared");let re=Ji;function hh(n){const e=n.length;if(e<6)return 1;let t=0;for(let r=0,i=n[e-2],s=n[e-1];r<e;r+=2){const o=n[r],a=n[r+1];t+=(o-i)*(a+s),i=o,s=a}return t<0?-1:1}function ch(n,e,t=2){const r=e.length,i=r?e[0]*t:n.length;let s=eo(n,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(r&&(s=gh(n,e,s,t)),n.length>80*t){a=1/0,l=1/0;let c=-1/0,u=-1/0;for(let f=t;f<i;f+=t){const p=n[f],y=n[f+1];p<a&&(a=p),y<l&&(l=y),p>c&&(c=p),y>u&&(u=y)}h=Math.max(c-a,u-l),h=h!==0?32767/h:0}return Mr(s,o,t,a,l,h,0),o}function eo(n,e,t,r,i){let s;if(i===Eh(n,e,t,r)>0)for(let o=e;o<t;o+=r)s=no(o/r|0,n[o],n[o+1],s);else for(let o=t-r;o>=e;o-=r)s=no(o/r|0,n[o],n[o+1],s);return s&&or(s,s.next)&&(Or(s),s=s.next),s}function ze(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(or(t,t.next)||ot(t.prev,t,t.next)===0)){if(Or(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function Mr(n,e,t,r,i,s,o){if(!n)return;!o&&s&&bh(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(s?fh(n,r,i,s):uh(n)){e.push(l.i,n.i,h.i),Or(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=dh(ze(n),e),Mr(n,e,t,r,i,s,2)):o===2&&ph(n,e,t,r,i,s):Mr(ze(n),e,t,r,i,s,1);break}}}function uh(n){const e=n.prev,t=n,r=n.next;if(ot(e,t,r)>=0)return!1;const i=e.x,s=t.x,o=r.x,a=e.y,l=t.y,h=r.y,c=Math.min(i,s,o),u=Math.min(a,l,h),f=Math.max(i,s,o),p=Math.max(a,l,h);let y=r.next;for(;y!==e;){if(y.x>=c&&y.x<=f&&y.y>=u&&y.y<=p&&Sr(i,a,s,l,o,h,y.x,y.y)&&ot(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function fh(n,e,t,r){const i=n.prev,s=n,o=n.next;if(ot(i,s,o)>=0)return!1;const a=i.x,l=s.x,h=o.x,c=i.y,u=s.y,f=o.y,p=Math.min(a,l,h),y=Math.min(c,u,f),_=Math.max(a,l,h),m=Math.max(c,u,f),b=ws(p,y,e,t,r),w=ws(_,m,e,t,r);let x=n.prevZ,C=n.nextZ;for(;x&&x.z>=b&&C&&C.z<=w;){if(x.x>=p&&x.x<=_&&x.y>=y&&x.y<=m&&x!==i&&x!==o&&Sr(a,c,l,u,h,f,x.x,x.y)&&ot(x.prev,x,x.next)>=0||(x=x.prevZ,C.x>=p&&C.x<=_&&C.y>=y&&C.y<=m&&C!==i&&C!==o&&Sr(a,c,l,u,h,f,C.x,C.y)&&ot(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;x&&x.z>=b;){if(x.x>=p&&x.x<=_&&x.y>=y&&x.y<=m&&x!==i&&x!==o&&Sr(a,c,l,u,h,f,x.x,x.y)&&ot(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;C&&C.z<=w;){if(C.x>=p&&C.x<=_&&C.y>=y&&C.y<=m&&C!==i&&C!==o&&Sr(a,c,l,u,h,f,C.x,C.y)&&ot(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function dh(n,e){let t=n;do{const r=t.prev,i=t.next.next;!or(r,i)&&io(r,t,t.next,i)&&Ar(r,i)&&Ar(i,r)&&(e.push(r.i,t.i,i.i),Or(t),Or(t.next),t=n=i),t=t.next}while(t!==n);return ze(t)}function ph(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Ph(o,a)){let l=so(o,a);o=ze(o,o.next),l=ze(l,l.next),Mr(o,e,t,r,i,s,0),Mr(l,e,t,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function gh(n,e,t,r){const i=[];for(let s=0,o=e.length;s<o;s++){const a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,h=eo(n,a,l,r,!1);h===h.next&&(h.steiner=!0),i.push(wh(h))}i.sort(mh);for(let s=0;s<i.length;s++)t=yh(i[s],t);return t}function mh(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function yh(n,e){const t=_h(n,e);if(!t)return e;const r=so(t,n);return ze(r,r.next),ze(t,t.next)}function _h(n,e){let t=e;const r=n.x,i=n.y;let s=-1/0,o;if(or(n,t))return t;do{if(or(n,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const u=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=r&&u>s&&(s=u,o=t.x<t.next.x?t:t.next,u===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,h=o.y;let c=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&ro(i<h?r:s,i,l,h,i<h?s:r,i,t.x,t.y)){const u=Math.abs(i-t.y)/(r-t.x);Ar(t,n)&&(u<c||u===c&&(t.x>o.x||t.x===o.x&&vh(o,t)))&&(o=t,c=u)}t=t.next}while(t!==a);return o}function vh(n,e){return ot(n.prev,n,e.prev)<0&&ot(e.next,n,n.next)<0}function bh(n,e,t,r){let i=n;do i.z===0&&(i.z=ws(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,xh(i)}function xh(n){let e,t=1;do{let r=n,i;n=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let h=0;h<t&&(a++,o=o.nextZ,!!o);h++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,t*=2}while(e>1);return n}function ws(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function wh(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function ro(n,e,t,r,i,s,o,a){return(i-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(r-a)}function Sr(n,e,t,r,i,s,o,a){return!(n===o&&e===a)&&ro(n,e,t,r,i,s,o,a)}function Ph(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Ch(n,e)&&(Ar(n,e)&&Ar(e,n)&&Th(n,e)&&(ot(n.prev,n,e.prev)||ot(n,e.prev,e))||or(n,e)&&ot(n.prev,n,n.next)>0&&ot(e.prev,e,e.next)>0)}function ot(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function or(n,e){return n.x===e.x&&n.y===e.y}function io(n,e,t,r){const i=yi(ot(n,e,t)),s=yi(ot(n,e,r)),o=yi(ot(t,r,n)),a=yi(ot(t,r,e));return!!(i!==s&&o!==a||i===0&&mi(n,t,e)||s===0&&mi(n,r,e)||o===0&&mi(t,n,r)||a===0&&mi(t,e,r))}function mi(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function yi(n){return n>0?1:n<0?-1:0}function Ch(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&io(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ar(n,e){return ot(n.prev,n,n.next)<0?ot(n,e,n.next)>=0&&ot(n,n.prev,e)>=0:ot(n,e,n.prev)<0||ot(n,n.next,e)<0}function Th(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function so(n,e){const t=Ps(n.i,n.x,n.y),r=Ps(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function no(n,e,t,r){const i=Ps(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Or(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Ps(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Eh(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}function Mh(n,e,t,r,i,s,o){const a=ch(n,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)s[o++]=a[h]+i,s[o++]=a[h+1]+i,s[o++]=a[h+2]+i;let l=i*r;for(let h=0;h<n.length;h+=2)t[l]=n[h],t[l+1]=n[h+1],l+=r}const oo=1e-4,Cs=1e-4;function ao(n,e,t,r,i,s,o,a){const l=n-t*i,h=e-r*i,c=n+t*s,u=e+r*s;let f,p;o?(f=r,p=-t):(f=-r,p=t);const y=l+f,_=h+p,m=c+f,b=u+p;return a.push(y,_),a.push(m,b),2}function Ve(n,e,t,r,i,s,o,a){const l=t-n,h=r-e;let c=Math.atan2(l,h),u=Math.atan2(i-n,s-e);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c;const p=u-c,y=Math.abs(p),_=Math.sqrt(l*l+h*h),m=(15*y*Math.sqrt(_)/Math.PI>>0)+1,b=p/m;if(f+=b,a){o.push(n,e),o.push(t,r);for(let w=1,x=f;w<m;w++,x+=b)o.push(n,e),o.push(n+Math.sin(x)*_,e+Math.cos(x)*_);o.push(n,e),o.push(i,s)}else{o.push(t,r),o.push(n,e);for(let w=1,x=f;w<m;w++,x+=b)o.push(n+Math.sin(x)*_,e+Math.cos(x)*_),o.push(n,e);o.push(i,s),o.push(n,e)}return m*2}function lo(n,e,t,r,i,s,o,a,l){const h=oo;if(n.length===0)return;const c=e;let u=c.alignment;if(e.alignment!==.5){let z=hh(n);t&&(z*=-1),u=(u-.5)*z+.5}const f=new re(n[0],n[1]),p=new re(n[n.length-2],n[n.length-1]),y=r,_=Math.abs(f.x-p.x)<h&&Math.abs(f.y-p.y)<h;if(y){n=n.slice(),_&&(n.pop(),n.pop(),p.set(n[n.length-2],n[n.length-1]));const z=(f.x+p.x)*.5,Y=(p.y+f.y)*.5;n.unshift(z,Y),n.push(z,Y)}const m=i,b=n.length/2;let w=n.length;const x=m.length/2,C=c.width/2,P=C*C,E=c.miterLimit*c.miterLimit;let A=n[0],S=n[1],T=n[2],O=n[3],$=0,N=0,B=-(S-O),M=A-T,L=0,F=0,X=Math.sqrt(B*B+M*M);B/=X,M/=X,B*=C,M*=C;const q=u,I=(1-q)*2,R=q*2;y||(c.cap==="round"?w+=Ve(A-B*(I-R)*.5,S-M*(I-R)*.5,A-B*I,S-M*I,A+B*R,S+M*R,m,!0)+2:c.cap==="square"&&(w+=ao(A,S,B,M,I,R,!0,m))),m.push(A-B*I,S-M*I),m.push(A+B*R,S+M*R);for(let z=1;z<b-1;++z){A=n[(z-1)*2],S=n[(z-1)*2+1],T=n[z*2],O=n[z*2+1],$=n[(z+1)*2],N=n[(z+1)*2+1],B=-(S-O),M=A-T,X=Math.sqrt(B*B+M*M),B/=X,M/=X,B*=C,M*=C,L=-(O-N),F=T-$,X=Math.sqrt(L*L+F*F),L/=X,F/=X,L*=C,F*=C;const Y=T-A,H=S-O,j=T-$,Q=N-O,tt=Y*j+H*Q,st=H*j-Q*Y,Zt=st<0;if(Math.abs(st)<.001*Math.abs(tt)){m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),tt>=0&&(c.join==="round"?w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+4:w+=2,m.push(T-L*R,O-F*R),m.push(T+L*I,O+F*I));continue}const me=(-B+A)*(-M+O)-(-B+T)*(-M+S),Kt=(-L+$)*(-F+O)-(-L+T)*(-F+N),kt=(Y*Kt-j*me)/st,Xt=(Q*me-H*Kt)/st,ye=(kt-T)*(kt-T)+(Xt-O)*(Xt-O),oe=T+(kt-T)*I,ae=O+(Xt-O)*I,wt=T-(kt-T)*R,ir=O-(Xt-O)*R,Fp=Math.min(Y*Y+H*H,j*j+Q*Q),Il=Zt?I:R,$p=Fp+Il*Il*P;ye<=$p?c.join==="bevel"||ye/P>E?(Zt?(m.push(oe,ae),m.push(T+B*R,O+M*R),m.push(oe,ae),m.push(T+L*R,O+F*R)):(m.push(T-B*I,O-M*I),m.push(wt,ir),m.push(T-L*I,O-F*I),m.push(wt,ir)),w+=2):c.join==="round"?Zt?(m.push(oe,ae),m.push(T+B*R,O+M*R),w+=Ve(T,O,T+B*R,O+M*R,T+L*R,O+F*R,m,!0)+4,m.push(oe,ae),m.push(T+L*R,O+F*R)):(m.push(T-B*I,O-M*I),m.push(wt,ir),w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+4,m.push(T-L*I,O-F*I),m.push(wt,ir)):(m.push(oe,ae),m.push(wt,ir)):(m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),c.join==="round"?Zt?w+=Ve(T,O,T+B*R,O+M*R,T+L*R,O+F*R,m,!0)+2:w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+2:c.join==="miter"&&ye/P<=E&&(Zt?(m.push(wt,ir),m.push(wt,ir)):(m.push(oe,ae),m.push(oe,ae)),w+=2),m.push(T-L*I,O-F*I),m.push(T+L*R,O+F*R),w+=2)}A=n[(b-2)*2],S=n[(b-2)*2+1],T=n[(b-1)*2],O=n[(b-1)*2+1],B=-(S-O),M=A-T,X=Math.sqrt(B*B+M*M),B/=X,M/=X,B*=C,M*=C,m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),y||(c.cap==="round"?w+=Ve(T-B*(I-R)*.5,O-M*(I-R)*.5,T-B*I,O-M*I,T+B*R,O+M*R,m,!1)+2:c.cap==="square"&&(w+=ao(T,O,B,M,I,R,!1,m)));const k=Cs*Cs;for(let z=x;z<w+x-2;++z)A=m[z*2],S=m[z*2+1],T=m[(z+1)*2],O=m[(z+1)*2+1],$=m[(z+2)*2],N=m[(z+2)*2+1],!(Math.abs(A*(O-N)+T*(N-S)+$*(S-O))<k)&&a.push(z,z+1,z+2)}const Sh=[],Ts={build(n,e){for(let t=0;t<n.points.length;t++)e[t]=n.points[t];return e},triangulate(n,e,t,r,i,s){Mh(n,Sh,e,t,r,i,s)}},Es={build(n,e){const t=n,r=t.x,i=t.y,s=t.width,o=t.height;return s>=0&&o>=0&&(e[0]=r,e[1]=i,e[2]=r+s,e[3]=i,e[4]=r+s,e[5]=i+o,e[6]=r,e[7]=i+o),e},triangulate(n,e,t,r,i,s){let o=0;r*=t,e[r+o]=n[0],e[r+o+1]=n[1],o+=t,e[r+o]=n[2],e[r+o+1]=n[3],o+=t,e[r+o]=n[6],e[r+o+1]=n[7],o+=t,e[r+o]=n[4],e[r+o+1]=n[5],o+=t;const a=r/t;i[s++]=a,i[s++]=a+1,i[s++]=a+2,i[s++]=a+1,i[s++]=a+3,i[s++]=a+2}},Ms={build(n,e){return e[0]=n.x,e[1]=n.y,e[2]=n.x2,e[3]=n.y2,e[4]=n.x3,e[5]=n.y3,e},triangulate(n,e,t,r,i,s){let o=0;r*=t,e[r+o]=n[0],e[r+o+1]=n[1],o+=t,e[r+o]=n[2],e[r+o+1]=n[3],o+=t,e[r+o]=n[4],e[r+o+1]=n[5];const a=r/t;i[s++]=a,i[s++]=a+1,i[s++]=a+2}},_i=[new re,new re,new re,new re];class Gt{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.width=r,this.height=i}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}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,r){const{width:i,height:s}=this;if(i<=0||s<=0)return!1;const o=this.x,a=this.y,l=o-r/2,h=o+i+r/2,c=a-r/2,u=a+s+r/2,f=o+r/2,p=o+i-r/2,y=a+r/2,_=a+s-r/2;return e>=l&&e<=h&&t>=c&&t<=u&&!(e>f&&e<p&&t>y&&t<_)}clone(){return new Gt(this.x,this.y,this.width,this.height)}copyFrom(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}copyTo(e){e.copyFrom(this)}intersects(e,t){if(!t){const N=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=N)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const r=this.left,i=this.right,s=this.top,o=this.bottom;if(i<=r||o<=s)return!1;const a=_i[0].set(e.left,e.top),l=_i[1].set(e.left,e.bottom),h=_i[2].set(e.right,e.top),c=_i[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const{a:u,d:f,b:p,c:y}=t.toObject(),_=Math.sign(u*f-p*y);if(_===0||([a.x,a.y]=t.applyToPoint(a.x,a.y),[l.x,l.y]=t.applyToPoint(l.x,l.y),[h.x,h.y]=t.applyToPoint(h.x,h.y),[c.x,c.y]=t.applyToPoint(c.x,a.y),Math.max(a.x,l.x,h.x,c.x)<=r||Math.min(a.x,l.x,h.x,c.x)>=i||Math.max(a.y,l.y,h.y,c.y)<=s||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const m=_*(l.y-a.y),b=_*(a.x-l.x),w=m*r+b*s,x=m*i+b*s,C=m*r+b*o,P=m*i+b*o;if(Math.max(w,x,C,P)<=m*a.x+b*a.y||Math.min(w,x,C,P)>=m*c.x+b*c.y)return!1;const E=_*(a.y-h.y),A=_*(h.x-a.x),S=E*r+A*s,T=E*i+A*s,O=E*r+A*o,$=E*i+A*o;return!(Math.max(S,T,O,$)<=E*a.x+A*a.y||Math.min(S,T,O,$)>=E*c.x+A*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),r=Math.min(this.x+this.width,e.x+e.width),i=Math.max(this.y,e.y),s=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(r-t,0),this.y=i,this.height=Math.max(s-i,0),this}ceil(e=1,t=.001){const r=Math.ceil((this.x+this.width-t)*e)/e,i=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=r-this.x,this.height=i-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),r=Math.max(this.x+this.width,e.x+e.width),i=Math.min(this.y,e.y),s=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=r-t,this.y=i,this.height=s-i,this}getBounds(e){return e=e||new Gt,e.copyFrom(this),e}buildOutline(e){Es.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Es.triangulate(r,e,2,0,t,0)}}class ie extends ve{constructor(t){super();d(this,"_array",[]);this.dim=t}get length(){return this.dim}_operate(t,r,i){const{dim:s,_array:o}=this;let a;typeof r=="number"?a=Array.from({length:s},()=>r):r instanceof le||r instanceof ie?a=r.toArray():a=r;let l,h=[];if(i?i instanceof ie?l=i:h=i:l=this,r instanceof le){const{cols:c}=r;switch(t){case"*":for(let u=0;u<s;u++){let f=0;for(let p=0;p<s;p++)f+=o[u]*a[p*c+u];h[u]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${t} ${r.toName()}'`)}}else switch(t){case"+":for(let c=0;c<s;c++)h[c]=o[c]+a[c];break;case"-":for(let c=0;c<s;c++)h[c]=o[c]-a[c];break;case"*":for(let c=0;c<s;c++)h[c]=o[c]*a[c];break;case"/":for(let c=0;c<s;c++)h[c]=o[c]/a[c];break;case"rot":{const c=Math.cos(a[0]),u=Math.sin(a[0]);h[0]=o[0]*c-o[1]*u,h[1]=o[1]*c+o[0]*u;break}case"==":{let c=!0;for(let u=0;u<s;u++)c=c&&o[u]===a[u];return c}case"=":for(let c=0;c<s;c++){const u=a[c];u!==void 0&&(o[c]=u)}return this._emitUpdate(o),this;default:throw new Error(`Not support operator in '${this.toName()} ${t} Vector'`)}return(l==null?void 0:l.set(h))??h}add(t,r){return this._operate("+",t,r)}sub(t,r){return this._operate("-",t,r)}multiply(t,r){return this._operate("*",t,r)}divide(t,r){return this._operate("/",t,r)}rotate(t){return this._operate("rot",t)}set(t,...r){return r.length&&typeof t=="number"&&(t=[t,...r]),this._operate("=",t)}equals(t){return this._operate("==",t)}clone(){const t=new this.constructor;return t.set(this.toArray()),t}onUpdate(t){return this.on("update",t),this}offUpdate(t){return this.off("update",t),this}_emitUpdate(t){this._onUpdate(t),this.emit("update",t)}_onUpdate(t){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class le extends ve{constructor(t,r,i){super();d(this,"_array",[]);this.rows=t,this.cols=r,i?this.set(i):this.identity()}get length(){return this.cols*this.rows}_operate(t,r,i){const{cols:s,rows:o,length:a,_array:l}=this;let h;typeof r=="number"?h=Array.from({length:a},()=>r):r instanceof ie||r instanceof le?h=r.toArray():h=r;let c,u=[];if(i?i instanceof ie||i instanceof le?c=i:u=i:r instanceof ie?c=new r.constructor:c=this,r instanceof ie){const{dim:f}=r;switch(t){case"*":for(let p=0;p<f;p++){let y=0;for(let _=0;_<s;_++)_<f&&(y+=l[p*s+_]*(h[_]??0));u[p]=y}break;default:throw new Error(`Not support operator in '${this.toName()} ${t} ${r.toName()}'`)}}else switch(t){case"*":for(let f=0;f<s;f++)for(let p=0;p<o;p++){const y=p*s;let _=0;for(let m=0;m<o;m++){const b=y+m,w=m*s+f;_+=l[b]*(h[w]??0)}u[y+f]=_}break;case"=":for(let f=0;f<a;f++){const p=h[f];p!==void 0&&(l[f]=p)}return this._emitUpdate(l),this;default:throw new Error(`Not support operator in '${this.toName()} ${t} Matrix2'`)}return(c==null?void 0:c.set(u))??u}identity(){const{cols:t,rows:r}=this,i=[];for(let s=0;s<t;s++)for(let o=0;o<r;o++){const a=o*t,l=s+a;i[l]=o+a===l?1:0}return this.set(i)}clone(){const t=new this.constructor;return t.set(this.toArray()),t}set(t){return this._operate("=",t)}multiply(t){return this._operate("*",t)}onUpdate(t){return this.on("update",t),this}offUpdate(t){return this.off("update",t),this}_emitUpdate(t){this._onUpdate(t),this.emit("update",t)}_onUpdate(t){}toArray(t=!1){const{cols:r,rows:i,_array:s}=this;if(t){const o=[];for(let a=0;a<i;a++)for(let l=0;l<r;l++)o[a+l*r]=s[l+a*r];return o}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}let Ss=class extends le{constructor(e){super(3,3,e)}invert(){const[e,t,r,i,s,o,a,l,h]=this._array,c=h*s-o*l,u=o*a-h*i,f=l*i-s*a,p=e*c+t*u+r*f;if(p===0)return this.set([0,0,0,0,0,0,0,0,0]);const y=1/p;return this.set([c*y,(r*l-h*t)*y,(o*t-r*s)*y,u*y,(h*e-r*a)*y,(r*i-o*e)*y,f*y,(t*a-l*e)*y,(s*e-t*i)*y])}};class qt extends Ss{constructor(t=!0){super();d(this,"_cx",1);d(this,"_sx",0);d(this,"_cy",0);d(this,"_sy",1);d(this,"_translateX",0);d(this,"_translateY",0);d(this,"_translateZ",1);d(this,"_scaleX",1);d(this,"_scaleY",1);d(this,"_skewX",0);d(this,"_skewY",0);d(this,"_rotate",0);d(this,"dirtyId",0);d(this,"_needsUpdateArray",!1);d(this,"_needsUpdateFields",!1);this.autoUpdate=t}_onUpdate(t){super._onUpdate(t),this._requestUpdateFields()}_updateSkew(){this._cx=Math.cos(this._rotate+this._skewY),this._sx=Math.sin(this._rotate+this._skewY),this._cy=-Math.sin(this._rotate-this._skewX),this._sy=Math.cos(this._rotate-this._skewX)}_requestUpdateArray(){this.autoUpdate?this._performUpdateArray():this._needsUpdateArray=!0}_requestUpdateFields(){this.autoUpdate?this._performUpdateFields():this._needsUpdateFields=!0}_performUpdateArray(){const t=this._cx*this._scaleX,r=this._sx*this._scaleX,i=this._cy*this._scaleY,s=this._sy*this._scaleY,o=this._translateX,a=this._translateY,l=this._translateZ,h=this._array;this._array=[t,i,o,r,s,a,h[6],h[7],l],this.dirtyId++}_performUpdateFields(){const{a:t,c:r,tx:i,b:s,d:o,ty:a,tz:l}=this.toObject(),h=-Math.atan2(-r,o),c=Math.atan2(s,t),u=Math.abs(h+c);u<1e-5||Math.abs(at-u)<1e-5?(this._rotate=c,this._skewX=this._skewY=0):(this._rotate=0,this._skewX=h,this._skewY=c),this._scaleX=Math.sqrt(t*t+s*s),this._scaleY=Math.sqrt(r*r+o*o),this._translateX=i,this._translateY=a,this._translateZ=l,this.dirtyId++}skew(t,r){return this._skewX=t,this._skewY=r,this._updateSkew(),this._requestUpdateArray(),this}skewX(t){return this.skew(t,this._skewY)}skewY(t){return this.skew(this._skewX,t)}translate(t,r,i=1){return this._translateX=t,this._translateY=r,this._translateZ=i,this._requestUpdateArray(),this}translateX(t){return this.translate(t,this._translateY)}translateY(t){return this.translate(this._translateX,t)}translateZ(t){return this.translate(this._translateX,this._translateY,t)}translate3d(t,r,i){return this.translate(t,r,i)}scale(t,r,i=1){return this._scaleX=t,this._scaleY=r,this._requestUpdateArray(),this}scaleX(t){return this.scale(t,this._scaleY)}scaleY(t){return this.scale(this._scaleX,t)}scale3d(t,r,i){return this.scale(t,r,i)}rotate(t){return this._rotate=t,this._updateSkew(),this._requestUpdateArray(),this}rotateX(t){return this.scaleY(this._rotateToScale(t))}rotateY(t){return this.scaleX(this._rotateToScale(t))}rotateZ(t){return this.rotate(t)}rotate3d(t,r,i,s){const[o,a,l]=this._rotate3d(t,r,i,s);return o&&this.rotateX(o),a&&this.rotateY(a),l&&this.rotateZ(l),this}_rotateToScale(t){const r=t/at;return r<=.5?r*-4+1:(r-1)*4+1}_rotate3d(t,r,i,s){if(t===1&&r===0&&i===0)return[s,0,0];if(t===0&&r===1&&i===0)return[0,s,0];if(t===0&&r===0)return[0,0,s];{const o=Math.cos(s),a=Math.sin(s),l=o+t*t*(1-o),h=t*r*(1-o)-i*a,c=t*i*(1-o)+r*a,u=o+r*r*(1-o),f=r*i*(1-o)-t*a,p=o+i*i*(1-o),y=-Math.atan2(-f,u),_=-Math.atan2(c,Math.sqrt(f*f+p*p)),m=-Math.atan2(-h,l);return[y,_,m]}}applyToPoint(t,r){const{a:i,c:s,tx:o,b:a,d:l,ty:h}=this.toObject();return[i*t+s*r+o,a*t+l*r+h]}inverse(){return this.clone().invert()}update(){let t=!1;return this._needsUpdateArray&&(this._needsUpdateArray=!1,this._performUpdateArray(),t=!0),this._needsUpdateFields&&(this._needsUpdateFields=!1,this._performUpdateFields(),t=!0),t}isIdentity(){const{a:t,b:r,c:i,d:s,tx:o,ty:a}=this.toObject();return t===1&&r===0&&i===0&&s===1&&o===0&&a===0}toObject(){const[t,r,i,s,o,a,,,l]=this._array;return{a:t,c:r,tx:i,b:s,d:o,ty:a,tz:l}}}const ho=new qt;class vi{constructor(e=1/0,t=1/0,r=-1/0,i=-1/0){d(this,"matrix",ho);d(this,"_rectangle");this.minX=e,this.minY=t,this.maxX=r,this.maxY=i}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}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}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Gt);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ho,this}set(e,t,r,i){return this.minX=e,this.minY=t,this.maxX=r,this.maxY=i,this}addFrame(e,t,r,i,s){s||(s=this.matrix);const{a:o,b:a,c:l,d:h,tx:c,ty:u}=s.toObject();let f=this.minX,p=this.minY,y=this.maxX,_=this.maxY,m=o*e+l*t+c,b=a*e+h*t+u;m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*r+l*t+c,b=a*r+h*t+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*e+l*i+c,b=a*e+h*i+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*r+l*i+c,b=a*r+h*i+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),this.minX=f,this.minY=p,this.maxX=y,this.maxY=_}addRect(e,t){return this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t),this}addBounds(e,t){return this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t),this}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,r=this.minY,i=this.maxX,s=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:u}=e.toObject();let f=o*t+l*r+c,p=a*t+h*r+u;this.minX=f,this.minY=p,this.maxX=f,this.maxY=p,f=o*i+l*r+c,p=a*i+h*r+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=o*t+l*s+c,p=a*t+h*s+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=o*i+l*s+c,p=a*i+h*s+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,r,i){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<r&&(this.minY=r),this.maxY>i&&(this.maxY=i),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,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 vi(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}addVertexData(e,t,r,i){let s=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const{a:h,b:c,c:u,d:f,tx:p,ty:y}=i.toObject();for(let _=t;_<r;_+=2){const m=e[_],b=e[_+1],w=h*m+u*b+p,x=c*m+f*b+y;s=w<s?w:s,o=x<o?x:o,a=w>a?w:a,l=x>l?x:l}this.minX=s,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}}const Ah=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Oh=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,As={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0};class co{constructor(e){d(this,"defines",[]);d(this,"_calls",[]);d(this,"_dirty",!1);typeof e=="string"?this.defines=this._parseDefines(e):this.defines=e.defines.slice(),this.update()}get path2D(){const e=new Os;return this._dirty&&(this._dirty=!1,this._calls.forEach(t=>{e[t.method](...t.args)})),e}_addCall(e,t=[],r=!0){return this._calls.push({method:e,args:t}),r&&(this._dirty=!0),this}_parseDefines(e){const t=[];return e.replace(Ah,(r,i,s)=>{var l;const o=((l=s.match(Oh))==null?void 0:l.map(Number))??[];let a=i.toLowerCase();for(a==="m"&&o.length>2&&(t.push({command:i,args:o.splice(0,2)}),a="l",i=i==="m"?"l":"L");;){if(o.length===As[a])return t.push({command:i,args:o}),"";if(o.length<As[a])throw new Error("malformed path defines");t.push({command:i,args:o.splice(0,As[a])})}}),t}update(){const e=[];let t=null,r=0,i=0;for(let s=0;s<this.defines.length;s++){const{command:o,args:a}=this.defines[s];switch(o){case"M":this._addCall("moveTo",[r=a[0],i=a[1]]);break;case"m":this._addCall("moveTo",[r+=a[0],i+=a[1]]);break;case"H":this._addCall("lineTo",[r=a[0],i]);break;case"h":this._addCall("lineTo",[r+=a[0],i]);break;case"V":this._addCall("lineTo",[r,i=a[0]]);break;case"v":this._addCall("lineTo",[r,i+=a[0]]);break;case"L":this._addCall("lineTo",[r=a[0],i=a[1]]);break;case"l":this._addCall("lineTo",[r+=a[0],i+=a[1]]);break;case"C":this._addCall("bezierCurveTo",[a[0],a[1],a[2],a[3],a[4],a[5]]),r=a[4],i=a[5];break;case"c":this._addCall("bezierCurveTo",[r+a[0],i+a[1],r+a[2],i+a[3],r+a[4],i+a[5]]),r+=a[4],i+=a[5];break;case"Q":this._addCall("quadraticCurveTo",[a[0],a[1],a[2],a[3]]),r=a[2],i=a[3];break;case"q":this._addCall("quadraticCurveTo",[r+a[0],i+a[1],r+a[2],i+a[3]]),r+=a[2],i+=a[3];break;case"S":this._smoothBezierCurveTo(a[0],a[1],a[2],a[3]),r=a[2],i=a[3];break;case"s":this._smoothBezierCurveTo(r+a[0],i+a[1],r+a[2],i+a[3]),r+=a[2],i+=a[3];break;case"T":this._smoothQuadraticCurveTo(r=a[0],i=a[1]);break;case"t":this._smoothQuadraticCurveTo(r+=a[0],i+=a[1]);break;case"A":this._addCall("ellipticalArc",[a[0],a[1],a[2],a[3],a[4],a[5],a[6]]),r=a[5],i=a[6];break;case"a":this._addCall("ellipticalArc",[a[0],a[1],a[2],a[3],a[4],a[5],a[6]]),r+=a[5],i+=a[6];break;case"Z":case"z":this._addCall("closePath"),e.length>0&&(t=e.pop(),t?(r=t.startX,i=t.startY):(r=0,i=0)),t=null;break;default:console.warn(`Unknown SVG path command: ${o}`)}o!=="Z"&&o!=="z"&&t===null&&(t={startX:r,startY:i},e.push(t))}}_getLastPoint(e){let t=this._calls.length-1,r=this._calls[t];if(!r)return e.x=0,e.y=0,e;for(;r.method==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;r=this._calls[t]}switch(r.method){case"moveTo":case"lineTo":e.set(r.args[0],r.args[1]);break;case"quadraticCurveTo":e.set(r.args[2],r.args[3]);break;case"bezierCurveTo":e.set(r.args[4],r.args[5]);break;case"arc":case"ellipticalArc":e.set(r.args[5],r.args[6]);break;case"addPath":r.args[0]._getLastPoint(e);break}return e}_smoothBezierCurveTo(e,t,r,i,s){const o=this._calls[this._calls.length-1],a=this._getLastPoint(re.shared);let l,h;if(!o||o.method!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.args[2],h=o.args[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this._addCall("bezierCurveTo",[l,h,e,t,r,i,s]),this}_smoothQuadraticCurveTo(e,t,r){const i=this._calls[this._calls.length-1],s=this._getLastPoint(re.shared);let o,a;if(!i||i.method!=="quadraticCurveTo")o=s.x,a=s.y;else{o=i.args[0],a=i.args[1];const l=s.x,h=s.y;o=l+(l-o),a=h+(h-a)}return this._addCall("quadraticCurveTo",[o,a,e,t,r]),this}}const Uh=new Gt;let Os=class{constructor(){d(this,"_polygon");d(this,"_bounds",new vi);d(this,"shapes",[])}get bounds(){const e=this._bounds;e.clear();const t=this.shapes;for(let r=0;r<t.length;r++){const i=t[r],s=i.shape.getBounds(Uh);i.transform?e.addRect(s,i.transform):e.addRect(s)}return e}startPolygon(e,t){return this._polygon&&this.endPolygon(),this._polygon=new Fe([e,t]),this}endPolygon(e=!1){const t=this._polygon;return t&&t.points.length>2&&(t.closed=e,this.shapes.push({shape:t})),this._polygon=void 0,this}ensurePolygon(e=!0){var t;if(!this._polygon&&(this._polygon=new Fe,e)){const r=this.shapes[this.shapes.length-1];if(r){let i=r.shape.x,s=r.shape.y;if(!((t=r.transform)!=null&&t.isIdentity())){const o=r.transform.toObject(),a=i;i=o.a*i+o.c*s+o.tx,s=o.b*a+o.d*s+o.ty}this._polygon.points.push(i,s)}else this._polygon.points.push(0,0)}}beginPath(){return this}moveTo(e,t){return this.startPolygon(e,t),this}lineTo(e,t){this.ensurePolygon();const r=this._polygon.points,i=r[r.length-2],s=r[r.length-1];return(i!==e||s!==t)&&r.push(e,t),this}bezierCurveTo(e,t,r,i,s,o,a){return this.ensurePolygon(),gs(this._polygon.points,this._polygon.lastX,this._polygon.lastY,e,t,r,i,s,o,a),this}quadraticCurveTo(e,t,r,i,s){return this.ensurePolygon(),Qn(this._polygon.points,this._polygon.lastX,this._polygon.lastY,e,t,r,i,s),this}rect(e,t,r,i,s){this.addShape(new Gt(e,t,r,i),s)}roundRect(e,t,r,i,s,o){this.addShape(new gi(e,t,r,i,s),o)}ellipse(e,t,r,i,s){this.addShape(new Tr(e,t,r,i),s)}arc(e,t,r,i,s,o){this.ensurePolygon(!1);const a=this._polygon.points;return _s(a,e,t,r,i,s,o),this}ellipticalArc(e,t,r,i,s,o,a){return to(this._polygon.points,this._polygon.lastX,this._polygon.lastY,o,a,e,t,r,i,s),this}poly(e,t=!1,r){const i=new Fe(e);return i.closed=t,this.addShape(i,r),this}addShape(e,t){return this.endPolygon(),this.shapes.push({shape:e,transform:t}),this}addPath(e){return this.endPolygon(),e.endPolygon(),e.shapes.forEach(t=>{this.shapes.push(t)}),this}addSVGPath(e){return this.addPath(new co(e).path2D),this}closePath(){return this.endPolygon(!0),this}buildOutline(e=[]){return this.shapes.forEach(t=>t.shape.buildOutline(e)),e}buildGeometry(e=[],t=[]){return this.shapes.forEach(r=>r.shape.buildGeometry(e,t)),{vertices:e,indices:t}}};class Ih extends le{constructor(e){super(2,2,e)}}class uo extends le{constructor(e){super(4,4,e)}}class fo extends Ss{constructor(e=0,t=0,r=0,i=0,s=!1){super(),this._x=e,this._y=t,this._width=r,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(e){return this._flipY!==e&&(this._flipY=e,this._performUpdateArray()),this}translate(e,t){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._performUpdateArray()),this}resize(e,t){return(this._width!==e||this._height!==t)&&(this._width=e,this._height=t,this._performUpdateArray()),this}_performUpdateArray(){const e=this._width,t=this._height;if(!e||!t)return;const r=this._x,i=this._y,s=this._flipY?-1:1,o=1/e*2,a=s*(1/t*2),l=-1-r*o,h=-s-i*a;this.set([o,0,l,0,a,h,0,0,1])}}const po=Et/180,Dh=180/Et;function Me(n,e,t){return Math.max(n,Math.min(e,t))}function dt(n,e,t){return(1-t)*n+t*e}const Rh={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(n,e=20){if(!this.adaptive||!n||Number.isNaN(n))return e;let t=Math.ceil(n/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};let Bh=class ss extends ie{get x(){return this._array[0]}set x(e){const[t,r]=this._array;t!==e&&this.set(e,r)}get y(){return this._array[1]}set y(e){const[t,r]=this._array;r!==e&&this.set(t,e)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}constructor(e=0,t){super(2),this.set(typeof e=="number"?[e,t??e]:e)}update(e,t){const[r,i]=this._array;return(r!==e||i!==t)&&this.set(e,t),this}getLength(){const[e,t]=this._array;return Math.sqrt(e*e+t*t)}getAngle(){const[e,t]=this._array;return Math.atan2(-e,-t)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){const[e,t]=this._array,r=1/(this.getLength()||1);return this.set(e*r,t*r),this}static lerp(e,t,r){return new ss(t).clone().sub(new ss(e)).multiply(r).add(new ss(e))}};class Lh extends ie{constructor(){super(3)}}class go extends ie{constructor(e=0,t=0,r=0,i=0){super(4),this.set([e,t,r,i])}}var kh=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,ar=(n,e,t,r)=>{for(var i=r>1?void 0:r?Nh(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&kh(e,t,i),i},Ur=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n))(Ur||{});g.Node=class extends ps{constructor(t){super();d(this,"renderable");d(this,"name",`${this.tag}:${String(this.instanceId)}`);d(this,"mask");d(this,"_computedVisibleDelay",0);d(this,"_computedVisibleDuration",Number.MAX_SAFE_INTEGER);d(this,"_computedVisibility","visible");d(this,"_internalMode",0);d(this,"_readyed",!1);d(this,"_tree");d(this,"_parent");d(this,"_children",[]);d(this,"_meta",new Map);this.setProperties(t).on("enterTree",this._onEnterTree.bind(this)).on("exitTree",this._onExitTree.bind(this)).on("parented",this._onParented.bind(this)).on("unparented",this._onUnparented.bind(this)).on("ready",this._onReady.bind(this)).on("process",this._onProcess.bind(this))}get children(){return this.getChildren()}get visibleTimeline(){const t=this._computedVisibleDelay;return[t,t+this._computedVisibleDuration]}get visibleRelativeTime(){var t;return(((t=this._tree)==null?void 0:t.timeline.current)??0)-this.visibleTimeline[0]}get visibleProgress(){const[t,r]=this.visibleTimeline;return Me(0,this.visibleRelativeTime/(r-t),1)}get siblingIndex(){return this.getIndex()}set siblingIndex(t){var r;(r=this._parent)==null||r.moveChild(this,t)}get previousSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[this.getIndex()-1]}get nextSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[this.getIndex()+1]}get firstSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[0]}get lastSibling(){var r;const t=(r=this._parent)==null?void 0:r.getChildren();return t?t[t.length-1]:void 0}hasMeta(t){return this._meta.has(t)}getMeta(t,r){return this._meta.get(t)??r}setMeta(t,r){this._meta.set(t,r)}deleteMeta(t){this._meta.delete(t)}clearMeta(){this._meta.clear()}setName(t){return this.name=t,this}getTree(){return this._tree}getViewport(){var t;return(t=this._tree)==null?void 0:t.getCurrentViewport()}getWindow(){var t;return(t=this._tree)==null?void 0:t.root}isInsideTree(){return!!this._tree}_setTree(t){const r=this._tree;if(t!==r){t?(this._tree=t,this.emit("enterTree")):r&&(this.emit("exitTree"),this._tree=t);for(let i=this._children.length,s=0;s<i;s++){const o=this._children[s];!t&&this.emit("childExitingTree",o),o._setTree(t),t&&this.emit("childEnteredTree",o)}t&&(this.emit("postEnterTree"),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}isRenderable(){return this.renderable!==!1&&this.constructor.renderable&&this.isVisible()}isVisible(){return this._computedVisibility!=="hidden"}_updateVisibility(){var s;const t=this._parent;this._computedVisibleDelay=this.visibleDelay+((t==null?void 0:t._computedVisibleDelay)??0),t!=null&&t._computedVisibleDuration?this._computedVisibleDuration=Math.min(this._computedVisibleDelay+this.visibleDuration,t.visibleTimeline[1])-this._computedVisibleDelay:this._computedVisibleDuration=this.visibleDuration;let r=this.visibility??(t==null?void 0:t._computedVisibility)??"visible";const i=((s=this._tree)==null?void 0:s.timeline.current)??0;if(r!=="hidden"){const[o,a]=this.visibleTimeline;(i<o||i>a)&&(r="hidden")}this._computedVisibility=r}_onEnterTree(){this._enterTree(),this.emit("treeEntered")}_onExitTree(){this.emit("treeExiting"),this._exitTree(),this.emit("treeExited")}_onParented(){this._parented()}_onUnparented(){this._unparented()}_onReady(){this._ready()}_onProcess(t=0){this._updateVisibility();const r=this._tree;r==null||r.emit("nodeProcessing",this),this._process(t);const i=this.isRenderable();let s;if(r&&i){const o=r.renderStack.push(this);s=r.renderStack.currentCall,r.renderStack.currentCall=o}if(this.mask instanceof g.Node)this.getNode("__$mask")||(this.mask.renderable=!1,this.addChild(this.mask,1));else{const o=this.getNode("__$mask");o&&this.removeChild(o)}for(let o=this._children.length,a=0;a<o;a++)this._children[a].emit("process",t);r&&i&&(r.renderStack.currentCall=s),r==null||r.emit("nodeProcessed",this)}render(t,r){const i=this.mask;i&&(t.flush(),t.mask.push(this,i)),this._render(t),r==null||r(),i&&(t.flush(),t.mask.pop(this))}input(t){for(let r=this._children.length-1;r>=0;r--)this._children[r].input(t);this._input(t)}get parent(){return this._parent}hasParent(){return!!this._parent}getParent(){return this._parent}_setParent(t){var r;return(r=this._parent)!=null&&r.is(t)||(this._parent=t,this._setTree(t==null?void 0:t._tree),this.emit(t?"parented":"unparented")),this}getChildren(t=!1){switch(t){case!0:return this._children;case!1:return this._children.filter(r=>r._internalMode===0);default:return this._children.filter(r=>r._internalMode===t)}}getIndex(t=!1){var r;return((r=this._parent)==null?void 0:r.getChildren(t).indexOf(this))??0}getNode(t){return this._children.find(r=>r.name===t)}removeNode(t){var r;(r=this.getNode(t))==null||r.remove()}addSibling(t){return this.is(t)||!this.hasParent()||t.hasParent()?this:(t._internalMode=this._internalMode,this._parent.moveChild(t,this.getIndex(!0)+1),this)}addChild(t,r=t._internalMode){if(this.is(t)||t.hasParent())return this;switch(r){case 0:case 1:{const i=r===0?2:1,s=this._children.findIndex(o=>o._internalMode===i);s>-1?this._children.splice(s,0,t):this._children.push(t);break}case 2:this._children.push(t);break}return t._internalMode=r,t._setParent(this),this.emit("addChild",t),this}moveChild(t,r,i=t._internalMode){if(this.is(t)||t.hasParent()&&!this.is(t.parent))return this;t._internalMode=i;const s=this._children.indexOf(t);let o=this._children.findIndex(h=>{switch(i){case 0:return h._internalMode!==1;case 2:return h._internalMode===2;case 1:default:return!0}});o=o>-1?o:Math.max(0,this._children.length-1);let a=this._children.slice(o).findIndex(h=>{switch(i){case 1:return h._internalMode!==1;case 0:return h._internalMode===2;case 2:default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=Me(o,r>-1?r:a,a);return l!==s&&(s>-1&&this._children.splice(s,1),t._setParent(this),l>-1&&l<this._children.length?this._children.splice(l,0,t):this._children.push(t),s>-1?this.emit("moveChild",t,l,s):this.emit("addChild",t)),this}removeChild(t){const r=t.getIndex(!0);return this.is(t.parent)&&r>-1&&(this._children.splice(r,1),t._setParent(void 0),this.emit("removeChild",t,r)),this}removeChildren(){this.children.forEach(t=>this.removeChild(t))}remove(){var t;(t=this._parent)==null||t.removeChild(this)}forEach(t){return this.children.forEach(t),this}deepForEach(t){return this.children.forEach(r=>{t(r),r.deepForEach(t)}),this}is(t){return!!(t&&this.instanceId===t.instanceId)}_enterTree(){}_ready(){}_exitTree(){}_parented(){}_unparented(){}_process(t){}_input(t){}_render(t){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.children.map(t=>t.toJSON())}}static parse(t){if(Array.isArray(t))return t.map(l=>this.parse(l));const{tag:r,props:i,children:s}=t,o=oi.get(r)??g.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},ar([U()],g.Node.prototype,"name",2),ar([U()],g.Node.prototype,"mask",2),ar([U({default:"visible"})],g.Node.prototype,"visibility",2),ar([U({default:0})],g.Node.prototype,"visibleDelay",2),ar([U({default:Number.MAX_SAFE_INTEGER})],g.Node.prototype,"visibleDuration",2),g.Node=ar([Z("Node")],g.Node);class mo{constructor(){d(this,"currentCall");d(this,"calls",[])}createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){var r;const t=this.createCall(e);return(((r=this.currentCall)==null?void 0:r.calls)??this.calls).push(t),t}render(e){this.calls.forEach(function t(r){r.fn(e,()=>{r.calls.forEach(t)})}),this.calls=[]}}var Fh=Object.defineProperty,$h=Object.getOwnPropertyDescriptor,Ir=(n,e,t,r)=>{for(var i=r>1?void 0:r?$h(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Fh(e,t,i),i};g.Timer=class extends g.Node{static from(e){const[t,r]=e?Array.isArray(e)?e:[0,e]:[];return new g.Timer({start:t,end:r})}constructor(e){super(),this.setProperties(e)}_onUpdateProperty(e,t,r){switch(super._onUpdateProperty(e,t,r),e){case"start":this.start=Math.min(t,this.end);break;case"end":this.end=t||Number.MAX_SAFE_INTEGER;break}}addTime(e){const t=this.start,r=this.end;let i=this.current+e;return this.loop&&i>r&&(i=t+i%r),this.current=Me(t,i,r),this.emit("update",this.current,e),this}_process(e){super._process(e),this.addTime(e)}},Ir([U({default:0})],g.Timer.prototype,"start",2),Ir([U({default:0})],g.Timer.prototype,"current",2),Ir([U({default:Number.MAX_SAFE_INTEGER})],g.Timer.prototype,"end",2),Ir([U({default:!1})],g.Timer.prototype,"loop",2),g.Timer=Ir([Z("Timer")],g.Timer);var zh=Object.defineProperty,lr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&zh(e,t,i),i};class pt extends Ee{constructor(t){super();d(this,"_isPowerOfTwo",!1);d(this,"_needsUpload",!1);this.source=t,this._updateSize()}static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}_refreshPOT(){this._isPowerOfTwo=ns(this.realWidth)&&ns(this.realHeight)}_glTextureOptions(t,r){let i=this.source;"pixels"in i&&(i={pixels:i.pixels,width:this.realWidth,height:this.realHeight});let s=this.wrapMode;return t.version===1&&!this._isPowerOfTwo&&(s="clamp_to_edge"),{value:i,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:s,...r}}_glTexture(t,r){return t.getRelated(this,()=>t.texture.create(this._glTextureOptions(t,r)))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"width":case"height":case"filterMode":case"wrapMode":case"pixelRatio":case"source":this.requestUpload();break}}_updateSize(){const t=this.source;"pixels"in t?(this.width=Math.max(this.width,t.width),this.height=Math.max(this.height,t.height)):(this.width=Number(t.naturalWidth||t.videoWidth||t.width||0),this.height=Number(t.naturalHeight||t.videoHeight||t.height||0))}requestUpload(){this._needsUpload=!0,this._updateSize(),this._refreshPOT()}upload(t,r){return this._needsUpload?(this._needsUpload=!1,t.texture.update(this._glTexture(t,r),this._glTextureOptions(t,r)),!0):!1}activate(t,r=0){t.texture.bind({target:"texture_2d",value:this._glTexture(t,{location:r}),location:r}),this.upload(t,{location:r})}inactivate(t){t.texture.unbind(this._glTexture(t))}destroy(){Ln&&this.source instanceof ImageBitmap&&this.source.close()}}lr([nt()],pt.prototype,"source"),lr([nt({default:0})],pt.prototype,"width"),lr([nt({default:0})],pt.prototype,"height"),lr([nt({default:"linear"})],pt.prototype,"filterMode"),lr([nt({default:"clamp_to_edge"})],pt.prototype,"wrapMode"),lr([nt({default:1})],pt.prototype,"pixelRatio");function Vh(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&as,crossorigin:(n==null?void 0:n.crossorigin)??null}}class Xh extends pt{constructor(t,r){const i=Vh(r);super(t);d(this,"bitmap");d(this,"useBitmap");d(this,"preserveBitmap",!1);d(this,"_loadSource");d(this,"_loadBitmap");const s=t.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(t=>{this._loadSource=void 0;const r=this.source,i=()=>{r.onload=null,r.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>t(this)):t(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${r.src}`,a),this.emit("error",a),t(this)};r.complete&&r.src?s():(r.onload=s,r.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!as)return Promise.resolve(this);const t=this.source,r=!t.crossOrigin||t.crossOrigin==="anonymous";return this._loadBitmap=fetch(t.src,{mode:r?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,t.width,t.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(t){return{...super._glTextureOptions(t),value:this.bitmap??this.source}}upload(t){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(Pr&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const r=super.upload(t);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),r}}class Us extends pt{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}}var jh=Object.defineProperty,yo=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&jh(e,t,i),i};function Gh(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),autoPlay:!!((n==null?void 0:n.autoPlay)??!1),fps:Number((n==null?void 0:n.fps)??0),crossorigin:(n==null?void 0:n.crossorigin)??null,loop:!!((n==null?void 0:n.loop)??!1),muted:!!((n==null?void 0:n.muted)??!1),playsinline:!!((n==null?void 0:n.playsinline)??!0)}}const Is=(er=class extends pt{constructor(t,r){const i=Gh(r);if(!Vn(t)){typeof t=="string"&&(t=[t]);const s=t[0].src||t[0],o=document.createElement("video");i.autoLoad&&o.setAttribute("preload","auto"),i.playsinline&&(o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline","")),i.muted&&(o.setAttribute("muted",""),o.muted=!0),i.loop&&o.setAttribute("loop",""),i.autoPlay&&o.setAttribute("autoplay",""),Yn(o,s,i.crossorigin);for(let a=0;a<t.length;++a){let{src:l,mime:h}=t[a];if(l=l||t[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const u=l.split("?").shift().toLowerCase(),f=u.slice(u.lastIndexOf(".")+1);h=h||er.mimeTypes.get(f)||`video/${f}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}t=o}super(t);d(this,"_spf",0);d(this,"_autoPlay",!1);d(this,"_sourceLoad");d(this,"_nextTime",0);d(this,"_connected",!1);d(this,"_requestId");d(this,"_resolve");d(this,"_reject");d(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});d(this,"_onPlayStop",()=>{this._setupAutoUpdate()});d(this,"_onCanPlay",()=>{const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const r=this.valid;this._nextTime=0,this.requestUpload(),this._nextTime=0,!r&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&t.play()});d(this,"_onError",t=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=void 0,this._resolve=void 0)});d(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});d(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});d(this,"requestUpload",()=>{const t=Math.floor(ft.elapsed*this.source.playbackRate);this._nextTime-=t,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(t){this.source.currentTime=t}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"fps":this._spf=r?Math.floor(1e3/r):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(ft.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(ft.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(ft.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const t=this.source;(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.isReady?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((r,i)=>{this.valid?(this._sourceLoad=void 0,r(this)):(this._resolve=r,this._reject=i,t.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load())}},d(er,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),er);yo([nt({default:!0})],Is.prototype,"autoUpdate"),yo([nt({default:0})],Is.prototype,"fps");let _o=Is;class Ds extends Us{}var qh=Object.defineProperty,Yh=Object.getOwnPropertyDescriptor,Dr=(n,e,t,r)=>{for(var i=r>1?void 0:r?Yh(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&qh(e,t,i),i};g.Viewport=class extends g.Node{constructor(t=!1){super();d(this,"_projection",new fo);d(this,"_framebufferIndex",0);d(this,"_framebuffers",[{texture:new Ds,needsUpload:!1},{texture:new Ds,needsUpload:!1}]);this.flipY=t,this._projection.flipY(t)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(t){const{width:r,height:i}=this,{pixelRatio:s}=t;return this._framebuffers.forEach(o=>{const a=o.texture;a.pixelRatio=s,a.width=r,a.height=i,a.upload(t)}),{width:r,height:i,colorTextures:[this.texture._glTexture(t)]}}_glFramebuffer(t){return t.getRelated(this.framebuffer,()=>t.framebuffer.create(this._glFramebufferOptions(t)))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y);break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height);break}}requestUpload(){this._framebuffers.forEach(t=>t.needsUpload=!0)}resize(t,r){this.width=t,this.height=r}upload(t){const r=this.framebuffer;return r.needsUpload?(r.needsUpload=!1,t.framebuffer.update(this._glFramebuffer(t),this._glFramebufferOptions(t)),!0):!1}activate(t){var r;t.flush(),(r=this._tree)==null||r.setCurrentViewport(this),t.framebuffer.bind(this._glFramebuffer(t)),this.upload(t)}redraw(t,r){t.flush();const i=this.framebuffer.texture;this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(t),t.clear(),i.activate(t,0),r()}activateWithCopy(t,r){this.resize(r.width,r.height),this.activate(t),t.clear(),r.texture.activate(t,0),et.draw(t,ci.instance,{sampler:0})}render(t,r){var s,o;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(t),t.clear(),super.render(t,r),t.flush(),i?i.activate(t):(t.framebuffer.bind(null),(o=this._tree)==null||o.setCurrentViewport(void 0))}toProjectionArray(t=!1){return this._projection.toArray(t)}},Dr([U({default:0})],g.Viewport.prototype,"x",2),Dr([U({default:0})],g.Viewport.prototype,"y",2),Dr([U({default:0})],g.Viewport.prototype,"width",2),Dr([U({default:0})],g.Viewport.prototype,"height",2),g.Viewport=Dr([Z({tag:"Viewport",renderable:!0})],g.Viewport);class vo extends ui{constructor(){super(...arguments);d(this,"renderStack",new mo);d(this,"root",new g.Viewport(!0)._setTree(this));d(this,"timeline",new g.Timer({loop:!0})._setTree(this));d(this,"_currentViewport")}getCurrentViewport(){return this._currentViewport}setCurrentViewport(t){this._currentViewport=t}_render(t,r=0){return this.timeline.addTime(r),this.emit("processing"),this.root.emit("process",r),this.emit("processed"),t.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(t),this._renderScreen(t),this}_renderScreen(t){t.state.reset();const r=t.pixelRatio,{width:i,height:s}=this.root;t.framebuffer.bind(null),t.viewport.bind({x:0,y:0,width:i*r,height:s*r}),t.clear();const o=this.root.texture;o.activate(t,0),et.draw(t),t.texture.unbind(o)}}var Wh={grad:.9,turn:360,rad:360/(2*Math.PI)},xe=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},yt=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},Qt=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},bo=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},xo=function(n){return{r:Qt(n.r,0,255),g:Qt(n.g,0,255),b:Qt(n.b,0,255),a:Qt(n.a)}},Rs=function(n){return{r:yt(n.r),g:yt(n.g),b:yt(n.b),a:yt(n.a,3)}},Hh=/^#([0-9a-f]{3,8})$/i,bi=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},wo=function(n){var e=n.r,t=n.g,r=n.b,i=n.a,s=Math.max(e,t,r),o=s-Math.min(e,t,r),a=o?s===e?(t-r)/o:s===t?2+(r-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:i}},Po=function(n){var e=n.h,t=n.s,r=n.v,i=n.a;e=e/360*6,t/=100,r/=100;var s=Math.floor(e),o=r*(1-t),a=r*(1-(e-s)*t),l=r*(1-(1-e+s)*t),h=s%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:i}},Co=function(n){return{h:bo(n.h),s:Qt(n.s,0,100),l:Qt(n.l,0,100),a:Qt(n.a)}},To=function(n){return{h:yt(n.h),s:yt(n.s),l:yt(n.l),a:yt(n.a,3)}},Eo=function(n){return Po((t=(e=n).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},Rr=function(n){return{h:(e=wo(n)).h,s:(i=(200-(t=e.s))*(r=e.v)/100)>0&&i<200?t*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,r,i},Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bs={string:[[function(n){var e=Hh.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?yt(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?yt(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=Qh.exec(n)||Jh.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:xo({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=Zh.exec(n)||Kh.exec(n);if(!e)return null;var t,r,i=Co({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(Wh[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Eo(i)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,r=n.b,i=n.a,s=i===void 0?1:i;return xe(e)&&xe(t)&&xe(r)?xo({r:Number(e),g:Number(t),b:Number(r),a:Number(s)}):null},"rgb"],[function(n){var e=n.h,t=n.s,r=n.l,i=n.a,s=i===void 0?1:i;if(!xe(e)||!xe(t)||!xe(r))return null;var o=Co({h:Number(e),s:Number(t),l:Number(r),a:Number(s)});return Eo(o)},"hsl"],[function(n){var e=n.h,t=n.s,r=n.v,i=n.a,s=i===void 0?1:i;if(!xe(e)||!xe(t)||!xe(r))return null;var o=function(a){return{h:bo(a.h),s:Qt(a.s,0,100),v:Qt(a.v,0,100),a:Qt(a.a)}}({h:Number(e),s:Number(t),v:Number(r),a:Number(s)});return Po(o)},"hsv"]]},Mo=function(n,e){for(var t=0;t<e.length;t++){var r=e[t][0](n);if(r)return[r,e[t][1]]}return[null,void 0]},tc=function(n){return typeof n=="string"?Mo(n.trim(),Bs.string):typeof n=="object"&&n!==null?Mo(n,Bs.object):[null,void 0]},Ls=function(n,e){var t=Rr(n);return{h:t.h,s:Qt(t.s+100*e,0,100),l:t.l,a:t.a}},ks=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},So=function(n,e){var t=Rr(n);return{h:t.h,s:t.s,l:Qt(t.l+100*e,0,100),a:t.a}},Ns=function(){function n(e){this.parsed=tc(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return yt(ks(this.rgba),2)},n.prototype.isDark=function(){return ks(this.rgba)<.5},n.prototype.isLight=function(){return ks(this.rgba)>=.5},n.prototype.toHex=function(){return e=Rs(this.rgba),t=e.r,r=e.g,i=e.b,o=(s=e.a)<1?bi(yt(255*s)):"","#"+bi(t)+bi(r)+bi(i)+o;var e,t,r,i,s,o},n.prototype.toRgb=function(){return Rs(this.rgba)},n.prototype.toRgbString=function(){return e=Rs(this.rgba),t=e.r,r=e.g,i=e.b,(s=e.a)<1?"rgba("+t+", "+r+", "+i+", "+s+")":"rgb("+t+", "+r+", "+i+")";var e,t,r,i,s},n.prototype.toHsl=function(){return To(Rr(this.rgba))},n.prototype.toHslString=function(){return e=To(Rr(this.rgba)),t=e.h,r=e.s,i=e.l,(s=e.a)<1?"hsla("+t+", "+r+"%, "+i+"%, "+s+")":"hsl("+t+", "+r+"%, "+i+"%)";var e,t,r,i,s},n.prototype.toHsv=function(){return e=wo(this.rgba),{h:yt(e.h),s:yt(e.s),v:yt(e.v),a:yt(e.a,3)};var e},n.prototype.invert=function(){return he({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),he(Ls(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),he(Ls(this.rgba,-e))},n.prototype.grayscale=function(){return he(Ls(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),he(So(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),he(So(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?he({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):yt(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=Rr(this.rgba);return typeof e=="number"?he({h:e,s:t.s,l:t.l,a:t.a}):yt(t.h)},n.prototype.isEqual=function(e){return this.toHex()===he(e).toHex()},n}(),he=function(n){return n instanceof Ns?n:new Ns(n)},Ao=[],ec=function(n){n.forEach(function(e){Ao.indexOf(e)<0&&(e(Ns,Bs),Ao.push(e))})};function rc(n,e){var t={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"},r={};for(var i in t)r[t[i]]=i;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=r[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,f="black";if(!s.length)for(var p in t)s[p]=new n(t[p]).toRgb();for(var y in t){var _=(a=c,l=s[y],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<u&&(u=_,f=y)}return f}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new n(l).toRgb():null},"name"])}ec([rc]);class Se{get value(){return this._value}set value(e){if(this._value===e)return;this._value=e;let t;typeof e=="number"?t={r:e>>24&255,g:e>>16&255,b:e>>8&255,a:e&255}:t=e;const r=he(t);r.isValid()?this._colord=r:console.warn(`Unable to convert color ${e}`)}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(e=0){this.value=e}toArgb(e=this.a,t=!0){if(e===1)return(255<<24)+this.rgb;if(e===0)return t?0:this.rgb;let r=this.r8,i=this.g8,s=this.b8;return t&&(r=r*e+.5|0,i=i*e+.5|0,s=s*e+.5|0),(e*255<<24)+(r<<16)+(i<<8)+s}toHex(){return this._colord.toHex()}toArray(){return[this.r,this.g,this.b,this.a]}}class Fs extends le{constructor(e){super(4,5,e)}hueRotate(e=0){const t=Math.sin(e),r=Math.cos(e),i=.213,s=.715,o=.072;return this.multiply([i+r*(1-i)+t*-i,s+r*-s+t*-s,o+r*-o+t*(1-o),0,0,i+r*-i+t*.143,s+r*(1-s)+t*.14,o+r*-o+t*-.283,0,0,i+r*-i+t*-(1-i),s+r*-s+t*s,o+r*(1-o)+t*o,0,0,0,0,0,1,0])}saturate(e=1){const t=(e-1)*2/3+1,r=(t-1)*-.5;return this.multiply([t,r,r,0,0,r,t,r,0,0,r,r,t,0,0,0,0,0,1,0])}brightness(e=1){const t=e;return this.multiply([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0])}contrast(e=1){const t=e,r=-128*(t-1);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}invert(e=1){const t=dt(1,-1,e),r=dt(0,255,e);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}sepia(e=1){const t=Me(0,e,1);return this.multiply([dt(1,.393,t),dt(0,.7689999,t),dt(0,.18899999,t),0,0,dt(0,.349,t),dt(1,.6859999,t),dt(0,.16799999,t),0,0,dt(0,.272,t),dt(0,.5339999,t),dt(1,.13099999,t),0,0,0,0,0,1,0])}opacity(e=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e,0])}grayscale(e=1){const t=Me(0,e,1),r=dt(1,.3,t),i=dt(0,.3,t),s=dt(1,.59,t),o=dt(0,.59,t),a=dt(1,.11,t),l=dt(0,.11,t);return this.multiply([r,o,l,0,0,i,s,l,0,0,i,o,a,0,0,0,0,0,1,0])}multiply(e){const t=e,r=this._array;return this.set([r[0]*t[0]+r[1]*t[5]+r[2]*t[10]+r[3]*t[15],r[0]*t[1]+r[1]*t[6]+r[2]*t[11]+r[3]*t[16],r[0]*t[2]+r[1]*t[7]+r[2]*t[12]+r[3]*t[17],r[0]*t[3]+r[1]*t[8]+r[2]*t[13]+r[3]*t[18],r[0]*t[4]+r[1]*t[9]+r[2]*t[14]+r[3]*t[19]+r[4],r[5]*t[0]+r[6]*t[5]+r[7]*t[10]+r[8]*t[15],r[5]*t[1]+r[6]*t[6]+r[7]*t[11]+r[8]*t[16],r[5]*t[2]+r[6]*t[7]+r[7]*t[12]+r[8]*t[17],r[5]*t[3]+r[6]*t[8]+r[7]*t[13]+r[8]*t[18],r[5]*t[4]+r[6]*t[9]+r[7]*t[14]+r[8]*t[19]+r[9],r[10]*t[0]+r[11]*t[5]+r[12]*t[10]+r[13]*t[15],r[10]*t[1]+r[11]*t[6]+r[12]*t[11]+r[13]*t[16],r[10]*t[2]+r[11]*t[7]+r[12]*t[12]+r[13]*t[17],r[10]*t[3]+r[11]*t[8]+r[12]*t[13]+r[13]*t[18],r[10]*t[4]+r[11]*t[9]+r[12]*t[14]+r[13]*t[19]+r[14],r[15]*t[0]+r[16]*t[5]+r[17]*t[10]+r[18]*t[15],r[15]*t[1]+r[16]*t[6]+r[17]*t[11]+r[18]*t[16],r[15]*t[2]+r[16]*t[7]+r[17]*t[12]+r[18]*t[17],r[15]*t[3]+r[16]*t[8]+r[17]*t[13]+r[18]*t[18],r[15]*t[4]+r[16]*t[9]+r[17]*t[14]+r[18]*t[19]+r[19]])}toMatrix4(){const e=this._array;return new uo([e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]])}toVector4(){const e=this._array;return new go(e[4]/255,e[9]/255,e[14]/255,e[19]/255)}}class xi extends pt{constructor(e){const t=new Se(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}var ic=Object.defineProperty,Nt=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ic(e,t,i),i};function Ft(){return function(n,e){Object.defineProperty(n.constructor.prototype,e,{get(){return(...t)=>(this._path2D[e](...t),this)},configurable:!0,enumerable:!0})}}class Mt{constructor(){d(this,"textureTransform");d(this,"fillStyle");d(this,"strokeStyle");d(this,"lineCap");d(this,"lineJoin");d(this,"lineWidth");d(this,"miterLimit");d(this,"_path2D",new Os);d(this,"_defaultStyle",pt.EMPTY);d(this,"_stroked",[]);d(this,"_filled",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof pt?e=this.strokeStyle:e=new xi(this.strokeStyle)),this._path2D.endPolygon(),this._path2D.shapes.length&&(this._stroked.push({shapes:this._path2D.shapes.slice(),texture:e,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this._path2D.shapes.length=0)}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(){let e=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof pt?e=this.fillStyle:e=new xi(this.fillStyle)),this._filled.push({shapes:this._path2D.shapes.slice(),texture:e,textureTransform:this.textureTransform}),this._path2D.shapes.length=0}reset(){this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._path2D.endPolygon(),this._path2D.shapes.length=0,this._stroked.length=0,this._filled.length=0}buildUvs(e,t,r,i,s){if(i){let o=i.width,a=i.height;s&&([o,a]=s.applyToPoint(o,a));for(let l=t.length,h=e;h<l;h+=2)r.push(t[h]/o,t[h+1]/a)}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];let t=[],r=[],i=[],s=0,o;const a=l=>{e.push({type:l,vertices:t,indices:r,uvs:i,texture:o}),t=[],r=[],i=[],o=void 0};for(let l=this._stroked.length,h=0;h<l;h++){const c=this._stroked[h];o??(o=c.texture);const u=[];for(let f=c.shapes.length,p=0;p<f;p++)c.shapes[p].shape.buildOutline(u);s=t.length,lo(u,c.style,!1,!0,t,0,0,r),this.buildUvs(s,t,i,c.texture,c.textureTransform),a("stroke")}for(let l=this._filled.length,h=0;h<l;h++){const c=this._filled[h];o??(o=c.texture),o!==c.texture&&a("fill"),s=t.length;for(let u=c.shapes.length,f=0;f<u;f++)c.shapes[f].shape.buildGeometry(t,r);this.buildUvs(s,t,i,c.texture,c.textureTransform)}return t.length&&a("fill"),e}}Nt([Ft()],Mt.prototype,"moveTo"),Nt([Ft()],Mt.prototype,"lineTo"),Nt([Ft()],Mt.prototype,"bezierCurveTo"),Nt([Ft()],Mt.prototype,"quadraticCurveTo"),Nt([Ft()],Mt.prototype,"ellipticalArc"),Nt([Ft()],Mt.prototype,"rect"),Nt([Ft()],Mt.prototype,"roundRect"),Nt([Ft()],Mt.prototype,"ellipse"),Nt([Ft()],Mt.prototype,"arc"),Nt([Ft()],Mt.prototype,"poly"),Nt([Ft()],Mt.prototype,"addShape"),Nt([Ft()],Mt.prototype,"addPath"),Nt([Ft()],Mt.prototype,"addSvgPath"),Nt([Ft()],Mt.prototype,"closePath");class Ae{}class Oo extends Ae{install(e){const t=async r=>{const{parseFont:i}=await Promise.resolve().then(()=>Wf);return await e.fetch(r).then(s=>s.arrayBuffer()).then(s=>i(s))};return this.load=r=>e.loadBy(r,()=>t(r)),["woff","ttf"].forEach(r=>{e.register(r,t)}),e.font=this,this}}class Uo extends Ae{install(e){const t=async r=>{const{decodeFrames:i}=await import("modern-gif");return await e.fetch(r).then(s=>s.arrayBuffer()).then(s=>i(s)).then(s=>new Ci(s.map(o=>({duration:o.delay,texture:new Us(o.data,o.width,o.height)}))))};return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif"].forEach(r=>{e.register(r,t)}),e.gif=this,this}}class Io extends Ae{install(e){const t=r=>e.fetch(r).then(i=>i.json());return this.load=r=>e.loadBy(r,()=>t(r)),["json"].forEach(r=>{e.register(r,t)}),e.json=this,this}}class Do extends Ae{install(e){const t=async(r,i)=>(await import("lottie-web").then(o=>o.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await e.fetch(r).then(o=>o.json())});return this.load=(r,i)=>e.loadBy(r,()=>t(r,i)),["lottie"].forEach(r=>{e.register(r,t)}),e.lottie=this,this}}class Ro extends Ae{install(e){const t=async r=>await e.fetch(r).then(i=>i.text());return this.load=r=>e.loadBy(r,()=>t(r)),e.text=this,this}}class Bo extends Ae{install(e){const t=r=>e.fetchImageBitmap(r,{premultiplyAlpha:"premultiply"}).then(i=>new pt(i));return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(r=>{e.register(r,t)}),e.texture=this,this}}class Lo extends Ae{install(e){const t=r=>new _o(r).load();return this.load=r=>e.loadBy(r,()=>t(r)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(r=>{e.register(r,t)}),e.video=this,this}}const sc=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function nc(n){for(const[e,t]of sc)if(t.includes(n))return e}async function oc(n){var t,r;let e;if(n.startsWith("data:"))e=(t=n.match(/^data:(.+?);/))==null?void 0:t[1];else if(n.startsWith("http")){const i=(r=n.split(/[#?]/)[0].split(".").pop())==null?void 0:r.trim();i&&(e=nc(i))}return e??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const wi="WeakRef"in globalThis;class ko{constructor(){d(this,"defaultHandler",e=>this.fetch(e));d(this,"_handlers",new Map);d(this,"_handleing",new Map);d(this,"_handled",new Map);d(this,"_gc",wi?new FinalizationRegistry(e=>{const t=this.get(e);t&&"destroy"in t&&t.destroy(),this._handled.delete(e)}):void 0);wi||ft.on(this.gc.bind(this),{sort:2})}use(e){return e.install(this),this}register(e,t){return this._handlers.set(e,t),this}fetch(e){return fetch(e)}_fixSVG(e){const t=new DOMParser().parseFromString(decodeURIComponent(e.split(",")[1]),"image/svg+xml").documentElement;return t.setAttribute("width","512"),t.setAttribute("height","512"),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t.outerHTML)}`}async fetchImageBitmap(e,t){return e.startsWith("http")?await this.fetch(e).then(r=>r.blob()).then(r=>r.type==="image/svg+xml"?r.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),t)):createImageBitmap(r,t)):(e.startsWith("data:image/svg+xml;")&&(e=this._fixSVG(e)),new Promise(r=>{const i=new Image;i.src=e,i.onload=()=>i.decode().finally(()=>r(i))}).then(r=>createImageBitmap(r,t)))}get(e){let t=this._handled.get(e);return wi&&t instanceof WeakRef&&(t=t.deref(),t||this._handleing.delete(e)),t}set(e,t){let r=t;wi&&typeof t=="object"&&(this._gc.register(t,e),r=new WeakRef(t)),this._handled.set(e,r)}async loadBy(e,t){const r=this.get(e)??this._handleing.get(e);if(r)return r;const i=t().then(s=>(this.set(e,s),s)).finally(()=>{this._handleing.delete(e)});return this._handleing.set(e,i),i}async load(e,t){return this.loadBy(e,async()=>{const r=await oc(e);return(this._handlers.get(r)??this.defaultHandler)(e,t)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()))}gc(){this._handled.forEach((e,t)=>{const r=this.get(t);r&&"destroy"in r&&r.destroy()}),this._handled.clear()}}const we=new ko().use(new Oo).use(new Uo).use(new Io).use(new Do).use(new Ro).use(new Bo).use(new Lo);class hr{}class No extends hr{install(e){W(e,"backgroundColor"),W(e,"backgroundImage"),e.prototype.getComputedBackground=ac}}async function ac(){if(this.backgroundImage)return await we.texture.load(this.backgroundImage);if(this.backgroundColor)return new xi(this.backgroundColor)}class Fo extends hr{install(e){W(e,"filter",{default:""}),e.prototype.getComputedFilter=lc,e.prototype.getComputedFilterColorMatrix=hc}}const $o={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function lc(){const n=wr(this.filter).reduce((e,{name:t,args:r})=>(e[t]=r[0].normalizedIntValue,e),{});return Object.keys($o).forEach(e=>{n[e]=n[e]??$o[e]}),n}function hc(){const n=new Fs,e=this.getComputedFilter();for(const t in e){const r=e[t];switch(t){case"hue-rotate":n.hueRotate(r*at);break;case"saturate":n.saturate(r);break;case"brightness":n.brightness(r);break;case"contrast":n.contrast(r);break;case"invert":n.invert(r);break;case"sepia":n.sepia(r);break;case"opacity":n.opacity(r);break;case"grayscale":n.grayscale(r);break}}return n}class zo extends hr{install(e){W(e,"offsetPath"),W(e,"offsetAnchor"),W(e,"offsetDistance"),W(e,"offsetPosition"),e.prototype.getComputedOffset=cc}}function cc(){var e;const n=this.offsetPath;if(n)if(n.startsWith("path")){const t=(e=n.match(/path\(["'](.+)["']\)/))==null?void 0:e[1];if(!t)return;t.split(" ").forEach(r=>{})}else n.startsWith("ray")||n.startsWith("url")||n.startsWith("circle")||n.startsWith("ellipse")||n.startsWith("insett")||n.startsWith("polygon")||n.startsWith("rect")||n.startsWith("xywh")}class Vo extends hr{install(e){W(e,"color",{default:"#000000"}),W(e,"fontSize",{default:14}),W(e,"fontWeight",{default:"normal"}),W(e,"fontFamily",{default:"sans-serif"}),W(e,"fontStyle",{default:"normal"}),W(e,"fontKerning",{default:"normal"}),W(e,"textWrap",{default:"wrap"}),W(e,"textAlign",{default:"start"}),W(e,"verticalAlign",{default:"middle"}),W(e,"textTransform",{default:"none"}),W(e,"textDecoration",{default:null}),W(e,"textStrokeWidth",{default:0}),W(e,"textStrokeColor",{default:"#000000"}),W(e,"direction",{default:"inherit"}),W(e,"lineHeight",{default:1}),W(e,"letterSpacing",{default:0}),W(e,"writingMode",{default:"horizontal-tb"})}}class Xo extends hr{install(e){W(e,"left",{default:0}),W(e,"top",{default:0}),W(e,"width",{default:0}),W(e,"height",{default:0}),W(e,"rotate",{default:0}),W(e,"scaleX",{default:1}),W(e,"scaleY",{default:1}),W(e,"transform"),W(e,"transformOrigin",{default:"center"}),e.prototype.getComputedTransform=uc,e.prototype.getComputedTransformOrigin=fc}}function uc(){const n=new qt,e=new qt(!1),t=new qt(!1).scale(this.scaleX,this.scaleY).translate(this.left,this.top).rotate(this.rotate*po);wr(this.transform??"",{width:this.width,height:this.height}).forEach(({name:c,args:u})=>{const f=u.map(p=>p.normalizedIntValue);switch(n.identity(),c){case"translate":n.translate(f[0]*this.width,(f[1]??f[0])*this.height);break;case"translateX":n.translateX(f[0]*this.width);break;case"translateY":n.translateY(f[0]*this.height);break;case"translateZ":n.translateZ(f[0]);break;case"translate3d":n.translate3d(f[0]*this.width,(f[1]??f[0])*this.height,f[2]??f[1]??f[0]);break;case"scale":n.scale(f[0],f[1]??f[0]);break;case"scaleX":n.scaleX(f[0]);break;case"scaleY":n.scaleY(f[0]);break;case"scale3d":n.scale3d(f[0],f[1]??f[0],f[2]??f[1]??f[0]);break;case"rotate":n.rotate(f[0]*at);break;case"rotateX":n.rotateX(f[0]*at);break;case"rotateY":n.rotateY(f[0]*at);break;case"rotateZ":n.rotateZ(f[0]*at);break;case"rotate3d":n.rotate3d(f[0]*at,(f[1]??f[0])*at,(f[2]??f[1]??f[0])*at,(f[3]??f[2]??f[1]??f[0])*at);break;case"skew":n.skew(f[0],f[0]??f[1]);break;case"skewX":n.skewX(f[0]);break;case"skewY":n.skewY(f[0]);break;case"matrix":n.set(f);break}e.multiply(n)}),t.update(),e.update();const r=t.toArray(),i=e.toArray(),s=[i[0]*r[0]+i[3]*r[1],i[1]*r[0]+i[4]*r[1],i[2]*r[0]+i[5]*r[1]+r[2],i[0]*r[3]+i[3]*r[4],i[1]*r[3]+i[4]*r[4],i[2]*r[3]+i[5]*r[4]+r[5],0,0,1],[o,a]=this.getComputedTransformOrigin(),l=o*this.width,h=a*this.height;return s[2]+=s[0]*-l+s[1]*-h+l,s[5]+=s[3]*-l+s[4]*-h+h,new qt().set(s)}function fc(){const[n,e=n]=this.transformOrigin.split(" ");return[n,e].map(t=>{switch(t=t.trim(),t){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(t)}})}const dc=Object.freeze(Object.defineProperty({__proto__:null,Style2DBackgroundModule:No,Style2DFilterModule:Fo,Style2DOffsetModule:zo,Style2DTextModule:Vo,Style2DTransformModule:Xo},Symbol.toStringTag,{value:"Module"}));var pc=Object.defineProperty,Xe=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&pc(e,t,i),i};class ce extends li{constructor(e){super(),this.setProperties(e)}_onUpdateProperty(e,t,r){switch(super._onUpdateProperty(e,t,r),e){case"fontSize":t<=0&&(this.fontSize=14);break;case"fontWeight":t||(this.fontWeight="normal");break;case"lineHeight":t||(this.lineHeight=1);break}}}Xe([U({default:"#000000"})],ce.prototype,"shadowColor"),Xe([U({default:0})],ce.prototype,"shadowOffsetX"),Xe([U({default:0})],ce.prototype,"shadowOffsetY"),Xe([U({default:0})],ce.prototype,"shadowBlur"),Xe([U({default:1})],ce.prototype,"opacity"),Xe([U({default:0})],ce.prototype,"borderRadius"),Xe([U({default:"visible"})],ce.prototype,"overflow"),Object.values(dc).forEach(n=>{new n().install(ce)});var gc=Object.defineProperty,mc=Object.getOwnPropertyDescriptor,$s=(n,e,t,r)=>{for(var i=r>1?void 0:r?mc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gc(e,t,i),i};g.CanvasItem=class extends g.Node{constructor(t){super();d(this,"tint");d(this,"blendMode");d(this,"opacity",1);d(this,"_parentOpacity");d(this,"_tint",new Se(4294967295));d(this,"_backgroundColor",new Se(0));d(this,"context",new Mt);d(this,"_resetContext",!0);d(this,"_waitingRedraw",!1);d(this,"_waitingReflow",!1);d(this,"_waitingRepaint",!1);d(this,"_originalBatchables",[]);d(this,"_layoutedBatchables",[]);d(this,"_batchables",[]);this._onUpdateStyleProperty=this._onUpdateStyleProperty.bind(this),this.setProperties(t),this.style=new ce}get style(){return this._style}set style(t){var r;t.on("updateProperty",this._onUpdateStyleProperty),(r=this._style)==null||r.off("updateProperty",this._onUpdateStyleProperty),this._style=t}setProperties(t){if(t){const{style:r,...i}=t;r&&this.style.setProperties(r),super.setProperties(i)}return this}_onUpdateProperty(t,r,i,s){switch(super._onUpdateProperty(t,r,i,s),t){case"blendMode":this.requestRepaint();break;case"tint":this._tint.value=r||4294967295,this.requestRepaint();break}}_onUpdateStyleProperty(t,r,i,s){switch(t){case"backgroundColor":this._backgroundColor.value=r||0,this._originalBatchables.length?this.requestRepaint():this._backgroundColor.a>0&&this.requestRedraw();break;case"opacity":this._updateOpacity();break;case"filter":this.requestRepaint();break}}_updateOpacity(){var r;const t=Me(0,this.style.opacity,1)*(((r=this._parent)==null?void 0:r.opacity)??1);this.opacity!==t&&(this.opacity=t,this.requestRepaint())}isVisible(){return this.opacity>0&&super.isVisible()}requestRedraw(){this._waitingRedraw=!0}requestReflow(){this._waitingReflow=!0}requestRepaint(){this._waitingRepaint=!0}_process(t){var i;const r=(i=this._parent)==null?void 0:i.opacity;r!==this._parentOpacity&&(this._parentOpacity=r,this._updateOpacity()),super._process(t)}_draw(){}_relayout(t){return this._reflow(t)}_reflow(t){return this._repaint(t)}_repaint(t){const r=this.style.getComputedFilterColorMatrix();return t.map(i=>({...i,backgroundColor:this._backgroundColor.abgr,tint:this._tint.toArgb(this.opacity,!0),colorMatrix:r.toMatrix4().toArray(!0),colorMatrixOffset:r.toVector4().toArray(),blendMode:this.blendMode}))}_render(t){let r;this._waitingRedraw?(this._draw(),this._originalBatchables=this.context.toBatchables(),this._layoutedBatchables=this._relayout(this._originalBatchables),r=this._layoutedBatchables,this._resetContext&&this.context.reset()):this._waitingReflow?(this._layoutedBatchables=this._reflow(this._originalBatchables),r=this._layoutedBatchables):this._waitingRepaint&&(r=this._repaint(this._layoutedBatchables)),r&&(this._batchables=r,this._waitingRedraw=!1,this._waitingReflow=!1,this._waitingRepaint=!1),this._batchables.forEach(i=>{var s,o;(s=i.texture)==null||s.upload(t),t.batch2D.render({...i,texture:(o=i.texture)==null?void 0:o._glTexture(t)})}),super._render(t)}toJSON(){const t=super.toJSON();return{...t,props:{style:this.style.toJSON(),...t.props}}}},$s([U()],g.CanvasItem.prototype,"tint",2),$s([U()],g.CanvasItem.prototype,"blendMode",2),g.CanvasItem=$s([Z("CanvasItem")],g.CanvasItem);var yc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,je=(n,e,t,r)=>{for(var i=r>1?void 0:r?_c(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yc(e,t,i),i};const jo=n=>n,Go=cr(.25,.1,.25,1),qo=cr(.42,0,1,1),Yo=cr(0,0,.58,1),Wo=cr(.42,0,.58,1);function cr(n,e,t,r){const s=3*n-3*t+1,o=3*t-6*n,a=3*n,l=3*e-3*r+1,h=3*r-6*e,c=3*e,u=_=>(3*s*_+2*o)*_+a,f=_=>((s*_+o)*_+a)*_,p=_=>((l*_+h)*_+c)*_;function y(_){let m=_,b,w;for(let P=0;P<8;P++){if(w=f(m)-_,Math.abs(w)<1e-6)return m;if(b=u(m),Math.abs(b)<1e-6)break;m-=w/b}let x=1,C=0;for(m=_;x>C;){if(w=f(m)-_,Math.abs(w)<1e-6)return m;w>0?x=m:C=m,m=(x+C)/2}return m}return _=>p(y(_))}const Pi={linear:jo,ease:Go,easeIn:qo,easeOut:Yo,easeInOut:Wo};g.Animation2D=class extends g.Node{constructor(t){super();d(this,"easing");d(this,"_keyframes",[]);d(this,"_starting",!1);d(this,"_startProps",new WeakMap);this.setProperties(t),this._onUpdateTime=this._onUpdateTime.bind(this)}_enterTree(){var t;(t=this._tree)==null||t.timeline.on("update",this._onUpdateTime),this._updateStartProps()}_exitTree(){var t;(t=this._tree)==null||t.timeline.off("update",this._onUpdateTime),this.cancel()}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"mode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var r;let t;switch(this.mode){case"sibling":t=((r=this.getParent())==null?void 0:r.getChildren(!0).filter(i=>i instanceof g.CanvasItem))??[];break;case"parent":default:t=[this.getParent()].filter(Boolean);break}return t.map(i=>i.style)}_updateKeyframes(){const t=[],r=this.keyframes;for(let o=r.length,a=0;a<o;a++){const{offset:l=a===0?0:a/(o-1),easing:h="linear",...c}=r[a];t.push({offset:l,easing:this._parseEasing(h),props:c})}const i=t[0],s=t[t.length-1];i&&i.offset!==0&&t.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),s&&s.offset!==1&&t.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=t,this._updateStartProps()}_onUpdateTime(){if(!this.keyframes.length)return;if(this.isVisible())this._starting||(this._starting=!0,this._updateStartProps());else{if(!this._starting)return;this._starting=!1}const t=this._getTargets(),r=1/t.length,i=this.visibleProgress;t.forEach((s,o)=>{const a=r===1?i:Me(0,Math.max(0,i-r*o)/r,1),l=this._startProps.get(s);if(!l)return;const h=this._parseKeyframes(a,l);h!=null&&h.length&&this._commitStyle(a,s,l,h[0],h[1])})}_updateStartProps(){this.cancel(),this._getTargets().forEach(t=>{const r=new Map,i=this._keyframes;for(let s=i.length,o=0;o<s;o++)Object.keys(i[o].props).forEach(a=>{r.set(a,t[a])});this._startProps.set(t,r)})}_parseEasing(t){if(!t)return Pi.linear;if(t in Pi)return Pi[t];const r=t.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return cr(r[0],r[1],r[2],r[3])}_parseKeyframes(t,r){let i;const s=this._keyframes;for(let o=s.length,a=0;a<o;a++){const l=s[a],{offset:h,easing:c}=l,u={...l.props};if(i&&t<=h){const{offset:f,easing:p}=i,y={...i.props};return r.forEach((_,m)=>{(!(m in y)||y[m]===null)&&(y[m]=_),(!(m in u)||u[m]===null)&&(u[m]=_)}),[{offset:f,easing:p,props:y},{offset:h,easing:c,props:u}]}i=l}return null}_commitStyle(t,r,i,s,o){const{offset:a,easing:l,props:h}=s,{offset:c,props:u}=o,f=c-a,p=l((t-a)/f),y={width:r.width,height:r.height,fontSize:r.fontSize};i.forEach((_,m)=>{r[m]=this._getDiffValue(m,h[m],u[m],p,y)})}_getDiffValue(t,r,i,s,o){let a,l;if(r===void 0||i===void 0)if(r!==void 0)a=xr(t,String(r),o),l=os(a);else if(i!==void 0)l=xr(t,String(i),o),a=os(l);else return;else a=xr(t,String(r),o),l=xr(t,String(i),o);if(Array.isArray(a)&&Array.isArray(l)){const h=new Set,c={},u={};a.forEach(({name:p,args:y})=>{c[p]=y,h.add(p)}),l.forEach(({name:p,args:y})=>{u[p]=y,h.add(p)});let f="";return h.forEach(p=>{var b,w;const y=Math.max(((b=c[p])==null?void 0:b.length)??0,((w=u[p])==null?void 0:w.length)??0),_=c[p],m=u[p];f+=`${p}(${Array.from({length:y},(x,C)=>{const P=_==null?void 0:_[C],E=m==null?void 0:m[C],A=(P==null?void 0:P.normalizedIntValue)??0,S=(E==null?void 0:E.normalizedIntValue)??0;return Number.isNaN(A)||Number.isNaN(S)?(E==null?void 0:E.value)??0:dt(A,S,s)}).join(", ")}) `}),f}else if(!Array.isArray(a)&&!Array.isArray(l))return Number.isNaN(a.normalizedIntValue)||Number.isNaN(l.normalizedIntValue)?l.value:dt(a.normalizedIntValue,l.normalizedIntValue,s)}cancel(){this._getTargets().forEach(t=>{var r;(r=this._startProps.get(t))==null||r.forEach((i,s)=>{t[s]=i}),this._startProps.delete(t)})}},je([U({default:"parent"})],g.Animation2D.prototype,"mode",2),je([U({default:!1})],g.Animation2D.prototype,"loop",2),je([U({default:[]})],g.Animation2D.prototype,"keyframes",2),je([U()],g.Animation2D.prototype,"easing",2),je([U({alias:"visibleDelay",default:0})],g.Animation2D.prototype,"delay",2),je([U({alias:"visibleDuration",default:2e3})],g.Animation2D.prototype,"duration",2),g.Animation2D=je([Z("Animation2D")],g.Animation2D);var vc=Object.defineProperty,bc=Object.getOwnPropertyDescriptor,xc=(n,e,t,r)=>{for(var i=r>1?void 0:r?bc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&vc(e,t,i),i};g.Node2D=class extends g.CanvasItem{constructor(t){super();d(this,"_transform",new qt);d(this,"_parentTransformDirtyId");this.setProperties(t)}getBoundingBox(){let{left:t,top:r,width:i,height:s,rotate:o}=this.style;if(o){o=Math.abs(o%180),o=o/180*Math.PI;const a=Math.abs(Math.sin(o)),l=Math.abs(Math.cos(o)),h=s*a+i*l,c=s*l+i*a;t+=(i-h)/2,r+=(s-c)/2,i=h,s=c}return new Gt(t,r,i,s)}_onUpdateStyleProperty(t,r,i){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":case"height":this.mask instanceof g.Node2D&&(this.mask.style.width=this.style.width,this.mask.style.height=this.style.height),this.requestRedraw();case"scaleX":case"scaleY":case"left":case"top":case"rotate":case"transform":case"transformOrigin":this._updateTransform();break}}_updateTransform(){const t=this.getParent(),r=t==null?void 0:t._transform;this._parentTransformDirtyId=r==null?void 0:r.dirtyId;const i=this.style.getComputedTransform().toArray();let s;if(r){const o=r.toArray();s=[i[0]*o[0]+i[3]*o[1],i[1]*o[0]+i[4]*o[1],i[2]*o[0]+i[5]*o[1]+o[2],i[0]*o[3]+i[3]*o[4],i[1]*o[3]+i[4]*o[4],i[2]*o[3]+i[5]*o[4]+o[5],0,0,1]}else s=i;this._transform.set(s),this.requestReflow()}_transformVertices(t){const[r,i,s,o,a,l]=this._transform.toArray(),h=t.slice();for(let c=t.length,u=0;u<c;u+=2){const f=t[u],p=t[u+1];h[u]=r*f+i*p+s,h[u+1]=o*f+a*p+l}return h}_reflow(t){return super._reflow(t.map(r=>({...r,vertices:this._transformVertices(r.vertices)})))}_process(t){var i;const r=this.getParent();((i=r==null?void 0:r._transform)==null?void 0:i.dirtyId)!==this._parentTransformDirtyId&&this._updateTransform(),super._process(t)}input(t){if(super.input(t),!t.target&&this.isRenderable()){const{screenX:r,screenY:i}=t;if(r&&i){const{width:s,height:o}=this.style,[a,l]=this._transform.inverse().applyToPoint(r,i);a>=0&&a<s&&l>=0&&l<o&&(t.target=this)}}}},g.Node2D=xc([Z("Node2D")],g.Node2D);var wc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,Ho=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wc(e,t,i),i};g.Element2D=class extends g.Node2D{constructor(t){super();d(this,"draggable");d(this,"_background");this.setProperties(t)}_onUpdateStyleProperty(t,r,i){switch(super._onUpdateStyleProperty(t,r,i),t){case"backgroundImage":this._updateBackground();break;case"borderRadius":this.requestRedraw();break;case"overflow":this._updateOverflow();break}}async _updateBackground(){this._background=await this.style.getComputedBackground(),this.requestRedraw()}_updateTransform(){super._updateTransform(),this._updateOverflow()}_updateOverflow(){if(this.style.overflow==="hidden"){const[t,r,i,s,o,a]=this._transform.toArray(),l=this.style.width,h=this.style.height;this.mask={x:i,y:a,width:t*l+r*h,height:s*l+o*h}}else this.mask=void 0}_draw(){super._draw(),this._drawBackground(),this._drawContent()}_drawBackground(){const t=this._background;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),this._drawRect())}_drawContent(){this._drawRect()}_drawRect(){this.style.borderRadius?this.context.roundRect(0,0,this.style.width,this.style.height,this.style.borderRadius):this.context.rect(0,0,this.style.width,this.style.height),this.context.fill()}},Ho([U()],g.Element2D.prototype,"draggable",2),g.Element2D=Ho([Z({tag:"Element2D",renderable:!0})],g.Element2D);var Cc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,mt=(n,e,t,r)=>{for(var i=r>1?void 0:r?Tc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Cc(e,t,i),i};function _t(n){return function(e,t){Object.defineProperty(e.constructor.prototype,t,{get(){return n!=null&&n.method?(...r)=>(this.context[t].call(this.context,...r),n.redraw&&this.requestRedraw(),e):this.context[t]},set(r){this.context[t]=r},configurable:!0,enumerable:!0})}}g.Graphics2D=class extends g.Node2D{constructor(){super(...arguments);d(this,"_resetContext",!1);d(this,"lineCap");d(this,"lineJoin");d(this,"fillStyle");d(this,"strokeStyle");d(this,"lineWidth");d(this,"miterLimit")}drawCircle(t,r,i){return this.arc(t+i,r+i,i,0,at),this.fill(),this}drawEllipse(t,r,i,s){const o=i/2,a=s/2;return this.ellipse(t+o,r+a,o,a,0,0,at),this.fill(),this}},mt([_t()],g.Graphics2D.prototype,"lineCap",2),mt([_t()],g.Graphics2D.prototype,"lineJoin",2),mt([_t()],g.Graphics2D.prototype,"fillStyle",2),mt([_t()],g.Graphics2D.prototype,"strokeStyle",2),mt([_t()],g.Graphics2D.prototype,"lineWidth",2),mt([_t()],g.Graphics2D.prototype,"miterLimit",2),mt([_t({method:!0})],g.Graphics2D.prototype,"rect",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"fillRect",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"strokeRect",2),mt([_t({method:!0})],g.Graphics2D.prototype,"roundRect",2),mt([_t({method:!0})],g.Graphics2D.prototype,"ellipse",2),mt([_t({method:!0})],g.Graphics2D.prototype,"arc",2),mt([_t({method:!0})],g.Graphics2D.prototype,"beginPath",2),mt([_t({method:!0})],g.Graphics2D.prototype,"moveTo",2),mt([_t({method:!0})],g.Graphics2D.prototype,"lineTo",2),mt([_t({method:!0})],g.Graphics2D.prototype,"closePath",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"fill",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"stroke",2),g.Graphics2D=mt([Z({tag:"Graphics2D",renderable:!0})],g.Graphics2D);class Ci extends Ee{constructor(t){super();d(this,"frames");let r;if(Array.isArray(t))r=t;else if(t instanceof pt)r=[{texture:t,duration:0}];else throw new TypeError("Failed new Image2DResource");this.frames=r,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((t,r)=>r.duration+t,0),this}destroy(){this.frames.forEach(t=>{t.texture.destroy()})}}var Ec=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Ti=(n,e,t,r)=>{for(var i=r>1?void 0:r?Mc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ec(e,t,i),i};g.Image2D=class extends g.Element2D{constructor(t){super();d(this,"resource");d(this,"_frameIndex",0);d(this,"_complete",!1);d(this,"_wait",Promise.resolve());this.setProperties(t)}get currentTexture(){var t,r;return(r=(t=this.resource)==null?void 0:t.frames[this._frameIndex])==null?void 0:r.texture}get duration(){var t;return((t=this.resource)==null?void 0:t.duration)??0}get naturalWidth(){var t;return((t=this.currentTexture)==null?void 0:t.realWidth)??0}get naturalHeight(){var t;return((t=this.currentTexture)==null?void 0:t.realHeight)??0}get complete(){return this._complete}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._wait=this._load(r);break}}decode(){return this._wait}setResource(t){let r;if(t instanceof Ci?r=t:r=new Ci(t),this.resource=r.updateDuration(),this.currentTexture&&(!this.style.width||!this.style.height)){const i=this.currentTexture;this.style.width=i.realWidth,this.style.height=i.realHeight}return this}async _load(t){if(this._complete=!1,t)try{this.setResource(this.gif?await we.gif.load(t):await we.texture.load(t)),this.requestRedraw(),this.emit("load")}catch(r){console.warn(r),this.emit("error",r)}else this.resource=void 0;this._complete=!0}_getCurrentTime(){var i;const t=((i=this.resource)==null?void 0:i.duration)??0;if(!t||!this._tree)return 0;const r=this.visibleRelativeTime;return r<0?0:r%t}_updateFrameIndex(){if(!this.resource)return this;const t=this._getCurrentTime(),r=this.resource.frames,i=r.length;if(i<=1&&this._frameIndex===0)return this;let s=i-1;for(let o=0,a=0;a<i;a++)if(o+=r[a].duration??0,o>=t){s=a;break}return this._frameIndex!==s&&(this._frameIndex=s,this.requestRepaint()),this}_process(t){this._updateFrameIndex(),super._process(t)}_drawContent(){const t=this.currentTexture;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),super._drawContent())}_repaint(t){const r=this.currentTexture;return super._repaint(t.map((i,s)=>(this._background?s===1:s===0)&&i.type==="fill"?{...i,texture:r!=null&&r.valid?r:void 0}:i))}},Ti([nt()],g.Image2D.prototype,"resource",2),Ti([U({default:!1})],g.Image2D.prototype,"gif",2),Ti([U({default:""})],g.Image2D.prototype,"src",2),g.Image2D=Ti([Z("Image2D")],g.Image2D);var Sc=Object.defineProperty,Ac=Object.getOwnPropertyDescriptor,zs=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ac(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Sc(e,t,i),i};g.Lottie2D=class extends g.Element2D{constructor(t){super();d(this,"duration",0);d(this,"texture",new pt(document.createElement("canvas")));d(this,"animation");this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._load();break}}_onUpdateStyleProperty(t,r,i){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":this.texture.source.width=this.style.width*this.pixelRatio;break;case"height":this.texture.source.height=this.style.height*this.pixelRatio;break}}async _load(){this.animation=await we.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(t){var r;(r=this.animation)==null||r.goToAndStop(this.visibleRelativeTime,!1),this.texture.requestUpload(),this.requestRepaint(),super._process(t)}_drawContent(){const t=this.texture;t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),super._drawContent())}},zs([U({default:2})],g.Lottie2D.prototype,"pixelRatio",2),zs([U({default:""})],g.Lottie2D.prototype,"src",2),g.Lottie2D=zs([Z("Lottie2D")],g.Lottie2D);const Oc={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Vs(n,e){const{fill:t="#000",stroke:r="none",strokeWidth:i=r==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:u=0,shadowBlur:f=0,shadowColor:p="rgba(0, 0, 0, 0)"}=e;n.fillStyle=t,n.strokeStyle=r,n.lineWidth=i,n.lineCap=s,n.lineJoin=Oc[o],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=c,n.shadowOffsetY=u,n.shadowBlur=f,n.shadowColor=p}class D{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new D(1/0,1/0)}static get MIN(){return new D(-1/0,-1/0)}get array(){return[this.x,this.y]}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const r=-e/180*Math.PI,i=this.x-t.x,s=-(this.y-t.y),o=Math.sin(r),a=Math.cos(r);return this.set(t.x+(i*a-s*o),t.y-(i*o+s*a)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,r={x:0,y:0}){const i=e<0?r.x-this.x+r.x:this.x,s=t<0?r.y-this.y+r.y:this.y;return this.x=i*Math.abs(e),this.y=s*Math.abs(t),this}skew(e,t=0,r={x:0,y:0}){const i=this.x-r.x,s=this.y-r.y;return this.x=r.x+(i+Math.tan(e)*s),this.y=r.y+(s+Math.tan(t)*i),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new D(this.x,this.y)}}class K{constructor(e=0,t=0,r=0,i=0){this.left=e,this.top=t,this.width=r,this.height=i}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new D((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new K;if(e.length===1)return e[0].clone();const t=e[0],r=e.slice(1).reduce((i,s)=>(i.left=Math.min(i.left,s.left),i.top=Math.min(i.top,s.top),i.right=Math.max(i.right,s.right),i.bottom=Math.max(i.bottom,s.bottom),i),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new K(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new K(this.left,this.top,this.width,this.height)}}class $t{constructor(e=1,t=0,r=0,i=0,s=1,o=0,a=0,l=0,h=1){d(this,"elements",[]);this.set(e,t,r,i,s,o,a,l,h)}set(e,t,r,i,s,o,a,l,h){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],h=r[1],c=r[4],u=r[7],f=r[2],p=r[5],y=r[8],_=i[0],m=i[3],b=i[6],w=i[1],x=i[4],C=i[7],P=i[2],E=i[5],A=i[8];return s[0]=o*_+a*w+l*P,s[3]=o*m+a*x+l*E,s[6]=o*b+a*C+l*A,s[1]=h*_+c*w+u*P,s[4]=h*m+c*x+u*E,s[7]=h*b+c*C+u*A,s[2]=f*_+p*w+y*P,s[5]=f*m+p*x+y*E,s[8]=f*b+p*C+y*A,this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],h=e[7],c=e[8],u=c*o-a*h,f=a*l-c*s,p=h*s-o*l,y=t*u+r*f+i*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return e[0]=u*_,e[1]=(i*h-c*r)*_,e[2]=(a*r-i*o)*_,e[3]=f*_,e[4]=(c*t-i*l)*_,e[5]=(i*s-a*t)*_,e[6]=p*_,e[7]=(r*l-h*t)*_,e[8]=(o*t-r*s)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(Xs.makeScale(e,t)),this}rotate(e){return this.premultiply(Xs.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xs.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Xs=new $t;function Zo(n,e,t,r){const i=n*t+e*r,s=Math.sqrt(n*n+e*e)*Math.sqrt(t*t+r*r);let o=Math.acos(Math.max(-1,Math.min(1,i/s)));return n*r-e*t<0&&(o=-o),o}function Uc(n,e,t,r,i,s,o,a){if(e===0||t===0){n.lineTo(a.x,a.y);return}r=r*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const l=(o.x-a.x)/2,h=(o.y-a.y)/2,c=Math.cos(r)*l+Math.sin(r)*h,u=-Math.sin(r)*l+Math.cos(r)*h;let f=e*e,p=t*t;const y=c*c,_=u*u,m=y/f+_/p;if(m>1){const O=Math.sqrt(m);e=O*e,t=O*t,f=e*e,p=t*t}const b=f*_+p*y,w=(f*p-b)/b;let x=Math.sqrt(Math.max(0,w));i===s&&(x=-x);const C=x*e*u/t,P=-x*t*c/e,E=Math.cos(r)*C-Math.sin(r)*P+(o.x+a.x)/2,A=Math.sin(r)*C+Math.cos(r)*P+(o.y+a.y)/2,S=Zo(1,0,(c-C)/e,(u-P)/t),T=Zo((c-C)/e,(u-P)/t,(-c-C)/e,(-u-P)/t)%(Math.PI*2);n.ellipse(E,A,e,t,r,S,S+T,s===0)}function ur(n,e){return n-(e-n)}function Ko(n,e){const t=new D,r=new D;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o.type==="m"||o.type==="M")o.type==="m"?t.add(o):t.copy(o),e.moveTo(t.x,t.y),r.copy(t);else if(o.type==="h"||o.type==="H")o.type==="h"?t.x+=o.x:t.x=o.x,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="v"||o.type==="V")o.type==="v"?t.y+=o.y:t.y=o.y,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="l"||o.type==="L")o.type==="l"?t.add(o):t.copy(o),e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="c"||o.type==="C")o.type==="c"?(e.bezierCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="s"||o.type==="S")o.type==="s"?(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="q"||o.type==="Q")o.type==="q"?(e.quadraticCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x,t.y+o.y),r.x=t.x+o.x1,r.y=t.y+o.y1,t.add(o)):(e.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,t.copy(o));else if(o.type==="t"||o.type==="T"){const a=ur(t.x,r.x),l=ur(t.y,r.y);r.x=a,r.y=l,o.type==="t"?(e.quadraticCurveTo(a,l,t.x+o.x,t.y+o.y),t.add(o)):(e.quadraticCurveTo(a,l,o.x,o.y),t.copy(o))}else if(o.type==="a"||o.type==="A"){const a=t.clone();if(o.type==="a"){if(o.x===0&&o.y===0)continue;t.add(o)}else{if(t.equals(o))continue;t.copy(o)}r.copy(t),Uc(e,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,a,t)}else o.type==="z"||o.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",o)}}const ct={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function ue(n,e,t=0){let a=0,l=!0,h="",c="";const u=[];function f(m,b,w){const x=new SyntaxError(`Unexpected character "${m}" at index ${b}.`);throw x.partial=w,x}function p(){h!==""&&(c===""?u.push(Number(h)):u.push(Number(h)*10**Number(c))),h="",c=""}let y;const _=n.length;for(let m=0;m<_;m++){if(y=n[m],Array.isArray(e)&&e.includes(u.length%t)&&ct.FLAGS.test(y)){a=1,h=y,p();continue}if(a===0){if(ct.WHITESPACE.test(y))continue;if(ct.DIGIT.test(y)||ct.SIGN.test(y)){a=1,h=y;continue}if(ct.POINT.test(y)){a=2,h=y;continue}ct.COMMA.test(y)&&(l&&f(y,m,u),l=!0)}if(a===1){if(ct.DIGIT.test(y)){h+=y;continue}if(ct.POINT.test(y)){h+=y,a=2;continue}if(ct.EXP.test(y)){a=3;continue}ct.SIGN.test(y)&&h.length===1&&ct.SIGN.test(h[0])&&f(y,m,u)}if(a===2){if(ct.DIGIT.test(y)){h+=y;continue}if(ct.EXP.test(y)){a=3;continue}ct.POINT.test(y)&&h[h.length-1]==="."&&f(y,m,u)}if(a===3){if(ct.DIGIT.test(y)){c+=y;continue}if(ct.SIGN.test(y)){if(c===""){c+=y;continue}c.length===1&&ct.SIGN.test(c)&&f(y,m,u)}}ct.WHITESPACE.test(y)?(p(),a=0,l=!1):ct.COMMA.test(y)?(p(),a=0,l=!0):ct.SIGN.test(y)?(p(),a=1,h=y):ct.POINT.test(y)?(p(),a=2,h=y):f(y,m,u)}return p(),u}function Ic(n){let e,t;const r=[];for(let i=0,s=n.length;i<s;i++){const o=n[i];switch(o.type){case"m":case"M":if(o.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&o.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y},e={x:o.x,y:o.y};break;case"h":case"H":r.push(`${o.type} ${o.x}`),t={x:o.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":r.push(`${o.type} ${o.y}`),t={x:(t==null?void 0:t.x)??0,y:o.y};break;case"l":case"L":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"c":case"C":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"s":case"S":r.push(`${o.type} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"q":case"Q":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"t":case"T":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"a":case"A":r.push(`${o.type} ${o.rx} ${o.ry} ${o.angle} ${o.largeArcFlag} ${o.sweepFlag} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"z":case"Z":r.push(o.type),e&&(t={x:e.x,y:e.y});break}}return r.join(" ")}const Dc=/[a-df-z][^a-df-z]*/gi;function Qo(n){const e=[],t=n.match(Dc);if(!t)return e;for(let r=0,i=t.length;r<i;r++){const s=t[r],o=s.charAt(0),a=s.slice(1).trim();let l;switch(o){case"m":case"M":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)h===0?e.push({type:o,x:l[h],y:l[h+1]}):e.push({type:o==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=ue(a);for(let h=0,c=l.length;h<c;h++)e.push({type:o,x:l[h]});break;case"v":case"V":l=ue(a);for(let h=0,c=l.length;h<c;h++)e.push({type:o,y:l[h]});break;case"l":case"L":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:o,x:l[h],y:l[h+1]});break;case"c":case"C":l=ue(a);for(let h=0,c=l.length;h<c;h+=6)e.push({type:o,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=ue(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:o,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=ue(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:o,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:o,x:l[h],y:l[h+1]});break;case"a":case"A":l=ue(a,[3,4],7);for(let h=0,c=l.length;h<c;h+=7)e.push({type:o,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":e.push({type:o});break;default:console.warn(s)}}return e}class Ge{constructor(){d(this,"arcLengthDivisions",200);d(this,"_cacheArcLengths");d(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),r=this.getPoint(1);return(t.x-e.x)*(r.y-t.y)-(t.y-e.y)*(r.x-t.x)<0}getPointAt(e,t=new D){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,h;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),h=r[i]-o,h<0)a=i+1;else if(h>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const c=r[i],f=r[i+1]-c,p=(o-c)/f;return(i+p)/(s-1)}getTangent(e,t=new D){const i=Math.max(0,e-1e-4),s=Math.min(1,e+1e-4);return t.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new D){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let r=0,i=1,s=(r+i)/2;for(;i-r>t;){s=(r+i)/2;const o=this.getPoint(s);if(o.distanceTo(e)<t)return s;o.x<e.x?r=s:i=s}return s}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=D.MAX,t=D.MIN){return this.getPoints().forEach(r=>{e.min(r),t.max(r)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new K(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return Ic(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}function Jo(n,e,t,r,i){const s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function Rc(n,e){const t=1-n;return t*t*e}function Bc(n,e){return 2*(1-n)*n*e}function Lc(n,e){return n*n*e}function ta(n,e,t,r){return Rc(n,e)+Bc(n,t)+Lc(n,r)}function kc(n,e){const t=1-n;return t*t*t*e}function Nc(n,e){const t=1-n;return 3*t*t*n*e}function Fc(n,e){return 3*(1-n)*n*n*e}function $c(n,e){return n*n*n*e}function ea(n,e,t,r,i){return kc(n,e)+Nc(n,t)+Fc(n,r)+$c(n,i)}class zc extends Ge{constructor(e=new D,t=new D,r=new D,i=new D){super(),this.start=e,this.startControl=t,this.endControl=r,this.end=i}getPoint(e,t=new D){const{start:r,startControl:i,endControl:s,end:o}=this;return t.set(ea(e,r.x,i.x,s.x,o.x),ea(e,r.y,i.y,s.y,o.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,r){const i=t*t-4*e*r;if(i<0)return[];const s=Math.sqrt(i),o=(-t+s)/(2*e),a=(-t-s)/(2*e);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(e=D.MAX,t=D.MIN){const r=this.start,i=this.startControl,s=this.endControl,o=this.end,a=this._solveQuadratic(3*(i.x-r.x),6*(s.x-i.x),3*(o.x-s.x)),l=this._solveQuadratic(3*(i.y-r.y),6*(s.y-i.y),3*(o.y-s.y)),h=[0,1,...a,...l];return((u,f)=>{for(const p of u)for(let y=0;y<=f;y++){const _=y/f-.5,m=Math.min(1,Math.max(0,p+_)),b=this.getPoint(m);e.x=Math.min(e.x,b.x),e.y=Math.min(e.y,b.y),t.x=Math.max(t.x,b.x),t.y=Math.max(t.y,b.y)}})(h,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:r,end:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:r.x,y2:r.y,x:i.x,y:i.y}]}drawTo(e){const{start:t,startControl:r,endControl:i,end:s}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Vc=new $t,ra=new $t,ia=new $t,Ei=new D;class Xc extends Ge{constructor(e=new D,t=1,r=1,i=0,s=0,o=Math.PI*2,a=!1){super(),this.center=e,this.radiusX=t,this.radiusY=r,this.rotation=i,this.startAngle=s,this.endAngle=o,this.clockwise=a}isClockwise(){return this.clockwise}getPoint(e,t=new D){const r=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(s?i=0:i=r),this.clockwise&&!s&&(i===r?i=-r:i=i-r);const o=this.startAngle+e*i;let a=this.center.x+this.radiusX*Math.cos(o),l=this.center.y+this.radiusY*Math.sin(o);if(this.rotation!==0){const h=Math.cos(this.rotation),c=Math.sin(this.rotation),u=a-this.center.x,f=l-this.center.y;a=u*h-f*c+this.center.x,l=u*c+f*h+this.center.y}return t.set(a,l)}toCommands(){const{center:e,radiusX:t,radiusY:r,startAngle:i,endAngle:s,clockwise:o,rotation:a}=this,{x:l,y:h}=e,c=l+t*Math.cos(i)*Math.cos(a)-r*Math.sin(i)*Math.sin(a),u=h+t*Math.cos(i)*Math.sin(a)+r*Math.sin(i)*Math.cos(a),f=Math.abs(i-s),p=f>Math.PI?1:0,y=o?1:0,_=a*180/Math.PI;if(f>=2*Math.PI){const m=i+Math.PI,b=l+t*Math.cos(m)*Math.cos(a)-r*Math.sin(m)*Math.sin(a),w=h+t*Math.cos(m)*Math.sin(a)+r*Math.sin(m)*Math.cos(a);return[{type:"M",x:c,y:u},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:0,sweepFlag:y,x:b,y:w},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:0,sweepFlag:y,x:c,y:u}]}else{const m=l+t*Math.cos(s)*Math.cos(a)-r*Math.sin(s)*Math.sin(a),b=h+t*Math.cos(s)*Math.sin(a)+r*Math.sin(s)*Math.cos(a);return[{type:"M",x:c,y:u},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:p,sweepFlag:y,x:m,y:b}]}}drawTo(e){const{center:t,radiusX:r,radiusY:i,rotation:s,startAngle:o,endAngle:a,clockwise:l}=this;return e.ellipse(t.x,t.y,r,i,s,o,a,!l),this}matrix(e){return Ei.set(this.center.x,this.center.y),Ei.applyMatrix3(e),this.center.x=Ei.x,this.center.y=Ei.y,qc(e)?jc(this,e):Gc(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=D.MAX,t=D.MIN){const{center:r,radiusX:i,radiusY:s,rotation:o}=this,{x:a,y:l}=r,h=Math.cos(o),c=Math.sin(o),u=Math.sqrt(i*i*h*h+s*s*c*c),f=Math.sqrt(i*i*c*c+s*s*h*h);return e.x=Math.min(e.x,a-u),e.y=Math.min(e.y,l-f),t.x=Math.max(t.x,a+u),t.y=Math.max(t.y,l+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function jc(n,e){const t=n.radiusX,r=n.radiusY,i=Math.cos(n.rotation),s=Math.sin(n.rotation),o=new D(t*i,t*s),a=new D(-r*s,r*i),l=o.applyMatrix3(e),h=a.applyMatrix3(e),c=Vc.set(l.x,h.x,0,l.y,h.y,0,0,0,1),u=ra.copy(c).invert(),y=ia.copy(u).transpose().multiply(u).elements,_=Yc(y[0],y[1],y[4]),m=Math.sqrt(_.rt1),b=Math.sqrt(_.rt2);if(n.radiusX=1/m,n.radiusY=1/b,n.rotation=Math.atan2(_.sn,_.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const x=ra.set(m,0,0,0,b,0,0,0,1),C=ia.set(_.cs,_.sn,0,-_.sn,_.cs,0,0,0,1),P=x.multiply(C).multiply(c),E=A=>{const{x:S,y:T}=new D(Math.cos(A),Math.sin(A)).applyMatrix3(P);return Math.atan2(T,S)};n.startAngle=E(n.startAngle),n.endAngle=E(n.endAngle),sa(e)&&(n.clockwise=!n.clockwise)}}function Gc(n,e){const t=na(e),r=oa(e);n.radiusX*=t,n.radiusY*=r;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);n.rotation+=i,sa(e)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function sa(n){const e=n.elements;return e[0]*e[4]-e[1]*e[3]<0}function qc(n){const e=n.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const r=na(n),i=oa(n);return Math.abs(t/(r*i))>Number.EPSILON}function na(n){const e=n.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function oa(n){const e=n.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Yc(n,e,t){let r,i,s,o,a;const l=n+t,h=n-t,c=Math.sqrt(h*h+4*e*e);return l>0?(r=.5*(l+c),a=1/r,i=n*a*t-e*a*e):l<0?i=.5*(l-c):(r=.5*c,i=-.5*c),h>0?s=h+c:s=h-c,Math.abs(s)>2*Math.abs(e)?(a=-2*e/s,o=1/Math.sqrt(1+a*a),s=a*o):Math.abs(e)===0?(s=1,o=0):(a=-.5*s/e,s=1/Math.sqrt(1+a*a),o=a*s),h>0&&(a=s,s=-o,o=a),{rt1:r,rt2:i,cs:s,sn:o}}class js extends Ge{constructor(e=new D,t=new D){super(),this.start=e,this.end=t}getPoint(e,t=new D){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new D){return this.getPoint(e,t)}getTangent(e,t=new D){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new D){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=D.MAX,t=D.MIN){const{start:r,end:i}=this;return e.x=Math.min(e.x,r.x,i.x),e.y=Math.min(e.y,r.y,i.y),t.x=Math.max(t.x,r.x,i.x),t.y=Math.max(t.y,r.y,i.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:r}=this;return e.lineTo(t.x,t.y),e.lineTo(r.x,r.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class Wc extends Ge{constructor(e=new D,t=new D,r=new D){super(),this.start=e,this.control=t,this.end=r}getPoint(e,t=new D){const{start:r,control:i,end:s}=this;return t.set(ta(e,r.x,i.x,s.x),ta(e,r.y,i.y,s.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=D.MAX,t=D.MIN){const{start:r,control:i,end:s}=this,o=.5*(r.x+i.x),a=.5*(r.y+i.y),l=.5*(r.x+s.x),h=.5*(r.y+s.y);return e.x=Math.min(e.x,r.x,s.x,o,l),e.y=Math.min(e.y,r.y,s.y,a,h),t.x=Math.max(t.x,r.x,s.x,o,l),t.y=Math.max(t.y,r.y,s.y,a,h),{min:e,max:t}}toCommands(){const{start:e,control:t,end:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:r.x,y:r.y}]}drawTo(e){const{start:t,control:r,end:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(r.x,r.y,i.x,i.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class Hc extends Ge{constructor(t,r,i=1,s=0,o=1){super();d(this,"curves",[]);d(this,"curveT",0);this.center=t,this.rx=r,this.aspectRatio=i,this.start=s,this.end=o,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:r}=this.center,i=this.rx,s=this.rx/this.aspectRatio,o=[new D(t-i,r-s),new D(t+i,r-s),new D(t+i,r+s),new D(t-i,r+s)];for(let a=0;a<4;a++)this.curves.push(new js(o[a].clone(),o[(a+1)%4].clone()));return this}getCurve(t){let r=(t*(this.end-this.start)+this.start)%1;r<0&&(r+=1),r*=(1+this.aspectRatio)*2;let i;return r<this.aspectRatio?(i=0,this.curveT=r/this.aspectRatio):r<this.aspectRatio+1?(i=1,this.curveT=(r-this.aspectRatio)/1):r<2*this.aspectRatio+1?(i=2,this.curveT=(r-this.aspectRatio-1)/this.aspectRatio):(i=3,this.curveT=(r-2*this.aspectRatio-1)/1),this.curves[i]}getPoint(t,r){return this.getCurve(t).getPoint(this.curveT,r)}getPointAt(t,r){return this.getPoint(t,r)}getTangent(t,r){return this.getCurve(t).getTangent(this.curveT,r)}getNormal(t,r){return this.getCurve(t).getNormal(this.curveT,r)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=D.MAX,r=D.MIN){return this.curves.forEach(i=>i.getMinMax(t,r)),{min:t,max:r}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(r=>r.drawTo(t)),this}}class Zc extends Ge{constructor(e=[]){super(),this.points=e}getPoint(e,t=new D){const{points:r}=this,i=(r.length-1)*e,s=Math.floor(i),o=i-s,a=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return t.set(Jo(o,a.x,l.x,h.x,c.x),Jo(o,a.y,l.y,h.y,c.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++)this.points.push(e.points[t].clone());return this}}class Br extends Ge{constructor(t){super();d(this,"curves",[]);d(this,"startPoint");d(this,"currentPoint");d(this,"autoClose",!1);d(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let r=1,i=t.length;r<i;r++){const{x:s,y:o}=t[r];this.lineTo(s,o)}return this}addCommands(t){return Ko(t,this),this}addData(t){return this.addCommands(Qo(t)),this}getPoint(t,r=new D){const i=t*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=i){const a=s[o]-i,l=this.curves[o],h=l.getLength();return l.getPointAt(h===0?0:1-a/h,r)}o++}return r}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let r=0;for(let i=0,s=this.curves.length;i<s;i++)r+=this.curves[i].getLength(),t.push(r);return this._cacheLengths=t,t}getSpacedPoints(t=40){const r=[];for(let i=0;i<=t;i++)r.push(this.getPoint(i/t));return this.autoClose&&r.push(r[0]),r}getPoints(t=12){const r=[],i=this.curves;let s;for(let o=0,a=i.length;o<a;o++){const h=i[o].getPoints(t);for(let c=0;c<h.length;c++){const u=h[c];s!=null&&s.equals(u)||(r.push(u),s=u)}}return this.autoClose&&r.length>1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r}_setCurrentPoint(t){return this.currentPoint=new D(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const r=this.currentPoint;r&&!t.equals(r)&&(this.curves.push(new js(r.clone(),t)),r.copy(t)),this.startPoint=void 0}return this}moveTo(t,r){return this.currentPoint=new D(t,r),this.startPoint=this.currentPoint.clone(),this}lineTo(t,r){const i=this.currentPoint;return i!=null&&i.equals({x:t,y:r})||this.curves.push(new js((i==null?void 0:i.clone())??new D,new D(t,r))),this._setCurrentPoint({x:t,y:r}),this}bezierCurveTo(t,r,i,s,o,a){const l=this.currentPoint;return l!=null&&l.equals({x:o,y:a})||this.curves.push(new zc((l==null?void 0:l.clone())??new D,new D(t,r),new D(i,s),new D(o,a))),this._setCurrentPoint({x:o,y:a}),this}quadraticCurveTo(t,r,i,s){const o=this.currentPoint;return o!=null&&o.equals({x:i,y:s})||this.curves.push(new Wc((o==null?void 0:o.clone())??new D,new D(t,r),new D(i,s))),this._setCurrentPoint({x:i,y:s}),this}arc(t,r,i,s,o,a){return this.ellipse(t,r,i,i,0,s,o,a),this}relativeArc(t,r,i,s,o,a){const l=this.currentPoint??new D;return this.arc(t+l.x,r+l.y,i,s,o,a),this}arcTo(t,r,i,s,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,r,i,s,o,a,l,h=!0){const c=new Xc(new D(t,r),i,s,o,a,l,!h);if(this.curves.length>0){const u=c.getPoint(0);(!this.currentPoint||!u.equals(this.currentPoint))&&this.lineTo(u.x,u.y)}return this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(t,r,i,s,o,a,l,h){const c=this.currentPoint??new D;return this.ellipse(t+c.x,r+c.y,i,s,o,a,l,h),this}rect(t,r,i,s){return this.curves.push(new Hc(new D(t+i/2,r+s/2),i/2,i/s)),this._setCurrentPoint({x:t,y:r}),this}splineThru(t){const r=this.currentPoint??new D;return this.curves.push(new Zc([r].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=D.MAX,r=D.MIN){return this.curves.forEach(i=>i.getMinMax(t,r)),{min:t,max:r}}getBoundingBox(){const{min:t,max:r}=this.getMinMax();return new K(t.x,t.y,r.x-t.x,r.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var i;const r=(i=this.curves[0])==null?void 0:i.getPoint(0);return r&&t.moveTo(r.x,r.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var r;super.copy(t),this.curves=[];for(let i=0,s=t.curves.length;i<s;i++)this.curves.push(t.curves[i].clone());return this.autoClose=t.autoClose,this.currentPoint=(r=t.currentPoint)==null?void 0:r.clone(),this}}function Kc(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Qc(n,e,t,r){const i=e.clone().sub(n),s=r.clone().sub(t),o=t.clone().sub(n),a=i.cross(s);if(a===0)return new D((n.x+t.x)/2,(n.y+t.y)/2);const l=o.cross(s)/a;return Math.abs(l)>1?new D((n.x+t.x)/2,(n.y+t.y)/2):new D(n.x+l*i.x,n.y+l*i.y)}class zt{constructor(e,t={}){d(this,"currentPath",new Br);d(this,"paths",[this.currentPath]);d(this,"style");e&&(e instanceof zt?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e)),this.style=t}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof zt?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new Br().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:r,curves:i}=this.currentPath;return r!=null&&r.equals({x:e,y:t})||(i.length?(this.currentPath=new Br().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}arc(e,t,r,i,s,o){return this.currentPath.arc(e,t,r,i,s,o),this}arcTo(e,t,r,i,s){return this.currentPath.arcTo(e,t,r,i,s),this}ellipse(e,t,r,i,s,o,a,l){return this.currentPath.ellipse(e,t,r,i,s,o,a,l),this}rect(e,t,r,i){return this.currentPath.rect(e,t,r,i),this}addCommands(e){return Ko(e,this),this}addData(e){return this.addCommands(Qo(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,r={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.scale(e,t,r)}),this}skew(e,t=0,r={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.skew(e,t,r)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(r=>{r.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),r=[],i=[],s=[];t.forEach((a,l)=>{const h=a.getControlPoints(),c=a.isClockwise();s[l]=h,i[l]=c;const u=h[0],f=h[h.length-1]??u;r.push({start:c?f:u,end:c?u:f,index:l})});const o=[];return r.forEach((a,l)=>{o[l]=[],r.forEach((h,c)=>{c!==l&&h.start.equals(a.end)&&o[l].push(h.index)})}),t.forEach((a,l)=>{const h=i[l];s[l].forEach(u=>{const f=a.getTForPoint(u),p=a.getNormal(f).scale(h?e:-e);u.add(p)})}),o.forEach((a,l)=>{const h=s[l];a.forEach(c=>{const u=s[c],f=Qc(h[h.length-1],h[h.length-2]??h[h.length-1],u[0],u[1]??u[0]);f&&(h[h.length-1].copy(f),u[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=D.MAX,t=D.MIN,r=!0){const i=this.strokeWidth;return this.getCurves().forEach(s=>{if(s.getMinMax(e,t),r&&i>1){const o=i/2,a=s.isClockwise(),l=[];for(let h=0;h<=1;h+=1/s.arcLengthDivisions){const c=s.getPoint(h),u=s.getNormal(h),f=u.clone().scale(a?o:-o),p=u.clone().scale(a?-o:o);l.push(c.clone().add(f),c.clone().add(p),c.clone().add({x:o,y:0}),c.clone().add({x:-o,y:0}),c.clone().add({x:0,y:o}),c.clone().add({x:0,y:-o}),c.clone().add({x:o,y:o}),c.clone().add({x:-o,y:-o}))}e.min(...l),t.max(...l)}}),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:r}=this.getMinMax(void 0,void 0,e);return new K(t.x,t.y,r.x-t.x,r.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Vs(e,t),this.paths.forEach(s=>{s.drawTo(e)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Vs(e,t),this.getControlPoints().forEach(s=>{e.moveTo(s.x,s.y),e.arc(s.x,s.y,4,0,Math.PI*2)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSVGPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[Kc(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const i in t)t[i]!==void 0&&(r+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${r}"></path>`}toSVGString(){const{x:e,y:t,width:r,height:i}=this.getBoundingBox(),s=this.toSVGPathString();return`<svg viewBox="${e} ${t} ${r} ${i}" width="${r}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...r}=e,{left:i,top:s,width:o,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=o*t,l.height=a*t,l.style.width=`${o}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(t,t),h.translate(-i,-s),this.drawTo(h,r)),l}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Jc="px",tu=90,aa=["mm","cm","in","pt","pc","px"],la={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function J(n){let e="px";if(typeof n=="string"||n instanceof String)for(let r=0,i=aa.length;r<i;r++){const s=aa[r];if(n.endsWith(s)){e=s,n=n.substring(0,n.length-s.length);break}}let t;return t=la[e][Jc],t<0&&(t=la[e].in*tu),t*Number.parseFloat(n)}const eu=new $t,Mi=new $t,ha=new $t,ca=new $t;function ru(n,e,t){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const r=iu(n);return t.length>0&&r.premultiply(t[t.length-1]),e.copy(r),t.push(r),r}function iu(n){const e=new $t,t=eu;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&e.translate(J(n.getAttribute("x")),J(n.getAttribute("y"))),n.hasAttribute("transform")){const r=n.getAttribute("transform").split(")");for(let i=r.length-1;i>=0;i--){const s=r[i].trim();if(s==="")continue;const o=s.indexOf("("),a=s.length;if(o>0&&o<a){const l=s.slice(0,o),h=ue(s.slice(o+1));switch(t.identity(),l){case"translate":if(h.length>=1){const c=h[0];let u=0;h.length>=2&&(u=h[1]),t.translate(c,u)}break;case"rotate":if(h.length>=1){let c=0,u=0,f=0;c=h[0]*Math.PI/180,h.length>=3&&(u=h[1],f=h[2]),Mi.makeTranslation(-u,-f),ha.makeRotation(c),ca.multiplyMatrices(ha,Mi),Mi.makeTranslation(u,f),t.multiplyMatrices(Mi,ca)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function su(n){return new zt().addPath(new Br().arc(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("r")||0),0,Math.PI*2))}function nu(n,e){if(!(!n.sheet||!n.sheet.cssRules||!n.sheet.cssRules.length))for(let t=0;t<n.sheet.cssRules.length;t++){const r=n.sheet.cssRules[t];if(r.type!==1)continue;const i=r.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim()),s={};for(let o=r.style.length,a=0;a<o;a++){const l=r.style.item(a);s[l]=r.style.getPropertyValue(l)}for(let o=0;o<i.length;o++)e[i[o]]=Object.assign(e[i[o]]||{},{...s})}}function ou(n){return new zt().addPath(new Br().ellipse(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("rx")||0),J(n.getAttribute("ry")||0),0,0,Math.PI*2))}function au(n){return new zt().moveTo(J(n.getAttribute("x1")||0),J(n.getAttribute("y1")||0)).lineTo(J(n.getAttribute("x2")||0),J(n.getAttribute("y2")||0))}function lu(n){const e=new zt,t=n.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const hu=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function cu(n){var r;const e=new zt;let t=0;return(r=n.getAttribute("points"))==null||r.replace(hu,(i,s,o)=>{const a=J(s),l=J(o);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,i}),e.currentPath.autoClose=!0,e}const uu=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function fu(n){var r;const e=new zt;let t=0;return(r=n.getAttribute("points"))==null||r.replace(uu,(i,s,o)=>{const a=J(s),l=J(o);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,i}),e.currentPath.autoClose=!1,e}function du(n){const e=J(n.getAttribute("x")||0),t=J(n.getAttribute("y")||0),r=J(n.getAttribute("rx")||n.getAttribute("ry")||0),i=J(n.getAttribute("ry")||n.getAttribute("rx")||0),s=J(n.getAttribute("width")),o=J(n.getAttribute("height")),a=1-.551915024494,l=new zt;return l.moveTo(e+r,t),l.lineTo(e+s-r,t),(r!==0||i!==0)&&l.bezierCurveTo(e+s-r*a,t,e+s,t+i*a,e+s,t+i),l.lineTo(e+s,t+o-i),(r!==0||i!==0)&&l.bezierCurveTo(e+s,t+o-i*a,e+s-r*a,t+o,e+s-r,t+o),l.lineTo(e+r,t+o),(r!==0||i!==0)&&l.bezierCurveTo(e+r*a,t+o,e,t+o-i*a,e,t+o-i),l.lineTo(e,t+i),(r!==0||i!==0)&&l.bezierCurveTo(e,t+i*a,e+r*a,t,e+r,t),l}function fe(n,e,t){e=Object.assign({},e);let r={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)r=Object.assign(r,t[`.${h[c]}`])}n.hasAttribute("id")&&(r=Object.assign(r,t[`#${n.getAttribute("id")}`]));for(let h=n.style.length,c=0;c<h;c++){const u=n.style.item(c),f=n.style.getPropertyValue(u);e[u]=f,r[u]=f}function i(h,c,u=s){n.hasAttribute(h)&&(e[c]=u(n.getAttribute(h))),r[h]&&(e[c]=u(r[h]))}function s(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function o(h){return Math.max(0,Math.min(1,J(h)))}function a(h){return Math.max(0,J(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>J(c))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",a),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",a),i("stroke-dasharray","strokeDasharray",l),i("stroke-dashoffset","strokeDashoffset",J),i("visibility","visibility"),e}function Gs(n,e,t=[],r={}){var u;if(n.nodeType!==1)return t;let i=!1,s=null,o={...e};switch(n.nodeName){case"svg":o=fe(n,o,r);break;case"style":nu(n,r);break;case"g":o=fe(n,o,r);break;case"path":o=fe(n,o,r),n.hasAttribute("d")&&(s=lu(n));break;case"rect":o=fe(n,o,r),s=du(n);break;case"polygon":o=fe(n,o,r),s=cu(n);break;case"polyline":o=fe(n,o,r),s=fu(n);break;case"circle":o=fe(n,o,r),s=su(n);break;case"ellipse":o=fe(n,o,r),s=ou(n);break;case"line":o=fe(n,o,r),s=au(n);break;case"defs":i=!0;break;case"use":{o=fe(n,o,r);const p=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),y=(u=n.viewportElement)==null?void 0:u.getElementById(p);y?Gs(y,o,t,r):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(n);break}if(o.display==="none")return t;Object.assign(e,o);const a=new $t,l=[],h=ru(n,a,l);s&&(s.matrix(a),t.push(s),s.style=e);const c=n.childNodes;for(let f=0,p=c.length;f<p;f++){const y=c[f];i&&y.nodeName!=="style"&&y.nodeName!=="defs"||Gs(y,e,t,r)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}const ua="data:image/svg+xml;",fa=`${ua}base64,`,da=`${ua}charset=utf8,`;function pa(n){if(typeof n=="string"){let e;n.startsWith(fa)?(n=n.substring(fa.length,n.length),e=atob(n)):n.startsWith(da)?(n=n.substring(da.length,n.length),e=decodeURIComponent(n)):e=n;const t=new DOMParser().parseFromString(e,"text/xml"),r=t.querySelector("parsererror");if(r)throw new Error(`${r.textContent??"parser error"}
27
+ ${e}`);return t.documentElement}else return n}function ga(n){return Gs(pa(n),{})}function Lr(n,e=!0){if(!n.length)return;const t=D.MAX,r=D.MIN;return n.forEach(i=>i.getMinMax(t,r,e)),new K(t.x,t.y,r.x-t.x,r.y-t.y)}function pu(){return{overflow:"visible",visibility:"visible",filter:"none",left:0,top:0,width:0,height:0,rotate:0,opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"50% 50%",backgroundImage:"none",backgroundColor:"transparent",shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,borderRadius:0,borderColor:"transparent",borderWidth:1}}function gu(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%",scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"50% 50%",shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function mu(){return{...pu(),...gu()}}var St=Uint8Array,Yt=Uint16Array,qs=Int32Array,Si=new St([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ai=new St([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ys=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ma=function(n,e){for(var t=new Yt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];for(var i=new qs(t[30]),r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return{b:t,r:i}},ya=ma(Si,2),_a=ya.b,Ws=ya.r;_a[28]=258,Ws[258]=28;for(var va=ma(Ai,0),yu=va.b,ba=va.r,Hs=new Yt(32768),rt=0;rt<32768;++rt){var Oe=(rt&43690)>>1|(rt&21845)<<1;Oe=(Oe&52428)>>2|(Oe&13107)<<2,Oe=(Oe&61680)>>4|(Oe&3855)<<4,Hs[rt]=((Oe&65280)>>8|(Oe&255)<<8)>>1}for(var de=function(n,e,t){for(var r=n.length,i=0,s=new Yt(e);i<r;++i)n[i]&&++s[n[i]-1];var o=new Yt(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new Yt(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var h=i<<4|n[i],c=e-n[i],u=o[n[i]-1]++<<c,f=u|(1<<c)-1;u<=f;++u)a[Hs[u]>>l]=h}else for(a=new Yt(r),i=0;i<r;++i)n[i]&&(a[i]=Hs[o[n[i]-1]++]>>15-n[i]);return a},Ue=new St(288),rt=0;rt<144;++rt)Ue[rt]=8;for(var rt=144;rt<256;++rt)Ue[rt]=9;for(var rt=256;rt<280;++rt)Ue[rt]=7;for(var rt=280;rt<288;++rt)Ue[rt]=8;for(var kr=new St(32),rt=0;rt<32;++rt)kr[rt]=5;var _u=de(Ue,9,0),vu=de(Ue,9,1),bu=de(kr,5,0),xu=de(kr,5,1),Zs=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},se=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},Ks=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Qs=function(n){return(n+7)/8|0},xa=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new St(n.subarray(e,t))},wu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ne=function(n,e,t){var r=new Error(e||wu[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,ne),!t)throw r;return r},Pu=function(n,e,t,r){var i=n.length,s=0;if(!i||e.f&&!e.l)return t||new St(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new St(i*3));var h=function(Kt){var kt=t.length;if(Kt>kt){var Xt=new St(Math.max(kt*2,Kt));Xt.set(t),t=Xt}},c=e.f||0,u=e.p||0,f=e.b||0,p=e.l,y=e.d,_=e.m,m=e.n,b=i*8;do{if(!p){c=se(n,u,1);var w=se(n,u+1,3);if(u+=3,w)if(w==1)p=vu,y=xu,_=9,m=5;else if(w==2){var E=se(n,u,31)+257,A=se(n,u+10,15)+4,S=E+se(n,u+5,31)+1;u+=14;for(var T=new St(S),O=new St(19),$=0;$<A;++$)O[Ys[$]]=se(n,u+$*3,7);u+=A*3;for(var N=Zs(O),B=(1<<N)-1,M=de(O,N,1),$=0;$<S;){var L=M[se(n,u,B)];u+=L&15;var x=L>>4;if(x<16)T[$++]=x;else{var F=0,X=0;for(x==16?(X=3+se(n,u,3),u+=2,F=T[$-1]):x==17?(X=3+se(n,u,7),u+=3):x==18&&(X=11+se(n,u,127),u+=7);X--;)T[$++]=F}}var q=T.subarray(0,E),I=T.subarray(E);_=Zs(q),m=Zs(I),p=de(q,_,1),y=de(I,m,1)}else ne(1);else{var x=Qs(u)+4,C=n[x-4]|n[x-3]<<8,P=x+C;if(P>i){l&&ne(0);break}a&&h(f+C),t.set(n.subarray(x,P),f),e.b=f+=C,e.p=u=P*8,e.f=c;continue}if(u>b){l&&ne(0);break}}a&&h(f+131072);for(var R=(1<<_)-1,k=(1<<m)-1,z=u;;z=u){var F=p[Ks(n,u)&R],Y=F>>4;if(u+=F&15,u>b){l&&ne(0);break}if(F||ne(2),Y<256)t[f++]=Y;else if(Y==256){z=u,p=null;break}else{var H=Y-254;if(Y>264){var $=Y-257,j=Si[$];H=se(n,u,(1<<j)-1)+_a[$],u+=j}var Q=y[Ks(n,u)&k],tt=Q>>4;Q||ne(3),u+=Q&15;var I=yu[tt];if(tt>3){var j=Ai[tt];I+=Ks(n,u)&(1<<j)-1,u+=j}if(u>b){l&&ne(0);break}a&&h(f+131072);var st=f+H;if(f<I){var Zt=s-I,me=Math.min(I,st);for(Zt+f<0&&ne(3);f<me;++f)t[f]=r[Zt+f]}for(;f<st;++f)t[f]=t[f-I]}}e.l=p,e.p=z,e.b=f,e.f=c,p&&(c=1,e.m=_,e.d=y,e.n=m)}while(!c);return f!=t.length&&o?xa(t,0,f):t.subarray(0,f)},Pe=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8},Nr=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},Js=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return{t:Ta,l:0};if(i==1){var o=new St(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(P,E){return P.f-E.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],h=0,c=1,u=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=t[t[h].f<t[u].f?h++:u++],l=t[h!=c&&t[h].f<t[u].f?h++:u++],t[c++]={s:-1,f:a.f+l.f,l:a,r:l};for(var f=s[0].s,r=1;r<i;++r)s[r].s>f&&(f=s[r].s);var p=new Yt(f+1),y=tn(t[c-1],p,0);if(y>e){var r=0,_=0,m=y-e,b=1<<m;for(s.sort(function(E,A){return p[A.s]-p[E.s]||E.f-A.f});r<i;++r){var w=s[r].s;if(p[w]>e)_+=b-(1<<y-p[w]),p[w]=e;else break}for(_>>=m;_>0;){var x=s[r].s;p[x]<e?_-=1<<e-p[x]++-1:++r}for(;r>=0&&_;--r){var C=s[r].s;p[C]==e&&(--p[C],++_)}y=e}return{t:new St(p),l:y}},tn=function(n,e,t){return n.s==-1?Math.max(tn(n.l,e,t+1),tn(n.r,e,t+1)):e[n.s]=t},wa=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new Yt(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return{c:t.subarray(0,r),n:e}},Fr=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},Pa=function(n,e,t){var r=t.length,i=Qs(e+2);n[i]=r&255,n[i+1]=r>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s<r;++s)n[i+s+4]=t[s];return(i+4+r)*8},Ca=function(n,e,t,r,i,s,o,a,l,h,c){Pe(e,c++,t),++i[256];for(var u=Js(i,15),f=u.t,p=u.l,y=Js(s,15),_=y.t,m=y.l,b=wa(f),w=b.c,x=b.n,C=wa(_),P=C.c,E=C.n,A=new Yt(19),S=0;S<w.length;++S)++A[w[S]&31];for(var S=0;S<P.length;++S)++A[P[S]&31];for(var T=Js(A,7),O=T.t,$=T.l,N=19;N>4&&!O[Ys[N-1]];--N);var B=h+5<<3,M=Fr(i,Ue)+Fr(s,kr)+o,L=Fr(i,f)+Fr(s,_)+o+14+3*N+Fr(A,O)+2*A[16]+3*A[17]+7*A[18];if(l>=0&&B<=M&&B<=L)return Pa(e,c,n.subarray(l,l+h));var F,X,q,I;if(Pe(e,c,1+(L<M)),c+=2,L<M){F=de(f,p,0),X=f,q=de(_,m,0),I=_;var R=de(O,$,0);Pe(e,c,x-257),Pe(e,c+5,E-1),Pe(e,c+10,N-4),c+=14;for(var S=0;S<N;++S)Pe(e,c+3*S,O[Ys[S]]);c+=3*N;for(var k=[w,P],z=0;z<2;++z)for(var Y=k[z],S=0;S<Y.length;++S){var H=Y[S]&31;Pe(e,c,R[H]),c+=O[H],H>15&&(Pe(e,c,Y[S]>>5&127),c+=Y[S]>>12)}}else F=_u,X=Ue,q=bu,I=kr;for(var S=0;S<a;++S){var j=r[S];if(j>255){var H=j>>18&31;Nr(e,c,F[H+257]),c+=X[H+257],H>7&&(Pe(e,c,j>>23&31),c+=Si[H]);var Q=j&31;Nr(e,c,q[Q]),c+=I[Q],Q>3&&(Nr(e,c,j>>5&8191),c+=Ai[Q])}else Nr(e,c,F[j]),c+=X[j]}return Nr(e,c,F[256]),c+X[256]},Cu=new qs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ta=new St(0),Tu=function(n,e,t,r,i,s){var o=s.z||n.length,a=new St(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),h=s.l,c=(s.r||0)&7;if(e){c&&(l[0]=s.r>>3);for(var u=Cu[e-1],f=u>>13,p=u&8191,y=(1<<t)-1,_=s.p||new Yt(32768),m=s.h||new Yt(y+1),b=Math.ceil(t/3),w=2*b,x=function(ye){return(n[ye]^n[ye+1]<<b^n[ye+2]<<w)&y},C=new qs(25e3),P=new Yt(288),E=new Yt(32),A=0,S=0,T=s.i||0,O=0,$=s.w||0,N=0;T+2<o;++T){var B=x(T),M=T&32767,L=m[B];if(_[M]=L,m[B]=M,$<=T){var F=o-T;if((A>7e3||O>24576)&&(F>423||!h)){c=Ca(n,l,0,C,P,E,S,O,N,T-N,c),O=A=S=0,N=T;for(var X=0;X<286;++X)P[X]=0;for(var X=0;X<30;++X)E[X]=0}var q=2,I=0,R=p,k=M-L&32767;if(F>2&&B==x(T-k))for(var z=Math.min(f,F)-1,Y=Math.min(32767,T),H=Math.min(258,F);k<=Y&&--R&&M!=L;){if(n[T+q]==n[T+q-k]){for(var j=0;j<H&&n[T+j]==n[T+j-k];++j);if(j>q){if(q=j,I=k,j>z)break;for(var Q=Math.min(k,j-2),tt=0,X=0;X<Q;++X){var st=T-k+X&32767,Zt=_[st],me=st-Zt&32767;me>tt&&(tt=me,L=st)}}}M=L,L=_[M],k+=M-L&32767}if(I){C[O++]=268435456|Ws[q]<<18|ba[I];var Kt=Ws[q]&31,kt=ba[I]&31;S+=Si[Kt]+Ai[kt],++P[257+Kt],++E[kt],$=T+q,++A}else C[O++]=n[T],++P[n[T]]}}for(T=Math.max(T,$);T<o;++T)C[O++]=n[T],++P[n[T]];c=Ca(n,l,h,C,P,E,S,O,N,T-N,c),h||(s.r=c&7|l[c/8|0]<<3,c-=7,s.h=m,s.p=_,s.i=T,s.w=$)}else{for(var T=s.w||0;T<o+h;T+=65535){var Xt=T+65535;Xt>=o&&(l[c/8|0]=h,Xt=o),c=Pa(l,c+1,n.subarray(T,Xt))}s.i=o}return xa(a,0,r+Qs(c)+i)},Ea=function(){var n=1,e=0;return{p:function(t){for(var r=n,i=e,s=t.length|0,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}n=r,e=i},d:function(){return n%=65521,e%=65521,(n&255)<<24|(n&65280)<<8|(e&255)<<8|e>>8}}},Eu=function(n,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new St(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return Tu(n,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+e.mem,t,r,i)},Ma=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},Mu=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(n[0]=120,n[1]=r<<6|(e.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,e.dictionary){var i=Ea();i.p(e.dictionary),Ma(n,2,i.d())}},Su=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&ne(6,"invalid zlib data"),(n[1]>>5&1)==+!e&&ne(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Au(n,e){e||(e={});var t=Ea();t.p(n);var r=Eu(n,e,e.dictionary?6:2,4);return Mu(r,e),Ma(r,r.length-4,t.d()),r}function Ou(n,e){return Pu(n.subarray(Su(n,e),-4),{i:2},e,e)}var Uu=typeof TextDecoder<"u"&&new TextDecoder,Iu=0;try{Uu.decode(Ta,{stream:!0}),Iu=1}catch{}const Du="modern-font";function $r(n,e){if(!n)throw new Error(`[${Du}] ${e}`)}function Ru(n){if("buffer"in n){const e=n.buffer;return n.byteOffset>0||n.byteLength<n.buffer.byteLength?e.slice(n.byteOffset,n.byteOffset+n.byteLength):e}else return n}function fr(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Bu(n){let e="";for(let t=0,r=n.length,i;t<r;t++)i=n.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function Oi(n){n=Bu(n);const e=[];for(let t=0,r=n.length,i;t<r;t++)i=n.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Lu(n){let e="";for(let t=0,r=n.length;t<r;t++)n[t]<127?e+=String.fromCharCode(n[t]):e+=`%${(256+n[t]).toString(16).slice(1)}`;return unescape(e)}function ku(n){let e="";for(let t=0,r=n.length;t<r;t+=2)e+=String.fromCharCode((n[t]<<8)+n[t+1]);return e}var Nu=Object.defineProperty,At=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Nu(e,t,i),i};const zr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ot(){return function(n,e){Object.defineProperty(n.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class vt extends DataView{constructor(t,r,i,s){super(Ru(t),r,i);d(this,"cursor",0);this.littleEndian=s}readColumn(t){if(t.size){const r=Array.from({length:t.size},(i,s)=>this.read(t.type,t.offset+s));switch(t.type){case"char":return r.join("");default:return r}}else return this.read(t.type,t.offset)}writeColumn(t,r){t.size?Array.from({length:t.size},(i,s)=>{this.write(t.type,r[s],t.offset+s)}):this.write(t.type,r,t.offset)}read(t,r=this.cursor,i=this.littleEndian){var h;switch(t){case"char":return this.readChar(r);case"fixed":return this.readFixed(r,i);case"longDateTime":return this.readLongDateTime(r,i)}const s=`get${t.replace(/^\S/,c=>c.toUpperCase())}`,o=this,a=(h=o[s])==null?void 0:h.bind(o),l=a==null?void 0:a(r,i);return this.cursor+=zr[t],l}readUint24(t=this.cursor){const[r,i,s]=this.readBytes(t,3);return(r<<16)+(i<<8)+s}readBytes(t,r){r==null&&(r=t,t=this.cursor);const i=[];for(let s=0;s<r;++s)i.push(this.getUint8(t+s));return this.cursor=t+r,i}readString(t,r){const i=this.readBytes(t,r);let s="";for(let o=0,a=i.length;o<a;o++)s+=String.fromCharCode(i[o]);return s}readFixed(t,r){const i=this.readInt32(t,r)/65536;return Math.ceil(i*1e5)/1e5}readLongDateTime(t=this.cursor,r){const i=this.readUint32(t+4,r),s=new Date;return s.setTime(i*1e3+-20775456e5),s}readChar(t){return this.readString(t,1)}write(t,r,i=this.cursor,s=this.littleEndian){var c;switch(t){case"char":return this.writeChar(r,i);case"fixed":return this.writeFixed(r,i);case"longDateTime":return this.writeLongDateTime(r,i)}const o=`set${t.replace(/^\S/,u=>u.toUpperCase())}`,a=this,l=(c=a[o])==null?void 0:c.bind(a),h=l==null?void 0:l(i,r,s);return this.cursor+=zr[t.toLowerCase()],h}writeString(t="",r=this.cursor){const i=t.replace(/[^\x00-\xFF]/g,"11").length;this.seek(r);for(let s=0,o=t.length,a;s<o;++s)a=t.charCodeAt(s)||0,a>127?this.writeUint16(a):this.writeUint8(a);return this.cursor+=i,this}writeChar(t,r){return this.writeString(t,r)}writeFixed(t,r){return this.writeInt32(Math.round(t*65536),r),this}writeLongDateTime(t,r=this.cursor){typeof t>"u"?t=-20775456e5:typeof t.getTime=="function"?t=t.getTime():/^\d+$/.test(t)?t=+t:t=Date.parse(t);const s=Math.round((t- -20775456e5)/1e3);return this.writeUint32(0,r),this.writeUint32(s,r+4),this}writeBytes(t,r=this.cursor){let i;if(Array.isArray(t)){i=t.length;for(let s=0;s<i;++s)this.setUint8(r+s,t[s])}else{const s=fr(t);i=s.byteLength;for(let o=0;o<i;++o)this.setUint8(r+o,s.getUint8(o))}return this.cursor=r+i,this}seek(t){return this.cursor=t,this}}At([Ot()],vt.prototype,"readInt8"),At([Ot()],vt.prototype,"readInt16"),At([Ot()],vt.prototype,"readInt32"),At([Ot()],vt.prototype,"readUint8"),At([Ot()],vt.prototype,"readUint16"),At([Ot()],vt.prototype,"readUint32"),At([Ot()],vt.prototype,"readFloat32"),At([Ot()],vt.prototype,"readFloat64"),At([Ot()],vt.prototype,"writeInt8"),At([Ot()],vt.prototype,"writeInt16"),At([Ot()],vt.prototype,"writeInt32"),At([Ot()],vt.prototype,"writeUint8"),At([Ot()],vt.prototype,"writeUint16"),At([Ot()],vt.prototype,"writeUint32"),At([Ot()],vt.prototype,"writeFloat32"),At([Ot()],vt.prototype,"writeFloat64");const Sa=new WeakMap;function v(n){const e=typeof n=="object"?n:{type:n},{size:t=1,type:r}=e;return(i,s)=>{if(typeof s!="string")return;let o=Sa.get(i);o||(o={columns:[],byteLength:0},Sa.set(i,o));const a={...e,name:s,byteLength:t*zr[r],offset:e.offset??o.columns.reduce((l,h)=>l+h.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,h)=>l+zr[h.type]*(h.size??1),0),Object.defineProperty(i.constructor.prototype,s,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class Wt{constructor(e,t,r,i){d(this,"view");this.view=new vt(e,t,r,i)}}class Ui extends Wt{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Fu=Object.defineProperty,Dt=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Fu(e,t,i),i};const Rt=class Dl extends Ui{constructor(){super(...arguments);d(this,"format","EmbeddedOpenType");d(this,"mimeType","application/vnd.ms-fontobject")}static from(t){const r=t.sfnt,s=r.name.names,o=Oi(s.fontFamily||""),a=o.length,l=Oi(s.fontStyle||""),h=l.length,c=Oi(s.version||""),u=c.length,f=Oi(s.fullName||""),p=f.length,y=86+a+4+h+4+u+4+p+2+t.view.byteLength,_=new Dl(new ArrayBuffer(y),0,y,!0);_.EOTSize=_.view.byteLength,_.FontDataSize=t.view.byteLength,_.Version=131073,_.Flags=0,_.Charset=1,_.MagicNumber=20556,_.Padding1=0,_.CheckSumAdjustment=r.head.checkSumAdjustment;const m=r.os2;return m&&(_.FontPANOSE=m.fontPANOSE,_.Italic=m.fsSelection,_.Weight=m.usWeightClass,_.fsType=m.fsType,_.UnicodeRange=m.ulUnicodeRange,_.CodePageRange=m.ulCodePageRange),_.view.writeUint16(a),_.view.writeBytes(o),_.view.writeUint16(0),_.view.writeUint16(h),_.view.writeBytes(l),_.view.writeUint16(0),_.view.writeUint16(u),_.view.writeBytes(c),_.view.writeUint16(0),_.view.writeUint16(p),_.view.writeBytes(f),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(t.view),_}};Dt([v("uint32")],Rt.prototype,"EOTSize"),Dt([v("uint32")],Rt.prototype,"FontDataSize"),Dt([v("uint32")],Rt.prototype,"Version"),Dt([v("uint32")],Rt.prototype,"Flags"),Dt([v({type:"uint8",size:10})],Rt.prototype,"FontPANOSE"),Dt([v("uint8")],Rt.prototype,"Charset"),Dt([v("uint8")],Rt.prototype,"Italic"),Dt([v("uint32")],Rt.prototype,"Weight"),Dt([v("uint16")],Rt.prototype,"fsType"),Dt([v("uint16")],Rt.prototype,"MagicNumber"),Dt([v({type:"uint8",size:16})],Rt.prototype,"UnicodeRange"),Dt([v({type:"uint8",size:8})],Rt.prototype,"CodePageRange"),Dt([v("uint32")],Rt.prototype,"CheckSumAdjustment"),Dt([v({type:"uint8",size:16})],Rt.prototype,"Reserved"),Dt([v("uint16")],Rt.prototype,"Padding1");var $u=Object.defineProperty,Ii=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&$u(e,t,i),i};class dr extends Wt{constructor(e,t){super(e,t,16)}}Ii([v({type:"char",size:4})],dr.prototype,"tag"),Ii([v("uint32")],dr.prototype,"checkSum"),Ii([v("uint32")],dr.prototype,"offset"),Ii([v("uint32")],dr.prototype,"length");const en=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],zu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class rn{constructor(e){d(this,"index");d(this,"name");d(this,"isComposite",!1);d(this,"components",[]);d(this,"pathCommands",[]);const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*r,{xScale:a=o,yScale:l=o}=i,h=this.pathCommands,c=[];for(let u=0,f=h.length;u<f;u+=1){const p=h[u];p.type==="M"?c.push({type:"M",x:e+p.x*a,y:t+-p.y*l}):p.type==="L"?c.push({type:"L",x:e+p.x*a,y:t+-p.y*l}):p.type==="Q"?c.push({type:"Q",x1:e+p.x1*a,y1:t+-p.y1*l,x:e+p.x*a,y:t+-p.y*l}):p.type==="C"?c.push({type:"C",x1:e+p.x1*a,y1:t+-p.y1*l,x2:e+p.x2*a,y2:t+-p.y2*l,x:e+p.x*a,y:t+-p.y*l}):p.type==="Z"&&c.push({type:"Z"})}return c}}class Vu extends rn{parse(e,t,r){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,h=e.topDict.paintType,c=this.index;let u,f,p,y;const _=[],m=[];let b=0,w=!1,x=!1,C=o,P=0,E=0;function A(M,L){_.push({type:"L",x:M,y:L})}function S(M,L,F,X,q,I){_.push({type:"C",x1:M,y1:L,x2:F,y2:X,x:q,y:I})}function T(M,L){x&&h!==2&&O(),x=!0,_.push({type:"M",x:M,y:L})}function O(){_.push({type:"Z"})}function $(M){_.push(...M)}function N(){m.length%2!==0&&!w&&(C=m.shift()+s),b+=m.length>>1,m.length=0,w=!0}function B(M){let L,F,X,q,I,R,k,z,Y,H,j,Q,tt=0;for(;tt<M.length;){let st=M[tt++];switch(st){case 1:N();break;case 3:N();break;case 4:m.length>1&&!w&&(C=m.shift()+s,w=!0),E+=m.pop(),T(P,E);break;case 5:for(;m.length>0;)P+=m.shift(),E+=m.shift(),A(P,E);break;case 6:for(;m.length>0&&(P+=m.shift(),A(P,E),m.length!==0);)E+=m.shift(),A(P,E);break;case 7:for(;m.length>0&&(E+=m.shift(),A(P,E),m.length!==0);)P+=m.shift(),A(P,E);break;case 8:for(;m.length>0;)u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);break;case 10:I=m.pop()+l,R=e.subrs[I],R&&B(R);break;case 11:return;case 12:switch(st=M[tt],tt+=1,st){case 35:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y+m.shift(),Y=k+m.shift(),H=z+m.shift(),j=Y+m.shift(),Q=H+m.shift(),P=j+m.shift(),E=Q+m.shift(),m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 34:u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y,Y=k+m.shift(),H=y,j=Y+m.shift(),Q=E,P=j+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 36:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y,Y=k+m.shift(),H=y,j=Y+m.shift(),Q=H+m.shift(),P=j+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 37:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y+m.shift(),Y=k+m.shift(),H=z+m.shift(),j=Y+m.shift(),Q=H+m.shift(),Math.abs(j-P)>Math.abs(Q-E)?P=j+m.shift():E=Q+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;default:console.warn(`Glyph ${c}: unknown operator ${1200+st}`),m.length=0}break;case 14:if(m.length>=4){const Zt=en[m.pop()],me=en[m.pop()],Kt=m.pop(),kt=m.pop();if(Zt&&me){i.isComposite=!0,i.components=[];const Xt=e.charset.indexOf(Zt),ye=e.charset.indexOf(me);i.components.push({glyphIndex:ye,dx:0,dy:0}),i.components.push({glyphIndex:Xt,dx:kt,dy:Kt}),$(r.get(ye).pathCommands);const oe=JSON.parse(JSON.stringify(r.get(Xt).pathCommands));for(let ae=0;ae<oe.length;ae+=1){const wt=oe[ae];wt.type!=="Z"&&(wt.x+=kt,wt.y+=Kt),(wt.type==="Q"||wt.type==="C")&&(wt.x1+=kt,wt.y1+=Kt),wt.type==="C"&&(wt.x2+=kt,wt.y2+=Kt)}$(oe)}}else m.length>0&&!w&&(C=m.shift()+s,w=!0);x&&h!==2&&(O(),x=!1);break;case 18:N();break;case 19:case 20:N(),tt+=b+7>>3;break;case 21:m.length>2&&!w&&(C=m.shift()+s,w=!0),E+=m.pop(),P+=m.pop(),T(P,E);break;case 22:m.length>1&&!w&&(C=m.shift()+s,w=!0),P+=m.pop(),T(P,E);break;case 23:N();break;case 24:for(;m.length>2;)u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);P+=m.shift(),E+=m.shift(),A(P,E);break;case 25:for(;m.length>6;)P+=m.shift(),E+=m.shift(),A(P,E);u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);break;case 26:for(m.length%2&&(P+=m.shift());m.length>0;)u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p,E=y+m.shift(),S(u,f,p,y,P,E);break;case 27:for(m.length%2&&(E+=m.shift());m.length>0;)u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y,S(u,f,p,y,P,E);break;case 28:L=M[tt],F=M[tt+1],m.push((L<<24|F<<16)>>16),tt+=2;break;case 29:I=m.pop()+a,R=e.gsubrs[I],R&&B(R);break;case 30:for(;m.length>0&&(u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+(m.length===1?m.shift():0),S(u,f,p,y,P,E),m.length!==0);)u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),E=y+m.shift(),P=p+(m.length===1?m.shift():0),S(u,f,p,y,P,E);break;case 31:for(;m.length>0&&(u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),E=y+m.shift(),P=p+(m.length===1?m.shift():0),S(u,f,p,y,P,E),m.length!==0);)u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+(m.length===1?m.shift():0),S(u,f,p,y,P,E);break;default:st<32?console.warn(`Glyph ${c}: unknown operator ${st}`):st<247?m.push(st-139):st<251?(L=M[tt],tt+=1,m.push((st-247)*256+L+108)):st<255?(L=M[tt],tt+=1,m.push(-(st-251)*256-L-108)):(L=M[tt],F=M[tt+1],X=M[tt+2],q=M[tt+3],tt+=4,m.push((L<<24|F<<16|X<<8|q)/65536))}}}B(t),this.pathCommands=_,w&&(this.advanceWidth=C)}}class sn{constructor(e){d(this,"_items",[]);this._sfnt=e}get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const s=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);s&&(r.unicode??(r.unicode=s[0]),r.unicodes??(r.unicodes=s)),this._items[e]=r}return r}}class Xu extends sn{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new Vu({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var ju=Object.defineProperty,Aa=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ju(e,t,i),i};class Di extends Wt{constructor(t,r,i,s){super(t,r,i,s);d(this,"_offsets");d(this,"_objects");this._init()}get offsets(){return this._offsets??(this._offsets=this.readOffsets())}get objects(){return this._objects??(this._objects=this.readObjects())}_init(){const t=this.view,r=this.count,i=this.offsetSize;this.objectOffset=(r+1)*i+2,this.endOffset=t.byteOffset+this.objectOffset+this.offsets[r]}readOffsets(){const t=this.view,r=this.count,i=this.offsetSize;t.seek(3);const s=[];for(let o=0,a=r+1;o<a;o++){const l=this.view;let h=0;for(let c=0;c<i;c++)h<<=8,h+=l.readUint8();s.push(h)}return s}readObjects(){const t=[];for(let r=0,i=this.count;r<i;r++)t.push(this.get(r));return t}get(t){const r=this.offsets,i=this.objectOffset,s=i+r[t],a=i+r[t+1]-s;return this._isString?this.view.readString(s,a):this.view.readBytes(s,a)}}Aa([v("uint16")],Di.prototype,"count"),Aa([v("uint8")],Di.prototype,"offsetSize");class Ri extends Di{constructor(){super(...arguments);d(this,"_isString",!1)}}class Oa extends Di{constructor(){super(...arguments);d(this,"_isString",!0)}}const Gu=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],qu=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],Yu=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Wu=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function Bi(n,e){return e<=390?Gu[e]:n[e-391]}function it(n,e="number",t){return(r,i)=>{if(typeof i!="string")return;const s={type:e,operator:n,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(s)},set(o){this._setProp(s,o)},configurable:!0,enumerable:!0})}}class Ua extends Wt{constructor(){super(...arguments);d(this,"_dict");d(this,"_stringIndex")}get dict(){return this._dict??(this._dict=this._readDict())}setStringIndex(t){return this._stringIndex=t,this}_readFloatOperand(){const t=this.view;let r="";const i=15,s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const o=t.readUint8(),a=o>>4,l=o&15;if(a===i||(r+=s[a],l===i))break;r+=s[l]}return Number.parseFloat(r)}_readOperand(t){const r=this.view;let i,s,o,a;if(t===28)return i=r.readUint8(),s=r.readUint8(),i<<8|s;if(t===29)return i=r.readUint8(),s=r.readUint8(),o=r.readUint8(),a=r.readUint8(),i<<24|s<<16|o<<8|a;if(t===30)return this._readFloatOperand();if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return i=r.readUint8(),(t-247)*256+i+108;if(t>=251&&t<=254)return i=r.readUint8(),-(t-251)*256-i-108;throw new Error(`invalid b0 ${t}, at: ${r.cursor}`)}_readDict(){const t=this.view;t.seek(0);let r=[];const i=t.cursor+t.byteLength,s={};for(;t.cursor<i;){let o=t.readUint8();o<=21?(o===12&&(o=1200+t.readUint8()),s[o]=r,r=[]):r.push(this._readOperand(o))}return s}_getProp(t){var i;const r=this.dict[t.operator]??t.default;switch(t.type){case"number":return r[0];case"string":return Bi(((i=this._stringIndex)==null?void 0:i.objects)??[],r[0]);case"number[]":return r}return r}_setProp(t,r){}}var Hu=Object.defineProperty,nn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Hu(e,t,i),i};class Li extends Ua{}nn([it(19)],Li.prototype,"subrs"),nn([it(20)],Li.prototype,"defaultWidthX"),nn([it(21)],Li.prototype,"nominalWidthX");var Zu=Object.defineProperty,ut=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Zu(e,t,i),i};class ht extends Ua{}ut([it(0,"string")],ht.prototype,"version"),ut([it(1,"string")],ht.prototype,"notice"),ut([it(1200,"string")],ht.prototype,"copyright"),ut([it(2,"string")],ht.prototype,"fullName"),ut([it(3,"string")],ht.prototype,"familyName"),ut([it(4,"string")],ht.prototype,"weight"),ut([it(1201)],ht.prototype,"isFixedPitch"),ut([it(1202)],ht.prototype,"italicAngle"),ut([it(1203,"number",-100)],ht.prototype,"underlinePosition"),ut([it(1204,"number",50)],ht.prototype,"underlineThickness"),ut([it(1205)],ht.prototype,"paintType"),ut([it(1206,"number",2)],ht.prototype,"charstringType"),ut([it(1207,"number[]",[.001,0,0,.001,0,0])],ht.prototype,"fontMatrix"),ut([it(13)],ht.prototype,"uniqueId"),ut([it(5,"number[]",[0,0,0,0])],ht.prototype,"fontBBox"),ut([it(1208)],ht.prototype,"strokeWidth"),ut([it(14)],ht.prototype,"xuid"),ut([it(15)],ht.prototype,"charset"),ut([it(16)],ht.prototype,"encoding"),ut([it(17)],ht.prototype,"charStrings"),ut([it(18,"number[]",[0,0])],ht.prototype,"private");function Pt(n,e=n){return t=>{qe.tableDefinitions.set(n,{tag:n,prop:e,class:t}),Object.defineProperty(qe.prototype,e,{get(){return this.get(n)},set(r){return this.set(n,r)},configurable:!0,enumerable:!0})}}const rr=class rr{constructor(e){d(this,"tables",new Map);d(this,"tableViews",new Map);(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,s=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)s[a]=t.get(r[a])||o;return s}getPathCommands(e,t,r,i,s){const o=[];return this.forEachGlyph(e,t,r,i,s,(a,l,h,c,u)=>{o.push(...a.getPathCommands(l,h,c,u,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,s={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let h=0;h<l.length;h+=1){const c=l[h];o.call(this,c,t,r,i,s),c.advanceWidth&&(t+=c.advanceWidth*a),s.letterSpacing?t+=s.letterSpacing*i:s.tracking&&(t+=s.tracking/1e3*i)}return t}clone(){return new rr(this.tableViews)}delete(e){const t=rr.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=rr.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=rr.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const s=this.tableViews.get(e);if(!s)return;r=new i(s.buffer,s.byteOffset,s.byteLength).setSfnt(this),this.tables.set(t.prop,r)}}return r}};d(rr,"tableDefinitions",new Map);let qe=rr;class Ut extends Wt{setSfnt(e){return this._sfnt=e,this}getSfnt(){return this._sfnt}}var Ku=Object.defineProperty,Qu=Object.getOwnPropertyDescriptor,Vr=(n,e,t,r)=>{for(var i=r>1?void 0:r?Qu(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ku(e,t,i),i};let Ye=class extends Ut{constructor(e,t,r,i){super(e,t,r,i);d(this,"_glyphs");d(this,"privateDict");d(this,"subrsIndex");this._init()}get glyphs(){return this._glyphs??(this._glyphs=new Xu(this._sfnt))}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}get defaultWidthX(){var e;return((e=this.privateDict)==null?void 0:e.defaultWidthX)??0}get nominalWidthX(){var e;return((e=this.privateDict)==null?void 0:e.nominalWidthX)??0}get subrs(){var e;return((e=this.subrsIndex)==null?void 0:e.objects)??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}_init(){const e=this.view,{buffer:t,byteOffset:r}=e,i=r+4;this.nameIndex=new Oa(t,i),this.topDictIndex=new Ri(t,this.nameIndex.endOffset),this.stringIndex=new Oa(t,this.topDictIndex.endOffset),this.globalSubrIndex=new Ri(t,this.stringIndex.endOffset),this.topDict=new ht(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const s=this.topDict.private[0],o=this.topDict.private[1];s&&(this.privateDict=new Li(t,r+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Ri(t,r+o+this.privateDict.subrs))),this.charStringsIndex=new Ri(t,r+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=qu:this.topDict.charset===1?this.charset=Yu:this.topDict.charset===2?this.charset=Wu:this.charset=this._readCharset(r+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=en:this.topDict.encoding===1?this.encoding=zu:this.encoding=this._readEncoding(r+this.topDict.encoding)}_readCharset(e,t,r){const i=this.view;i.seek(e);let s,o,a;t-=1;const l=[".notdef"],h=i.readUint8();if(h===0)for(s=0;s<t;s+=1)o=i.readUint16(),l.push(Bi(r,o));else if(h===1)for(;l.length<=t;)for(o=i.readUint16(),a=i.readUint8(),s=0;s<=a;s+=1)l.push(Bi(r,o)),o+=1;else if(h===2)for(;l.length<=t;)for(o=i.readUint16(),a=i.readUint16(),s=0;s<=a;s+=1)l.push(Bi(r,o)),o+=1;else throw new Error(`Unknown charset format ${h}`);return l}_readEncoding(e){const t=this.view;t.seek(e);let r,i;const s={},o=t.readUint8();if(o===0){const a=t.readUint8();for(r=0;r<a;r+=1)i=t.readUint8(),s[i]=r}else if(o===1){const a=t.readUint8();for(i=1,r=0;r<a;r+=1){const l=t.readUint8(),h=t.readUint8();for(let c=l;c<=l+h;c+=1)s[c]=i,i+=1}}else console.warn(`unknown encoding format:${o}`);return s}_calcSubroutineBias(e){let t;return e.length<1240?t=107:e.length<33900?t=1131:t=32768,t}};Vr([v("uint8")],Ye.prototype,"majorVersion",2),Vr([v("uint8")],Ye.prototype,"minorVersion",2),Vr([v("uint8")],Ye.prototype,"headerSize",2),Vr([v("uint8")],Ye.prototype,"offsetSize",2),Ye=Vr([Pt("CFF ","cff")],Ye);var Ju=Object.defineProperty,ki=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Ju(e,t,i),i};const Xr=class Rl extends Wt{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new Rl;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};ki([v("uint16")],Xr.prototype,"format"),ki([v("uint16")],Xr.prototype,"length"),ki([v("uint16")],Xr.prototype,"language"),ki([v({type:"uint8",size:256})],Xr.prototype,"glyphIndexArray");let on=Xr;var tf=Object.defineProperty,an=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&tf(e,t,i),i};class jr extends Wt{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,s=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(h=>h===i);let l=0;for(let h=0;h<256;h++)if(r[h]===0)h>=a||h<s[0].firstCode||h>=s[0].firstCode+s[0].entryCount||s[0].idRangeOffset+(h-s[0].firstCode)>=o.length?l=0:(l=o[s[0].idRangeOffset+(h-s[0].firstCode)],l!==0&&(l=l+s[0].idDelta)),l!==0&&l<e&&t.set(h,l);else{const c=r[h];for(let u=0,f=s[c].entryCount;u<f;u++)if(s[c].idRangeOffset+u>=o.length?l=0:(l=o[s[c].idRangeOffset+u],l!==0&&(l=l+s[c].idDelta)),l!==0&&l<e){const p=(h<<8|u+s[c].firstCode)%65535;t.set(p,l)}}return t}}an([v("uint16")],jr.prototype,"format"),an([v("uint16")],jr.prototype,"length"),an([v("uint16")],jr.prototype,"language");function Ia(n){return n>32767?n-65536:n<-32767?n+65536:n}function ln(n,e){let t;const r=[];let i={};return n.forEach((s,o)=>{e&&o>e||((!t||o!==t.unicode+1||s!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:s,delta:Ia(s-o)}):(i.start=Number(o),i.startId=s,i.delta=Ia(s-o))),t={unicode:o,glyphIndex:s})}),t&&(i.end=t.unicode,r.push(i)),r}var ef=Object.defineProperty,We=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ef(e,t,i),i};const Ie=class Bl extends Wt{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=ln(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),s=2*2**i,o=new Bl(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=s,o.entrySelector=i,o.rangeShift=2*r-s,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,s=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<t;++h)for(let c=i[h],u=s[h];c<=u;++c)if(o[h]===0)e.set(c,(c+a[h])%65536);else{const f=h+o[h]/2+(c-i[h])-r,p=l[f];p!==0?e.set(c,(p+a[h])%65536):e.set(c,0)}return e.delete(65535),e}};We([v("uint16")],Ie.prototype,"format"),We([v("uint16")],Ie.prototype,"length"),We([v("uint16")],Ie.prototype,"language"),We([v("uint16")],Ie.prototype,"segCountX2"),We([v("uint16")],Ie.prototype,"searchRange"),We([v("uint16")],Ie.prototype,"entrySelector"),We([v("uint16")],Ie.prototype,"rangeShift");let hn=Ie;var rf=Object.defineProperty,Gr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&rf(e,t,i),i};class He extends Wt{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}Gr([v("uint16")],He.prototype,"format"),Gr([v("uint16")],He.prototype,"length"),Gr([v("uint16")],He.prototype,"language"),Gr([v("uint16")],He.prototype,"firstCode"),Gr([v("uint16")],He.prototype,"entryCount");var sf=Object.defineProperty,qr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&sf(e,t,i),i};const pr=class Ll extends Wt{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=ln(e),r=new Ll(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const s=t[r];let o=s.startGlyphCode,a=s.startCharCode;const l=s.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};qr([v("uint16")],pr.prototype,"format"),qr([v("uint16")],pr.prototype,"reserved"),qr([v("uint32")],pr.prototype,"length"),qr([v("uint32")],pr.prototype,"language"),qr([v("uint32")],pr.prototype,"nGroups");let cn=pr;var nf=Object.defineProperty,un=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&nf(e,t,i),i};class Yr extends Wt{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:s}=t[r];s.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}un([v("uint16")],Yr.prototype,"format"),un([v("uint32")],Yr.prototype,"length"),un([v("uint32")],Yr.prototype,"numVarSelectorRecords");var of=Object.defineProperty,af=Object.getOwnPropertyDescriptor,fn=(n,e,t,r)=>{for(var i=r>1?void 0:r?af(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&of(e,t,i),i};let gr=class extends Ut{constructor(){super(...arguments);d(this,"_unicodeToGlyphIndexMap");d(this,"_glyphIndexToUnicodesMap")}static from(e){const t=Array.from(e.keys()).some(u=>u>65535),r=hn.from(e),i=on.from(e),s=t?cn.from(e):void 0,o=4+(s?32:24),a=o+r.view.byteLength,l=a+i.view.byteLength,h=[{platformID:0,platformSpecificID:3,offset:o},{platformID:1,platformSpecificID:0,offset:a},{platformID:3,platformSpecificID:1,offset:o},s&&{platformID:3,platformSpecificID:10,offset:l}].filter(Boolean),c=new gr(new ArrayBuffer(4+8*h.length+r.view.byteLength+i.view.byteLength+((s==null?void 0:s.view.byteLength)??0)));return c.numberSubtables=h.length,c.view.seek(4),h.forEach(u=>{c.view.writeUint16(u.platformID),c.view.writeUint16(u.platformSpecificID),c.view.writeUint32(u.offset)}),c.view.writeBytes(r.view,o),c.view.writeBytes(i.view,a),s&&c.view.writeBytes(s.view,l),c}get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??(this._unicodeToGlyphIndexMap=this.readunicodeToGlyphIndexMap())}get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const e=new Map,t=this.unicodeToGlyphIndexMap,r=Array.from(t.keys());for(let i=0,s=r.length;i<s;i++){const o=r[i],a=t.get(o);e.has(a)?e.get(a).push(o):e.set(a,[o])}this._glyphIndexToUnicodesMap=e}return this._glyphIndexToUnicodesMap}readSubtables(){const e=this.numberSubtables;return this.view.seek(4),Array.from({length:e},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(t=>{this.view.seek(t.offset);const r=this.view.readUint16();let i;switch(r){case 0:i=new on(this.view.buffer,t.offset);break;case 2:i=new jr(this.view.buffer,t.offset,this.view.readUint16());break;case 4:i=new hn(this.view.buffer,t.offset,this.view.readUint16());break;case 6:i=new He(this.view.buffer,t.offset,this.view.readUint16());break;case 12:i=new cn(this.view.buffer,t.offset,this.view.readUint32(t.offset+4));break;case 14:default:i=new Yr(this.view.buffer,t.offset,this.view.readUint32());break}return{...t,format:r,view:i}})}readunicodeToGlyphIndexMap(){var a,l,h,c,u;const e=this.readSubtables(),t=(a=e.find(f=>f.format===0))==null?void 0:a.view,r=(l=e.find(f=>f.platformID===3&&f.platformSpecificID===3&&f.format===2))==null?void 0:l.view,i=(h=e.find(f=>f.platformID===3&&f.platformSpecificID===1&&f.format===4))==null?void 0:h.view,s=(c=e.find(f=>f.platformID===3&&f.platformSpecificID===10&&f.format===12))==null?void 0:c.view,o=(u=e.find(f=>f.platformID===0&&f.platformSpecificID===5&&f.format===14))==null?void 0:u.view;return new Map([...(t==null?void 0:t.getUnicodeToGlyphIndexMap())??[],...(r==null?void 0:r.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(i==null?void 0:i.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};fn([v("uint16")],gr.prototype,"version",2),fn([v("uint16")],gr.prototype,"numberSubtables",2),gr=fn([Pt("cmap")],gr);class lf extends rn{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const s=e[i];r.push(s),s.lastPointOfContour&&(t.push(r),r=[])}return $r(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const s=e[i],o={x:t.xScale*s.x+t.scale10*s.y+t.dx,y:t.scale01*s.x+t.yScale*s.y+t.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,s){let o;return(t&i)>0?(o=e.view.readUint8(),t&s||(o=-o),o=r+o):(t&s)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let _=0;_<i;_++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();$r(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let _=0;_<l;++_)h.push(e.view.readUint8());const c=e.view.byteOffset,u=a[a.length-1]+1;$r(u<2e4,`Bad numberOfCoordinates:${c}`);const f=[];let p,y=0;for(;y<u;)if(p=e.view.readUint8(),f.push(p),y++,p&8&&y<u){const _=e.view.readUint8();for(let m=0;m<_;m++)f.push(p),y++}if($r(f.length===u,`Bad flags length: ${f.length}, numberOfCoordinates: ${u}`),a.length>0){const _=[];let m;if(u>0){for(let x=0;x<u;x+=1)p=f[x],m={},m.onCurve=!!(p&1),m.lastPointOfContour=a.includes(x),_.push(m);let b=0;for(let x=0;x<u;x+=1)p=f[x],m=_[x],m.x=this._parseGlyphCoordinate(e,p,b,2,16),b=m.x;let w=0;for(let x=0;x<u;x+=1)p=f[x],m=_[x],m.y=this._parseGlyphCoordinate(e,p,w,4,32),w=m.y}this.points=_}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const h={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(h.dx=e.view.readInt16(),h.dy=e.view.readInt16()):h.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(h.dx=e.view.readInt8(),h.dy=e.view.readInt8()):h.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?h.xScale=h.yScale=e.view.readInt16()/16384:(a&64)>0?(h.xScale=e.view.readInt16()/16384,h.yScale=e.view.readInt16()/16384):(a&128)>0&&(h.xScale=e.view.readInt16()/16384,h.scale01=e.view.readInt16()/16384,h.scale10=e.view.readInt16()/16384,h.yScale=e.view.readInt16()/16384),this.components.push(h),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let h=0;h<this.instructionLength;h+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],h=r.get(l.glyphIndex);if(h.getPathCommands(),h.points){let c;if(l.matchedPoints===void 0)c=this._transformPoints(h.points,l);else{$r(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const u=this.points[l.matchedPoints[0]];let f=h.points[l.matchedPoints[1]];const p={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};f=this._transformPoints([f],p)[0],p.dx=u.x-f.x,p.dy=u.y-f.y,c=this._transformPoints(h.points,p)}this.points=this.points.concat(c)}}const s=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const h=o[a];let c=h[h.length-1],u=h[0];c.onCurve?s.push({type:"M",x:c.x,y:c.y}):u.onCurve?s.push({type:"M",x:u.x,y:u.y}):s.push({type:"M",x:(c.x+u.x)*.5,y:(c.y+u.y)*.5});for(let f=0,p=h.length;f<p;++f)if(c=u,u=h[(f+1)%p],c.onCurve)s.push({type:"L",x:c.x,y:c.y});else{let y=u;u.onCurve||(y={x:(c.x+u.x)*.5,y:(c.y+u.y)*.5}),s.push({type:"Q",x1:c.x,y1:c.y,x:y.x,y:y.y})}s.push({type:"Z"})}this.pathCommands=s}}class hf extends sn{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new lf({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var cf=Object.defineProperty,uf=Object.getOwnPropertyDescriptor,ff=(n,e,t,r)=>{for(var i=r>1?void 0:r?uf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&cf(e,t,i),i};let Ni=class extends Ut{constructor(){super(...arguments);d(this,"_glyphs")}static from(e){const t=e.reduce((i,s)=>i+s.byteLength,0),r=new Ni(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeBytes(i)}),r}get glyphs(){return this._glyphs??(this._glyphs=new hf(this._sfnt))}};Ni=ff([Pt("glyf")],Ni);var df=Object.defineProperty,pf=Object.getOwnPropertyDescriptor,gf=(n,e,t,r)=>{for(var i=r>1?void 0:r?pf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&df(e,t,i),i};let dn=class extends Ut{};dn=gf([Pt("GPOS","gpos")],dn);var mf=Object.defineProperty,yf=Object.getOwnPropertyDescriptor,Ze=(n,e,t,r)=>{for(var i=r>1?void 0:r?yf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&mf(e,t,i),i};let Ce=class extends Ut{};Ze([v("uint16")],Ce.prototype,"majorVersion",2),Ze([v("uint16")],Ce.prototype,"minorVersion",2),Ze([v("uint16")],Ce.prototype,"scriptListOffset",2),Ze([v("uint16")],Ce.prototype,"featureListOffset",2),Ze([v("uint16")],Ce.prototype,"lookupListOffset",2),Ze([v("uint16")],Ce.prototype,"featureVariationsOffset",2),Ce=Ze([Pt("GSUB","gsub")],Ce);var _f=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,bt=(n,e,t,r)=>{for(var i=r>1?void 0:r?vf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_f(e,t,i),i};let gt=class extends Ut{constructor(n=new ArrayBuffer(54),e){super(n,e,Math.min(54,n.byteLength-(e??0)))}};bt([v("fixed")],gt.prototype,"version",2),bt([v("fixed")],gt.prototype,"fontRevision",2),bt([v("uint32")],gt.prototype,"checkSumAdjustment",2),bt([v("uint32")],gt.prototype,"magickNumber",2),bt([v("uint16")],gt.prototype,"flags",2),bt([v("uint16")],gt.prototype,"unitsPerEm",2),bt([v({type:"longDateTime"})],gt.prototype,"created",2),bt([v({type:"longDateTime"})],gt.prototype,"modified",2),bt([v("int16")],gt.prototype,"xMin",2),bt([v("int16")],gt.prototype,"yMin",2),bt([v("int16")],gt.prototype,"xMax",2),bt([v("int16")],gt.prototype,"yMax",2),bt([v("uint16")],gt.prototype,"macStyle",2),bt([v("uint16")],gt.prototype,"lowestRecPPEM",2),bt([v("int16")],gt.prototype,"fontDirectionHint",2),bt([v("int16")],gt.prototype,"indexToLocFormat",2),bt([v("int16")],gt.prototype,"glyphDataFormat",2),gt=bt([Pt("head")],gt);var bf=Object.defineProperty,xf=Object.getOwnPropertyDescriptor,Bt=(n,e,t,r)=>{for(var i=r>1?void 0:r?xf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&bf(e,t,i),i};let Ct=class extends Ut{constructor(n=new ArrayBuffer(36),e){super(n,e,Math.min(36,n.byteLength-(e??0)))}};Bt([v("fixed")],Ct.prototype,"version",2),Bt([v("int16")],Ct.prototype,"ascent",2),Bt([v("int16")],Ct.prototype,"descent",2),Bt([v("int16")],Ct.prototype,"lineGap",2),Bt([v("uint16")],Ct.prototype,"advanceWidthMax",2),Bt([v("int16")],Ct.prototype,"minLeftSideBearing",2),Bt([v("int16")],Ct.prototype,"minRightSideBearing",2),Bt([v("int16")],Ct.prototype,"xMaxExtent",2),Bt([v("int16")],Ct.prototype,"caretSlopeRise",2),Bt([v("int16")],Ct.prototype,"caretSlopeRun",2),Bt([v("int16")],Ct.prototype,"caretOffset",2),Bt([v({type:"int16",size:4})],Ct.prototype,"reserved",2),Bt([v("int16")],Ct.prototype,"metricDataFormat",2),Bt([v("uint16")],Ct.prototype,"numOfLongHorMetrics",2),Ct=Bt([Pt("hhea")],Ct);var wf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,Cf=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wf(e,t,i),i};let Fi=class extends Ut{constructor(){super(...arguments);d(this,"_metrics")}static from(e){const t=e.length*4,r=new Fi(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeUint16(i.advanceWidth),r.view.writeUint16(i.leftSideBearing)}),r}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){const e=this._sfnt.maxp.numGlyphs,t=this._sfnt.hhea.numOfLongHorMetrics;let r=0;const i=this.view;return i.seek(0),Array.from({length:e}).map((s,o)=>(o<t&&(r=i.readUint16()),{advanceWidth:r,leftSideBearing:i.readUint16()}))}};Fi=Cf([Pt("hmtx")],Fi);var Tf=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,Mf=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ef(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tf(e,t,i),i};let pn=class extends Ut{};pn=Mf([Pt("kern","kern")],pn);var Sf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,Of=(n,e,t,r)=>{for(var i=r>1?void 0:r?Af(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Sf(e,t,i),i};let $i=class extends Ut{constructor(){super(...arguments);d(this,"_locations")}static from(e,t=1){const r=e.length*(t?4:2),i=new $i(new ArrayBuffer(r));return e.forEach(s=>{t?i.view.writeUint32(s):i.view.writeUint16(s/2)}),i}get locations(){return this._locations??(this._locations=this.readLocations())}readLocations(){const e=this._sfnt.maxp.numGlyphs,t=this._sfnt.head.indexToLocFormat,r=this.view;return r.seek(0),Array.from({length:e}).map(()=>t?r.readUint32():r.readUint16()*2)}};$i=Of([Pt("loca")],$i);var Uf=Object.defineProperty,If=Object.getOwnPropertyDescriptor,It=(n,e,t,r)=>{for(var i=r>1?void 0:r?If(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Uf(e,t,i),i};let xt=class extends Ut{constructor(n=new ArrayBuffer(32),e){super(n,e,Math.min(32,n.byteLength-(e??0)))}};It([v("fixed")],xt.prototype,"version",2),It([v("uint16")],xt.prototype,"numGlyphs",2),It([v("uint16")],xt.prototype,"maxPoints",2),It([v("uint16")],xt.prototype,"maxContours",2),It([v("uint16")],xt.prototype,"maxComponentPoints",2),It([v("uint16")],xt.prototype,"maxComponentContours",2),It([v("uint16")],xt.prototype,"maxZones",2),It([v("uint16")],xt.prototype,"maxTwilightPoints",2),It([v("uint16")],xt.prototype,"maxStorage",2),It([v("uint16")],xt.prototype,"maxFunctionDefs",2),It([v("uint16")],xt.prototype,"maxInstructionDefs",2),It([v("uint16")],xt.prototype,"maxStackElements",2),It([v("uint16")],xt.prototype,"maxSizeOfInstructions",2),It([v("uint16")],xt.prototype,"maxComponentElements",2),It([v("uint16")],xt.prototype,"maxComponentDepth",2),xt=It([Pt("maxp")],xt);var Df=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,zi=(n,e,t,r)=>{for(var i=r>1?void 0:r?Rf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Df(e,t,i),i};const Da={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},gn={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Bf={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},Ra={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let mr=class extends Ut{constructor(){super(...arguments);d(this,"_names")}get names(){return this._names??(this._names=this.readNames())}readNames(){const e=this.count;this.view.seek(6);const t=[];for(let l=0;l<e;++l)t.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const r=this.stringOffset;for(let l=0;l<e;++l){const h=t[l];h.name=this.view.readBytes(r+h.offset,h.length)}let i=gn.Macintosh,s=Bf.Default,o=0;t.some(l=>l.platform===gn.Microsoft&&l.encoding===Ra.UCS2&&l.language===1033)&&(i=gn.Microsoft,s=Ra.UCS2,o=1033);const a={};for(let l=0;l<e;++l){const h=t[l];h.platform===i&&h.encoding===s&&h.language===o&&Da[h.nameId]&&(a[Da[h.nameId]]=o===0?Lu(h.name):ku(h.name))}return a}};zi([v("uint16")],mr.prototype,"format",2),zi([v("uint16")],mr.prototype,"count",2),zi([v("uint16")],mr.prototype,"stringOffset",2),mr=zi([Pt("name")],mr);var Lf=Object.defineProperty,kf=Object.getOwnPropertyDescriptor,G=(n,e,t,r)=>{for(var i=r>1?void 0:r?kf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Lf(e,t,i),i};let V=class extends Ut{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};G([v("uint16")],V.prototype,"version",2),G([v("int16")],V.prototype,"xAvgCharWidth",2),G([v("uint16")],V.prototype,"usWeightClass",2),G([v("uint16")],V.prototype,"usWidthClass",2),G([v("uint16")],V.prototype,"fsType",2),G([v("uint16")],V.prototype,"ySubscriptXSize",2),G([v("uint16")],V.prototype,"ySubscriptYSize",2),G([v("uint16")],V.prototype,"ySubscriptXOffset",2),G([v("uint16")],V.prototype,"ySubscriptYOffset",2),G([v("uint16")],V.prototype,"ySuperscriptXSize",2),G([v("uint16")],V.prototype,"ySuperscriptYSize",2),G([v("uint16")],V.prototype,"ySuperscriptXOffset",2),G([v("uint16")],V.prototype,"ySuperscriptYOffset",2),G([v("uint16")],V.prototype,"yStrikeoutSize",2),G([v("uint16")],V.prototype,"yStrikeoutPosition",2),G([v("uint16")],V.prototype,"sFamilyClass",2),G([v({type:"uint8"})],V.prototype,"bFamilyType",2),G([v({type:"uint8"})],V.prototype,"bSerifStyle",2),G([v({type:"uint8"})],V.prototype,"bWeight",2),G([v({type:"uint8"})],V.prototype,"bProportion",2),G([v({type:"uint8"})],V.prototype,"bContrast",2),G([v({type:"uint8"})],V.prototype,"bStrokeVariation",2),G([v({type:"uint8"})],V.prototype,"bArmStyle",2),G([v({type:"uint8"})],V.prototype,"bLetterform",2),G([v({type:"uint8"})],V.prototype,"bMidline",2),G([v({type:"uint8"})],V.prototype,"bXHeight",2),G([v({type:"uint8",size:16})],V.prototype,"ulUnicodeRange",2),G([v({type:"char",size:4})],V.prototype,"achVendID",2),G([v("uint16")],V.prototype,"fsSelection",2),G([v("uint16")],V.prototype,"usFirstCharIndex",2),G([v("uint16")],V.prototype,"usLastCharIndex",2),G([v("int16")],V.prototype,"sTypoAscender",2),G([v("int16")],V.prototype,"sTypoDescender",2),G([v("int16")],V.prototype,"sTypoLineGap",2),G([v("uint16")],V.prototype,"usWinAscent",2),G([v("uint16")],V.prototype,"usWinDescent",2),G([v({offset:72,type:"uint8",size:8})],V.prototype,"ulCodePageRange",2),G([v({offset:72,type:"int16"})],V.prototype,"sxHeight",2),G([v("int16")],V.prototype,"sCapHeight",2),G([v("uint16")],V.prototype,"usDefaultChar",2),G([v("uint16")],V.prototype,"usBreakChar",2),G([v("uint16")],V.prototype,"usMaxContext",2),V=G([Pt("OS/2","os2")],V);var Nf=Object.defineProperty,Ff=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ff(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Nf(e,t,i),i};let Jt=class extends Ut{constructor(n=new ArrayBuffer(32),e,t){super(n,e,t)}};pe([v("fixed")],Jt.prototype,"format",2),pe([v("fixed")],Jt.prototype,"italicAngle",2),pe([v("int16")],Jt.prototype,"underlinePosition",2),pe([v("int16")],Jt.prototype,"underlineThickness",2),pe([v("uint32")],Jt.prototype,"isFixedPitch",2),pe([v("uint32")],Jt.prototype,"minMemType42",2),pe([v("uint32")],Jt.prototype,"maxMemType42",2),pe([v("uint32")],Jt.prototype,"minMemType1",2),pe([v("uint32")],Jt.prototype,"maxMemType1",2),Jt=pe([Pt("post")],Jt);var $f=Object.defineProperty,zf=Object.getOwnPropertyDescriptor,Lt=(n,e,t,r)=>{for(var i=r>1?void 0:r?zf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&$f(e,t,i),i};let Tt=class extends Ut{constructor(n=new ArrayBuffer(36),e){super(n,e,Math.min(36,n.byteLength-(e??0)))}};Lt([v("fixed")],Tt.prototype,"version",2),Lt([v("int16")],Tt.prototype,"vertTypoAscender",2),Lt([v("int16")],Tt.prototype,"vertTypoDescender",2),Lt([v("int16")],Tt.prototype,"vertTypoLineGap",2),Lt([v("int16")],Tt.prototype,"advanceHeightMax",2),Lt([v("int16")],Tt.prototype,"minTopSideBearing",2),Lt([v("int16")],Tt.prototype,"minBottomSideBearing",2),Lt([v("int16")],Tt.prototype,"yMaxExtent",2),Lt([v("int16")],Tt.prototype,"caretSlopeRise",2),Lt([v("int16")],Tt.prototype,"caretSlopeRun",2),Lt([v("int16")],Tt.prototype,"caretOffset",2),Lt([v({type:"int16",size:4})],Tt.prototype,"reserved",2),Lt([v("int16")],Tt.prototype,"metricDataFormat",2),Lt([v("int16")],Tt.prototype,"numOfLongVerMetrics",2),Tt=Lt([Pt("vhea")],Tt);var Vf=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,jf=(n,e,t,r)=>{for(var i=r>1?void 0:r?Xf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Vf(e,t,i),i};let Vi=class extends Ut{constructor(){super(...arguments);d(this,"_metrics")}static from(e){const t=e.length*4,r=new Vi(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeUint16(i.advanceHeight),r.view.writeInt16(i.topSideBearing)}),r}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){var s;const e=this._sfnt.maxp.numGlyphs,t=((s=this._sfnt.vhea)==null?void 0:s.numOfLongVerMetrics)??0,r=this.view;r.seek(0);let i=0;return Array.from({length:e}).map((o,a)=>(a<t&&(i=r.readUint16()),{advanceHeight:i,topSideBearing:r.readUint8()}))}};Vi=jf([Pt("vmtx")],Vi);var Gf=Object.defineProperty,Wr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Gf(e,t,i),i};class te extends Ui{constructor(){super(...arguments);d(this,"format","TrueType");d(this,"mimeType","font/ttf");d(this,"_sfnt")}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(fr(t).getUint32(0))}static checksum(t){const r=fr(t);let i=r.byteLength;for(;i%4;)i++;let s=0;for(let o=0,a=i/4;o<a;o+=4)o*4<i-4&&(s+=r.getUint32(o*4,!1));return s&4294967295}static from(t){const r=f=>f+3&-4,i=t.tableViews.size,s=Array.from(t.tableViews.values()).reduce((f,p)=>f+r(p.byteLength),0),o=new this(new ArrayBuffer(12+i*16+s));o.scalerType=65536,o.numTables=i;const a=Math.log(2);o.searchRange=Math.floor(Math.log(i)/a)*16,o.entrySelector=Math.floor(o.searchRange/a),o.rangeShift=i*16-o.searchRange;let l=12+i*16,h=0;const c=o.getDirectories();t.tableViews.forEach((f,p)=>{const y=c[h++];y.tag=p,y.checkSum=this.checksum(f),y.offset=l,y.length=f.byteLength,o.view.writeBytes(f,l),l+=r(y.length)});const u=o.createSfnt().head;return u.checkSumAdjustment=0,u.checkSumAdjustment=2981146554-this.checksum(o.view),o}getDirectories(){let t=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const r=new dr(this.view.buffer,t);return t+=r.view.byteLength,r})}createSfnt(){return new qe(this.getDirectories().reduce((t,r)=>(t[r.tag]=new DataView(this.view.buffer,this.view.byteOffset+r.offset,r.length),t),{}))}}d(te,"signature",new Set([65536,1953658213,1954115633])),Wr([v("uint32")],te.prototype,"scalerType"),Wr([v("uint16")],te.prototype,"numTables"),Wr([v("uint16")],te.prototype,"searchRange"),Wr([v("uint16")],te.prototype,"entrySelector"),Wr([v("uint16")],te.prototype,"rangeShift");class Xi extends te{constructor(){super(...arguments);d(this,"format","OpenType");d(this,"mimeType","font/otf")}static from(t){return super.from(t)}}d(Xi,"signature",new Set([1330926671]));var qf=Object.defineProperty,Hr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&qf(e,t,i),i};class Ke extends Wt{constructor(e,t){super(e,t,20)}}Hr([v({type:"char",size:4})],Ke.prototype,"tag"),Hr([v("uint32")],Ke.prototype,"offset"),Hr([v("uint32")],Ke.prototype,"compLength"),Hr([v("uint32")],Ke.prototype,"origLength"),Hr([v("uint32")],Ke.prototype,"origChecksum");var Yf=Object.defineProperty,Ht=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Yf(e,t,i),i};const Vt=(ke=class extends Ui{constructor(){super(...arguments);d(this,"format","WOFF");d(this,"mimeType","font/woff");d(this,"_sfnt")}get subfontFormat(){return te.is(this.flavor)?"TrueType":Xi.is(this.flavor)?"OpenType":"Open"}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(fr(t).getUint32(0))}static checkSum(t){const r=fr(t),i=r.byteLength,s=Math.floor(i/4);let o=0,a=0;for(;a<s;)o+=r.getUint32(4*a++,!1);let l=i-s*4;if(l){let h=s*4;for(;l>0;)o+=r.getUint8(h)<<l*8,h++,l--}return o%4294967296}static from(t,r=new ArrayBuffer(0)){const i=f=>f+3&-4,s=[];t.tableViews.forEach((f,p)=>{const y=fr(Au(new Uint8Array(f.buffer,f.byteOffset,f.byteLength)));s.push({tag:p,view:y.byteLength<f.byteLength?y:f,rawView:f})});const o=s.length,a=s.reduce((f,p)=>f+i(p.view.byteLength),0),l=new ke(new ArrayBuffer(44+20*o+a+r.byteLength));l.signature=2001684038,l.flavor=65536,l.length=l.view.byteLength,l.numTables=o,l.totalSfntSize=12+16*o+s.reduce((f,p)=>f+i(p.rawView.byteLength),0);let h=44+o*20,c=0;const u=l.getDirectories();return s.forEach(f=>{const p=u[c++];p.tag=f.tag,p.offset=h,p.compLength=f.view.byteLength,p.origChecksum=ke.checkSum(f.rawView),p.origLength=f.rawView.byteLength,l.view.writeBytes(f.view,h),h+=i(p.compLength)}),l.view.writeBytes(r),l}getDirectories(){let t=44;return Array.from({length:this.numTables},()=>{const r=new Ke(this.view.buffer,t);return t+=r.view.byteLength,r})}createSfnt(){return new qe(this.getDirectories().reduce((t,r)=>{const i=r.tag,s=this.view.byteOffset+r.offset,o=r.compLength,a=r.origLength,l=s+o;return t[i]=o>=a?new DataView(this.view.buffer,s,o):new DataView(Ou(new Uint8Array(this.view.buffer.slice(s,l))).buffer),t},{}))}},d(ke,"signature",new Set([2001684038])),ke);Ht([v("uint32")],Vt.prototype,"signature"),Ht([v("uint32")],Vt.prototype,"flavor"),Ht([v("uint32")],Vt.prototype,"length"),Ht([v("uint16")],Vt.prototype,"numTables"),Ht([v("uint16")],Vt.prototype,"reserved"),Ht([v("uint32")],Vt.prototype,"totalSfntSize"),Ht([v("uint16")],Vt.prototype,"majorVersion"),Ht([v("uint16")],Vt.prototype,"minorVersion"),Ht([v("uint32")],Vt.prototype,"metaOffset"),Ht([v("uint32")],Vt.prototype,"metaLength"),Ht([v("uint32")],Vt.prototype,"metaOrigLength"),Ht([v("uint32")],Vt.prototype,"privOffset"),Ht([v("uint32")],Vt.prototype,"privLength");let ji=Vt;function Ba(n,e=!0){if(te.is(n))return new te(n);if(Xi.is(n))return new Xi(n);if(ji.is(n))return new ji(n);if(e)throw new Error("Failed to parseFont")}const ts=class ts{constructor(){d(this,"fallbackFont");d(this,"loading",new Map);d(this,"loaded",new Map);d(this,"familyToUrl",new Map)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...ts.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=document.createElement("style");return r.appendChild(document.createTextNode(`@font-face {
28
+ font-family: "${e}";
29
+ src: url(${t});
30
+ }`)),document.head.appendChild(r),this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(r=>this.familyToUrl.get(r.trim())??this.familyToUrl.get(r)??r)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((i,s)=>i||this.loaded.get(s),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(e,t={}){const{cancelOther:r,injectFontFace:i=!0,injectStyleTag:s=!0,...o}=t,{src:a}=e;if(this.loaded.has(a))return r&&(this.loading.forEach(f=>f.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,o),this.loading.set(a,l)),r&&this.loading.forEach((f,p)=>{f!==l&&(f.cancel(),this.loading.delete(p))}),l.when.then(f=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const p=u(f);return t.noAdd||this.loaded.set(e.src,p),p.familySet.forEach(y=>{this.familyToUrl.set(y,a),typeof document<"u"&&(i&&this.injectFontFace(y,f),s&&this.injectStyleTag(y,a))}),p}}).catch(f=>{if(f instanceof DOMException&&f.message==="The user aborted a request.")return u();throw f}).finally(()=>{this.loading.delete(a)});function h(){return e.family?Array.isArray(e.family)?e.family:[e.family]:[]}function c(f){return h().forEach(p=>{f.familySet.add(p)}),f}function u(f=new ArrayBuffer(0)){let p;function y(){return p||(p=f.byteLength?Ba(f,!1):void 0),p}function _(){const m=y();if(m instanceof te||m instanceof ji)return m.sfnt}return{...e,buffer:f,familySet:new Set(h()),getFont:y,getSfnt:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}};d(ts,"defaultRequestInit",{cache:"force-cache"});let Gi=ts;const La=new Gi,Wf=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:Ui,get Cff(){return Ye},get Cmap(){return gr},CmapSubtableFormat0:on,CmapSubtableFormat12:cn,CmapSubtableFormat14:Yr,CmapSubtableFormat2:jr,CmapSubtableFormat4:hn,CmapSubtableFormat6:He,FontDataObject:Wt,FontDataView:vt,Fonts:Gi,get Glyf(){return Ni},Glyph:rn,GlyphSet:sn,get Gpos(){return dn},get Gsub(){return Ce},get Head(){return gt},get Hhea(){return Ct},get Hmtx(){return Fi},get Kern(){return pn},get Loca(){return $i},get Maxp(){return xt},get Name(){return mr},get Os2(){return V},get Post(){return Jt},Sfnt:qe,TableDirectory:dr,Ttf:te,get Vhea(){return Tt},get Vmtx(){return Vi},Woff:ji,WoffTableDirectoryEntry:Ke,createCmapSegments:ln,dataTypeToByteLength:zr,defineColumn:v,defineSfntTable:Pt,fonts:La,parseFont:Ba},Symbol.toStringTag,{value:"Module"}));function mn(n,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:r,y0:i,x1:s,y1:o,stops:a}=Hf(e,t.left,t.top,t.width,t.height),l=n.createLinearGradient(r,i,s,o);return a.forEach(h=>l.addColorStop(h.offset,h.color)),l}return e}function qi(n,e,t){n!=null&&n.color&&(n.color=mn(t,n.color,e)),n!=null&&n.backgroundColor&&(n.backgroundColor=mn(t,n.backgroundColor,e)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=mn(t,n.textStrokeColor,e))}function Hf(n,e,t,r,i){var p;const s=((p=n.match(/linear-gradient\((.+)\)$/))==null?void 0:p[1])??"",o=s.split(",")[0],a=o.includes("deg")?o:"0deg",l=s.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),c=(Number(a.replace("deg",""))||0)*Math.PI/180,u=r*Math.sin(c),f=i*Math.cos(c);return{x0:e+r/2-u,y0:t+i/2+f,x1:e+r/2+u,y1:t+i/2-f,stops:Array.from(l).map(y=>{let _=y[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(y[3].replace("%",""))/100,color:_}})}}function Zr(n){const{ctx:e,path:t,fontSize:r,clipRect:i}=n;e.save(),e.beginPath();const s=t.style,o={...s,fill:n.color??s.fill,stroke:n.textStrokeColor??s.stroke,strokeWidth:n.textStrokeWidth?n.textStrokeWidth*r:s.strokeWidth,shadowOffsetX:(n.shadowOffsetX??0)*r,shadowOffsetY:(n.shadowOffsetY??0)*r,shadowBlur:(n.shadowBlur??0)*r,shadowColor:n.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function Zf(n,e,t){const{left:r,top:i,width:s,height:o}=t,a=n.canvas;a.dataset.viewBox=`${r} ${i} ${s} ${o}`,a.dataset.pixelRatio=String(e);const l=s,h=o;a.width=Math.max(1,Math.ceil(l*e)),a.height=Math.max(1,Math.ceil(h*e)),a.style.width=`${l}px`,a.style.height=`${h}px`,n.clearRect(0,0,a.width,a.height),n.scale(e,e),n.translate(-r,-i)}function Kf(n,e){const{paragraphs:t,computedStyle:r,glyphBox:i}=e;qi(r,i,n),t.forEach(s=>{qi(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{qi(o.computedStyle,o.inlineBox,n)})})}const Qf=new Set(["©","®","÷"]),Jf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),td={1:"italic",32:"bold"},ed={1:"italic",2:"bold"},ka={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class rd{constructor(e,t,r){d(this,"path",new zt);d(this,"lineBox",new K);d(this,"inlineBox",new K);d(this,"glyphBox");d(this,"advanceWidth",0);d(this,"advanceHeight",0);d(this,"underlinePosition",0);d(this,"underlineThickness",0);d(this,"strikeoutPosition",0);d(this,"strikeoutSize",0);d(this,"ascender",0);d(this,"descender",0);d(this,"typoAscender",0);d(this,"typoDescender",0);d(this,"typoLineGap",0);d(this,"winAscent",0);d(this,"winDescent",0);d(this,"xHeight",0);d(this,"capHeight",0);d(this,"baseline",0);d(this,"centerDiviation",0);d(this,"fontStyle");this.content=e,this.index=t,this.parent=r}get center(){var e;return(e=this.glyphBox)==null?void 0:e.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(e){const t=this.computedStyle.fontFamily,r=e??La,i=t?r.get(t):r.fallbackFont;return i==null?void 0:i.getSfnt()}updateGlyph(e=this._getFontSfnt()){if(!e)return this;const{hhea:t,os2:r,post:i,head:s}=e,o=s.unitsPerEm,a=t.ascent,l=t.descent,{content:h,computedStyle:c,isVertical:u}=this,{fontSize:f}=c,p=o/f,y=e.getAdvanceWidth(h,f),_=(a+Math.abs(l))/p,m=a/p;return this.advanceWidth=y,this.advanceHeight=_,this.inlineBox.width=u?_:y,this.inlineBox.height=u?y:_,this.underlinePosition=(a-i.underlinePosition)/p,this.underlineThickness=i.underlineThickness/p,this.strikeoutPosition=(a-r.yStrikeoutPosition)/p,this.strikeoutSize=r.yStrikeoutSize/p,this.ascender=a/p,this.descender=l/p,this.typoAscender=r.sTypoAscender/p,this.typoDescender=r.sTypoDescender/p,this.typoLineGap=r.sTypoLineGap/p,this.winAscent=r.usWinAscent/p,this.winDescent=r.usWinDescent/p,this.xHeight=r.sxHeight/p,this.capHeight=r.sCapHeight/p,this.baseline=m,this.centerDiviation=_/2-m,this.fontStyle=td[r.fsSelection]??ed[s.macStyle],this}update(e){const t=this._getFontSfnt(e);if(!t)return this;this.updateGlyph(t);const{isVertical:r,content:i,computedStyle:s,baseline:o,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:u,advanceWidth:f,advanceHeight:p}=this,{left:y,top:_}=a,m=s.fontStyle==="italic"&&u!=="italic";let b=y,w=_+o,x;const C=new zt;if(r&&(b+=(p-f)/2,Math.abs(f-p)>.1&&(w-=(l-c)/(l+Math.abs(h))*p),x=void 0),r&&!Qf.has(i)&&(i.codePointAt(0)<=256||Jf.has(i))){C.addCommands(t.getPathCommands(i,b,_+o-(p-f)/2,s.fontSize));const E={y:_-(p-f)/2+p/2,x:b+f/2};m&&this._italic(C,r?{x:E.x,y:_-(p-f)/2+o}:void 0),C.rotate(90,E)}else x!==void 0?(C.addCommands(t.glyphs.get(x).getPathCommands(b,w,s.fontSize)),m&&this._italic(C,r?{x:b+f/2,y:_+c/(l+Math.abs(h))*p}:void 0)):(C.addCommands(t.getPathCommands(i,b,w,s.fontSize)),m&&this._italic(C,r?{x:b+p/2,y:w}:void 0));const P=s.fontWeight??400;return P in ka&&(P===700||P==="bold")&&u!=="bold"&&C.bold(ka[P]*s.fontSize*.05),C.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=C,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,r){var i;if((i=this.path.paths[0])!=null&&i.curves.length)return this.path.getMinMax(e,t,r)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:r,max:i}=t;return new K(r.x,r.y,i.x-r.x,i.y-r.y)}drawTo(e,t={}){const r=this.computedStyle,i={ctx:e,path:this.path,fontSize:r.fontSize,color:r.color,...t};if(this.glyphBox)Zr(i);else{e.save(),e.beginPath();const s=this.path.style,o={...s,fill:i.color??s.fill,stroke:i.textStrokeColor??s.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:s.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};Vs(e,o),e.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function yn(n,e){return typeof n=="number"?n:n.endsWith("%")?(n=n.substring(0,n.length-1),Math.ceil(Number(n)/100*e.total)):n.endsWith("rem")?(n=n.substring(0,n.length-3),Number(n)*e.fontSize):n.endsWith("em")?(n=n.substring(0,n.length-2),Number(n)*e.fontSize):Number(n)}function Na(n){const e=De(n)?{}:n;return Object.keys(e).reduce((t,r)=>{let i=e[r];const s=Fa(r),o=Fa(i);return s&&(r=s),o&&(i=o),t[r]=i,t},{})}function De(n){return!n||n==="none"}function id(n,e){const t=Object.keys(n),r=Object.keys(e);return Array.from(new Set([...t,...r])).every(s=>yr(n[s],e[s]))}function yr(n,e){const t=typeof n;return t===typeof e?t==="object"?id(n,e):n===e:!1}function Fa(n){const e=n.startsWith("#")?n.slice(1):n;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(e))return null;const r=e.length===3?e.split("").map(a=>a+a).join(""):e,i=Number.parseInt(r.slice(0,2),16),s=Number.parseInt(r.slice(2,4),16),o=Number.parseInt(r.slice(4,6),16);return`rgb(${i}, ${s}, ${o})`}function _n(n){if(!n)return n;const e={};for(const t in n)n[t]!==""&&n[t]!==void 0&&(e[t]=n[t]);return e}function vn(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class sd{constructor(e,t={},r){d(this,"inlineBox",new K);this.content=e,this.style=t,this.parent=r,this.updateComputedStyle().initCharacters()}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,..._n(this.style)},this}initCharacters(){const e=[];let t=0;for(const r of this.computedContent)e.push(new rd(r,t++,this));return this.characters=e,this}}class Kr{constructor(e,t){d(this,"lineBox",new K);d(this,"fragments",[]);this.style=e,this.parentStyle=t,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={..._n(this.parentStyle),..._n(this.style)},this}addFragment(e,t){const r=new sd(e,t,this);return this.fragments.push(r),r}}function Xp(n){return n}const br=class br{_styleToDomStyle(e){const t={};for(const r in e){const i=e[r];br.notZeroStyles.has(r)&&i===0||(typeof i=="number"&&br.pxStyles.has(r)?t[r]=`${i}px`:t[r]=i)}return t}createParagraphDom(e,t){const r=document.createDocumentFragment(),i=document.createElement("section"),s={...t},o=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":s.justifyContent="start";break;case"center":s.justifyContent="center";break;case"end":case"right":s.justifyContent="end";break}switch(t.verticalAlign){case"top":s.alignItems="top";break;case"middle":s.alignItems="center";break;case"bottom":s.alignItems="end";break}const a=!!(s.justifyContent||s.alignItems);Object.assign(i.style,{boxSizing:"border-box",display:a?"inline-flex":void 0,width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(s),position:"fixed",visibility:"hidden"});const l=document.createElement("ul");return Object.assign(l.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:a&&o?"100%":void 0,height:a&&!o?"100%":void 0}),e.forEach(h=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._styleToDomStyle(h.style)}),h.fragments.forEach(u=>{const f=document.createElement("span");Object.assign(f.style,{verticalAlign:"inherit",...this._styleToDomStyle(u.style)}),f.appendChild(document.createTextNode(u.content)),c.appendChild(f)}),l.appendChild(c)}),i.appendChild(l),r.appendChild(i),document.body.appendChild(r),{dom:i,destory:()=>{var h;return(h=i.parentNode)==null?void 0:h.removeChild(i)}}}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const r=e.data??"";let i=0;return Array.from(r).map(s=>{var u;const o=i+=r.substring(i).indexOf(s),a=o+s.length;i+=s.length,t.setStart(e,Math.max(o,0)),t.setEnd(e,a);const l=((u=t.getClientRects)==null?void 0:u.call(t))??[t.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=t.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(e){const t=[],r=[],i=[];return e.querySelectorAll("li").forEach((s,o)=>{const a=s.getBoundingClientRect();t.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();r.push({paragraphIndex:o,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let u=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(f=>{i.push({...f,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:u++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(f=>{f.firstChild instanceof window.Text&&this.measureDomText(f.firstChild).forEach(p=>{i.push({...p,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:u++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:r,characters:i}}measureParagraphDom(e,t){const r=t.getBoundingClientRect(),i=this.measureDom(t);i.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const u=e[l].fragments[h].characters[c],{fontHeight:f,isVertical:p}=u,y=s[o];u.inlineBox.left=y.left,u.inlineBox.top=y.top,u.inlineBox.width=y.width,u.inlineBox.height=y.height,p?(u.lineBox.left=y.left+(y.width-f)/2,u.lineBox.top=y.top,u.lineBox.width=f,u.lineBox.height=y.height):(u.lineBox.left=y.left,u.lineBox.top=y.top+(y.height-f)/2,u.lineBox.width=y.width,u.lineBox.height=f),o++}),{paragraphs:e,boundingBox:new K(0,0,r.width,r.height)}}measure(e,t,r){let i;r||({dom:r,destory:i}=this.createParagraphDom(e,t));const s=this.measureParagraphDom(e,r);return i==null||i(),s}};d(br,"notZeroStyles",new Set(["width","height"])),d(br,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let bn=br;class nd{constructor(){d(this,"eventListeners",new Map)}addEventListener(e,t,r){const i={value:t,options:r},s=this.eventListeners.get(e);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(e,[s,i]):this.eventListeners.set(e,i),this}removeEventListener(e,t,r){var s,o;if(!t)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==t||typeof r=="object"&&(r!=null&&r.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===t&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,t){var i,s;const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let o=r.length,a=0;a<o;a++){const l=r[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(e,l.value,l.options),l.value.apply(this,[t])}else typeof r.options=="object"&&((s=r.options)!=null&&s.once)&&this.off(e,r.value,r.options),r.value.apply(this,[t]);return!0}else return!1}on(e,t,r){return this.addEventListener(e,t,r)}once(e,t){return this.addEventListener(e,t,{once:!0})}off(e,t,r){return this.removeEventListener(e,t,r)}emit(e,t){this.dispatchEvent(e,t)}}function xn(n){const{highlight:e,highlightImage:t,highlightReferImage:r,highlightColormap:i,highlightLine:s,highlightSize:o,highlightThickness:a}=n;return{image:(e==null?void 0:e.image)??t??"none",referImage:(e==null?void 0:e.referImage)??r??"none",colormap:(e==null?void 0:e.colormap)??i??"none",line:(e==null?void 0:e.line)??s??"none",size:(e==null?void 0:e.size)??o??"cover",thickness:(e==null?void 0:e.thickness)??a??"100%"}}function od(){const n=[],e=[],t=new Map,r=new Map;async function i(o){if(!t.has(o)){t.set(o,o);try{t.set(o,await fetch(o).then(a=>a.text()))}catch(a){console.warn(a),t.delete(o)}}}function s(o){let a=r.get(o);if(!a){const l=pa(vn(o)?t.get(o)??o:o),h=ga(l);a={dom:l,paths:h},r.set(o,a)}return a}return{name:"highlight",paths:n,load:async o=>{const a=new Set;o.forEachCharacter(l=>{const{computedStyle:h}=l,{image:c,referImage:u}=xn(h);vn(c)&&a.add(c),vn(u)&&a.add(u)}),await Promise.all(Array.from(a).map(l=>i(l)))},update:o=>{e.length=0,n.length=0;let a=[],l,h;o.forEachCharacter(c=>{const{computedStyle:u}=c,f=xn(u),{image:p,colormap:y,line:_,size:m,thickness:b}=f;if(De(p))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:w,isVertical:x}=c,{fontSize:C}=u;(!h||yr(h.image,p)&&yr(h.colormap,y)&&yr(h.line,_)&&yr(h.size,m)&&yr(h.thickness,b))&&(l!=null&&l.length)&&(x?l[0].inlineBox.left===w.left:l[0].inlineBox.top===w.top)&&l[0].fontSize===C?l.push(c):(l=[],l.push(c),a.push(l))}h=f}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const u=a[c],f=u[0],p=K.from(...u.filter(q=>q.glyphBox).map(q=>q.glyphBox)),{computedStyle:y}=f,{fontSize:_,writingMode:m}=y,{image:b,referImage:w,colormap:x,line:C,size:P,thickness:E}=xn(y),A=m.includes("vertical"),S=yn(E,{fontSize:_,total:p.width})/p.width,T=Na(x),{paths:O,dom:$}=s(b),N=Lr(O,!0),B=_/N.width*2,M=new K().copy(p);A&&(M.width=p.height,M.height=p.width,M.left=p.left+p.width);const L=Math.floor(M.width);let F=L;if(P!=="cover"&&(F=yn(P,{fontSize:_,total:p.width})||L,M.width=F),!De(w)&&De(C)){const q=Lr(s(w).paths,!0);N.copy(q)}else{let q;if(De(C))if(N.width/N.height>4){q="underline";const I=$.getAttribute("viewBox");if(I){const[R,k,z,Y]=I.split(" ").map(j=>Number(j)),H=k+Y/2;N.y<H&&N.y+N.height>H?q="line-through":N.y+N.height<H?q="overline":q="underline"}}else q="outline";else q=C;switch(q){case"outline":{const I=M.width*.2,R=M.height*.2;M.width+=I,M.height+=R,A?(M.x-=R/2,M.y-=I/2,M.x+=M.height):(M.x-=I/2,M.y-=R/2);break}case"overline":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width:M.y=f.inlineBox.top;break;case"line-through":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width-f.strikeoutPosition+M.height/2:M.y=f.inlineBox.top+f.strikeoutPosition-M.height/2;break;case"underline":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width-f.underlinePosition:M.y=f.inlineBox.top+f.underlinePosition;break}}const X=new $t().translate(-N.x,-N.y).scale(M.width/N.width,M.height/N.height);A&&X.rotate(-Math.PI/2),X.translate(M.x,M.y);for(let q=0;q<Math.ceil(L/F);q++){const I=X.clone();A?I.translate(0,q*M.width):I.translate(q*M.width,0),O.forEach(R=>{const k=R.clone().matrix(I);k.style.strokeWidth&&(k.style.strokeWidth*=B*S),k.style.strokeMiterlimit&&(k.style.strokeMiterlimit*=B),k.style.strokeDashoffset&&(k.style.strokeDashoffset*=B),k.style.strokeDasharray&&(k.style.strokeDasharray=k.style.strokeDasharray.map(z=>z*B)),k.style.fill&&k.style.fill in T&&(k.style.fill=T[k.style.fill]),k.style.stroke&&k.style.stroke in T&&(k.style.stroke=T[k.style.stroke]),n.push(k),L!==F&&(A?e[n.length-1]=new K(p.left-p.width*2,p.top,p.width*4,p.height):e[n.length-1]=new K(p.left,p.top-p.height*2,p.width,p.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if(Zr({ctx:o,path:l,fontSize:a.computedStyle.fontSize,clipRect:e[h]}),a.debug){const c=Lr([l]);c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function ad(n,e){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
31
+ <circle cx="${n}" cy="${n}" r="${n}" fill="${e}" />
32
+ </svg>`}function ld(){const n=[];return{name:"listStyle",paths:n,update:e=>{n.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,s=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:u,listStyleType:f}=a,p=Na(c);let y=u,_;if(!De(h))_=h;else if(!De(f)){const x=i*.38/2;switch(y=y==="cover"?x*2:y,f){case"disc":_=ad(x,String(l));break}}if(!_)return;const m=ga(_),b=Lr(m);let w;o.fragments.forEach(x=>{x.characters.forEach(C=>{const{inlineBox:P}=C;if(r?(w==null?void 0:w.inlineBox.left)!==P.left:(w==null?void 0:w.inlineBox.top)!==P.top){w=C;const E=y==="cover"?1:yn(y,{total:i,fontSize:i})/i,A=new $t;if(r){const S=i/b.height*E;A.translate(-b.left,-b.top).rotate(Math.PI/2).scale(S,S).translate(P.left+(P.width-b.height*S)/2,P.top-s)}else{const S=i/b.height*E;A.translate(-b.left,-b.top).scale(S,S).translate(P.left-b.width*S-s,P.top+(P.height-b.height*S)/2)}n.push(...m.map(S=>{const T=S.clone();return T.matrix(A),T.style.fill&&T.style.fill in p&&(T.style.fill=p[T.style.fill]),T.style.stroke&&T.style.stroke in p&&(T.style.stroke=p[T.style.stroke]),T}))}})})})}}}const Re=new D,_r=new $t,Be=new $t;function hd(){return{name:"render",getBoundingBox:n=>{const{characters:e,fontSize:t,effects:r}=n,i=[];return e.forEach(s=>{r==null||r.forEach(o=>{if(!s.glyphBox)return;const a=s.glyphBox.clone(),l=wn(n,o);Re.set(a.left,a.top),Re.applyMatrix3(l),a.left=Re.x,a.top=Re.y,Re.set(a.right,a.bottom),Re.applyMatrix3(l),a.width=Re.x-a.left,a.height=Re.y-a.top;const h=(o.shadowOffsetX??0)*t,c=(o.shadowOffsetY??0)*t,u=Math.max(.1,o.textStrokeWidth??0)*t;a.left+=h-u,a.top+=c-u,a.width+=u*2,a.height+=u*2,i.push(a)})}),i.length?K.from(...i):void 0},render:(n,e)=>{const{paragraphs:t,glyphBox:r,effects:i,style:s}=e;function o(a,l){n.fillStyle=a,n.fillRect(l.left,l.top,l.width,l.height)}s!=null&&s.backgroundColor&&o(s.backgroundColor,new K(0,0,n.canvas.width,n.canvas.height)),t.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&o(a.style.backgroundColor,a.lineBox)}),i?i.forEach(a=>{qi(a,r,n),n.save();const[l,h,c,u,f,p]=wn(e,a).transpose().elements;n.transform(l,u,h,f,c,p),e.forEachCharacter(y=>{var _;(_=y.parent.style)!=null&&_.backgroundColor&&o(y.parent.style.backgroundColor,y.inlineBox),y.drawTo(n,a)}),n.restore()}):t.forEach(a=>{a.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&o(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(n)})})}),e.debug&&t.forEach(a=>{n.strokeRect(a.lineBox.x,a.lineBox.y,a.lineBox.width,a.lineBox.height)})}}}function wn(n,e){const{fontSize:t,glyphBox:r}=n,i=(e.translateX??0)*t,s=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:h,top:c,width:u,height:f}=r,p=h+u/2,y=c+f/2;return _r.identity(),Be.makeTranslation(i,s),_r.multiply(Be),Be.makeTranslation(p,y),_r.multiply(Be),Be.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),_r.multiply(Be),Be.makeTranslation(-p,-y),_r.multiply(Be),_r.clone()}function cd(){const n=[];return{name:"textDecoration",paths:n,update:e=>{n.length=0;const t=[];let r,i;e.forEachCharacter(s=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:u,strikeoutSize:f}=s,{color:p,textDecoration:y,writingMode:_}=o;if(De(y))i=void 0;else{let m=!1;if((i==null?void 0:i.textDecoration)===y&&(i==null?void 0:i.writingMode)===_&&(i==null?void 0:i.color)===p&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(y){case"underline":r[0].underlinePosition===h&&r[0].underlineThickness===c&&(m=!0);break;case"line-through":r[0].strikeoutPosition===u&&r[0].strikeoutSize===f&&(m=!0);break}m?r.push(s):(r=[],r.push(s),t.push(r)),i=o}}),t.forEach(s=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:u}=s[0],{color:f,textDecoration:p}=o,{left:y,top:_,width:m,height:b}=K.from(...s.map(E=>E.inlineBox));let w=a?y+m:_;const x=a?-1:1;let C=0;switch(p){case"overline":C=h*2;break;case"underline":w+=x*l,C=h*2;break;case"line-through":w+=x*c,C=u*2;break}w-=C;let P;a?P=new zt([{type:"M",x:w,y:_},{type:"L",x:w,y:_+b},{type:"L",x:w+C,y:_+b},{type:"L",x:w+C,y:_},{type:"Z"}],{fill:f}):P=new zt([{type:"M",x:y,y:w},{type:"L",x:y+m,y:w},{type:"L",x:y+m,y:w+C},{type:"L",x:y,y:w+C},{type:"Z"}],{fill:f}),n.push(P)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(s=>{e.save();const[o,a,l,h,c,u]=wn(t,s).transpose().elements;e.transform(o,h,a,c,l,u),n.forEach(f=>{Zr({ctx:e,path:f,fontSize:i.fontSize,...s})}),e.restore()}):n.forEach(s=>{Zr({ctx:e,path:s,fontSize:i.fontSize})})}}}const Pn=mu();class $a extends nd{constructor(t={}){super();d(this,"debug");d(this,"content");d(this,"style");d(this,"effects");d(this,"measureDom");d(this,"needsUpdate",!0);d(this,"computedStyle",{...Pn});d(this,"paragraphs",[]);d(this,"lineBox",new K);d(this,"rawGlyphBox",new K);d(this,"glyphBox",new K);d(this,"pathBox",new K);d(this,"boundingBox",new K);d(this,"measurer",new bn);d(this,"plugins",new Map);d(this,"fonts");this.debug=t.debug??!1,this.content=t.content??"",this.style=t.style??{},this.measureDom=t.measureDom,this.effects=t.effects,this.fonts=t.fonts,this.use(ld()).use(cd()).use(od()).use(hd()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(r=>r.characters))}use(t){return this.plugins.set(t.name,t),this}forEachCharacter(t){return this.paragraphs.forEach((r,i)=>{r.fragments.forEach((s,o)=>{s.characters.forEach((a,l)=>{t(a,{paragraphIndex:i,fragmentIndex:o,characterIndex:l})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(t=>{var r;return(r=t.load)==null?void 0:r.call(t,this)}))}updateParagraphs(){this.computedStyle={...Pn,...this.style};let{content:t,computedStyle:r}=this;const i=[];if(typeof t=="string"){const s=new Kr({},r);s.addFragment(t),i.push(s)}else{t=Array.isArray(t)?t:[t];for(const s of t)if(typeof s=="string"){const o=new Kr({},r);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new Kr({},r);s.forEach(a=>{if(typeof a=="string")o.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&o.addFragment(l,h)}}),i.push(o)}else if("fragments"in s){const{fragments:o,...a}=s,l=new Kr(a,r);o.forEach(h=>{const{content:c,...u}=h;c!==void 0&&l.addFragment(c,u)}),i.push(l)}else if("content"in s){const{content:o,...a}=s;if(o!==void 0){const l=new Kr(a,r);l.addFragment(o),i.push(l)}}}return this.paragraphs=i,this}measure(t=this.measureDom){const r={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const i=this.measurer.measure(this.paragraphs,this.computedStyle,t);this.paragraphs=i.paragraphs,this.lineBox=i.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,o)=>(s.updateOrder??0)-(o.updateOrder??0)).forEach(s=>{var o;(o=s.update)==null||o.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in r)i[s]=this[s],this[s]=r[s];return this.emit("measure",{text:this,result:i}),i}getGlyphBox(){const t=D.MAX,r=D.MIN;return this.characters.forEach(i=>{if(!i.getGlyphMinMax(t,r)){const{inlineBox:s}=i,o=new D(s.left,s.top),a=new D(s.left+s.width,s.top+s.height);t.min(o,a),r.max(o,a)}}),new K(t.x,t.y,r.x-t.x,r.y-t.y)}updatePathBox(){return this.pathBox=K.from(this.glyphBox,...Array.from(this.plugins.values()).map(t=>t.getBoundingBox?t.getBoundingBox(this):Lr(t.paths??[])).filter(Boolean)),this}updateBoundingBox(){const{lineBox:t,rawGlyphBox:r,pathBox:i}=this,s=Math.min(i.left,i.left+t.left-r.left),o=Math.min(i.top,i.top+t.top-r.top),a=Math.max(i.right,i.right+t.right-r.right),l=Math.max(i.bottom,i.bottom+t.bottom-r.bottom);return this.boundingBox=new K(s,o,a-s,l-o),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(t){const{view:r,pixelRatio:i=2}=t,s=r.getContext("2d");s&&(this.needsUpdate&&this.update(),Zf(s,i,this.boundingBox),Kf(s,this),Array.from(this.plugins.values()).sort((o,a)=>(o.renderOrder??0)-(a.renderOrder??0)).forEach(o=>{var a;if(o.render)(a=o.render)==null||a.call(o,s,this);else if(o.paths){const l=this.computedStyle;o.paths.forEach(h=>{Zr({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:r,pixelRatio:i}))}}function ud(n,e){return new $a(n).measure()}function fd(n,e){return new $a(n).render(n)}var dd=Object.defineProperty,pd=Object.getOwnPropertyDescriptor,Qr=(n,e,t,r)=>{for(var i=r>1?void 0:r?pd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&dd(e,t,i),i};const gd=new Set(Object.keys(Pn));g.Text2D=class extends g.Element2D{constructor(t){super();d(this,"effects");d(this,"texture",new pt(document.createElement("canvas")));d(this,"_subTextsCount",0);this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"content":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&t==="effects"&&this._getSubTexts().forEach(s=>{s.setProperties({[t]:r})})}_onUpdateStyleProperty(t,r,i){if(t!=="height"){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":this.split&&this._updateSubTexts();break}typeof t=="string"&&gd.has(t)&&(this._subTextsCount&&t!=="width"&&t!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[t]:r})}),this.requestRedraw())}}_getSubTexts(){return this.getChildren(Ur.FRONT).filter(t=>t instanceof g.Text2D)}_updateSubTexts(){const t=this._getSubTexts(),r=this.measure();let i=0;this.split&&r.paragraphs.forEach(s=>{s.fragments.forEach(o=>{o.characters.forEach(a=>{const l=t[i];l&&(l.style.left=a.inlineBox.left,l.style.top=a.inlineBox.top),i++})})})}measure(){const t=ud({content:this.content,style:{...this.style.toJSON(),height:void 0}});return this.style.width||(this.style.width=t.boundingBox.width),this.style.height||(this.style.height=t.boundingBox.height),t}_updateSplit(){this._subTextsCount&&(this.getChildren(Ur.FRONT).forEach(r=>this.removeChild(r)),this._subTextsCount=0);const t=this.measure();this.split&&t.paragraphs.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(s=>{this.addChild(new g.Text2D({pixelRatio:this.pixelRatio,content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),Ur.FRONT),this._subTextsCount++})})})}_drawContent(){var t,r;if(!this.split){const i=(r=(t=this.children)==null?void 0:t.find(s=>"onText2DRender"in s))==null?void 0:r.onText2DRender;i?i():fd({view:this.texture.source,pixelRatio:this.pixelRatio,content:this.content,effects:this.effects,style:this.style.toJSON()}),this.texture.requestUpload(),this.context.fillStyle=this.texture,this.context.textureTransform=new qt().scale(1/this.pixelRatio,1/this.pixelRatio),super._drawContent()}}},Qr([U({default:2})],g.Text2D.prototype,"pixelRatio",2),Qr([U({default:!1})],g.Text2D.prototype,"split",2),Qr([U({default:""})],g.Text2D.prototype,"content",2),Qr([U()],g.Text2D.prototype,"effects",2),g.Text2D=Qr([Z("Text2D")],g.Text2D);var md=Object.defineProperty,yd=Object.getOwnPropertyDescriptor,za=(n,e,t,r)=>{for(var i=r>1?void 0:r?yd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&md(e,t,i),i};g.Video2D=class extends g.Element2D{constructor(t){super();d(this,"texture");d(this,"_wait",Promise.resolve());this.setProperties(t)}get duration(){var t;return(((t=this.texture)==null?void 0:t.duration)??0)*1e3}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._wait=this._load(r);break}}waitLoad(){return this._wait}async _load(t){this.texture=await we.video.load(t),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_drawContent(){const t=this.texture;t&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height)),super._drawContent()}_updateVideoCurrentTime(){let t=this.visibleRelativeTime;if(t<0)return;const r=this.texture;if(!r)return;const i=r.duration;t=i?t%(i*1e3):0,!r.isPlaying&&!r.seeking&&(t=~~t/1e3,r.currentTime!==t&&(r.currentTime=t))}_process(t){this._updateVideoCurrentTime(),super._process(t)}},za([U({default:""})],g.Video2D.prototype,"src",2),g.Video2D=za([Z("Video2D")],g.Video2D);const es=class es extends ve{constructor(){super(...arguments);d(this,"playbackRate",1);d(this,"muted",!1);d(this,"volume",1);d(this,"paused",!1)}static get instance(){return this._instance||(this._instance=new es),this._instance}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(t){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}};d(es,"_instance");let Yi=es;const si=class si extends ve{constructor(){super(...arguments);d(this,"_source",null);d(this,"_audio",null);d(this,"_end",0);d(this,"_pausedReal",!1);d(this,"_duration",0);d(this,"_start",0);d(this,"_playing",!1);d(this,"_paused",!1);d(this,"_playbackRate",1);d(this,"_volume",1);d(this,"_loop",!1);d(this,"_muted",!1);d(this,"_onUpdate",()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())})}get progress(){var t;return(((t=this._source)==null?void 0:t.currentTime)??0)/this._duration}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh())}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}set(t,r){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"playbackRate":this.playbackRate=r;break;case"volume":this.volume=r;break;case"paused":this.paused=r;break;case"loop":this.loop=r;break;case"muted":this.muted=r;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(t){this._playing=!1,this._duration=t.source.duration;const r=this._source=t.source.cloneNode(!1);return r.src=t.parent.src,r.onplay=this._onPlay.bind(this),r.onpause=this._onPause.bind(this),t.context.on("refresh",this.refresh),t.context.on("refreshPaused",this.refreshPaused),this._audio=t,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(t){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const t=this._audio.context,r=this._audio.parent;this._source.loop=this._loop||r.loop;const i=t.volume*(t.muted?0:1),s=r.volume*(r.muted?0:1),o=this._volume*(this._muted?0:1);this._source.volume=o*i*s,this._source.playbackRate=this._playbackRate*t.playbackRate*r.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const t=this._paused||this._audio.parent.paused||this._audio.context.paused;t!==this._pausedReal&&(this._pausedReal=t,t?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",t))}play(t={}){if(!this._source)return;const{start:r=0,end:i=0}=t;i&&console.assert(i>r,"End time is before start time"),t.playbackRate!==void 0&&(this._playbackRate=t.playbackRate),t.volume!==void 0&&(this._volume=t.volume),t.loop!==void 0&&(this._loop=t.loop),t.muted!==void 0&&(this._muted=t.muted),this.refresh(),this.loop&&i!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=r,this._end=i||this._duration,this._start=Math.max(0,this._start-si.PADDING),this._end=Math.min(this._end+si.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=r,this._source.onloadedmetadata=null,this.emit("progress",r,this._duration),ft.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){ft.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){ft.off(this._onUpdate),this.removeAllListeners();const t=this._source;t&&(t.onended=null,t.onplay=null,t.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}};d(si,"PADDING",.1);let Wi=si;class Va{constructor(e){d(this,"source",new globalThis.Audio);d(this,"_src","");this.parent=e}get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return Yi.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new Wi}}class Cn extends ve{constructor(t,r){super();d(this,"_processers",[]);this._input=t,this._output=r}get processors(){return this._processers}set processors(t){if(this._processers.forEach(r=>r.disconnect()),this._processers.length=0,this._input.connect(this._output),t.length){this._processers=t.slice(0),this._input.disconnect();let r;t.forEach(i=>{r?r.connect(i.destination):this._input.connect(i.destination),r=i}),r.connect(this._output)}}get destination(){return this._input}}class _d{constructor(e,t=null){this.destination=e,this.source=t}connect(e){var t;(t=this.source)==null||t.connect(e)}disconnect(){var e;(e=this.source)==null||e.disconnect()}}function vd(){if(ls)return new AudioContext;if(hs){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function bd(n,e,t){if(cs)return new OfflineAudioContext(n,e,t);if($n){const r=globalThis.webkitOfflineAudioContext;return new r(n,e,t)}else throw new Error("Failed to createOfflineAudioContext")}const rs=class rs extends Cn{constructor(){const t=vd(),r=bd(1,2,cs?Math.max(8e3,Math.min(96e3,t.sampleRate)):44100),i=t.createDynamicsCompressor(),s=t.createAnalyser();s.connect(i),i.connect(t.destination);super(s,i);d(this,"_context");d(this,"_offlineContext");d(this,"_locked");d(this,"muted",!1);d(this,"volume",1);d(this,"playbackRate",1);d(this,"autoPause",!0);d(this,"_paused",!1);d(this,"_pausedOnBlur",!1);d(this,"_compressor");d(this,"_analyser");d(this,"_unlock",()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))});this._context=t,this._offlineContext=r,this._compressor=i,this._analyser=s,this._locked=t.state==="suspended"&&(_e||Fn),Pr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}static get instance(){return this._instance||(this._instance=new rs),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(t,r){this.instance.setParamValue(t,r)}static decode(t){return this.instance.decode(t)}get audioContext(){return this._context}get offlineContext(){return this._offlineContext}get paused(){return this._paused}set paused(t){t&&this._context.state==="running"?this._context.suspend():!t&&this._context.state==="suspended"&&this._context.resume(),this._paused=t}_onFocus(){if(!this.autoPause)return;const t=this._context.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}playEmptySound(){const t=this._context.createBufferSource();t.buffer=this._context.createBuffer(1,1,22050),t.connect(this._context.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t){return new Promise((r,i)=>{const s=a=>{i(new Error((a==null?void 0:a.message)||"Unable to decode file"))},o=this._offlineContext.decodeAudioData(t,r,s);o&&o.catch(s)})}setParamValue(t,r){t.setValueAtTime?t.setValueAtTime(r,this._context.currentTime):t.value=r}};d(rs,"_instance");let Le=rs;class Xa extends ve{constructor(){super(...arguments);d(this,"_audio",null);d(this,"_sourceNode",null);d(this,"_gain",null);d(this,"_progress",0);d(this,"_pausedReal",!1);d(this,"_paused",!1);d(this,"_volume",1);d(this,"_playbackRate",1);d(this,"_loop",!1);d(this,"_muted",!1);d(this,"_duration",0);d(this,"_end",0);d(this,"_elapsed",0);d(this,"_lastUpdate",this._now());d(this,"_processors",[]);d(this,"_onComplete",()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)});d(this,"_updateListener",()=>this._update())}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh(),this._update(!0))}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}init(t){return this._audio=t,t.context.on("refresh",this.refresh),t.context.on("refreshPaused",this.refreshPaused),this}_now(){var t;return((t=this._audio)==null?void 0:t.context.audioContext.currentTime)??0}play(t={}){var a;if(!this._audio)return;const{end:r=0,start:i=0}=t;r&&console.assert(r>i,"End time is before start time"),this._end=r,this._elapsed=i,t.volume!==void 0&&(this._volume=t.volume),t.playbackRate!==void 0&&(this._playbackRate=t.playbackRate),t.muted!==void 0&&(this._muted=t.muted),t.loop!==void 0&&(this._loop=t.loop),t.processors!==void 0&&(this._processors=t.processors),this._paused=!1;const{source:s,gain:o}=this._audio.cloneSource();this._sourceNode=s,this._gain=o,this.refresh(),s.onended=this._onComplete.bind(this),this._duration=((a=s.buffer)==null?void 0:a.duration)??0,this._lastUpdate=this._now(),this._loop?(s.loopStart=i,s.loopEnd=r,s.start(0,i)):r?s.start(0,i,r-i):s.start(0,i),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(t=!1){if(this._sourceNode){const r=this._now(),i=r-this._lastUpdate;if(i>0||t){this._elapsed+=i*this._sourceNode.playbackRate.value,this._lastUpdate=r;const s=this._duration;let o;if(this._sourceNode.loopStart){const a=this._sourceNode.loopEnd-this._sourceNode.loopStart;o=(this._sourceNode.loopStart+this._elapsed%a)/s}else o=this._elapsed%s/s;this._progress=o,this.emit("progress",o,s)}}}refresh(){if(!this._audio||!this._sourceNode)return;const t=this._audio.context,r=this._audio.parent;this._sourceNode.loop=this._loop||r.loop,t.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*r.volume*(r.muted?0:1)*t.volume*(t.muted?0:1)),t.setParamValue(this._sourceNode.playbackRate,this._playbackRate*r.playbackRate*t.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let t=this._sourceNode;this._processors.forEach(r=>{t.connect(r.destination),t=r}),t.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const t=this._paused||this._audio.parent.paused||this._audio.context.paused;t!==this._pausedReal&&(this._pausedReal=t,t?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",t))}_enableTicker(t){ft.off(this._updateListener),t&&ft.on(this._updateListener)}destroy(){var t,r,i;this.removeAllListeners(),this._stop(),(t=this._gain)==null||t.disconnect(),this._gain=null,(r=this._audio)==null||r.context.off("refresh",this.refresh),(i=this._audio)==null||i.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(s=>s.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class ja extends Cn{constructor(t){const r=Le.audioContext,i=r.createBufferSource(),s=r.createGain(),o=r.createAnalyser();i.connect(o),o.connect(s),s.connect(Le.instance.destination);super(o,s);d(this,"_sourceBuffer");d(this,"_sourceNode");d(this,"_sourceLoad");d(this,"gain");d(this,"analyser");this.parent=t,this._sourceNode=i,this.gain=s,this.analyser=o}get context(){return Le.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){var t;return((t=this._sourceNode.buffer)==null?void 0:t.duration)??0}get buffer(){return this._sourceNode.buffer}set buffer(t){this._sourceNode.buffer=t}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(t=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>t(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>t(this)):t(this)})),this._sourceLoad}_loadUrl(t){return new Promise(r=>{fetch(t).then(i=>i.arrayBuffer()).then(i=>this._decode(i)).finally(()=>r(this))})}_decode(t){return Promise.resolve(t instanceof AudioBuffer?t:Le.decode(t)).then(r=>(this.parent.isLoaded=!0,this.buffer=r,r))}cloneSource(){const t=this.context,r=this._sourceNode,i=t.audioContext.createBufferSource(),s=t.audioContext.createGain();return i.buffer=r.buffer,i.loop=r.loop,t.setParamValue(i.playbackRate,r.playbackRate.value),i.connect(s),s.connect(this.destination),{source:i,gain:s}}createSound(){return new Xa}}var Ga=Object.defineProperty,xd=Object.getOwnPropertyDescriptor,wd=(n,e,t)=>e in n?Ga(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Pd=(n,e,t,r)=>{for(var i=r>1?void 0:r?xd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ga(e,t,i),i},Cd=(n,e,t)=>wd(n,e+"",t);g.Audio=class extends g.Node{constructor(t=""){super();d(this,"_sounds",[]);d(this,"_platformAudio",zn?new ja(this):new Va(this));d(this,"_src");d(this,"isLoaded",!1);d(this,"_volume",1);d(this,"_muted",!1);d(this,"_loop",!1);d(this,"_playbackRate",1);d(this,"_isPlaying",!1);d(this,"_paused",!1);d(this,"multiple",!1);d(this,"start",0);d(this,"end",0);d(this,"_onComplete",t=>{if(this._sounds){const r=this._sounds.indexOf(t);r>-1&&this._sounds.splice(r,1),this._isPlaying=this._sounds.length>0}this._recycleSound(t)});d(this,"_prevTime",0);d(this,"_timer",0);this.src=t}get platformAudio(){return this._platformAudio}get src(){return this._src}set src(t){this._src!==t&&(this._src=t,this.load())}get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get duration(){return this._platformAudio.duration*1e3}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh())}get isPlaying(){return this._isPlaying}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let t=this._sounds.length-1;t>=0;t--)this._sounds[t].stop();return this}play(t={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const r=this._createSound();this._sounds.push(r),r.once("end",()=>{var o;(o=t.complete)==null||o.call(t),this._onComplete(r)}),r.once("stop",()=>this._onComplete(r));const i=((t==null?void 0:t.start)??this.start)/1e3,s=((t==null?void 0:t.end)??this.end)/1e3;return r.play({...t,start:i,end:s}),r}_removeSounds(){for(let t=this._sounds.length-1;t>=0;t--)this._recycleSound(this._sounds[t]);this._sounds.length=0}_createSound(){return g.Audio._soundPool.length>0?g.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let t=this._sounds.length,r=0;r<t;r++)this._sounds[r].refresh()}refreshPaused(){for(let t=this._sounds.length,r=0;r<t;r++)this._sounds[r].refreshPaused()}_recycleSound(t){t.destroy(),g.Audio._soundPool.includes(t)||g.Audio._soundPool.push(t)}_process(t){var r;if(super._process(t),this.isRenderable()){const i=((r=this._tree)==null?void 0:r.timeline.current)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.visibleDelay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Cd(g.Audio,"_soundPool",[]),g.Audio=Pd([Z("Audio")],g.Audio);class Td extends g.Element2D{}var Ed=Object.defineProperty,Md=Object.getOwnPropertyDescriptor,Hi=(n,e,t,r)=>{for(var i=r>1?void 0:r?Md(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ed(e,t,i),i};g.AudioWaveform=class extends g.Element2D{constructor(t={}){super();d(this,"src");d(this,"gap",0);d(this,"color","#000000");d(this,"_audioBuffer");d(this,"_src",Pr?new pt(document.createElement("canvas")):void 0);d(this,"_needsUpdateTexture",!1);this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._loadSrc(r);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(t){await globalThis.fetch(t).then(r=>r.arrayBuffer()).then(r=>Le.decode(r)).then(r=>{this._audioBuffer=r,this.syncTexture(!0)})}syncTexture(t=!1){var u,f;const r=this._audioBuffer;if(!r||!t&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(u=this._src)==null?void 0:u.source;if(!i)return;const{width:s=0,height:o=0}=this.style;i.width=s,i.height=o;const a=i.getContext("2d");if(!a){console.warn("Failed to getContext('2d') in syncTexture");return}a.fillStyle=this.color;const l=r.getChannelData(0),h=Math.ceil(l.length/s),c=o/2;for(let p=1,y=-1,_=0;_<s;_++){for(let m=0;m<h;m++){const b=l[_*h+m];b<p&&(p=b),b>y&&(y=b)}if(!this.gap||_%(this.gap*2)===0){const m=_,b=(1+p)*c,w=this.gap||1,x=Math.max(1,(y-p)*c);a.fillRect(m,b,w,x),p=1,y=-1}}(f=this._src)==null||f.requestUpload(),this.requestRedraw()}_process(t){this.syncTexture(),super._process(t)}_drawSrc(){const t=this._src;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height))}},Hi([U()],g.AudioWaveform.prototype,"src",2),Hi([U()],g.AudioWaveform.prototype,"gap",2),Hi([U()],g.AudioWaveform.prototype,"color",2),g.AudioWaveform=Hi([Z("AudioWaveform")],g.AudioWaveform);const Sd=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,Ad=/vec(\d)\((.*)\)/;function Od(n){n=n.trim();const e=n.match(Ad);if(e){const t=Array.from({length:Number(e[1])},()=>0);return e[2].split(",").forEach((r,i)=>{t[i]=Number(r.trim())}),t}return Number(n)}const ni=class ni extends lt{constructor(t){super();d(this,"vert",`attribute vec2 position;
33
+ attribute vec2 uv;
34
+ varying vec2 vUv;
35
+ void main() {
36
+ gl_Position = vec4(position, 0.0, 1.0);
37
+ vUv = uv;
38
+ }`);d(this,"uniforms",new Map([["ratio",0],["from",0],["to",1],["progress",0]]));d(this,"has",{getColor:!1,getFromColor:!1,getToColor:!1,transform:!1,transition:!1});const r=this.has;for(const s in ni.RE)r[s]=ni.RE[s].test(t);this.frag=`precision highp float;
39
+ varying vec2 vUv;
40
+ uniform float ratio;
41
+ uniform float progress;
42
+ ${r.getColor||r.getFromColor||r.getToColor?`
43
+ uniform sampler2D from;`:""}${r.getFromColor||r.getToColor?`
44
+ uniform sampler2D to;`:""}
45
+ ${r.getColor?`
46
+ vec4 getColor(vec2 uv) { return texture2D(from, uv); }`:""}${r.getFromColor||r.getToColor?`
47
+ vec4 getFromColor(vec2 uv) { return texture2D(from, uv); }
48
+ vec4 getToColor(vec2 uv) { return texture2D(to, uv); }`:""}
49
+ ${t}${r.transform?`
50
+ void main(void) { gl_FragColor = transform(vUv); }`:r.transition?`
51
+ void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=t.matchAll(Sd);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),Od(s[2]))})}};d(ni,"RE",{getColor:/\sgetColor\s*\(/,getFromColor:/\sgetFromColor\s*\(/,getToColor:/\sgetToColor\s*\(/,transform:/\stransform\s*\(/,transition:/\stransition\s*\(/});let Zi=ni;var Ud=Object.defineProperty,Id=Object.getOwnPropertyDescriptor,Qe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Id(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ud(e,t,i),i};g.Effect=class extends g.Node{constructor(t){super();d(this,"material");d(this,"mode");d(this,"viewport",new g.Viewport);d(this,"viewport2",new g.Viewport);d(this,"_renderId",0);d(this,"_renderViewport");d(this,"_previousSibling");d(this,"_nextSibling");d(this,"_onProcessing",()=>{switch(this._updateVisibility(),this._mode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}});d(this,"_onNodeProcessed",t=>{var i;if(!this.isRenderable())return;const r=(i=this._tree)==null?void 0:i.renderStack;if(r)switch(this._mode){case"transition":t.is(this._previousSibling)?(this._previousSibling=void 0,r.push(this)):t.is(this._nextSibling)&&(this._nextSibling=void 0,r.push(this));break}});this.setProperties(t)}get _mode(){return this.mode??"parent"}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"glsl":{const s=new Zi(r);!this.mode&&s.has.transition&&(this.mode="transition"),this.material=s;break}case"glslSrc":{r?we.text.load(r).then(s=>this.glsl=s):this.glsl="";break}}}_enterTree(){const t=this._tree;t.on("processing",this._onProcessing),t.on("nodeProcessed",this._onNodeProcessed),this.viewport._setTree(t),this.viewport2._setTree(t)}_exitTree(){const t=this._tree;t.off("processing",this._onProcessing),t.off("nodeProcessed",this._onNodeProcessed),this.viewport._setTree(void 0),this.viewport2._setTree(void 0)}_processParent(){var a,l;const t=(a=this._tree)==null?void 0:a.renderStack;if(!t)return;const r=(l=t.currentCall)==null?void 0:l.parentCall;if(!r)return;const i=r.calls;let s,o;i.forEach((h,c)=>{var u;(h.renderable.is(this._parent)||(u=h.renderable.parent)!=null&&u.is(this._parent))&&(s=s??c,o=c)}),!(s===void 0||o===void 0)&&(i.splice(o+1,0,t.createCall(this)),i.splice(s,0,t.createCall(this)))}_processChildren(){var t;this._children.length&&(super.emit("process"),(t=this._tree)==null||t.renderStack.push(this))}_onProcess(t=0){switch(this._renderId=0,this._mode){case"before":super._onProcess(t);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(t){var i;const r=(i=this._tree)==null?void 0:i.getCurrentViewport();r&&this.apply(t,r,{redraw:!0})}_renderTransition(t){var r;if(this._renderId%2===0)this._renderViewport=(r=this._tree)==null?void 0:r.getCurrentViewport(),this._renderViewport&&(this.viewport.activateWithCopy(t,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(t),t.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(t),t.clear(),this.viewport.texture.activate(t,0),this.viewport2.texture.activate(t,1),this.apply(t,i,{from:this.viewport,to:this.viewport2}),t.texture.unbind(0),t.texture.unbind(1))}}_renderParentOrChildren(t){var r;if(this._renderId%2===0)this._renderViewport=(r=this._tree)==null?void 0:r.getCurrentViewport(),this._renderViewport&&this.viewport.resize(this._renderViewport.width,this._renderViewport.height),this.viewport.activate(t),t.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport.activate(t),this.apply(t,this.viewport,{redraw:!0,target:this._mode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(t),this.viewport.texture.activate(t,0),et.draw(t))}}_parseTargetArea(){if(this._mode==="parent"&&this._parent instanceof g.Node2D){const t=this._parent.getBoundingBox();return[t.left/this.viewport.width,t.top/this.viewport.height,t.width/this.viewport.width,t.height/this.viewport.height]}}_render(t){switch(this._mode){case"before":this._renderBefore(t);break;case"transition":this._renderTransition(t);break;case"parent":case"children":default:this._renderParentOrChildren(t);break}this._renderId++}apply(t,r,i){this.material&&(i!=null&&i.redraw?r.redraw(t,()=>{et.draw(t,this.material,{from:0,to:1,progress:this.visibleProgress,ratio:r.width/r.height})}):et.draw(t,this.material,{from:0,to:1,progress:this.visibleProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Qe([nt()],g.Effect.prototype,"material",2),Qe([U()],g.Effect.prototype,"mode",2),Qe([U({default:""})],g.Effect.prototype,"glsl",2),Qe([U({default:""})],g.Effect.prototype,"glslSrc",2),Qe([U({alias:"visibleDelay"})],g.Effect.prototype,"delay",2),Qe([U({alias:"visibleDuration"})],g.Effect.prototype,"duration",2),g.Effect=Qe([Z({tag:"Effect",renderable:!0})],g.Effect);var qa=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Rd=(n,e,t)=>e in n?qa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Tn=(n,e,t,r)=>{for(var i=r>1?void 0:r?Dd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&qa(e,t,i),i},Ya=(n,e,t)=>Rd(n,typeof e!="symbol"?e+"":e,t);const Bd=`attribute vec2 position;
52
+ attribute vec2 uv;
53
+ varying vec2 vUv[9];
54
+ uniform float strength;
55
+
56
+ void main(void) {
57
+ gl_Position = vec4(position, 0, 1);
58
+ vUv[0] = uv + vec2(-4.0 * strength, 0.0);
59
+ vUv[1] = uv + vec2(-3.0 * strength, 0.0);
60
+ vUv[2] = uv + vec2(-2.0 * strength, 0.0);
61
+ vUv[3] = uv + vec2(-1.0 * strength, 0.0);
62
+ vUv[4] = uv + vec2(0.0 * strength, 0.0);
63
+ vUv[5] = uv + vec2(1.0 * strength, 0.0);
64
+ vUv[6] = uv + vec2(2.0 * strength, 0.0);
65
+ vUv[7] = uv + vec2(3.0 * strength, 0.0);
66
+ vUv[8] = uv + vec2(4.0 * strength, 0.0);
67
+ }`,Ld=`attribute vec2 position;
68
+ attribute vec2 uv;
69
+ uniform float strength;
70
+ varying vec2 vUv[9];
71
+
72
+ void main(void) {
73
+ gl_Position = vec4(position, 0, 1);
74
+ vUv[0] = uv + vec2(0.0, -4.0 * strength);
75
+ vUv[1] = uv + vec2(0.0, -3.0 * strength);
76
+ vUv[2] = uv + vec2(0.0, -2.0 * strength);
77
+ vUv[3] = uv + vec2(0.0, -1.0 * strength);
78
+ vUv[4] = uv + vec2(0.0, 0.0 * strength);
79
+ vUv[5] = uv + vec2(0.0, 1.0 * strength);
80
+ vUv[6] = uv + vec2(0.0, 2.0 * strength);
81
+ vUv[7] = uv + vec2(0.0, 3.0 * strength);
82
+ vUv[8] = uv + vec2(0.0, 4.0 * strength);
83
+ }`,Wa=`varying vec2 vUv[9];
84
+ uniform sampler2D sampler;
85
+
86
+ void main(void) {
87
+ gl_FragColor = vec4(0.0);
88
+ float flag = 0.0;
89
+ for (int i = 0; i < 9; i++) {
90
+ vec2 uv = vUv[i];
91
+ if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
92
+ flag = 1.0;
93
+ break;
94
+ }
95
+ }
96
+ if (flag == 1.0) {
97
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.028532;
98
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.067234;
99
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.124009;
100
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.179044;
101
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.20236;
102
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.179044;
103
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.124009;
104
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.067234;
105
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.028532;
106
+ } else {
107
+ gl_FragColor += texture2D(sampler, vUv[0]) * 0.028532;
108
+ gl_FragColor += texture2D(sampler, vUv[1]) * 0.067234;
109
+ gl_FragColor += texture2D(sampler, vUv[2]) * 0.124009;
110
+ gl_FragColor += texture2D(sampler, vUv[3]) * 0.179044;
111
+ gl_FragColor += texture2D(sampler, vUv[4]) * 0.20236;
112
+ gl_FragColor += texture2D(sampler, vUv[5]) * 0.179044;
113
+ gl_FragColor += texture2D(sampler, vUv[6]) * 0.124009;
114
+ gl_FragColor += texture2D(sampler, vUv[7]) * 0.067234;
115
+ gl_FragColor += texture2D(sampler, vUv[8]) * 0.028532;
116
+ }
117
+ }`;g.BlurEffect=class extends g.Effect{apply(e,t){t.redraw(e,()=>{et.draw(e,g.BlurEffect.materialX,{sampler:0,strength:1/t.width*this.strength/this.quality})}),t.redraw(e,()=>{et.draw(e,g.BlurEffect.materialY,{sampler:0,strength:1/t.height*this.strength/this.quality})})}},Ya(g.BlurEffect,"materialX",new lt({vert:Bd,frag:Wa})),Ya(g.BlurEffect,"materialY",new lt({vert:Ld,frag:Wa})),Tn([U({default:8})],g.BlurEffect.prototype,"strength",2),Tn([U({default:4})],g.BlurEffect.prototype,"quality",2),g.BlurEffect=Tn([Z("BlurEffect")],g.BlurEffect);var Ha=Object.defineProperty,kd=Object.getOwnPropertyDescriptor,Nd=(n,e,t)=>e in n?Ha(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Te=(n,e,t,r)=>{for(var i=r>1?void 0:r?kd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ha(e,t,i),i},Fd=(n,e,t)=>Nd(n,e+"",t);g.ColorAdjustEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"saturation",1);d(this,"contrast",1);d(this,"brightness",1);d(this,"red",1);d(this,"green",1);d(this,"blue",1);d(this,"alpha",1);d(this,"gamma",1)}apply(t,r){r.redraw(t,()=>{et.draw(t,g.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Fd(g.ColorAdjustEffect,"material",new lt({vert:`precision mediump float;
118
+ attribute vec2 position;
119
+ attribute vec2 uv;
120
+ varying vec2 vUv;
121
+ void main() {
122
+ gl_Position = vec4(position, 0.0, 1.0);
123
+ vUv = uv;
124
+ }`,frag:`varying vec2 vUv;
125
+ uniform sampler2D sampler;
126
+ uniform float gamma;
127
+ uniform float contrast;
128
+ uniform float saturation;
129
+ uniform float brightness;
130
+ uniform float red;
131
+ uniform float green;
132
+ uniform float blue;
133
+ uniform float alpha;
134
+
135
+ void main(void) {
136
+ vec4 c = texture2D(sampler, vUv);
137
+ if (c.a > 0.0) {
138
+ c.rgb /= c.a;
139
+ vec3 rgb = pow(c.rgb, vec3(1. / gamma));
140
+ rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);
141
+ rgb.r *= red;
142
+ rgb.g *= green;
143
+ rgb.b *= blue;
144
+ c.rgb = rgb * brightness;
145
+ c.rgb *= c.a;
146
+ }
147
+ gl_FragColor = c * alpha;
148
+ }`})),Te([U()],g.ColorAdjustEffect.prototype,"saturation",2),Te([U()],g.ColorAdjustEffect.prototype,"contrast",2),Te([U()],g.ColorAdjustEffect.prototype,"brightness",2),Te([U()],g.ColorAdjustEffect.prototype,"red",2),Te([U()],g.ColorAdjustEffect.prototype,"green",2),Te([U()],g.ColorAdjustEffect.prototype,"blue",2),Te([U()],g.ColorAdjustEffect.prototype,"alpha",2),Te([U()],g.ColorAdjustEffect.prototype,"gamma",2),g.ColorAdjustEffect=Te([Z("ColorAdjustEffect")],g.ColorAdjustEffect);var Za=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,zd=(n,e,t)=>e in n?Za(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ka=(n,e,t,r)=>{for(var i=r>1?void 0:r?$d(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Za(e,t,i),i},Vd=(n,e,t)=>zd(n,e+"",t);g.ColorFilterEffect=class extends g.Effect{constructor(t){super();d(this,"_colorMatrix",new Fs);this.setProperties(t)}apply(t,r){if(!this.filter)return;const i=wr(this.filter),s=this._colorMatrix.identity();i.forEach(({name:o,args:a})=>{const l=a.map(h=>h.normalizedIntValue);switch(o){case"hue-rotate":case"hueRotate":s.hueRotate(l[0]*at);break;case"saturate":s.saturate(l[0]);break;case"brightness":s.brightness(l[0]);break;case"contrast":s.contrast(l[0]);break;case"invert":s.invert(l[0]);break;case"sepia":s.sepia(l[0]);break;case"opacity":s.opacity(l[0]);break;case"grayscale":s.grayscale(l[0]);break}}),r.redraw(t,()=>{et.draw(t,g.ColorFilterEffect.material,{sampler:0,m:s.toArray()})})}},Vd(g.ColorFilterEffect,"material",new lt({vert:`precision mediump float;
149
+ attribute vec2 position;
150
+ attribute vec2 uv;
151
+ varying vec2 vUv;
152
+ void main() {
153
+ gl_Position = vec4(position, 0.0, 1.0);
154
+ vUv = uv;
155
+ }`,frag:`precision highp float;
156
+ varying vec2 vUv;
157
+ uniform sampler2D sampler;
158
+ uniform float m[20];
159
+
160
+ void main(void) {
161
+ vec4 c = texture2D(sampler, vUv);
162
+ if (c.a > 0.0) {
163
+ c.rgb /= c.a;
164
+ }
165
+ gl_FragColor = vec4(
166
+ m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4] / 255.0,
167
+ m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9] / 255.0,
168
+ m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14] / 255.0,
169
+ m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19] / 255.0
170
+ );
171
+ }`})),Ka([U({default:""})],g.ColorFilterEffect.prototype,"filter",2),g.ColorFilterEffect=Ka([Z("ColorFilterEffect")],g.ColorFilterEffect);var Qa=Object.defineProperty,Xd=Object.getOwnPropertyDescriptor,jd=(n,e,t)=>e in n?Qa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,En=(n,e,t,r)=>{for(var i=r>1?void 0:r?Xd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Qa(e,t,i),i},Gd=(n,e,t)=>jd(n,e+"",t);const Jr=50;g.ColorOverlayEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"colors",[]);d(this,"alpha",.5);d(this,"_color",new Se)}apply(t,r){r.redraw(t,()=>{const i=this.colors.map(s=>{this._color.value=s;const o=this._color.toArray();return o[3]=this.alpha,o});for(;i.length<Jr;)i.push([0,0,0,0]);et.draw(t,g.ColorOverlayEffect.material,{sampler:0,colors:i.slice(0,Jr).flatMap(s=>s)})})}},Gd(g.ColorOverlayEffect,"material",new lt({vert:`precision mediump float;
172
+ attribute vec2 position;
173
+ attribute vec2 uv;
174
+ varying vec2 vUv;
175
+ void main() {
176
+ gl_Position = vec4(position, 0.0, 1.0);
177
+ vUv = uv;
178
+ }`,frag:`precision mediump float;
179
+ uniform sampler2D sampler;
180
+ uniform vec4 colors[${Jr}];
181
+ varying vec2 vUv;
182
+
183
+ float calcWidth() {
184
+ return distance(vec2(0, 0), vec2(1, 0));
185
+ }
186
+
187
+ int calcCount() {
188
+ int count = 0;
189
+ for (int i = 0; i < ${Jr}; i++) {
190
+ if (colors[i] != vec4(0,0,0,0)){
191
+ count++;
192
+ }
193
+ }
194
+ return count;
195
+ }
196
+
197
+ vec4 calcColor(float x) {
198
+ float perUnit = calcWidth() / float(calcCount());
199
+ int index = int(x / perUnit);
200
+
201
+ for(int i=0; i<${Jr}; i++){
202
+ if(i==index){
203
+ return colors[i];
204
+ }
205
+ }
206
+
207
+ return vec4(0, 0, 0, 0);
208
+ }
209
+
210
+ void main(void) {
211
+ vec4 color = texture2D(sampler, vUv);
212
+ vec4 mask = calcColor(vUv.x);
213
+ gl_FragColor = vec4(mix(color.rgb, mask.rgb, color.a * mask.a), color.a);
214
+ }`})),En([U()],g.ColorOverlayEffect.prototype,"colors",2),En([U()],g.ColorOverlayEffect.prototype,"alpha",2),g.ColorOverlayEffect=En([Z("ColorOverlayEffect")],g.ColorOverlayEffect);var Ja=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,Yd=(n,e,t)=>e in n?Ja(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Mn=(n,e,t,r)=>{for(var i=r>1?void 0:r?qd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ja(e,t,i),i},Wd=(n,e,t)=>Yd(n,e+"",t);g.ColorRemoveEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"colors",[]);d(this,"epsilon",.5);d(this,"_color",new Se)}apply(t,r){const s=new Float32Array(150),o=this.colors.map(a=>(this._color.value=a,this._color.toArray().slice(0,3)));for(;o.length<50;)o.push([-1,0,0]);o.slice(0,50).forEach((a,l)=>{s[l*3]=a[0],s[l*3+1]=a[1],s[l*3+2]=a[2]}),r.redraw(t,()=>{et.draw(t,g.ColorRemoveEffect.material,{sampler:0,epsilon:this.epsilon,originalColors:s})})}},Wd(g.ColorRemoveEffect,"material",new lt({vert:`precision mediump float;
215
+ attribute vec2 position;
216
+ attribute vec2 uv;
217
+ varying vec2 vUv;
218
+ void main() {
219
+ gl_Position = vec4(position, 0.0, 1.0);
220
+ vUv = uv;
221
+ }`,frag:`varying vec2 vUv;
222
+ uniform sampler2D sampler;
223
+ uniform float epsilon;
224
+ const int MAX_COLORS = 50;
225
+ uniform vec3 originalColors[MAX_COLORS];
226
+
227
+ void main(void) {
228
+ vec4 color = texture2D(sampler, vUv);
229
+
230
+ for (int i = 0; i < MAX_COLORS; i++) {
231
+ vec3 origColor = originalColors[i];
232
+ if (origColor.r < 0.0) {
233
+ break;
234
+ }
235
+ vec3 colorDiff = origColor - color.rgb;
236
+ if (length(colorDiff) < epsilon) {
237
+ gl_FragColor = vec4(0, 0, 0, 0);
238
+ return;
239
+ }
240
+ }
241
+
242
+ gl_FragColor = color;
243
+ }`})),Mn([U()],g.ColorRemoveEffect.prototype,"colors",2),Mn([U()],g.ColorRemoveEffect.prototype,"epsilon",2),g.ColorRemoveEffect=Mn([Z("ColorRemoveEffect")],g.ColorRemoveEffect);var tl=Object.defineProperty,Hd=Object.getOwnPropertyDescriptor,Zd=(n,e,t)=>e in n?tl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Sn=(n,e,t,r)=>{for(var i=r>1?void 0:r?Hd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&tl(e,t,i),i},Kd=(n,e,t)=>Zd(n,e+"",t);const ti=50;g.ColorReplaceEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"colors",[]);d(this,"epsilon",.05);d(this,"_color",new Se)}apply(t,r){const i=this.colors.map(l=>{this._color.value=l[0];const h=this._color.toArray().slice(0,3);this._color.value=l[1];const c=this._color.toArray().slice(0,3);return[h,c]}),s=this.epsilon,o=new Float32Array(ti*3),a=new Float32Array(ti*3);for(;i.length<ti;)i.push([[-1,0,0],[0,0,0,1]]);i.slice(0,ti).forEach(([l,h],c)=>{o[c*3]=l[0],o[c*3+1]=l[1],o[c*3+2]=l[2],a[c*3]=h[0],a[c*3+1]=h[1],a[c*3+2]=h[2]}),r.redraw(t,()=>{et.draw(t,g.ColorReplaceEffect.material,{sampler:0,epsilon:s,originalColors:o,targetColors:a})})}},Kd(g.ColorReplaceEffect,"material",new lt({vert:`precision mediump float;
244
+ attribute vec2 position;
245
+ attribute vec2 uv;
246
+ varying vec2 vUv;
247
+ void main() {
248
+ gl_Position = vec4(position, 0.0, 1.0);
249
+ vUv = uv;
250
+ }`,frag:`varying vec2 vUv;
251
+ uniform sampler2D sampler;
252
+ uniform float epsilon;
253
+ const int MAX_COLORS = ${ti};
254
+ uniform vec3 originalColors[MAX_COLORS];
255
+ uniform vec3 targetColors[MAX_COLORS];
256
+
257
+ void main(void) {
258
+ gl_FragColor = texture2D(sampler, vUv);
259
+
260
+ float alpha = gl_FragColor.a;
261
+ if (alpha < 0.0001) {
262
+ return;
263
+ }
264
+
265
+ vec3 color = gl_FragColor.rgb / alpha;
266
+
267
+ for(int i = 0; i < MAX_COLORS; i++) {
268
+ vec3 origColor = originalColors[i];
269
+ if (origColor.r < 0.0) {
270
+ break;
271
+ }
272
+ vec3 colorDiff = origColor - color;
273
+ if (length(colorDiff) < epsilon) {
274
+ vec3 targetColor = targetColors[i];
275
+ gl_FragColor = vec4((targetColor + colorDiff) * alpha, alpha);
276
+ return;
277
+ }
278
+ }
279
+ }`})),Sn([U()],g.ColorReplaceEffect.prototype,"colors",2),Sn([U()],g.ColorReplaceEffect.prototype,"epsilon",2),g.ColorReplaceEffect=Sn([Z("ColorReplaceEffect")],g.ColorReplaceEffect);var el=Object.defineProperty,Qd=Object.getOwnPropertyDescriptor,Jd=(n,e,t)=>e in n?el(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,rl=(n,e,t,r)=>{for(var i=r>1?void 0:r?Qd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&el(e,t,i),i},tp=(n,e,t)=>Jd(n,e+"",t);g.EmbossEffect=class extends g.Effect{constructor(t=5){super();d(this,"strength");this.strength=t}apply(t,r){r.redraw(t,()=>{et.draw(t,g.EmbossEffect.material,{sampler:0,strength:this.strength,inputSize:[r.width,r.height,1/r.width,1/r.height]})})}},tp(g.EmbossEffect,"material",new lt({vert:`precision mediump float;
280
+ attribute vec2 position;
281
+ attribute vec2 uv;
282
+ varying vec2 vUv;
283
+ void main() {
284
+ gl_Position = vec4(position, 0.0, 1.0);
285
+ vUv = uv;
286
+ }`,frag:`precision mediump float;
287
+ uniform sampler2D sampler;
288
+ uniform vec4 inputSize;
289
+ uniform float strength;
290
+ varying vec2 vUv;
291
+
292
+ void main(void) {
293
+ vec2 onePixel = inputSize.zw;
294
+ vec4 color;
295
+ color.rgb = vec3(0.5);
296
+ color -= texture2D(sampler, vUv - onePixel) * strength;
297
+ color += texture2D(sampler, vUv + onePixel) * strength;
298
+ color.rgb = vec3((color.r + color.g + color.b) / 3.0);
299
+ float alpha = texture2D(sampler, vUv).a;
300
+ gl_FragColor = vec4(color.rgb * alpha, alpha);
301
+ }`})),rl([U()],g.EmbossEffect.prototype,"strength",2),g.EmbossEffect=rl([Z("EmbossEffect")],g.EmbossEffect);var il=Object.defineProperty,ep=Object.getOwnPropertyDescriptor,rp=(n,e,t)=>e in n?il(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ge=(n,e,t,r)=>{for(var i=r>1?void 0:r?ep(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&il(e,t,i),i},ip=(n,e,t)=>rp(n,e+"",t);g.GlitchEffect=class extends g.Effect{constructor(){super();d(this,"_canvas");d(this,"_texture");d(this,"_sizes");d(this,"_offsets");d(this,"_redraw",!1);d(this,"slices",10);d(this,"sampleSize",512);d(this,"offset",100);d(this,"direction",0);d(this,"fillMode",2);d(this,"seed",0);d(this,"red",[2,2]);d(this,"green",[-10,4]);d(this,"blue",[10,-4]);this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new pt(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const t=this.sampleSize,r=this._texture,i=this._canvas.getContext("2d");i.clearRect(0,0,8,t);let s,o=0;for(let a=0;a<this.slices;a++){s=Math.floor(this._offsets[a]*256);const l=this._sizes[a]*t,h=s>0?s:0,c=s<0?-s:0;i.fillStyle=`rgba(${h}, ${c}, 0, 1)`,i.fillRect(0,o>>0,t,l+1>>0),o+=l}r.requestUpload()}apply(t,r){this._redraw||(this._redraw=!0,this.redraw());const i=r.width,s=r.height,o=this.direction*(Math.PI/180),a=Math.sin(o),l=Math.cos(o);r.redraw(t,()=>{this._texture.activate(t,1),et.draw(t,g.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[i,s,0,0],dimensions:[i,s],aspect:s/i,displacementMap:1,offset:this.offset,sinDir:a,cosDir:l,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},ip(g.GlitchEffect,"material",new lt({vert:`precision mediump float;
302
+ attribute vec2 position;
303
+ attribute vec2 uv;
304
+ varying vec2 vUv;
305
+ void main() {
306
+ gl_Position = vec4(position, 0.0, 1.0);
307
+ vUv = uv;
308
+ }`,frag:`precision mediump float;
309
+
310
+ varying vec2 vUv;
311
+ uniform sampler2D sampler;
312
+
313
+ uniform vec4 filterArea;
314
+ uniform vec4 filterClamp;
315
+ uniform vec2 dimensions;
316
+ uniform float aspect;
317
+
318
+ uniform sampler2D displacementMap;
319
+ uniform float offset;
320
+ uniform float sinDir;
321
+ uniform float cosDir;
322
+ uniform int fillMode;
323
+
324
+ uniform float seed;
325
+ uniform vec2 red;
326
+ uniform vec2 green;
327
+ uniform vec2 blue;
328
+
329
+ const int TRANSPARENT = 0;
330
+ const int ORIGINAL = 1;
331
+ const int LOOP = 2;
332
+ const int CLAMP = 3;
333
+ const int MIRROR = 4;
334
+
335
+ void main(void) {
336
+ vec2 coord = (vUv * filterArea.xy) / dimensions;
337
+
338
+ if (coord.x > 1.0 || coord.y > 1.0) {
339
+ return;
340
+ }
341
+
342
+ float cx = coord.x - 0.5;
343
+ float cy = (coord.y - 0.5) * aspect;
344
+ float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5;
345
+
346
+ // displacementMap: repeat
347
+ // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);
348
+
349
+ // displacementMap: mirror
350
+ ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);
351
+
352
+ vec4 dc = texture2D(displacementMap, vec2(0.5, ny));
353
+
354
+ float displacement = (dc.r - dc.g) * (offset / filterArea.x);
355
+
356
+ coord = vUv + vec2(cosDir * displacement, sinDir * displacement * aspect);
357
+
358
+ if (fillMode == CLAMP) {
359
+ coord = clamp(coord, filterClamp.xy, filterClamp.zw);
360
+ } else {
361
+ if (coord.x > filterClamp.z) {
362
+ if (fillMode == TRANSPARENT) {
363
+ discard;
364
+ } else if (fillMode == LOOP) {
365
+ coord.x -= filterClamp.z;
366
+ } else if (fillMode == MIRROR) {
367
+ coord.x = filterClamp.z * 2.0 - coord.x;
368
+ }
369
+ } else if (coord.x < filterClamp.x) {
370
+ if (fillMode == TRANSPARENT) {
371
+ discard;
372
+ } else if (fillMode == LOOP) {
373
+ coord.x += filterClamp.z;
374
+ } else if (fillMode == MIRROR) {
375
+ coord.x *= -filterClamp.z;
376
+ }
377
+ }
378
+
379
+ if (coord.y > filterClamp.w) {
380
+ if (fillMode == TRANSPARENT) {
381
+ discard;
382
+ } else if (fillMode == LOOP) {
383
+ coord.y -= filterClamp.w;
384
+ } else if (fillMode == MIRROR) {
385
+ coord.y = filterClamp.w * 2.0 - coord.y;
386
+ }
387
+ } else if (coord.y < filterClamp.y) {
388
+ if (fillMode == TRANSPARENT) {
389
+ discard;
390
+ } else if (fillMode == LOOP) {
391
+ coord.y += filterClamp.w;
392
+ } else if (fillMode == MIRROR) {
393
+ coord.y *= -filterClamp.w;
394
+ }
395
+ }
396
+ }
397
+
398
+ gl_FragColor.r = texture2D(sampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r;
399
+ gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
400
+ gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
401
+ gl_FragColor.a = texture2D(sampler, coord).a;
402
+ }`})),ge([U()],g.GlitchEffect.prototype,"slices",2),ge([U()],g.GlitchEffect.prototype,"sampleSize",2),ge([U()],g.GlitchEffect.prototype,"offset",2),ge([U()],g.GlitchEffect.prototype,"direction",2),ge([U()],g.GlitchEffect.prototype,"fillMode",2),ge([U()],g.GlitchEffect.prototype,"seed",2),ge([U()],g.GlitchEffect.prototype,"red",2),ge([U()],g.GlitchEffect.prototype,"green",2),ge([U()],g.GlitchEffect.prototype,"blue",2),g.GlitchEffect=ge([Z("GlitchEffect")],g.GlitchEffect);var sl=Object.defineProperty,sp=Object.getOwnPropertyDescriptor,np=(n,e,t)=>e in n?sl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Je=(n,e,t,r)=>{for(var i=r>1?void 0:r?sp(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&sl(e,t,i),i},op=(n,e,t)=>np(n,e+"",t);g.GodrayEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"angle",30);d(this,"gain",.5);d(this,"lacunarity",2.5);d(this,"parallel",!0);d(this,"center",[0,0]);d(this,"alpha",1)}apply(t,r){const i=this.angle*(Math.PI/180),s=this.parallel?[Math.cos(i),Math.sin(i)]:this.center;r.redraw(t,()=>{et.draw(t,g.GodrayEffect.material,{sampler:0,inputSize:[r.width,r.height,0,0],gain:this.gain,lacunarity:this.lacunarity,parallel:this.parallel,alpha:this.alpha,light:s,aspect:r.height/r.width})})}},op(g.GodrayEffect,"material",new lt({vert:`precision mediump float;
403
+ attribute vec2 position;
404
+ attribute vec2 uv;
405
+ varying vec2 vUv;
406
+ void main() {
407
+ gl_Position = vec4(position, 0.0, 1.0);
408
+ vUv = uv;
409
+ }`,frag:`varying vec2 vUv;
410
+ uniform sampler2D sampler;
411
+ uniform vec4 inputSize;
412
+ uniform vec2 light;
413
+ uniform bool parallel;
414
+ uniform float aspect;
415
+ uniform float gain;
416
+ uniform float lacunarity;
417
+ uniform float uTime;
418
+ uniform float alpha;
419
+
420
+ vec3 mod289(vec3 x) {
421
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
422
+ }
423
+
424
+ vec4 mod289(vec4 x) {
425
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
426
+ }
427
+
428
+ vec4 permute(vec4 x) {
429
+ return mod289(((x * 34.0) + 1.0) * x);
430
+ }
431
+
432
+ vec4 taylorInvSqrt(vec4 r) {
433
+ return 1.79284291400159 - 0.85373472095314 * r;
434
+ }
435
+
436
+ vec3 fade(vec3 t) {
437
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
438
+ }
439
+
440
+ float pnoise(vec3 P, vec3 rep) {
441
+ vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
442
+ vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
443
+ Pi0 = mod289(Pi0);
444
+ Pi1 = mod289(Pi1);
445
+ vec3 Pf0 = fract(P); // Fractional part for interpolation
446
+ vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
447
+ vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
448
+ vec4 iy = vec4(Pi0.yy, Pi1.yy);
449
+ vec4 iz0 = Pi0.zzzz;
450
+ vec4 iz1 = Pi1.zzzz;
451
+ vec4 ixy = permute(permute(ix) + iy);
452
+ vec4 ixy0 = permute(ixy + iz0);
453
+ vec4 ixy1 = permute(ixy + iz1);
454
+ vec4 gx0 = ixy0 * (1.0 / 7.0);
455
+ vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
456
+ gx0 = fract(gx0);
457
+ vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
458
+ vec4 sz0 = step(gz0, vec4(0.0));
459
+ gx0 -= sz0 * (step(0.0, gx0) - 0.5);
460
+ gy0 -= sz0 * (step(0.0, gy0) - 0.5);
461
+ vec4 gx1 = ixy1 * (1.0 / 7.0);
462
+ vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
463
+ gx1 = fract(gx1);
464
+ vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
465
+ vec4 sz1 = step(gz1, vec4(0.0));
466
+ gx1 -= sz1 * (step(0.0, gx1) - 0.5);
467
+ gy1 -= sz1 * (step(0.0, gy1) - 0.5);
468
+ vec3 g000 = vec3(gx0.x, gy0.x, gz0.x);
469
+ vec3 g100 = vec3(gx0.y, gy0.y, gz0.y);
470
+ vec3 g010 = vec3(gx0.z, gy0.z, gz0.z);
471
+ vec3 g110 = vec3(gx0.w, gy0.w, gz0.w);
472
+ vec3 g001 = vec3(gx1.x, gy1.x, gz1.x);
473
+ vec3 g101 = vec3(gx1.y, gy1.y, gz1.y);
474
+ vec3 g011 = vec3(gx1.z, gy1.z, gz1.z);
475
+ vec3 g111 = vec3(gx1.w, gy1.w, gz1.w);
476
+ vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
477
+ g000 *= norm0.x;
478
+ g010 *= norm0.y;
479
+ g100 *= norm0.z;
480
+ g110 *= norm0.w;
481
+ vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
482
+ g001 *= norm1.x;
483
+ g011 *= norm1.y;
484
+ g101 *= norm1.z;
485
+ g111 *= norm1.w;
486
+ float n000 = dot(g000, Pf0);
487
+ float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
488
+ float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
489
+ float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
490
+ float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
491
+ float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
492
+ float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
493
+ float n111 = dot(g111, Pf1);
494
+ vec3 fade_xyz = fade(Pf0);
495
+ vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
496
+ vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
497
+ float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
498
+ return 2.2 * n_xyz;
499
+ }
500
+ float turb(vec3 P, vec3 rep, float lacunarity, float gain) {
501
+ float sum = 0.0;
502
+ float sc = 1.0;
503
+ float totalgain = 1.0;
504
+ for (float i = 0.0; i < 6.0; i++)
505
+ {
506
+ sum += totalgain * pnoise(P * sc, rep);
507
+ sc *= lacunarity;
508
+ totalgain *= gain;
509
+ }
510
+ return abs(sum);
511
+ }
512
+
513
+ void main(void) {
514
+ vec4 color = texture2D(sampler, vUv);
515
+ vec2 coord = vUv;
516
+ float d;
517
+ if (parallel) {
518
+ d = (light.x * coord.x) + (light.y * coord.y * aspect);
519
+ } else {
520
+ float dx = coord.x - light.x / inputSize.x;
521
+ float dy = (coord.y - light.y / inputSize.y) * aspect;
522
+ float dis = sqrt(dx * dx + dy * dy) + 0.00001;
523
+ d = dy / dis;
524
+ }
525
+ vec3 dir = vec3(d, d, 0.0);
526
+ float noise = turb(dir + vec3(uTime, 0.0, 62.1 + uTime) * 0.05, vec3(480.0, 320.0, 480.0), lacunarity, gain);
527
+ noise = mix(noise, 0.0, 0.3);
528
+ vec4 mist = vec4(noise, noise, noise, 1.0) * (1.0 - coord.y);
529
+ mist.a = 1.0;
530
+ mist *= alpha;
531
+ gl_FragColor = vec4(color.rgb + mist.rgb, color.a);
532
+ }`})),Je([U()],g.GodrayEffect.prototype,"angle",2),Je([U()],g.GodrayEffect.prototype,"gain",2),Je([U()],g.GodrayEffect.prototype,"lacunarity",2),Je([U()],g.GodrayEffect.prototype,"parallel",2),Je([U()],g.GodrayEffect.prototype,"center",2),Je([U()],g.GodrayEffect.prototype,"alpha",2),g.GodrayEffect=Je([Z("GodrayEffect")],g.GodrayEffect);var nl=Object.defineProperty,ap=Object.getOwnPropertyDescriptor,lp=(n,e,t)=>e in n?nl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,hp=(n,e,t,r)=>{for(var i=r>1?void 0:r?ap(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&nl(e,t,i),i},cp=(n,e,t)=>lp(n,e+"",t);g.KawaseEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"blur",10);d(this,"quality",10)}apply(t,r){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=this.blur,l=this.quality,h=r.width,c=r.height,u=[],f=[a];if(a>0){let w=a;const x=a/l;for(let C=1;C<l;C++)w-=x,f.push(w)}const p=1/h,y=1/c,_=[];let m;const b=l-1;for(let w=0;w<b;w++)m=f[w]+.5,_[0]=m*p,_[1]=m*y,u.push({offset:_});m=f[b]+.5,_[0]=m*p,_[1]=m*y,u.push({offset:_}),u.forEach(w=>{et.draw(t,g.KawaseEffect.material,{sampler:s,progress:o,...w})})}},cp(g.KawaseEffect,"material",new lt({vert:`attribute vec2 position;
533
+ attribute vec2 uv;
534
+ varying vec2 vUv;
535
+ void main() {
536
+ gl_Position = vec4(position, 0.0, 1.0);
537
+ vUv = uv;
538
+ }`,frag:`precision highp float;
539
+ varying vec2 vUv;
540
+ uniform sampler2D sampler;
541
+ uniform vec2 offset;
542
+ uniform float progress;
543
+
544
+ void main(void) {
545
+ vec2 offset1 = vec2(offset.x - progress * offset.x, offset.y - progress * offset.y);
546
+ vec4 color = vec4(0.0);
547
+ color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y + offset1.y));
548
+ color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y + offset1.y));
549
+ color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y - offset1.y));
550
+ color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y - offset1.y));
551
+ color *= 0.25;
552
+ gl_FragColor = color;
553
+ }`})),g.KawaseEffect=hp([Z("KawaseEffect")],g.KawaseEffect);var ol=Object.defineProperty,up=Object.getOwnPropertyDescriptor,fp=(n,e,t)=>e in n?ol(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,dp=(n,e,t,r)=>{for(var i=r>1?void 0:r?up(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ol(e,t,i),i},pp=(n,e,t)=>fp(n,e+"",t);g.LeftEraseEffect=class extends g.Effect{apply(e){et.draw(e,g.LeftEraseEffect.material,{previous:0,next:1,progress:this.visibleProgress})}},pp(g.LeftEraseEffect,"material",new lt({vert:`attribute vec2 position;
554
+ attribute vec2 uv;
555
+ varying vec2 vUv;
556
+ void main() {
557
+ gl_Position = vec4(position, 0.0, 1.0);
558
+ vUv = uv;
559
+ }`,frag:`precision highp float;
560
+ varying vec2 vUv;
561
+ uniform float progress;
562
+ uniform sampler2D previous;
563
+ uniform sampler2D next;
564
+
565
+ float easeInOutQuint(float t) {
566
+ return t < 0.5 ? 16.0*t*t*t*t*t : 1.0+16.0*(--t)*t*t*t*t;
567
+ }
568
+
569
+ void main() {
570
+ vec4 src1Color = texture2D(previous, vUv);
571
+ vec4 src2Color = texture2D(next, vUv);
572
+ float mProgress = 1.0 - progress;
573
+ float mixPercent = 0.0;
574
+ if (vUv.x <= mProgress) {
575
+ mixPercent = 1.0;
576
+ }
577
+ gl_FragColor = mix(src2Color, src1Color, mixPercent);
578
+ }`})),g.LeftEraseEffect=dp([Z("LeftEraseEffect")],g.LeftEraseEffect);var al=Object.defineProperty,gp=Object.getOwnPropertyDescriptor,mp=(n,e,t)=>e in n?al(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,An=(n,e,t,r)=>{for(var i=r>1?void 0:r?gp(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&al(e,t,i),i},yp=(n,e,t)=>mp(n,e+"",t);g.MaskEffect=class extends g.Effect{constructor(t){super();d(this,"texture");this.setProperties(t)}async load(){this.texture=void 0,this.src&&(this.texture=await we.texture.load(this.src))}_onUpdateProperty(t,r,i){var s;switch(super._onUpdateProperty(t,r,i),t){case"src":this.load();break;case"texture":(s=i==null?void 0:i.destroy)==null||s.call(i);break}}apply(t,r,i){this.texture&&i.targetArea&&r.redraw(t,()=>{this.texture.activate(t,1),et.draw(t,g.MaskEffect.material,{sampler:0,mask:1,area:i.targetArea}),t.texture.unbind(1)})}},yp(g.MaskEffect,"material",new lt({vert:`precision mediump float;
579
+ attribute vec2 position;
580
+ attribute vec2 uv;
581
+ varying vec2 vUv;
582
+ void main() {
583
+ gl_Position = vec4(position, 0.0, 1.0);
584
+ vUv = uv;
585
+ }`,frag:`varying vec2 vUv;
586
+ uniform sampler2D sampler;
587
+ uniform sampler2D mask;
588
+ uniform float area[4];
589
+
590
+ void main(void) {
591
+ if (
592
+ vUv.x > area[0]
593
+ && vUv.x < (area[0] + area[2])
594
+ && (1.0 - vUv.y) > area[1]
595
+ && (1.0 - vUv.y) < (area[1] + area[3])
596
+ ) {
597
+ vec4 color = texture2D(sampler, vUv);
598
+ vec2 uv = vec2(
599
+ (vUv.x - area[0]) / area[2],
600
+ ((1.0 - vUv.y) - area[1]) / area[3]
601
+ );
602
+ vec4 maskColor = texture2D(mask, uv);
603
+ gl_FragColor = mix(vec4(0.), color, maskColor.a);
604
+ } else {
605
+ gl_FragColor = vec4(0.);
606
+ }
607
+ }`})),An([nt()],g.MaskEffect.prototype,"texture",2),An([U({default:""})],g.MaskEffect.prototype,"src",2),g.MaskEffect=An([Z("MaskEffect")],g.MaskEffect);var ll=Object.defineProperty,_p=Object.getOwnPropertyDescriptor,vp=(n,e,t)=>e in n?ll(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,hl=(n,e,t,r)=>{for(var i=r>1?void 0:r?_p(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ll(e,t,i),i},bp=(n,e,t)=>vp(n,e+"",t);g.PixelateEffect=class extends g.Effect{constructor(t=10){super();d(this,"size");this.size=t}apply(t,r){r.redraw(t,()=>{et.draw(t,g.PixelateEffect.material,{sampler:0,size:[this.size,this.size],filterArea:[r.width,r.height,0,0]})})}},bp(g.PixelateEffect,"material",new lt({vert:`precision mediump float;
608
+ attribute vec2 position;
609
+ attribute vec2 uv;
610
+ varying vec2 vUv;
611
+ void main() {
612
+ gl_Position = vec4(position, 0.0, 1.0);
613
+ vUv = uv;
614
+ }`,frag:`varying vec2 vUv;
615
+ uniform vec2 size;
616
+ uniform sampler2D sampler;
617
+ uniform vec4 filterArea;
618
+
619
+ vec2 mapCoord(vec2 coord) {
620
+ coord *= filterArea.xy;
621
+ coord += filterArea.zw;
622
+ return coord;
623
+ }
624
+
625
+ vec2 unmapCoord(vec2 coord) {
626
+ coord -= filterArea.zw;
627
+ coord /= filterArea.xy;
628
+ return coord;
629
+ }
630
+
631
+ vec2 pixelate(vec2 coord, vec2 size) {
632
+ return floor(coord / size) * size;
633
+ }
634
+
635
+ void main(void) {
636
+ vec2 coord = mapCoord(vUv);
637
+ coord = pixelate(coord, size);
638
+ coord = unmapCoord(coord);
639
+ gl_FragColor = texture2D(sampler, coord);
640
+ }`})),hl([U()],g.PixelateEffect.prototype,"size",2),g.PixelateEffect=hl([Z("PixelateEffect")],g.PixelateEffect);var cl=Object.defineProperty,xp=Object.getOwnPropertyDescriptor,wp=(n,e,t)=>e in n?cl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Pp=(n,e,t,r)=>{for(var i=r>1?void 0:r?xp(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&cl(e,t,i),i},Cp=(n,e,t)=>wp(n,e+"",t);g.TiltShiftEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"blur",100);d(this,"gradientBlur",600)}apply(t,r){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=r.width,l=r.height,h=[0,l/2],c=[600,l/2],u=[a,l],f=c[0]-h[0],p=c[1]-h[1],y=Math.sqrt(f*f+p*p);et.draw(t,g.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[f/y,p/y],texSize:u}),et.draw(t,g.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[-p/y,f/y],texSize:u})}},Cp(g.TiltShiftEffect,"material",new lt({vert:`attribute vec2 position;
641
+ attribute vec2 uv;
642
+ varying vec2 vUv;
643
+ void main() {
644
+ gl_Position = vec4(position, 0.0, 1.0);
645
+ vUv = uv;
646
+ }`,frag:`precision highp float;
647
+ varying vec2 vUv;
648
+ uniform sampler2D sampler;
649
+ uniform float blur;
650
+ uniform float gradientBlur;
651
+ uniform vec2 start;
652
+ uniform vec2 end;
653
+ uniform vec2 delta;
654
+ uniform vec2 texSize;
655
+ uniform float progress;
656
+
657
+ float random(vec3 scale, float seed) {
658
+ return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
659
+ }
660
+
661
+ void main(void) {
662
+ float blur1 = blur - progress * blur;
663
+ float gradientBlur1 = progress * gradientBlur;
664
+
665
+ vec4 color = vec4(0.0);
666
+ float total = 0.0;
667
+ float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
668
+ vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));
669
+ float radius = smoothstep(0.0, 1.0, abs(dot(vUv * texSize - start, normal)) / gradientBlur1) * blur1;
670
+
671
+ for (float t = -30.0; t <= 30.0; t++) {
672
+ float percent = (t + offset - 0.5) / 30.0;
673
+ float weight = 1.0 - abs(percent);
674
+ vec4 sample1 = texture2D(sampler, vUv + delta / texSize * percent * radius);
675
+ sample1.rgb *= sample1.a;
676
+ color += sample1 * weight;
677
+ total += weight;
678
+ }
679
+
680
+ color /= total;
681
+ color.rgb /= color.a + 0.00001;
682
+
683
+ gl_FragColor = color;
684
+ }`})),g.TiltShiftEffect=Pp([Z("TiltShiftEffect")],g.TiltShiftEffect);var ul=Object.defineProperty,Tp=Object.getOwnPropertyDescriptor,Ep=(n,e,t)=>e in n?ul(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Mp=(n,e,t,r)=>{for(var i=r>1?void 0:r?Tp(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ul(e,t,i),i},Sp=(n,e,t)=>Ep(n,e+"",t);g.TwistEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"radius");d(this,"angle",4);d(this,"padding",20);d(this,"offset")}apply(t,r){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=r.width,l=r.height;et.draw(t,g.TwistEffect.material,{sampler:s,progress:o,filterArea:[a,l,0,0],radius:this.radius??a,angle:this.angle,padding:this.padding,offset:this.offset??[a/2,l/2]})}},Sp(g.TwistEffect,"material",new lt({vert:`attribute vec2 position;
685
+ attribute vec2 uv;
686
+ varying vec2 vUv;
687
+ void main() {
688
+ gl_Position = vec4(position, 0.0, 1.0);
689
+ vUv = uv;
690
+ }`,frag:`precision highp float;
691
+ varying vec2 vUv;
692
+ uniform sampler2D sampler;
693
+ uniform float radius;
694
+ uniform float angle;
695
+ uniform vec2 offset;
696
+ uniform vec4 filterArea;
697
+ uniform float progress;
698
+
699
+ vec2 mapCoord(vec2 coord) {
700
+ coord -= filterArea.zw;
701
+ coord *= filterArea.xy;
702
+ return coord;
703
+ }
704
+
705
+ vec2 unmapCoord(vec2 coord) {
706
+ coord -= filterArea.zw;
707
+ coord /= filterArea.xy;
708
+ return coord;
709
+ }
710
+
711
+ vec2 twist(vec2 coord, float radius) {
712
+ coord -= offset;
713
+ float dist = length(coord);
714
+ if (dist < radius) {
715
+ float ratioDist = (radius - dist) / radius;
716
+ float angleMod = ratioDist * ratioDist * angle;
717
+ float s = sin(angleMod);
718
+ float c = cos(angleMod);
719
+ coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);
720
+ }
721
+ coord += offset;
722
+ return coord;
723
+ }
724
+
725
+ void main(void) {
726
+ vec2 coord = mapCoord(vUv);
727
+ coord = twist(coord, radius - (progress * radius));
728
+ coord = unmapCoord(coord);
729
+ gl_FragColor = texture2D(sampler, coord);
730
+ }`})),g.TwistEffect=Mp([Z("TwistEffect")],g.TwistEffect);var fl=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,Op=(n,e,t)=>e in n?fl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ei=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ap(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&fl(e,t,i),i},Up=(n,e,t)=>Op(n,e+"",t);g.ZoomBlurEffect=class extends g.Effect{constructor(){super(...arguments);d(this,"center");d(this,"innerRadius",20);d(this,"radius",-1);d(this,"strength",.1)}apply(t,r){r.redraw(t,()=>{et.draw(t,g.ZoomBlurEffect.material,{sampler:0,center:this.center??[r.width/2,r.height/2],innerRadius:this.innerRadius,radius:this.radius,strength:this.strength,inputSize:[r.width,r.height,1/r.width,1/r.height]})})}},Up(g.ZoomBlurEffect,"material",new lt({vert:`attribute vec2 position;
731
+ attribute vec2 uv;
732
+ varying vec2 vUv;
733
+ void main() {
734
+ gl_Position = vec4(position, 0.0, 1.0);
735
+ vUv = uv;
736
+ }`,frag:`varying vec2 vUv;
737
+ uniform sampler2D sampler;
738
+ uniform vec4 inputSize;
739
+
740
+ uniform vec2 center;
741
+ uniform float strength;
742
+ uniform float innerRadius;
743
+ uniform float radius;
744
+
745
+ const float MAX_KERNEL_SIZE = 32.0;
746
+
747
+ highp float rand(vec2 co, float seed) {
748
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
749
+ highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);
750
+ return fract(sin(sn) * c + seed);
751
+ }
752
+
753
+ void main() {
754
+ float minGradient = innerRadius * 0.3;
755
+ float innerRadius1 = (innerRadius + minGradient * 0.5) / inputSize.x;
756
+
757
+ float gradient = radius * 0.3;
758
+ float radius1 = (radius - gradient * 0.5) / inputSize.x;
759
+
760
+ float countLimit = MAX_KERNEL_SIZE;
761
+
762
+ vec2 dir = vec2(center.xy / inputSize.xy - vUv);
763
+ float dist = length(vec2(dir.x, dir.y * inputSize.y / inputSize.x));
764
+
765
+ float strength1 = strength;
766
+
767
+ float delta = 0.0;
768
+ float gap;
769
+ if (dist < innerRadius1) {
770
+ delta = innerRadius1 - dist;
771
+ gap = minGradient;
772
+ } else if (radius1 >= 0.0 && dist > radius1) { // radius1 < 0 means it's infinity
773
+ delta = dist - radius1;
774
+ gap = gradient;
775
+ }
776
+
777
+ if (delta > 0.0) {
778
+ float normalCount = gap / inputSize.x;
779
+ delta = (normalCount - delta) / normalCount;
780
+ countLimit *= delta;
781
+ strength1 *= delta;
782
+ if (countLimit < 1.0) {
783
+ gl_FragColor = texture2D(sampler, vUv);
784
+ return;
785
+ }
786
+ }
787
+
788
+ float offset = rand(vUv, 0.0);
789
+
790
+ float total = 0.0;
791
+ vec4 color = vec4(0.0);
792
+
793
+ dir *= strength1;
794
+
795
+ for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {
796
+ float percent = (t + offset) / MAX_KERNEL_SIZE;
797
+ float weight = 4.0 * (percent - percent * percent);
798
+ vec2 p = vUv + dir * percent;
799
+ color += texture2D(sampler, p) * weight;
800
+ total += weight;
801
+
802
+ if (t > countLimit){
803
+ break;
804
+ }
805
+ }
806
+
807
+ color /= total;
808
+
809
+ gl_FragColor = color;
810
+ }`})),ei([U()],g.ZoomBlurEffect.prototype,"center",2),ei([U()],g.ZoomBlurEffect.prototype,"innerRadius",2),ei([U()],g.ZoomBlurEffect.prototype,"radius",2),ei([U()],g.ZoomBlurEffect.prototype,"strength",2),g.ZoomBlurEffect=ei([Z("ZoomBlurEffect")],g.ZoomBlurEffect);class Ki{constructor(){d(this,"bubbles",!0);d(this,"cancelable",!1);d(this,"which");d(this,"cancelBubble",!0);d(this,"returnValue");d(this,"srcElement");d(this,"composed",!1);d(this,"currentTarget");d(this,"defaultPrevented",!1);d(this,"eventPhase",Ki.prototype.NONE);d(this,"isTrusted");d(this,"target");d(this,"timeStamp");d(this,"type");d(this,"nativeEvent");d(this,"originalEvent");d(this,"propagationStopped",!1);d(this,"propagationImmediatelyStopped",!1);d(this,"path");d(this,"detail");d(this,"view");d(this,"layer",{x:0,y:0});d(this,"page",{x:0,y:0});d(this,"NONE",0);d(this,"CAPTURING_PHASE",1);d(this,"AT_TARGET",2);d(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...e){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...e){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class On extends Ki{constructor(){super(...arguments);d(this,"altKey");d(this,"button");d(this,"buttons");d(this,"ctrlKey");d(this,"metaKey");d(this,"relatedTarget");d(this,"shiftKey");d(this,"client",{x:0,y:0});d(this,"movement",{x:0,y:0});d(this,"offset",{x:0,y:0});d(this,"global",{x:0,y:0});d(this,"screen",{x:0,y:0})}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(...t){throw new Error("Method not implemented.")}}class dl extends On{constructor(){super(...arguments);d(this,"width",0);d(this,"height",0);d(this,"isPrimary",!1);d(this,"pointerType");d(this,"pressure");d(this,"tangentialPressure");d(this,"tiltX");d(this,"tiltY");d(this,"twist")}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ri extends On{constructor(){super(...arguments);d(this,"deltaMode");d(this,"deltaX");d(this,"deltaY");d(this,"deltaZ");d(this,"DOM_DELTA_PIXEL",0);d(this,"DOM_DELTA_LINE",1);d(this,"DOM_DELTA_PAGE",2)}}d(ri,"DOM_DELTA_PIXEL",0),d(ri,"DOM_DELTA_LINE",1),d(ri,"DOM_DELTA_PAGE",2);const Ip={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class pl extends ve{constructor(){super(...arguments);d(this,"target");d(this,"cursor","default");d(this,"cursorStyles",{default:"inherit",pointer:"pointer"});d(this,"setuped",!1);d(this,"event");d(this,"enableMoveEvent",!0);d(this,"enableWheelEvent",!0);d(this,"enableClickEvent",!0);d(this,"onPointerDown",t=>{if(_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointerdown",this.event=this.clonePointerEvent(r[i]));this.setCursor(this.cursor)});d(this,"onPointerOver",t=>{if(!this.enableClickEvent||_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointerover",this.event=this.clonePointerEvent(r[i]))});d(this,"onPointerMove",t=>{if(!this.enableMoveEvent||_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointermove",this.event=this.clonePointerEvent(r[i]))});d(this,"onPointerUp",t=>{if(!this.enableClickEvent||_e&&t.pointerType==="touch")return;let r=t.target;t.composedPath&&t.composedPath().length>0&&(r=t.composedPath()[0]);const i=r!==this.target?"outside":"",s=this.normalize(t);for(let o=0,a=s.length;o<a;o++){const l=this.clonePointerEvent(s[o]);l.type+=i,this.emit("pointerup",this.event=l)}});d(this,"onWheel",t=>{if(!this.enableWheelEvent)return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("wheel",this.event=this.cloneWheelEvent(r[i]))})}setTarget(t){this.removeEventListeners(),this.target=t,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const t=this.target.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):sr&&(t.touchAction=""),sr?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),globalThis.document.removeEventListener("pointermove",this.onPointerMove),globalThis.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),globalThis.document.removeEventListener("mousemove",this.onPointerMove),globalThis.removeEventListener("mouseup",this.onPointerUp)),_e&&(this.target.removeEventListener("touchstart",this.onPointerDown),this.target.removeEventListener("touchmove",this.onPointerMove),this.target.removeEventListener("touchend",this.onPointerUp)),this.target.removeEventListener("wheel",this.onWheel),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const t=this.target.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):sr&&(t.touchAction="none")),sr?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),globalThis.document.addEventListener("pointermove",this.onPointerMove),globalThis.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),globalThis.document.addEventListener("mousemove",this.onPointerMove),globalThis.addEventListener("mouseup",this.onPointerUp)),_e&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel,{passive:!0}),this.setuped=!0}normalize(t){const r=[];if(_e&&t instanceof globalThis.TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const o=t.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.type=t.type,r.push(o)}else if(Nn&&t instanceof globalThis.WheelEvent)r.push(t);else if(sr&&t instanceof globalThis.PointerEvent)r.push(t);else{const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),r.push(i)}return r}cloneWheelEvent(t){const r=new ri;return this.copyMouseEvent(r,t),r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ,r.deltaMode=t.deltaMode,this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.x=r.screen.x,r.global.y=r.screen.y,r.offset.x=r.screen.x,r.offset.y=r.screen.y,r.nativeEvent=t,r.type=t.type,r}clonePointerEvent(t){const r=new dl;return r.originalEvent=null,r.nativeEvent=t,r.pointerId=t.pointerId,r.width=t.width,r.height=t.height,r.isPrimary=t.isPrimary,r.pointerType=t.pointerType,r.pressure=t.pressure,r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist,r.isTrusted=t.isTrusted,this.copyMouseEvent(r,t),this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.x=r.screen.x,r.global.y=r.screen.y,r.offset.x=r.screen.x,r.offset.y=r.screen.y,r.type==="pointerleave"?r.type="pointerout":r.type.startsWith("mouse")?r.type=r.type.replace("mouse","pointer"):r.type.startsWith("touch")&&(r.type=Ip[r.type]||r.type),r}copyMouseEvent(t,r){t.isTrusted=r.isTrusted,t.timeStamp=performance.now(),t.type=r.type,t.altKey=r.altKey,t.button=r.button,t.buttons=r.buttons,t.client.x=r.clientX,t.client.y=r.clientY,t.ctrlKey=r.ctrlKey,t.metaKey=r.metaKey,t.movement.x=r.movementX,t.movement.y=r.movementY,t.page.x=r.pageX,t.page.y=r.pageY,t.relatedTarget=null,t.shiftKey=r.shiftKey}setCursor(t){if(!this.target||(t=t||"default",this.cursor===t))return;this.cursor=t;const r=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),i=this.cursorStyles[t];if(i)switch(typeof i){case"string":r&&(this.target.style.cursor=i);break;case"function":i(t);break;case"object":r&&Object.assign(this.target.style,i);break}else r&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.target.style.cursor=t)}mapPositionToPoint(t,r,i){if(!this.target)return;const s=Number(this.target.getAttribute("width"))||0,o=Number(this.target.getAttribute("height"))||0,a=Number(this.target.getAttribute("data-pixel-ratio"))||1,l=this.target.isConnected?this.target.getBoundingClientRect():{x:0,y:0,width:s,height:o,left:0,top:0},h=1/a;t.x=(r-l.left)*(s/l.width)*h,t.y=(i-l.top)*(o/l.height)*h}}class gl{constructor(){d(this,"view");d(this,"pixelRatio",us);d(this,"screen",{x:0,y:0,width:0,height:0});d(this,"related",new WeakMap)}getRelated(e,t){let r=this.related.get(e);return r||(t?(this.related.set(e,r=t()),r):(console.warn("Failed to get related",e),null))}resize(e,t,r=!0){const i=Math.floor(e*this.pixelRatio),s=Math.floor(t*this.pixelRatio),o=i/this.pixelRatio,a=s/this.pixelRatio;this.view&&(this.view.width=i,this.view.height=s),this.screen.width=o,this.screen.height=a,r&&this.view&&(this.view.style.width=`${o}px`,this.view.style.height=`${a}px`)}}var vr=(n=>(n.NORMAL="normal",n.ADD="add",n.MULTIPLY="multiply",n.SCREEN="screen",n.NONE="none",n.NORMAL_NPM="normal_npm",n.ADD_NPM="add_npm",n.SCREEN_NPM="screen_npm",n.SRC_IN="src_in",n.SRC_OUT="src_out",n.SRC_ATOP="src_atop",n.DST_OVER="dst_over",n.DST_IN="dst_in",n.DST_OUT="dst_out",n.DST_ATOP="dst_atop",n.XOR="xor",n.SUBTRACT="subtract",n))(vr||{});function ml(n){return{normal:[n.ONE,n.ONE_MINUS_SRC_ALPHA],add:[n.ONE,n.ONE],multiply:[n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],screen:[n.ONE,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],add_npm:[n.SRC_ALPHA,n.ONE,n.ONE,n.ONE],screen_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],src_in:[n.DST_ALPHA,n.ZERO],src_out:[n.ONE_MINUS_DST_ALPHA,n.ZERO],src_atop:[n.DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],dst_over:[n.ONE_MINUS_DST_ALPHA,n.ONE],dst_in:[n.ZERO,n.SRC_ALPHA],dst_out:[n.ZERO,n.ONE_MINUS_SRC_ALPHA],dst_atop:[n.ONE_MINUS_DST_ALPHA,n.SRC_ALPHA],xor:[n.ONE_MINUS_DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],subtract:[n.ONE,n.ONE,n.ONE,n.ONE,n.FUNC_REVERSE_SUBTRACT,n.FUNC_ADD]}}class ee{get gl(){return this._renderer.gl}install(e){this._renderer=e}onUpdateContext(){}flush(){}reset(){}destroy(){}}const is=class is{constructor(e){d(this,"_blendMode",vr.NORMAL);d(this,"_polygonOffset",0);d(this,"bitmap",0);if(e)for(const t in e)this[t]=e[t]}static _init(){this._properties.forEach((e,t)=>{Object.defineProperty(this.prototype,e,{get(){return!!(this.bitmap&1<<t)},set(r){!!(this.bitmap&1<<t)!==r&&(this.bitmap^=1<<t)},enumerable:!0,configurable:!0})})}static for2D(){const e=new is;return e.depthTest=!1,e.blend=!0,e}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==vr.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}};d(is,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let tr=is;tr._init();class yl extends ee{constructor(){super(...arguments);d(this,"_blendEq",!1);d(this,"_setters",tr._properties.map(t=>this[`set${t.replace(/^\S/,r=>r.toUpperCase())}`]));d(this,"boundStateBitmap",0);d(this,"boundBlendMode");d(this,"blendModes");d(this,"defaultState",new tr({blend:!0}))}install(t){super.install(t),t.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=ml(this._renderer.gl)}toggle(t,r){this._renderer.gl[r?"enable":"disable"](t)}setBlend(t){this.toggle(this._renderer.gl.BLEND,t)}setOffsets(t){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,t)}setCulling(t){this.toggle(this._renderer.gl.CULL_FACE,t)}setDepthTest(t){this.toggle(this._renderer.gl.DEPTH_TEST,t)}setDepthMask(t){this._renderer.gl.depthMask(t)}setClockwiseFrontFace(t){const r=this._renderer.gl;r.frontFace(r[t?"CW":"CCW"])}setBlendMode(t){if(t===this.boundBlendMode)return;this.boundBlendMode=t;const r=this.blendModes[t],i=this._renderer.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,r){this._renderer.gl.polygonOffset(t,r)}bind(t){var r;if(this.boundStateBitmap!==t.bitmap){let i=this.boundStateBitmap^t.bitmap,s=0;for(;i;)i&1&&((r=this._setters[s])==null||r.call(this,!!(t.bitmap&1<<s))),i=i>>1,s++;this.boundStateBitmap=t.bitmap}t.blend&&this.setBlendMode(t.blendMode),t.offsets&&this.setPolygonOffset(1,t.polygonOffset)}reset(){super.reset();const t=this._renderer.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(vr.NORMAL)}}class _l extends ee{constructor(){super(...arguments);d(this,"_state",tr.for2D());d(this,"_batchSize",4096*4);d(this,"_vertexSize",27);d(this,"_drawCallUid",0);d(this,"_defaultTint",4294967295);d(this,"_defaultBackgroundColor",0);d(this,"_defaultColorMatrixOffset",[0,0,0,0]);d(this,"_defaultColorMatrix",[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);d(this,"_batchables",[]);d(this,"_vertexCount",0);d(this,"_indexCount",0);d(this,"_attributeBuffer",[]);d(this,"_indexBuffers",[]);d(this,"_shaders",new Map);d(this,"_attributes",{aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aTint:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}})}install(t){super.install(t),t.batch2D=this}_getShader(t){let r=this._shaders.get(t);return r||this._shaders.set(t,r=this._createShader(t)),r}_createShader(t){const r=this._renderer,i=r.program.create({vert:`precision highp float;
811
+ attribute float aTextureId;
812
+ attribute vec2 aPosition;
813
+ attribute vec2 aUv;
814
+ attribute vec4 aTint;
815
+ attribute vec4 aBackgroundColor;
816
+ attribute mat4 aColorMatrix;
817
+ attribute vec4 aColorMatrixOffset;
818
+
819
+ uniform mat3 projectionMatrix;
820
+ uniform mat3 translationMatrix;
821
+ uniform vec4 tint;
822
+
823
+ varying float vTextureId;
824
+ varying vec2 vUv;
825
+ varying vec4 vTint;
826
+ varying vec4 vBackgroundColor;
827
+ varying mat4 vColorMatrix;
828
+ varying vec4 vColorMatrixOffset;
829
+
830
+ void main(void) {
831
+ vTextureId = aTextureId;
832
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
833
+ vUv = aUv;
834
+ vTint = aTint * tint;
835
+ vBackgroundColor = aBackgroundColor;
836
+ vColorMatrix = aColorMatrix;
837
+ vColorMatrixOffset = aColorMatrixOffset;
838
+ }`,frag:`precision highp float;
839
+ varying float vTextureId;
840
+ varying vec2 vUv;
841
+ varying vec4 vTint;
842
+ varying vec4 vBackgroundColor;
843
+ varying mat4 vColorMatrix;
844
+ varying vec4 vColorMatrixOffset;
845
+
846
+ uniform sampler2D samplers[${t}];
847
+
848
+ void main(void) {
849
+ vec4 color;
850
+ if (vTextureId < 0.0)
851
+ {
852
+ color = vec4(0.0, 0.0, 0.0, 0.0);
853
+ }${Array.from({length:t},(c,u)=>{let f=" ";return u>=0&&(f+=`
854
+ else `),u<t-1&&(f+=`
855
+ if (vTextureId < ${u}.5)`),`${f}
856
+ {
857
+ color = texture2D(samplers[${u}], vUv);
858
+ }`}).join("")}
859
+
860
+ color += (1.0 - color.a) * vBackgroundColor;
861
+ if (color.a > 0.0) {
862
+ color *= vTint;
863
+ color = vColorMatrix * color;
864
+ color += vColorMatrixOffset;
865
+ }
866
+ gl_FragColor = color;
867
+ }`}),s=r.buffer.create({target:"array_buffer",data:new Float32Array(1),usage:"dynamic_draw"}),o=r.buffer.create({target:"element_array_buffer",data:new Uint16Array(1),usage:"dynamic_draw"}),a={attributes:Object.fromEntries(Object.entries(this._attributes).map(([c,u])=>[c,{...u,buffer:s}])),elementArrayBuffer:o},l=r.vertexArray.create(i,a),h=new Int32Array(Array.from({length:t},(c,u)=>u));return{update:(c,u)=>{r.vertexArray.bind(l??a),r.buffer.update(s,{target:"array_buffer",data:c}),r.buffer.update(o,{target:"element_array_buffer",data:u})},draw:c=>{const u=this._renderer;u.program.bind(i),u.program.updateUniforms(i,{samplers:h,tint:[1,1,1,1],translationMatrix:[1,0,0,0,1,0,0,0,1],...u.program.uniforms}),u.vertexArray.bind(l??a),u.draw(c)}}}render(t){const{vertices:r,indices:i}=t,s=r.length/2;this._vertexCount+s>this._batchSize&&this.flush(),this._vertexCount+=s,this._indexCount+=i.length,this._batchables.push(t)}flush(){if(super.flush(),this._vertexCount===0)return;const t=this._vertexCount,r=this._indexCount,i=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const s=this._renderer.texture.maxUnits,o=this._getAttributeBuffer(t),a=new Float32Array(o),l=new Uint32Array(o),h=this._getIndexBuffer(r);let c=0,u=0;const f=[];for(let y=i.length,_={id:++this._drawCallUid},m=[],b=new Map,w=0,x=0,C=0;C<y;C++){const P=i[C].texture,E=C===y-1;if(!P||b.has(P)){if(!E)continue}else m.push(P),b.set(P,w++);if(E||w>=s){_.textures=m,_.textureLocationMap=b,w=0,_.first=u;for(let A=x;A<=C;A++){const{indices:S,vertices:T,uvs:O=[],texture:$,tint:N=this._defaultTint,backgroundColor:B=this._defaultBackgroundColor,colorMatrix:M=this._defaultColorMatrix,colorMatrixOffset:L=this._defaultColorMatrixOffset,blendMode:F=vr.NORMAL}=i[A],X=($?b.get($):-1)??-1;x<A&&_.blendMode!==F&&(_.count=u-_.first,f.push(_),x=A,_={id:++this._drawCallUid},_.textures=m,_.first=u);const q=c/this._vertexSize;for(let I=T.length,R=0;R<I;R+=2){a[c++]=X,a[c++]=T[R],a[c++]=T[R+1],a[c++]=O[R]??0,a[c++]=O[R+1]??0,l[c++]=N,l[c++]=B;for(let k=0;k<4;k++)a[c++]=L[k]??0;for(let k=0;k<16;k++)a[c++]=M[k]??0}for(let I=S.length,R=0;R<I;R++)h[u++]=q+S[R];_.blendMode=F}x=C+1,_.count=u-_.first,f.push(_),_={id:++this._drawCallUid},m=[],b=new Map}}const p=this._getShader(s);p.update(o,h);for(let y=f.length,_=0;_<y;_++){const m=f[_],{first:b=0,textures:w,textureLocationMap:x}=m;for(let C=w.length,P=0;P<C;P++){const E=w[P],A=x.get(E);A!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:A,value:E})}this._state.blendMode=m.blendMode,this._renderer.state.bind(this._state),p.draw({mode:"triangles",count:m.count,first:b,bytesPerElement:2})}}_getAttributeBuffer(t){const r=Un(Math.ceil(t/8)),i=In(r),s=r*8;this._attributeBuffer.length<=i&&(this._indexBuffers.length=i+1);let o=this._attributeBuffer[s];return o||(this._attributeBuffer[s]=o=new ArrayBuffer(s*this._vertexSize*4)),o}_getIndexBuffer(t){const r=Un(Math.ceil(t/12)),i=In(r),s=r*12;this._indexBuffers.length<=i&&(this._indexBuffers.length=i+1);let o=this._indexBuffers[i];return o||(this._indexBuffers[i]=o=new Uint16Array(s)),o}}function Un(n){return n+=n===0?1:0,--n,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n+1}function In(n){let e=(n>65535?1:0)<<4;n>>>=e;let t=(n>255?1:0)<<3;return n>>>=t,e|=t,t=(n>15?1:0)<<2,n>>>=t,e|=t,t=(n>3?1:0)<<1,n>>>=t,e|=t,e|n>>1}class vl extends ee{constructor(){super(...arguments);d(this,"boundArrayBuffer",null);d(this,"boundTarget","array_buffer")}install(t){super.install(t),t.buffer=this}create(t){const r=this.gl.createBuffer();if(!r)throw new Error("failed to create");return t&&(this.bind({target:t.target,value:r}),this.update(t)),r}getMeta(t){return this._renderer.getRelated(t,()=>({id:Dn(t),length:0,byteLength:0,bytesPerElement:0}))}update(...t){if(t.length>1){this.bind({target:t[1].target,value:t[0]}),this.update(t[1]);return}const r=t[0],i=(r.target??this.boundTarget)==="array_buffer"?this.boundArrayBuffer:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer;if(!i)return;const s=this.getMeta(i);Object.assign(s,{target:r.target,usage:r.usage});const o=s.target??this.boundTarget,a=s.usage??"static_draw",l=r.data,h=this.gl;let c;Array.isArray(l)?o==="array_buffer"?c=new Float32Array(l):c=new Uint32Array(l):c=l;const u=this._renderer.getBindPoint(o);c&&c.byteLength<=s.byteLength?h.bufferSubData(u,0,c):(h.bufferData(u,c,this._renderer.getBindPoint(a)),s.length=(c==null?void 0:c.length)??0,s.byteLength=(c==null?void 0:c.byteLength)??0,s.bytesPerElement=s.length?s.byteLength/s.length:0)}bind(t){let{target:r,value:i}=t;if(i){const o=this.getMeta(i);r??(r=o.target??this.boundTarget),o.target=r}else r??(r=this.boundTarget);const s=this._renderer.getBindPoint(r);this._renderer.gl.bindBuffer(s,i),r==="array_buffer"?this.boundArrayBuffer=i:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer=i,this.boundTarget=r}unbind(t){return this.bind({target:t,value:null})}reset(){super.reset(),this.boundArrayBuffer=null,this.boundTarget="array_buffer"}}class bl extends ee{constructor(){super(...arguments);d(this,"boundFramebuffer",null);d(this,"_msaaSamples",[]);d(this,"_hasMRT",!0);d(this,"_writeDepthTexture",!0)}install(t){super.install(t),t.framebuffer=this}onUpdateContext(){if(this._hasMRT=!0,this._writeDepthTexture=!0,this._renderer.version===1){const t=this._renderer.gl,r=this._renderer.extensions.drawBuffers,i=this._renderer.extensions.depthTexture;r?t.drawBuffers=s=>r.drawBuffersWEBGL(s):(this._hasMRT=!1,t.drawBuffers=()=>{}),i||(this._writeDepthTexture=!1)}else{const t=this._renderer.gl;this._msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}}create(t){const r=this._renderer.gl.createFramebuffer();if(!r)throw new Error("Unable to create framebuffer");return t&&(this.bind(r),this.update(t)),r}getMeta(t){return this._renderer.getRelated(t,()=>({width:0,height:0,mipLevel:0,stencil:!1,depth:!1,depthTexture:null,colorTextures:[],multisample:0}))}update(...t){if(t.length>1)return this.bind(t[0]),this.update(t[1]);const r=this.boundFramebuffer;if(!r)return;const i=t[0],s=this.getMeta(r);Object.assign(s,{...i});const o=this._renderer.gl;let a=s.colorTextures.length;"drawBuffers"in o||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=s.colorTextures[l];this._renderer.texture.bind({location:0,target:"texture_2d",value:h,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+l,o.TEXTURE_2D,h,s.mipLevel),this._renderer.texture.unbind(h)}if(a>1&&o.drawBuffers(s.colorTextures.map((l,h)=>o.COLOR_ATTACHMENT0+h)),s.depthTexture&&(this._renderer.version>1||this._renderer.extensions.depthTexture)&&(this._renderer.texture.bind({location:0,target:"texture_2d",value:s.depthTexture,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,s.depthTexture,s.mipLevel),this._renderer.texture.unbind(s.depthTexture)),(s.stencilBuffer||s.stencil||s.depth)&&!(s.depthTexture&&this._writeDepthTexture)){s.stencilBuffer??(s.stencilBuffer=o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,s.stencilBuffer);const{attachment:l,format:h}=this._getAttachmentAndFormat(s);s.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,s.multisample,h,s.width,s.height):o.renderbufferStorage(o.RENDERBUFFER,h,s.width*this._renderer.pixelRatio,s.height*this._renderer.pixelRatio),o.framebufferRenderbuffer(o.FRAMEBUFFER,l,o.RENDERBUFFER,s.stencilBuffer)}else s.stencilBuffer&&(o.deleteRenderbuffer(s.stencilBuffer),s.stencilBuffer=null)}_getAttachmentAndFormat(t){const r=this.gl;let i,s;return this._renderer.version===1?(i=r.DEPTH_STENCIL_ATTACHMENT,s=r.DEPTH_STENCIL):t.depth&&t.stencil?(i=r.DEPTH_STENCIL_ATTACHMENT,s=r.DEPTH24_STENCIL8):t.depth?(i=r.DEPTH_ATTACHMENT,s=r.DEPTH_COMPONENT24):(i=r.STENCIL_ATTACHMENT,s=r.STENCIL_INDEX8),{attachment:i,format:s}}resize(t,r,i){const s=this.gl,o=this.getMeta(t);if(Object.assign(o,{width:r,height:i}),o.stencil){const{format:l}=this._getAttachmentAndFormat(o);s.bindRenderbuffer(s.RENDERBUFFER,o.stencil),o.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,l,o.width,o.height):s.renderbufferStorage(s.RENDERBUFFER,l,o.width,o.height)}let a=o.colorTextures.length;s.drawBuffers||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=o.colorTextures[l];this._renderer.texture.update(h,{value:{pixels:null,width:o.width,height:o.height}}),l===0&&o.msaaBuffer&&(s.bindRenderbuffer(s.RENDERBUFFER,o.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,s.RGBA,o.width,o.height))}o.depthTexture&&this._renderer.texture.update(o.depthTexture,{value:{pixels:null,width:o.width,height:o.height}})}bind(t){const r=this._renderer.gl,i=t;if({value:this.boundFramebuffer!==i}.value&&(r.bindFramebuffer(r.FRAMEBUFFER,i),this.boundFramebuffer=i),i){const a=this.getMeta(i);for(let c=0;c<a.colorTextures.length;c++)this._renderer.texture.unbind(a.colorTextures[c]);a.depthTexture&&this._renderer.texture.unbind(a.depthTexture);const l=a.width>>a.mipLevel,h=a.height>>a.mipLevel;this._renderer.viewport.bind({x:0,y:0,width:l*this._renderer.pixelRatio,height:h*this._renderer.pixelRatio})}else this._renderer.viewport.bind({x:0,y:0,width:this._renderer.screen.width,height:this._renderer.screen.height})}forceStencil(){const t=this.boundFramebuffer;if(!t)return;const r=this.getMeta(t);if(!r||r.stencilBuffer)return;const i=this._renderer.gl;r.stencilBuffer=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,r.stencilBuffer);let s,o;this._renderer.version===1?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH_STENCIL):r.depth?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH24_STENCIL8):(s=i.STENCIL_ATTACHMENT,o=i.STENCIL_INDEX8),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,o,r.width*this._renderer.pixelRatio,r.height*this._renderer.pixelRatio):i.renderbufferStorage(i.RENDERBUFFER,o,r.width*this._renderer.pixelRatio,r.height*this._renderer.pixelRatio),i.framebufferRenderbuffer(i.FRAMEBUFFER,s,i.RENDERBUFFER,r.stencilBuffer)}reset(){super.reset(),this.boundFramebuffer=null}}class xl extends ee{constructor(){super(...arguments);d(this,"stack",[])}install(t){super.install(t),t.mask=this}get length(){return this.stack.length}get last(){return this.stack[this.length-1]}push(t,r){const i={source:t,mask:r};this.stack.push(i),typeof i.mask=="number"?this.pushColorMask(i):"render"in i.mask?this._renderer.stencil.push(i):this._renderer.scissor.push(i)}pop(t){const r=this.stack.pop();!r||r.source!==t||(typeof r.mask=="number"?this.popColorMask(r):"render"in r.mask?this._renderer.stencil.pop(r):this._renderer.scissor.pop(r))}pushColorMask(t){const r=t.preComputedColor??15,i=t.preComputedColor=r&t.mask;i!==r&&this.useColorMask(i)}popColorMask(t){const r=t.preComputedColor??15,i=this.length>0?this.last.preComputedColor??15:15;i!==r&&this.useColorMask(i)}useColorMask(t){this._renderer.gl.colorMask((t&1)!==0,(t&2)!==0,(t&4)!==0,(t&8)!==0)}}class wl extends ee{constructor(){super(...arguments);d(this,"boundProgram",null);d(this,"uniforms",{projectionMatrix:[1,0,0,0,1,0,0,0,1]})}install(t){super.install(t),t.program=this}create(t){const r=this.gl.createProgram();if(!r)throw new Error("Unable to create program");return t&&this.update(r,t),r}getMeta(t){return this._renderer.getRelated(t,()=>({attributes:new Map,uniforms:new Map,boundUniforms:new WeakMap}))}update(...t){if(t.length>1){const h=this.boundProgram;this.boundProgram=t[0],this.update(t[1]),this.boundProgram=h;return}const r=t[0],i=this.boundProgram;if(!i)return;const s=this.gl,o=this.getMeta(i),a=this.createShader(r.vert,"vertex_shader"),l=this.createShader(r.frag,"fragment_shader");if(s.attachShader(i,a),s.attachShader(i,l),s.linkProgram(i),s.deleteShader(a),s.deleteShader(l),!s.getProgramParameter(i,s.LINK_STATUS))throw new Error(`Unable to link program: ${s.getProgramInfoLog(i)}`);o.attributes.clear(),o.uniforms.clear();for(let h=s.getProgramParameter(i,s.ACTIVE_ATTRIBUTES),c=0;c<h;c++){const u=s.getActiveAttrib(i,c);if(!u||u.name.startsWith("gl_"))continue;const f=this._renderer.bindPoints.get(u.type)??String(u.type);o.attributes.set(u.name,{type:f,name:u.name,size:Dp(f),location:s.getAttribLocation(i,u.name)})}for(let h=s.getProgramParameter(i,s.ACTIVE_UNIFORMS),c=0;c<h;c++){const u=s.getActiveUniform(i,c);if(!u)continue;const f=u.name.replace(/\[.*?\]$/,"");let p=s.getUniformLocation(i,f);p||(p=s.getUniformLocation(i,u.name)),o.uniforms.set(f,{name:f,index:c,type:this._renderer.bindPoints.get(u.type)??String(u.type),size:u.size,isArray:f!==u.name,location:p})}}bind(t){const r=this.gl;({value:this.boundProgram!==t}).value&&(r.useProgram(t),this.boundProgram=t)}createShader(t,r){const i=this.gl,s=i.createShader(this._renderer.getBindPoint(r));if(!s)throw new Error("Unable to create shader");if(i.shaderSource(s,t),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error(`Unable to compiling shader :
868
+ ${t}
869
+ ${i.getShaderInfoLog(s)}`);return s}updateUniforms(...t){if(t.length>1){this.bind(t[0]),this.updateUniforms(t[1]);return}const r=this.boundProgram;if(!r)return;const i=this.gl,s=t[0],{uniforms:o,boundUniforms:a}=this.getMeta(r);for(const l in s){const h=s[l],c=o.get(l);if(!c)continue;const{type:u,isArray:f,location:p}=c;if(!(!p||a.get(p)===h))switch(a.set(p,h),u){case"float":f?i.uniform1fv(p,h):i.uniform1f(p,h);break;case"unsigned_int":f?i.uniform1uiv(p,h):i.uniform1ui(p,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":f?i.uniform1iv(p,h):i.uniform1i(p,h);break;case"bool_vec2":case"int_vec2":i.uniform2iv(p,h);break;case"unsigned_int_vec2":i.uniform2uiv(p,h);break;case"float_vec2":i.uniform2fv(p,h);break;case"bool_vec3":case"int_vec3":i.uniform3iv(p,h);break;case"unsigned_int_vec3":i.uniform3uiv(p,h);break;case"float_vec3":i.uniform3fv(p,h);break;case"bool_vec4":case"int_vec4":i.uniform4iv(p,h);break;case"unsigned_int_vec4":i.uniform4uiv(p,h);break;case"float_vec4":i.uniform4fv(p,h);break;case"float_mat2":i.uniformMatrix2fv(p,!1,h);break;case"float_mat3":i.uniformMatrix3fv(p,!1,h);break;case"float_mat4":i.uniformMatrix4fv(p,!1,h);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={}}destroy(){super.destroy(),this.bind(null)}}function Dp(n){switch(n){case"float":case"int":case"unsigned_int":case"bool":case"sampler_2d":return 1;case"float_vec2":case"int_vec2":case"unsigned_int_vec2":case"bool_vec2":return 2;case"float_vec3":case"int_vec3":case"unsigned_int_vec3":case"bool_vec3":return 3;case"float_vec4":case"int_vec4":case"unsigned_int_vec4":case"bool_vec4":case"float_mat2":return 4;case"float_mat3":return 9;case"float_mat4":return 16;default:return 1}}class Pl extends ee{install(e){super.install(e),e.scissor=this}get length(){var e;return((e=this._renderer.mask.last)==null?void 0:e.scissorCounter)??0}push(e){const t=this._renderer.gl;t.enable(t.SCISSOR_TEST),e.scissorCounter??(e.scissorCounter=0),e.scissorCounter++,this.use()}pop(e){if(this.length>0)this.use();else{const t=this._renderer.gl;t.disable(t.SCISSOR_TEST)}}use(){const e=this._renderer,t=e.mask.last.mask;let r;e.viewport.boundViewport?r=e.viewport.boundViewport.height-t.height-t.y:r=e.screen.height-t.height-t.y,e.gl.scissor(t.x,r,t.width,t.height)}}class Cl extends ee{install(e){super.install(e),e.stencil=this}get length(){var e;return((e=this._renderer.mask.last)==null?void 0:e.stencilCounter)??0}push(e){const t=this._renderer.gl,r=e.mask,i=e.stencilCounter??(e.stencilCounter=0);e.stencilCounter===0&&(this._renderer.framebuffer.forceStencil(),t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.enable(t.STENCIL_TEST)),e.stencilCounter++;const s=e.color;s&&(e.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilFunc(t.EQUAL,i,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.INCR),r.render(this._renderer),this._renderer.flush(),s&&(e.color=s,t.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}pop(e){const t=this._renderer.gl,r=e.mask;if(!this.length)t.disable(t.STENCIL_TEST);else{const i=this._renderer.mask.last,s=(i==null?void 0:i.color)??15;s!==0&&(i.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),r.render(this._renderer),this._renderer.flush(),s!==0&&(i.color=s,t.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}}use(){const e=this._renderer.gl;e.stencilFunc(e.EQUAL,this.length,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}function Rp(n,e){const t=new Set([...Object.keys(n),...Object.keys(e)]),r={};return t.forEach(i=>{r[i]=n[i]!==e[i]}),r}class Tl extends ee{constructor(){super(...arguments);d(this,"maxUnits",0);d(this,"boundLocation",0);d(this,"boundTarget","texture_2d");d(this,"boundTextures",[]);d(this,"emptyTextures",{texture_2d:null,texture_cube_map:null})}install(t){super.install(t),t.texture=this}onUpdateContext(){super.onUpdateContext();const t=this.gl;this.maxUnits=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(let s=0;s<this.maxUnits;s++)this.boundTextures[s]={texture_2d:null,texture_cube_map:null};const r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4));const i=t.createTexture();t.bindTexture(t.TEXTURE_CUBE_MAP,i);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR),this.emptyTextures={texture_2d:r,texture_cube_map:i};for(let s=this.boundTextures.length,o=0;o<s;o++)this.unbind(o)}create(t){const r=this.gl.createTexture();if(!r)throw new Error("Unable to create texture");return t&&(this.bind({location:t.location,target:t.target,value:r,forceUpdateLocation:!0}),this.update({filterMode:"linear",wrapMode:"repeat",...t})),r}getMeta(t){return this._renderer.getRelated(t,()=>({}))}update(...t){if(t.length>1){this.bind({location:t[1].location,target:t[1].target,value:t[0],forceUpdateLocation:!0}),this.update(t[1]);return}const r=t[0],{value:i,...s}=r,o=this.boundTextures[this.boundLocation][r.target??this.boundTarget];if(!o)return;const a=this.gl,l=this.getMeta(o),h=Rp(l,s);Object.assign(l,s);const c=this._renderer.getBindPoint(l.target??this.boundTarget);if(i!==void 0&&(i===null?a.texImage2D(c,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,null):"pixels"in i?a.texImage2D(c,0,a.RGBA,i.width,i.height,0,a.RGBA,a.UNSIGNED_BYTE,i.pixels):a.texImage2D(c,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i)),h.wrapMode&&l.wrapMode){const f=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,f),a.texParameteri(c,a.TEXTURE_WRAP_T,f)}const u=l.filterMode;if(h.filterMode&&u){const f=this._renderer.getBindPoint(u.split("_")[0]);u.includes("_")?a.texParameteri(c,a.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(u)):a.texParameteri(c,a.TEXTURE_MIN_FILTER,f),a.texParameteri(c,a.TEXTURE_MAG_FILTER,f)}if(l.anisoLevel&&u==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:f,TEXTURE_MAX_ANISOTROPY_EXT:p}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,p,Math.min(l.anisoLevel,a.getParameter(f)))}}bind(t){const r=this.gl;let i,s,o,a;if(t&&"value"in t?{target:s,value:i,location:o,forceUpdateLocation:a}=t:i=t,i){const y=this.getMeta(i);y.target=s??(s=y.target??"texture_2d"),y.location=o??(o=y.location??0)}else s??(s="texture_2d"),o??(o=0);let l=this.boundTextures[o];l||(this.boundTextures[o]=l={texture_2d:null,texture_cube_map:null});const h=l[s]??null,c=this.boundLocation,u=i!==h,f={location:o!==c&&(u||a),texture:u},p=this._renderer.getBindPoint(s);f.location&&(r.activeTexture(r.TEXTURE0+o),this.boundLocation=o),f.texture&&(r.bindTexture(p,i??this.emptyTextures[s]),l[s]=i),this.boundTarget=s}unbind(t,r="texture_2d"){const i=this._renderer.gl;if(typeof t=="number")this.bind({value:null,target:r,location:t});else{const s=this.getMeta(t),{target:o=this.boundTarget}=s,a=this._renderer.getBindPoint(o);for(let l=0;l<this.boundTextures.length;l++)this.boundTextures[l][o]===t&&(this.boundLocation!==l&&(i.activeTexture(i.TEXTURE0+l),this.boundLocation=l),i.bindTexture(a,this.emptyTextures[o]),this.boundTextures[l][o]=null)}}reset(){super.reset(),this.boundLocation=0,this.boundTarget="texture_2d",this.boundTextures=[],this.maxUnits=0}}class El extends ee{constructor(){super(...arguments);d(this,"boundVertexArrayNull",{attributes:{},elementArrayBuffer:null});d(this,"boundVertexArrayObject",null);d(this,"boundVertexArray",this.boundVertexArrayNull)}install(t){super.install(t),t.vertexArray=this}enableVertexAttrib(t,r,i,s=1){const{buffer:o,size:a=0,type:l="float",normalized:h=!1,stride:c=0,offset:u=0,divisor:f}=i,p=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let y=0;y<s;y++)p.enableVertexAttribArray(r+y),p.vertexAttribPointer(r+y,a,this._renderer.getBindPoint(l),h,c,u+(c-u)/s*y);f&&("vertexAttribDivisor"in p?p.vertexAttribDivisor(r,f):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[t]={enable:!0,...i}}create(...t){const r=this._renderer.gl;if(!("createVertexArray"in r))return null;const i=r.createVertexArray();if(!i)throw new Error("Unable to create vertex array");return t.length===2?this.update(t[0],i,t[1]):t.length===1&&this.update(i,t[0]),i}getVertexArrayMeta(t){return this._renderer.getRelated(t,()=>({attributes:{},elementArrayBuffer:null}))}update(...t){var o,a,l;if(t.length>2){this._renderer.program.bind(t[0]),this.update(t[1],t[2]);return}else if(t.length===2)if(t[0]){const h=t[0],c=t[1],u=this.getVertexArrayMeta(h);this.bind(h),this.update(c),u.attributes=this.boundVertexArray.attributes,u.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(t[1]);const r=this._renderer.program.boundProgram;if(!r)return;const i=t[0];if(i.attributes){const h=this._renderer.program.getMeta(r),c={},u={};for(const p in i.attributes){const y=i.attributes[p],_=h.attributes.get(p);let m;"buffer"in y?m={...y}:m={buffer:y},m.size=m.size||(_==null?void 0:_.size)||0;const b=this._renderer.buffer.getMeta(m.buffer),w=Number(((o=_==null?void 0:_.type.match(/mat(\d)/))==null?void 0:o[1])??1);let x;switch(m.type){case"unsigned_byte":x=m.size;break;case"unsigned_short":x=m.size*2;break;case"float":default:x=m.size*4;break}x*=w,c[a=b.id]??(c[a]=0),c[b.id]+=x,u[p]={attrib:m,meta:b,info:_,byteLength:x,dimension:w}}const f={};for(const p in u){const{attrib:y,meta:_,info:m,byteLength:b,dimension:w}=u[p];(m==null?void 0:m.location)!==void 0&&(f[l=_.id]??(f[l]=0),y.offset??(y.offset=f[_.id]),y.stride??(y.stride=c[_.id]===b?0:c[_.id]),this.enableVertexAttrib(p,m.location,y,w),f[_.id]+=b)}}const s=i.elementArrayBuffer??null;this._renderer.buffer.bind({target:"element_array_buffer",value:s}),this.boundVertexArray.elementArrayBuffer=s}bind(t){const r=this._renderer.gl;if(t&&"attributes"in t)this.update(t);else if("bindVertexArray"in r){const i=this.boundVertexArrayObject;({value:t!==i}).value&&(r.bindVertexArray(t),this.boundVertexArrayObject=t,t?this.boundVertexArray={...this.getVertexArrayMeta(t)}:this.boundVertexArray=this.boundVertexArrayNull)}}unbind(){return this.bind(null)}reset(){super.reset(),this.boundVertexArrayNull={attributes:{},elementArrayBuffer:null},this.boundVertexArray=this.boundVertexArrayNull,this.boundVertexArrayObject=null}}class Ml extends ee{constructor(){super(...arguments);d(this,"boundViewport",{x:0,y:0,width:0,height:0})}install(t){super.install(t),t.viewport=this}bind(t){const r=this.boundViewport,i=Math.floor(t.x),s=Math.floor(t.y),o=Math.floor(t.width),a=Math.floor(t.height);r.x===i&&r.y===s&&r.width===o&&r.height===a||(this._renderer.gl.viewport(i,s,o,a),r.x=i,r.y=s,r.width=o,r.height=a)}reset(){super.reset(),this.boundViewport={x:0,y:0,width:0,height:0}}}class Sl extends gl{constructor(t=Gn(),r){super();d(this,"_modules",[new Tl,new vl,new bl,new wl,new El,new Ml,new yl,new xl,new Pl,new Cl,new _l]);d(this,"bindPoints",new Map);if(!t)throw new Error("Failed to createHTMLCanvas");Xn(t)?this._setupContext(t,r):(this.gl=t,this.version=jn(this.gl)?2:1),this._setupBindPoints()._setupExtensions()._setupPolyfill(),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._modules.forEach(i=>i.install(this)),this._modules.forEach(i=>i.onUpdateContext())}_setupContext(t,r){this.view=t;let i=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),s=2;if(i||(i=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),s=1),!i)throw new Error("Unable to getContext");return this.gl=i,this.version=s,this._onContextLost=this._onContextLost.bind(this),this._onContextRestored=this._onContextRestored.bind(this),t.addEventListener("webglcontextlost",this._onContextLost,!1),t.addEventListener("webglcontextrestored",this._onContextRestored,!1),this}_setupExtensions(){const t=this.gl,r={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tcSRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc")};return this.version===1?(r.instancedArrays=t.getExtension("ANGLE_instanced_arrays"),r.drawBuffers=t.getExtension("WEBGL_draw_buffers"),r.depthTexture=t.getExtension("WEBGL_depth_texture"),r.vertexArrayObject=t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),r.uint32ElementIndex=t.getExtension("OES_element_index_uint"),r.floatTexture=t.getExtension("OES_texture_float"),r.textureHalfFloat=t.getExtension("OES_texture_half_float"),r.textureHalfFloatLinear=t.getExtension("OES_texture_half_float_linear")):this.version===2&&(r.colorBufferFloat=t.getExtension("EXT_color_buffer_float")),this.extensions=r,this}_setupBindPoints(){for(const t in this.gl)if(t===t.toUpperCase()){const r=this.gl[t];typeof r=="number"&&this.bindPoints.set(r,t.toLowerCase())}return this}_setupPolyfill(){if(this.version===1){const{instancedArrays:t,vertexArrayObject:r,drawBuffers:i}=this.extensions,s=this.gl;r&&(s.createVertexArray=()=>r.createVertexArrayOES(),s.bindVertexArray=o=>r.bindVertexArrayOES(o),s.deleteVertexArray=o=>r.deleteVertexArrayOES(o)),t&&(s.vertexAttribDivisor=(o,a)=>t.vertexAttribDivisorANGLE(o,a),s.drawElementsInstanced=(o,a,l,h,c)=>t.drawElementsInstancedANGLE(o,a,l,h,c),s.drawArraysInstanced=(o,a,l,h)=>t.drawArraysInstancedANGLE(o,a,l,h)),i&&(s.drawBuffers=o=>i.drawBuffersWEBGL(o))}return this}_onContextLost(t){t.preventDefault(),setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0)}_onContextRestored(){}getBindPoint(t){return this.gl[t.toUpperCase()]}clear(t=this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT){this.gl.clear(t)}draw(t={}){const{mode:r="triangles",first:i=0,instanceCount:s}=t;let{count:o=0,bytesPerElement:a=0}=t;if(!o||!a){const h=this.vertexArray.boundVertexArray.elementArrayBuffer??Object.values(this.vertexArray.boundVertexArray.attributes)[0];if(h){const c=this.buffer.getMeta(h);o||(o=c.length),a||(a=c.bytesPerElement)}}const l=this.getBindPoint(r);if(a)if(a===2||a===4&&this.extensions.uint32ElementIndex){const h=a===2?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT;s&&"drawElementsInstanced"in this.gl?this.gl.drawElementsInstanced(l,o,h,i*a,s):this.gl.drawElements(l,o,h,i*a)}else console.warn("Unsupported index buffer type: uint32");else s&&"drawArraysInstanced"in this.gl?this.gl.drawArraysInstanced(l,i,o,s):this.gl.drawArrays(l,i,o)}reset(){this._modules.forEach(t=>t.reset())}flush(){this._modules.forEach(t=>t.flush())}destroy(){var t,r,i;this._modules.forEach(s=>s.destroy()),(t=this.view)==null||t.removeEventListener("webglcontextlost",this._onContextLost,!1),(r=this.view)==null||r.removeEventListener("webglcontextrestored",this._onContextRestored,!1),(i=this.extensions.loseContext)==null||i.loseContext()}toPixels(){const t=this.gl.drawingBufferWidth,r=this.gl.drawingBufferHeight,i=t*r*4,s=t*4,o=(r-1)*s,a=new Uint8Array(i),l=new Uint8ClampedArray(i);this.gl.readPixels(0,0,t,r,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a);for(let h=0;h<i;h+=s)l.set(a.subarray(h,h+s),o-h);return l}}const Al={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class Ol extends vo{constructor(t={}){var c,u;const{view:r,width:i,height:s,pixelRatio:o=us,background:a=0,autoResize:l,...h}=t;super();d(this,"input",new pl);d(this,"renderer");d(this,"_background",new Se);d(this,"_resizeObserver",kn?new ResizeObserver(t=>{const r=t[0];if(r.target===this.view){const{inlineSize:i,blockSize:s}=Array.isArray(r.contentBoxSize)?r.contentBoxSize[0]:r.contentBoxSize;this.resize(i,s)}}):void 0);this.renderer=new Sl(r,{...Al,...h}),this._setupInput(),this.pixelRatio=o,this.background=a,l?this.enableAutoResize(l):this.resize(i||this.gl.drawingBufferWidth||((c=this.view)==null?void 0:c.clientWidth)||200,s||this.gl.drawingBufferHeight||((u=this.view)==null?void 0:u.clientHeight)||200)}get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(t){this.renderer.pixelRatio=t,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(t))}get background(){return this._background.value}set background(t){this._background.value=t}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(t=>{this.input.on(t,r=>{this.hasEventListener(t)&&(this.root.input(r),this.emit(t,r))})})),this}enableAutoResize(t=!0){var r,i;return this.view&&(t?(r=this._resizeObserver)==null||r.observe(this.view):(i=this._resizeObserver)==null||i.unobserve(this.view)),this}resize(t,r,i=!1){return this.renderer.resize(t,r,i),this.root.width=t,this.root.height=r,this.renderer.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this}nextTick(){return ds()}waitUntilLoad(){return we.waitUntilLoad()}render(t=0){return this.gl.clearColor(...this._background.toArray()),this._render(this.renderer,t)}start(){return this.render(),super.start(t=>{this.render(t)})}destroy(){this.stop(),this.root.getChildren(!0).forEach(t=>this.root.removeChild(t)),this.input.removeEventListeners(),this.enableAutoResize(!1),this.renderer.destroy()}toPixels(){return this.render(),this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){var s,o;const t=this.toImageData(),r=document.createElement("canvas");r.width=t.width,r.height=t.height,(s=r.getContext("2d"))==null||s.putImageData(t,0,0);const i=document.createElement("canvas");return i.width=this.width,i.height=this.height,(o=i.getContext("2d"))==null||o.drawImage(r,0,0,r.width,r.height,0,0,i.width,i.height),i}}let ii,Bp;const Ul=[];async function Lp(n=100){for(;;){const e=Ul.shift();if(e)try{await e()}catch(t){console.error(t)}else await new Promise(t=>setTimeout(t,n))}}async function kp(n){ii??(ii=new Ol({width:1,height:1}));const e=ii.root;e.removeChildren();const{data:t,width:r,height:i}=n;return ii.resize(r,i),(Array.isArray(t)?t:[t]).forEach(s=>{s instanceof g.Node?e.addChild(s):e.addChild(g.Node.parse(s))}),await ii.waitUntilLoad(),ii.toCanvas2D()}async function Np(n){return Bp??(Bp=Lp()),new Promise(e=>{Ul.push(async()=>e(await kp(n)))})}g.Assets=ko,g.AudioPipeline=Cn,g.AudioProcessor=_d,g.AudioSpectrum=Td,g.Bounds=vi,g.CanvasContext=Mt,g.Circle=di,g.Color=Se,g.ColorMatrix=Fs,g.ColorTexture=xi,g.DEG_TO_RAD=po,g.DEVICE_PIXEL_RATIO=us,g.EffectMaterial=Zi,g.Ellipse=Tr,g.Engine=Ol,g.EventEmitter=ve,g.FontLoader=Oo,g.Geometry=hi,g.GifLoader=Uo,g.HTMLAudio=Va,g.HTMLAudioContext=Yi,g.HTMLSound=Wi,g.IN_BROWSER=Pr,g.Image2DResource=Ci,g.ImageTexture=Xh,g.IndexBuffer=nr,g.Input=pl,g.InternalMode=Ur,g.JsonLoader=Io,g.Loader=Ae,g.LottieLoader=Do,g.MainLoop=ui,g.Material=lt,g.Matrix=le,g.Matrix2=Ih,g.Matrix3=Ss,g.Matrix4=uo,g.MouseInputEvent=On,g.PI=Et,g.PI_2=at,g.Path2D=Os,g.PixelsTexture=Us,g.Point=re,g.PointerInputEvent=dl,g.Polygon=Fe,g.Projection2D=fo,g.QuadGeometry=Hl,g.QuadUvGeometry=et,g.RAD_TO_DEG=Dh,g.Rectangle=Gt,g.Reference=ps,g.RenderStack=mo,g.Renderer=gl,g.Resource=Ee,g.RoundedRectangle=gi,g.SUPPORTS_AUDIO_CONTEXT=ls,g.SUPPORTS_CLICK_EVENTS=Fn,g.SUPPORTS_CREATE_IMAGE_BITMAP=as,g.SUPPORTS_IMAGE_BITMAP=Ln,g.SUPPORTS_MOUSE_EVENTS=Vl,g.SUPPORTS_OFFLINE_AUDIO_CONTEXT=cs,g.SUPPORTS_POINTER_EVENTS=sr,g.SUPPORTS_RESIZE_OBSERVER=kn,g.SUPPORTS_TOUCH_EVENTS=_e,g.SUPPORTS_WEBGL2=Bn,g.SUPPORTS_WEBKIT_AUDIO_CONTEXT=hs,g.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=$n,g.SUPPORTS_WEB_AUDIO=zn,g.SUPPORTS_WHEEL_EVENTS=Nn,g.SVGPath=co,g.SceneTree=vo,g.Star=lh,g.Style2D=ce,g.Style2DBackgroundModule=No,g.Style2DFilterModule=Fo,g.Style2DModule=hr,g.Style2DOffsetModule=zo,g.Style2DTextModule=Vo,g.Style2DTransformModule=Xo,g.TextLoader=Ro,g.Texture=pt,g.TextureLoader=Bo,g.Ticker=ft,g.Transform2D=qt,g.Triangle=xs,g.UIInputEvent=Ki,g.UvGeometry=Zl,g.UvMaterial=ci,g.Vector=ie,g.Vector2=Bh,g.Vector3=Lh,g.Vector4=go,g.VertexAttribute=jt,g.VertexBuffer=be,g.VideoLoader=Lo,g.VideoTexture=_o,g.ViewportTexture=Ds,g.WebAudio=ja,g.WebAudioContext=Le,g.WebGLBatch2DModule=_l,g.WebGLBlendMode=vr,g.WebGLBufferModule=vl,g.WebGLFramebufferModule=bl,g.WebGLMaskModule=xl,g.WebGLModule=ee,g.WebGLProgramModule=wl,g.WebGLRenderer=Sl,g.WebGLScissorModule=Pl,g.WebGLState=tr,g.WebGLStateModule=yl,g.WebGLStencilModule=Cl,g.WebGLTextureModule=Tl,g.WebGLVertexArrayModule=El,g.WebGLViewportModule=Ml,g.WebSound=Xa,g.WheelInputEvent=ri,g._Object=li,g.assets=we,g.buildAdaptiveBezier=gs,g.buildAdaptiveQuadratic=Qn,g.buildArc=_s,g.buildArcTo=nh,g.buildArcToSvg=to,g.buildCircle=$e,g.buildLine=lo,g.buildPolygon=Ts,g.buildRectangle=Es,g.buildTriangle=Ms,g.clamp=Me,g.closePointEps=oo,g.createHTMLCanvas=Gn,g.createNode=jl,g.crossOrigin=Yn,g.cubicBezier=cr,g.curveEps=Cs,g.curves=Rh,g.customNode=Z,g.customNodes=oi,g.defaultOptions=Al,g.defineProperty=W,g.determineCrossOrigin=qn,g.ease=Go,g.easeIn=qo,g.easeInOut=Wo,g.easeOut=Yo,g.getDeclarations=ai,g.getDefaultCssPropertyValue=os,g.isCanvasElement=Xn,g.isElementNode=fs,g.isImageElement=Xl,g.isPow2=ns,g.isVideoElement=Vn,g.isWebgl2=jn,g.lerp=dt,g.linear=jo,g.log2=In,g.mapWebGLBlendModes=ml,g.nextPow2=Un,g.nextTick=ds,g.parseCssFunctions=wr,g.parseCssProperty=xr,g.property=U,g.protectedProperty=nt,g.render=Np,g.squaredDistanceToLineSegment=Er,g.timingFunctions=Pi,g.uid=Dn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});