textmode.js 0.4.0 → 0.6.0-beta.1
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/textmode.esm.js +2868 -2164
- package/dist/textmode.esm.min.js +2863 -2159
- package/dist/textmode.umd.js +11 -8
- package/dist/textmode.umd.min.js +11 -8
- package/dist/types/Textmode.d.ts +13 -22
- package/dist/types/index.d.ts +8 -6
- package/dist/types/rendering/index.d.ts +3 -3
- package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +89 -0
- package/dist/types/rendering/webgl/{VAOManager.d.ts → batching/GeometryAttributeCache.d.ts} +4 -4
- package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +87 -0
- package/dist/types/rendering/webgl/{InstanceBatch.d.ts → batching/InstanceBatch.d.ts} +25 -34
- package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +78 -0
- package/dist/types/rendering/webgl/{InstanceData.d.ts → batching/InstanceData.d.ts} +11 -18
- package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +70 -0
- package/dist/types/rendering/webgl/{Framebuffer.d.ts → core/Framebuffer.d.ts} +37 -39
- package/dist/types/rendering/webgl/core/Renderer.d.ts +64 -0
- package/dist/types/rendering/webgl/{Shader.d.ts → core/Shader.d.ts} +2 -23
- package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +103 -0
- package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +210 -0
- package/dist/types/rendering/webgl/geometries/{Arc.d.ts → 2d/Arc.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{BezierCurve.d.ts → 2d/BezierCurve.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Ellipse.d.ts → 2d/Ellipse.d.ts} +6 -5
- package/dist/types/rendering/webgl/geometries/{Line.d.ts → 2d/Line.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Rectangle.d.ts → 2d/Rectangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/{Triangle.d.ts → 2d/Triangle.d.ts} +5 -4
- package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +30 -26
- package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +33 -0
- package/dist/types/rendering/webgl/geometries/index.d.ts +6 -6
- package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +31 -0
- package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +16 -0
- package/dist/types/rendering/webgl/index.d.ts +15 -14
- package/dist/types/rendering/webgl/materials/Material.d.ts +26 -0
- package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +63 -0
- package/dist/types/rendering/webgl/materials/index.d.ts +2 -0
- package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +63 -0
- package/dist/types/rendering/webgl/pipeline/index.d.ts +7 -0
- package/dist/types/rendering/webgl/state/RenderState.d.ts +143 -0
- package/dist/types/rendering/webgl/types/DrawCommand.d.ts +5 -3
- package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +10 -10
- package/dist/types/rendering/webgl/types/RenderTypes.d.ts +1 -1
- package/dist/types/rendering/webgl/utils/GLUtils.d.ts +45 -0
- package/dist/types/rendering/webgl/utils/hash.d.ts +118 -0
- package/dist/types/textmode/AnimationController.d.ts +11 -21
- package/dist/types/textmode/Canvas.d.ts +10 -2
- package/dist/types/textmode/Grid.d.ts +2 -0
- package/dist/types/textmode/TextmodeColor.d.ts +57 -0
- package/dist/types/textmode/Textmodifier.d.ts +40 -212
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +272 -0
- package/dist/types/textmode/interfaces/index.d.ts +1 -0
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +21 -0
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +130 -0
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +237 -0
- package/dist/types/textmode/{font → loadables/font}/CharacterColorMapper.d.ts +1 -1
- package/dist/types/textmode/{font → loadables/font}/CharacterExtractor.d.ts +0 -10
- package/dist/types/textmode/{font → loadables/font}/TextmodeFont.d.ts +6 -3
- package/dist/types/textmode/{font → loadables/font}/TextureAtlas.d.ts +4 -11
- package/dist/types/textmode/{font → loadables/font}/typr/types.d.ts +0 -6
- package/dist/types/textmode/loadables/index.d.ts +5 -0
- package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +20 -0
- package/dist/types/textmode/loading/LoadingScreenManager.d.ts +170 -0
- package/dist/types/textmode/loading/LoadingScreenState.d.ts +22 -0
- package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +26 -0
- package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +17 -0
- package/dist/types/textmode/loading/index.d.ts +6 -0
- package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +2 -0
- package/dist/types/textmode/loading/templates/index.d.ts +1 -0
- package/dist/types/textmode/loading/types.d.ts +251 -0
- package/dist/types/textmode/managers/KeyboardManager.d.ts +2 -3
- package/dist/types/textmode/managers/MouseManager.d.ts +1 -1
- package/dist/types/textmode/{plugins → managers}/PluginManager.d.ts +12 -15
- package/dist/types/textmode/managers/TouchManager.d.ts +0 -2
- package/dist/types/textmode/mixins/AnimationMixin.d.ts +2 -122
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -77
- package/dist/types/textmode/mixins/KeyboardMixin.d.ts +3 -85
- package/dist/types/textmode/mixins/MouseMixin.d.ts +3 -130
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +2 -749
- package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +2 -44
- package/dist/types/textmode/mixins/TouchMixin.d.ts +2 -187
- package/dist/types/textmode/mixins/index.d.ts +8 -8
- package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +167 -0
- package/dist/types/textmode/mixins/interfaces/IFontMixin.d.ts +46 -0
- package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +235 -0
- package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +457 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +1085 -0
- package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +186 -0
- package/dist/types/textmode/types.d.ts +49 -0
- package/dist/types/textmode/utils/cssColor.d.ts +8 -0
- package/dist/types/utils/array.d.ts +34 -0
- package/dist/types/utils/math.d.ts +69 -0
- package/package.json +1 -1
- package/dist/types/rendering/webgl/DrawQueue.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderPipeline.d.ts +0 -30
- package/dist/types/rendering/webgl/RenderState.d.ts +0 -73
- package/dist/types/rendering/webgl/Renderer.d.ts +0 -158
- package/dist/types/rendering/webgl/ShaderManager.d.ts +0 -66
- package/dist/types/rendering/webgl/geometries/NoiseGrid.d.ts +0 -1
- package/dist/types/textmode/TextmodeImage.d.ts +0 -161
- package/dist/types/textmode/mixins/ShaderMixin.d.ts +0 -1
- /package/dist/types/rendering/webgl/{StateCache.d.ts → utils/ViewportCache.d.ts} +0 -0
- /package/dist/types/textmode/{font → loadables/font}/MetricsCalculator.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/index.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/types.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/typr/Typr.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/FontTableReader.d.ts +0 -0
- /package/dist/types/textmode/{font → loadables/font}/utils/index.d.ts +0 -0
package/dist/textmode.umd.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Vi=Object.defineProperty;var Wi=(L,R,z)=>R in L?Vi(L,R,{enumerable:!0,configurable:!0,writable:!0,value:z}):L[R]=z;var l=(L,R,z)=>Wi(L,typeof R!="symbol"?R+"":R,z);var s,e;s=this,e=function(L){class R extends Error{constructor(t,i={}){super(R.t(t,i)),this.name="TextmodeError"}static t(t,i){return`${t}${i&&Object.keys(i).length>0?`
|
|
2
2
|
|
|
3
|
-
📋 Context
|
|
4
|
-
- ${r}: ${R.
|
|
3
|
+
📋 Context:${Object.entries(i).map(([r,h])=>`
|
|
4
|
+
- ${r}: ${R.i(h)}`).join("")}`:""}
|
|
5
5
|
|
|
6
6
|
${"↓".repeat(24)}
|
|
7
|
-
`}static
|
|
8
|
-
in vec2
|
|
9
|
-
precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`),this.Qt=new z(this.gt,K,`#version 300 es
|
|
10
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`),this.ts=new z(this.gt,rt,"precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"),this.ss=new z(this.gt,K,`#version 300 es
|
|
11
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`)}es(){return this.Qt}Pt(){return this.Jt}rs(){return this.ts}ns(){return this.ss}hs(t){return new z(this.gt,K,t)}cs(t,i){return new z(this.gt,t,i)}Dt(){this.Qt.Dt(),this.Jt.Dt(),this.ts.Dt(),this.ss.Dt()}}var w=(l=>(l.RECTANGLE="rectangle",l.LINE="line",l.ELLIPSE="ellipse",l.ARC="arc",l.TRIANGLE="triangle",l.BEZIER_CURVE="bezier_curve",l.CUSTOM="custom",l))(w||{});class At{constructor(t){c(this,"gt");c(this,"ls",new Map);this.gt=t}us(t,i,r,n){const o=this.gt;let h=this.ls.get(t);h||(h=new Map,this.ls.set(t,h));let a=h.get(i)||null;if(!a){a=o.createVertexArray(),h.set(i,a),o.bindVertexArray(a),o.bindBuffer(o.ARRAY_BUFFER,n);const u=o.getAttribLocation(t,"a_position");u!==-1&&(o.enableVertexAttribArray(u),o.vertexAttribPointer(u,r.ds.fs.size,o.FLOAT,!1,r.ps,r.ds.fs.offset),o.vertexAttribDivisor(u,0));const f=o.getAttribLocation(t,"a_texCoord");f!==-1&&(o.enableVertexAttribArray(f),o.vertexAttribPointer(f,r.ds._s.size,o.FLOAT,!1,r.ps,r.ds._s.offset),o.vertexAttribDivisor(f,0))}o.bindVertexArray(a)}vs(){this.gt.bindVertexArray(null)}Dt(){for(const[,t]of this.ls)for(const[,i]of t)i&&this.gt.deleteVertexArray(i)}}class pt{constructor(t,i){c(this,"gs");c(this,"gt");c(this,"xt");c(this,"As",null);c(this,"Cs",null);this.gt=t,this.gs=new At(t),this.xt=i}ws(t,i,r){const{shader:n}=t,o=V(this.gt)||this.gt.getParameter(this.gt.VIEWPORT);n.Wt({U9:o[2]/o[3],Uy:[o[2],o[3]]});const h=f=>{if(!f||!f.bs())return;const g=f.unitGeometry,d=f.unitBuffer;try{this.gs.us(n.Zt,f.type+"",g,d),f.batch.Ms(n),f.batch.Fs(g.zs,g.Rs)}finally{f.batch.Ts(n),this.gs.vs(),f.Ps()}};let a=null,u=null;for(const f of i){if(f.type===w.CUSTOM){u&&(h(u),a=null,u=null),this.Ss(t,f.params,f.state,r.get(w.RECTANGLE));continue}a!==null&&f.type!==a&&(h(u),a=null,u=null);let g=u;g&&f.type===a||(g=r.get(f.type)||null,u=g,a=f.type),g&&g.$s(f.params,f.state)}h(u)}Ss(t,i,r,n){const{x:o,y:h,width:a,height:u,shader:f,uniforms:g}=i,d=this.Es(Math.max(1,Math.floor(a)),Math.max(1,Math.floor(u)));d.begin(),this.Ds(n,f,g,0,0,d.width,d.height,{}),d.end();const p=this.ks(),y={Ue:d.textures[0],Uf:d.textures[1],Ug:d.textures[2],Uh:d.textures[3],Ui:d.textures[4],Uj:[d.width,d.height]};this.Ds(n,p,y,Math.floor(o),Math.floor(h),Math.max(1,Math.floor(a)),Math.max(1,Math.floor(u)),r),t.shader.Nt()}Ds(t,i,r,n,o,h,a,u){i.Nt(),i.Wt(r);const f=this.gt.getParameter(this.gt.VIEWPORT);if(i.Wt({U9:f[2]/f[3],Uy:[f[2],f[3]]}),t.Ps(),t.$s({x:n,y:o,width:h,height:a},u),t.bs()){const g=t.unitGeometry,d=t.unitBuffer;try{this.gs.us(i.Zt,t.type+"",g,d),t.batch.Ms(i),t.batch.Fs(g.zs,g.Rs)}finally{t.batch.Ts(i),this.gs.vs(),t.Ps()}}}ks(){return this.xt.es()}Es(t,i){return this.As&&this.Cs&&this.Cs.w===t&&this.Cs.h===i||(this.As&&this.As.Dt(),this.As=new q(this.gt,t,i,5),this.Cs={w:t,h:i}),this.As}Dt(){this.gs.Dt(),this.As&&this.As.Dt()}}class vt{constructor(){c(this,"Bs",[]);c(this,"Ls",1);c(this,"Os",0)}Hs(t){if(this.Os>=this.Bs.length){const r={id:this.Ls++,type:t,params:{},state:{I:1,N:0,X:0,W:0,Y:[0,0,0],V:[1,1,1,1],q:[0,0,0,1],K:!1,j:!1,k:!1,L:[0,0]}};this.Bs.push(r)}const i=this.Bs[this.Os];return i.id=this.Ls++,i.type=t,this.Os++,i}Gs(t,i,r,n,o){const h=this.Hs(w.RECTANGLE);return h.params.x=t,h.params.y=i,h.params.width=r,h.params.height=n,o.J(h.state),h.id}Is(t,i,r,n,o,h,a){const u=this.Hs(w.CUSTOM);return u.params.x=t,u.params.y=i,u.params.width=r,u.params.height=n,u.params.shader=o,u.params.uniforms=h,a.J(u.state),u.id}Ns(t,i,r,n,o,h){const a=this.Hs(w.LINE);return a.params.x1=t,a.params.y1=i,a.params.x2=r,a.params.y2=n,a.params.thickness=o,h.J(a.state),a.id}Xs(t,i,r,n,o){const h=this.Hs(w.ELLIPSE);return h.params.x=t,h.params.y=i,h.params.width=r,h.params.height=n,o.J(h.state),h.id}Ws(t,i,r,n,o,h,a){const u=this.Hs(w.ARC);return u.params.x=t,u.params.y=i,u.params.width=r,u.params.height=n,u.params.start=o,u.params.stop=h,a.J(u.state),u.id}Ks(t,i,r,n,o,h,a){const u=this.Hs(w.TRIANGLE);return u.params.x1=t,u.params.y1=i,u.params.x2=r,u.params.y2=n,u.params.x3=o,u.params.y3=h,a.J(u.state),u.id}js(t,i,r,n,o,h,a,u,f,g){const d=this.Hs(w.BEZIER_CURVE);return d.params.x1=t,d.params.y1=i,d.params.cp1x=r,d.params.cp1y=n,d.params.cp2x=o,d.params.cp2y=h,d.params.x2=a,d.params.y2=u,d.params.thickness=f,g.J(d.state),d.id}get length(){return this.Os}get isEmpty(){return this.Os===0}Ys(){this.Os=0}[Symbol.iterator](){let t=0;const i=this.Os,r=this.Bs;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}const _=class _{static Vs(t,i,r=0){var h,a,u,f,g,d,p,y,A,m;const n=i||new Float32Array(_.FLOATS_PER_INSTANCE);let o=r;return n[o++]=t.fs[0],n[o++]=t.fs[1],n[o++]=t.Os[0],n[o++]=t.Os[1],n[o++]=t.Y[0],n[o++]=t.Y[1],n[o++]=t.Y[2],n[o++]=t.V[0],n[o++]=t.V[1],n[o++]=t.V[2],n[o++]=t.V[3],n[o++]=t.q[0],n[o++]=t.q[1],n[o++]=t.q[2],n[o++]=t.q[3],n[o++]=t.L[0],n[o++]=t.L[1],n[o++]=t.qs[0],n[o++]=t.qs[1],n[o++]=t.qs[2],n[o++]=t.N,n[o++]=t.X,n[o++]=t.W,n[o++]=t.Zs[0],n[o++]=t.Zs[1],n[o++]=((h=t.Qs)==null?void 0:h[0])||0,n[o++]=((a=t.Qs)==null?void 0:a[1])||0,n[o++]=((u=t.Js)==null?void 0:u[0])||0,n[o++]=((f=t.Js)==null?void 0:f[1])||0,n[o++]=((g=t.te)==null?void 0:g[0])||0,n[o++]=((d=t.te)==null?void 0:d[1])||0,n[o++]=((p=t.se)==null?void 0:p[0])||0,n[o++]=((y=t.se)==null?void 0:y[1])||0,n[o++]=((A=t.ee)==null?void 0:A[0])||0,n[o++]=((m=t.ee)==null?void 0:m[1])||0,n}static ie(t){const i=t.length*_.FLOATS_PER_INSTANCE,r=new Float32Array(i);for(let n=0;n<t.length;n++){const o=n*_.FLOATS_PER_INSTANCE;_.Vs(t[n],r,o)}return r}};c(_,"BYTES_PER_INSTANCE",140),c(_,"FLOATS_PER_INSTANCE",35);let B=_;const F=class F{};c(F,"STRIDE",B.BYTES_PER_INSTANCE),c(F,"ATTRIBUTES",{a_instancePosition:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:0,divisor:1},a_instanceSize:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:8,divisor:1},a_instanceCharacter:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:16,divisor:1},a_instancePrimaryColor:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:28,divisor:1},a_instanceSecondaryColor:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:44,divisor:1},a_instanceRotation:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:60,divisor:1},a_instanceTransform:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:68,divisor:1},a_instanceGlobalRotation:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:80,divisor:1},a_instanceRotationCenter:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:92,divisor:1},a_instanceArcAngles:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:100,divisor:1},a_instanceBezierCP1:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:108,divisor:1},a_instanceBezierCP2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:116,divisor:1},a_instanceBezierStart:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:124,divisor:1},a_instanceBezierEnd:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:F.STRIDE,offset:132,divisor:1}});let j=F;class yt{constructor(t,i=1e3,r=1.5){c(this,"gt");c(this,"re",[]);c(this,"ne");c(this,"oe");c(this,"he",null);c(this,"ae",!0);c(this,"ce",0);c(this,"le",new Map);c(this,"ue",null);this.gt=t,this.ne=i,this.oe=r,this.fe()}$s(t){const i=this.re.length;return this.re.push(t),this.ae=!0,i}get count(){return this.re.length}get isEmpty(){return this.re.length===0}clear(){this.re.length=0,this.ae=!0}de(t){if(t<=this.ne)return;const i=Math.ceil(t*this.oe);this.ne=i,this.fe()}fe(){const t=this.gt;this.he&&t.deleteBuffer(this.he),this.he=t.createBuffer();const i=this.ne*B.BYTES_PER_INSTANCE;t.bindBuffer(t.ARRAY_BUFFER,this.he),t.bufferData(t.ARRAY_BUFFER,i,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),this.ae=!0,this.ce=0}pe(){if(!this.ae||this.re.length===0)return;const t=this.gt,i=this.re.length;this.de(i),(!this.ue||this.ue.length<i*B.FLOATS_PER_INSTANCE)&&(this.ue=new Float32Array(i*B.FLOATS_PER_INSTANCE));const r=B.ie(this.re);t.bindBuffer(t.ARRAY_BUFFER,this.he),i<=this.ce?t.bufferSubData(t.ARRAY_BUFFER,0,r):t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),this.ae=!1,this.ce=i}_e(t){let i=this.le.get(t);if(!i){i=new Map;const r=this.gt;for(const n in j.ATTRIBUTES){const o=r.getAttribLocation(t,n);o!==-1&&i.set(n,o)}this.le.set(t,i)}return i}Ms(t){if(!this.he||this.re.length===0)return;const i=this.gt,r=t.Zt;this.pe();const n=this._e(r);i.bindBuffer(i.ARRAY_BUFFER,this.he);for(const[o,h]of n){const a=j.ATTRIBUTES[o];a&&(i.enableVertexAttribArray(h),i.vertexAttribPointer(h,a.size,a.type,a.normalized,a.stride,a.offset),i.vertexAttribDivisor(h,a.divisor))}}Ts(t){const i=this.gt,r=this._e(t.Zt);for(const[,n]of r)i.disableVertexAttribArray(n),i.vertexAttribDivisor(n,0)}Fs(t,i){this.re.length!==0&&this.gt.drawArraysInstanced(t,0,i,this.re.length)}Dt(){this.he&&this.gt.deleteBuffer(this.he)}}class G{constructor(t,i,r,n){c(this,"gt");c(this,"me");c(this,"ve");c(this,"ge");c(this,"ye",null);this.gt=t,this.me=i,this.ve=r,this.ge=n;const o=this.gt.createBuffer();if(!o)throw Error("Failed to create unit geometry buffer");this.gt.bindBuffer(this.gt.ARRAY_BUFFER,o),this.gt.bufferData(this.gt.ARRAY_BUFFER,this.ge.Ae,this.gt.STATIC_DRAW),this.gt.bindBuffer(this.gt.ARRAY_BUFFER,null),this.ye=o}get type(){return this.ve}get unitGeometry(){return this.ge}get unitBuffer(){return this.ye}get batch(){return this.me}Ps(){this.me.clear()}bs(){return!this.me.isEmpty}Dt(){this.me.Dt(),this.gt.deleteBuffer(this.ye)}Ce(t,i,r,n,o){const h=this.we(t,i,r,n,o.N||0,o.X||0,o.W||0);return{fs:[t,i],Os:[r,n],Y:o.Y||[0,0,0],V:o.V||[1,1,1,1],q:o.q||[0,0,0,1],L:o.L||[0,0],qs:[o.k?1:0,o.K?1:0,o.j?1:0],N:h.radiansX,X:h.radiansY,W:h.radiansZ,Zs:[h.centerX,h.centerY]}}be(t,i){const r=V(this.gt)||[0,0,this.gt.canvas.width,this.gt.canvas.height];return{nx:t/r[2]*2-1,ny:1-i/r[3]*2}}xe(t,i,r){const n=this.be(i,r);t.Zs=[n.nx,n.ny]}we(t,i,r,n,o,h,a){const u=V(this.gt)||[0,0,this.gt.canvas.width,this.gt.canvas.height],f=u[2],g=u[3];return{centerX:(t+r/2)/f*2-1,centerY:1-(i+n/2)/g*2,radiansX:-o*Math.PI/180,radiansY:-h*Math.PI/180,radiansZ:-a*Math.PI/180,aspectRatio:f/g}}}const xt={Ae:new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,1,1,1]),Rs:6,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class Et extends G{constructor(t,i){super(t,i,w.RECTANGLE,xt)}$s(t,i){const r=this.Ce(t.x,t.y,t.width,t.height,i);return this.me.$s(r)}}const wt={Ae:new Float32Array([0,-.5,0,0,1,-.5,1,0,0,.5,0,1,0,.5,0,1,1,-.5,1,0,1,.5,1,1]),Rs:6,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class Tt extends G{constructor(t,i){super(t,i,w.LINE,wt)}$s(t,i){const r=t.x2-t.x1,n=t.y2-t.y1,o=Math.hypot(r,n),h=t.thickness||i.I||1,a=t.x1+r/2,u=t.y1+n/2,f=a-o/2,g=u,d=this.Ce(f,g,o,h,i);return this.xe(d,a,u),this.me.$s(d)}}const Rt={Ae:function(l=32){const t=[],i=2*Math.PI/l;for(let r=0;r<l;r++){const n=r*i,o=(r+1)%l*i,h=Math.cos(n),a=Math.sin(n),u=.5*(h+1),f=.5*(a+1),g=Math.cos(o),d=Math.sin(o),p=.5*(g+1),y=.5*(d+1);t.push(0,0,.5,.5,h,a,u,f,g,d,p,y)}return new Float32Array(t)}(32),Rs:96,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class bt extends G{constructor(t,i){super(t,i,w.ELLIPSE,Rt)}$s(t,i){const r=this.Ce(t.x,t.y,t.width,t.height,i);return this.xe(r,t.x,t.y),this.me.$s(r)}}let Ct={Ae:function(l){const t=[];for(let i=0;i<l;i++){const r=i/l,n=(i+1)/l;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),Rs:96,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class Ft extends G{constructor(t,i){super(t,i,w.ARC,Ct)}$s(t,i){const r=t.x-t.width/2,n=t.y-t.height/2,o=t.start*Math.PI/180,h=t.stop*Math.PI/180,a=this.Ce(r,n,t.width,t.height,i);return this.xe(a,t.x,t.y),a.Qs=[o,h],this.me.$s(a)}}const Ut={Ae:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Rs:3,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class Pt extends G{constructor(t,i){super(t,i,w.TRIANGLE,Ut)}$s(t,i){const r=Math.min(t.x1,t.x2,t.x3),n=Math.max(t.x1,t.x2,t.x3),o=Math.min(t.y1,t.y2,t.y3),h=n-r,a=Math.max(t.y1,t.y2,t.y3)-o,u=this.Ce(r,o,h,a,i),f=r+.5*h,g=o+a*(1/3);return this.xe(u,f,g),this.me.$s(u)}}function nt(l,t,i,r,n){const o=1-l,h=o*o,a=l*l;return h*o*t+3*h*l*i+3*o*a*r+a*l*n}const Ot={Ae:function(l=16){const t=[];for(let i=0;i<l;i++){const r=i/l,n=(i+1)/l;t.push(r,-.5,r,0),t.push(n,-.5,n,0),t.push(r,.5,r,1),t.push(r,.5,r,1),t.push(n,-.5,n,0),t.push(n,.5,n,1)}return new Float32Array(t)}(16),Rs:96,zs:WebGL2RenderingContext.TRIANGLES,ps:16,ds:{fs:{size:2,offset:0},_s:{size:2,offset:8}}};class Mt extends G{constructor(t,i){super(t,i,w.BEZIER_CURVE,Ot)}$s(t,i){const r=i.I||1,n=nt(.5,t.x1,t.cp1x,t.cp2x,t.x2),o=nt(.5,t.y1,t.cp1y,t.cp2y,t.y2),h=this.Ce(0,0,1,r,i);return this.xe(h,n,o),h.se=[t.x1,t.y1],h.Js=[t.cp1x,t.cp1y],h.te=[t.cp2x,t.cp2y],h.ee=[t.x2,t.y2],this.me.$s(h)}}class Lt{constructor(t){c(this,"gt");c(this,"Me",null);c(this,"Fe");c(this,"ze",null);c(this,"Re",{});c(this,"Te",null);c(this,"Pe",new Map);c(this,"Se");c(this,"$e");c(this,"Ee");c(this,"H",[]);this.gt=t,this.Fe=new mt(t),this.Ee=new st,this.Se=new pt(t,this),this.$e=new vt,this.Te=t.createBuffer(),k(this.gt,[0,0,this.gt.canvas.width,this.gt.canvas.height])}De(t){let i=this.Pe.get(t);if(i)return i;const r=new yt(this.gt);return i=(0,{[w.RECTANGLE]:()=>new Et(this.gt,r),[w.LINE]:()=>new Tt(this.gt,r),[w.ELLIPSE]:()=>new bt(this.gt,r),[w.ARC]:()=>new Ft(this.gt,r),[w.TRIANGLE]:()=>new Pt(this.gt,r),[w.BEZIER_CURVE]:()=>new Mt(this.gt,r)}[t])(),this.Pe.set(t,i),i}ke(t){this.Me!==t&&(this.Me=t,t.Nt())}cs(t,i){return this.Fe.cs(t,i)}es(){return this.Fe.es()}Pt(){return this.Fe.Pt()}rs(){return this.Fe.rs()}ns(){return this.Fe.ns()}Be(t){this.ze=t,t&&(this.Re={})}Kt(t,i){this.Re[t]=i}Le(t){Object.assign(this.Re,t)}hs(t){return this.Fe.hs(t)}Oe(t,i,r,n,o){const h=this.es(),a={Ue:t.textures[0],Uf:t.textures[1],Ug:t.textures[2],Uh:t.textures[3],Ui:t.textures[4],Uj:[t.width,t.height]};this.$e.Is(i,r,n,o,h,a,this.Ee)}He(t,i,r,n,o){const h=this.ns(),a=t.Ge(),u={Uk:a.texture,Ul:!!a.invert,Um:!!a.flipX,Un:!!a.flipY,Uo:a.charRotation,Up:a.charColorFixed,Uq:a.charColor,Ur:a.cellColorFixed,Us:a.cellColor,Ut:a.backgroundColor,Uu:a.charCount,Uv:a.charList};this.$e.Is(i,r,n,o,h,u,this.Ee)}Ie(t,i,r,n){var m;const o=this.gt,h=o.canvas.width,a=o.canvas.height,u=t/h*2-1,f=(t+r)/h*2-1,g=1-i/a*2,d=1-(i+n)/a*2,p=new Float32Array([u,d,f,d,u,g,f,d,f,g,u,g]);o.bindBuffer(o.ARRAY_BUFFER,this.Te),o.bufferData(o.ARRAY_BUFFER,p,o.DYNAMIC_DRAW);const y=((m=this.Me)==null?void 0:m.Zt)||o.getParameter(o.CURRENT_PROGRAM),A=y?o.getAttribLocation(y,"a_position"):-1;A!==-1&&(o.enableVertexAttribArray(A),o.vertexAttribPointer(A,2,o.FLOAT,!1,8,0)),o.drawArrays(o.TRIANGLES,0,6),A!==-1&&o.disableVertexAttribArray(A)}Ne(t,i,r,n){this.ze?(this.$e.Is(t,i,r,n,this.ze,{...this.Re},this.Ee),this.ze=null,this.Re={}):this.$e.Gs(t,i,r,n,this.Ee)}Xe(t,i,r,n){this.$e.Ns(t,i,r,n,this.Ee.lineWeight,this.Ee)}We(t,i,r,n){this.$e.Xs(t,i,r,n,this.Ee)}Ke(t,i,r,n,o,h){this.$e.Ks(t,i,r,n,o,h,this.Ee)}je(t,i,r,n,o,h,a,u){const f=this.Ee.lineWeight;this.$e.js(t,i,r,n,o,h,a,u,f,this.Ee)}Ye(t,i,r=1,n={}){return new q(this.gt,t,i,r,n,this,!0)}Ve(t,i,r,n,o,h){this.$e.Ws(t,i,r,n,o,h,this.Ee)}qe(t,i=t,r=t,n=255){this.Ee.ft(t,i,r,n),this.Ys(t/255,i/255,r/255,n/255)}Ys(t=0,i=0,r=0,n=0){this.gt.clearColor(t,i,r,n),this.gt.clear(this.gt.COLOR_BUFFER_BIT)}Ze(){this.gt.viewport(0,0,this.gt.canvas.width,this.gt.canvas.height),k(this.gt,[0,0,this.gt.canvas.width,this.gt.canvas.height])}get context(){return this.gt}get state(){return this.Ee}$t(t){this.H.push(this.Ee),this.Ee=t}Et(){const t=this.H.pop();t&&(this.Ee=t)}St(t){const i=t,r=V(this.gt)??this.gt.getParameter(this.gt.VIEWPORT),n={shader:i,gl:this.gt,viewport:r};this.ke(i);const o=new Set;for(const h of this.$e)h.type===w.CUSTOM?o.add(w.RECTANGLE):o.add(h.type);for(const h of o)h!==w.CUSTOM&&this.De(h);this.Se.ws(n,this.$e,this.Pe),this.$e.Ys()}Dt(){this.gt.deleteBuffer(this.Te),this.$e.Ys();for(const t of this.Pe.values())t.Dt();this.Fe.Dt(),this.Se.Dt()}}const b={readShort:(l,t)=>(b.t.uint16[0]=l[t]<<8|l[t+1],b.t.int16[0]),readUshort:(l,t)=>l[t]<<8|l[t+1],readUshorts(l,t,i){const r=[];for(let n=0;n<i;n++)r.push(b.readUshort(l,t+2*n));return r},readUint(l,t){const i=b.t.uint8;return i[3]=l[t],i[2]=l[t+1],i[1]=l[t+2],i[0]=l[t+3],b.t.uint32[0]},readASCII(l,t,i){let r="";for(let n=0;n<i;n++)r+=String.fromCharCode(l[t+n]);return r},writeUshort(l,t,i){l[t]=i>>>8&255,l[t+1]=255&i},writeUint(l,t,i){l[t]=i>>>24&255,l[t+1]=i>>>16&255,l[t+2]=i>>>8&255,l[t+3]=255&i},writeASCII(l,t,i){for(let r=0;r<i.length;r++)l[t+r]=255&i.charCodeAt(r)},t:(()=>{const l=new ArrayBuffer(8);return{uint8:new Uint8Array(l),int16:new Int16Array(l),uint16:new Uint16Array(l),uint32:new Uint32Array(l)}})()};function Z(l){return l+3&-4}function $(l,t,i){const r=t+i;let n=0;const o=b.t;for(let h=t;h<r;h+=4)o.uint8[3]=l[h]||0,o.uint8[2]=l[h+1]||0,o.uint8[1]=l[h+2]||0,o.uint8[0]=l[h+3]||0,n=n+(o.uint32[0]>>>0)>>>0;return n>>>0}class Dt{constructor(t){c(this,"b");c(this,"p",0);c(this,"bitbuf",0);c(this,"bitcnt",0);this.b=t}readBits(t){for(;this.bitcnt<t;){const r=this.b[this.p++]||0;this.bitbuf|=r<<this.bitcnt,this.bitcnt+=8}const i=this.bitbuf&(1<<t)-1;return this.bitbuf>>>=t,this.bitcnt-=t,i}alignToByte(){this.bitbuf=0,this.bitcnt=0}get offset(){return this.p}}function Y(l){let t=32,i=0;for(const a of l)a&&(a<t&&(t=a),a>i&&(i=a));if(i===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(i+1);for(const a of l)a&&r[a]++;const n=new Uint32Array(i+1);let o=0;r[0]=0;for(let a=1;a<=i;a++)o=o+r[a-1]<<1,n[a]=o;const h=new Map;for(let a=0;a<l.length;a++){const u=l[a];if(!u)continue;const f=n[u]++;let g=h.get(u);g||(g=[],h.set(u,g)),g[_t(f,u)]=a}return{min:t,max:i,table:h}}function tt(l,t){let i=0;for(let r=1;r<=t.max;r++){i|=l.readBits(1)<<r-1;const n=t.table.get(r);if(n&&i<n.length){const o=n[i];if(o!==void 0)return o}}throw Error("Invalid Huffman code")}function _t(l,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&l,l>>>=1;return i>>>0}function St(l){if(l.length<2)throw Error("ZLIB data too short");const t=l[0],i=l[1];if((15&t)!=8)throw Error("Unsupported ZLIB compression method");if(((t<<8)+i)%31!=0)throw Error("Bad ZLIB header check");let r=2;32&i&&(r+=4);const n=[];return function(o,h){const a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],u=[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],f=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],g=[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];let d=0;for(;!d;){d=o.readBits(1);const p=o.readBits(2);if(p===0){o.alignToByte();const y=o.readBits(16);if((65535&(65535^y))!==o.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let A=0;A<y;A++)h.push(o.readBits(8))}else{if(p!==1&&p!==2)throw Error("Unsupported DEFLATE type");{let y,A;if(p===1){const m=Array(288).fill(0);for(let x=0;x<=143;x++)m[x]=8;for(let x=144;x<=255;x++)m[x]=9;for(let x=256;x<=279;x++)m[x]=7;for(let x=280;x<=287;x++)m[x]=8;y=Y(m),A=Y(Array(32).fill(5))}else{const m=o.readBits(5)+257,x=o.readBits(5)+1,v=o.readBits(4)+4,T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E=Array(19).fill(0);for(let M=0;M<v;M++)E[T[M]]=o.readBits(3);const O=Y(E),U=[];for(;U.length<m+x;){const M=tt(o,O);if(M<=15)U.push(M);else if(M===16){const W=o.readBits(2)+3,N=U[U.length-1]||0;for(let gt=0;gt<W;gt++)U.push(N)}else if(M===17){const W=o.readBits(3)+3;for(let N=0;N<W;N++)U.push(0)}else{if(M!==18)throw Error("Invalid code length symbol");{const W=o.readBits(7)+11;for(let N=0;N<W;N++)U.push(0)}}}const P=U.slice(0,m),L=U.slice(m,m+x);y=Y(P),A=Y(L)}for(;;){const m=tt(o,y);if(m<256)h.push(m);else{if(m===256)break;if(m>256&&m<286){const x=m-257;let v=a[x];const T=u[x];T&&(v+=o.readBits(T));const E=tt(o,A);if(E>=30)throw Error("Invalid distance symbol");let O=f[E];const U=g[E];U&&(O+=o.readBits(U));const P=h.length-O;if(P<0)throw Error("Invalid distance");for(let L=0;L<v;L++)h.push(h[P+L]||0)}else if(m===286||m===287)throw Error("Reserved length symbol")}}}}}}(new Dt(l.subarray(r)),n),new Uint8Array(n)}function Bt(l){const t=b,i=new Uint8Array(l);if(t.readASCII(i,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(i,4),n=t.readUshort(i,12),o=t.readUint(i,16),h=[];let a=44;for(let v=0;v<n;v++){const T=t.readASCII(i,a,4),E=t.readUint(i,a+4),O=t.readUint(i,a+8),U=t.readUint(i,a+12),P=t.readUint(i,a+16);h.push({tag:T,offset:E,compLength:O,origLength:U,checksum:P}),a+=20}for(const v of h){const T=new Uint8Array(i.buffer,v.offset,v.compLength);if(v.compLength===v.origLength)v.data=new Uint8Array(T);else if(v.data=St(T),v.data.length!==v.origLength)if(v.data.length<v.origLength){const E=new Uint8Array(v.origLength);E.set(v.data),v.data=E}else v.data=v.data.subarray(0,v.origLength)}const u=n;let f=1,g=0;for(;f<<1<=u;)f<<=1,g++;const d=16*f,p=16*u-d;let y=12+16*u;const A={};for(const v of h)A[v.tag]=y,y=Z(y+v.data.length);const m=new Uint8Array(Math.max(o||0,y));t.writeUint(m,0,r),t.writeUshort(m,4,u),t.writeUshort(m,6,d),t.writeUshort(m,8,g),t.writeUshort(m,10,p);let x=12;for(const v of h){t.writeASCII(m,x,v.tag),x+=4;let T=v.data;if(v.tag==="head"&&T.length>=12){const E=new Uint8Array(T);t.writeUint(E,8,0);const O=$(E,0,Z(E.length));t.writeUint(m,x,O),x+=4}else{const E=$(T,0,Z(T.length));t.writeUint(m,x,E),x+=4}t.writeUint(m,x,A[v.tag]),x+=4,t.writeUint(m,x,v.data.length),x+=4}for(const v of h){const T=A[v.tag];m.set(v.data,T)}if(h.find(v=>v.tag==="head")){const v=A.head,T=function(E,O){const U=b,P=O+8,L=[E[P],E[P+1],E[P+2],E[P+3]];U.writeUint(E,P,0);const M=2981146554-($(E,0,Z(E.length))>>>0)>>>0;return E[P]=L[0],E[P+1]=L[1],E[P+2]=L[2],E[P+3]=L[3],M>>>0}(m,v);t.writeUint(m,v+8,T)}return m.buffer}const It={parseTab(l,t,i){const r={tables:[],ids:{},off:t};l=new Uint8Array(l.buffer,t,i),t=0;const n=b,o=n.readUshort,h=o(l,t+=2);t+=2;const a=[];for(let u=0;u<h;u++){const f=o(l,t),g=o(l,t+=2);t+=2;const d=n.readUint(l,t);t+=4;const p=`p${f}e${g}`;let y=a.indexOf(d);if(y===-1){let A;y=r.tables.length,a.push(d);const m=o(l,d);A=m===4?this.parse4(l,d):m===12?this.parse12(l,d):{format:m},r.tables.push(A)}r.ids[p]=y}return r},parse4(l,t){const i=b,r=i.readUshort,n=i.readUshorts,o=t,h=r(l,t+=2);t+=2;const a=r(l,t+=2)>>>1,u={format:4,searchRange:r(l,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(l,t),t+=2,u.rangeShift=r(l,t),t+=2,u.endCount=n(l,t,a),t+=2*a,t+=2,u.startCount=n(l,t,a),t+=2*a;for(let f=0;f<a;f++)u.idDelta.push(i.readShort(l,t)),t+=2;return u.idRangeOffset=n(l,t,a),t+=2*a,u.glyphIdArray=n(l,t,o+h-t>>1),u},parse12(l,t){const i=b.readUint;i(l,t+=4),i(l,t+=4);const r=i(l,t+=4);t+=4;const n=new Uint32Array(3*r);for(let o=0;o<3*r;o+=3)n[o]=i(l,t+(o<<2)),n[o+1]=i(l,t+(o<<2)+4),n[o+2]=i(l,t+(o<<2)+8);return{format:12,groups:n}}},Nt={parseTab(l,t,i){const r=b;t+=18;const n=r.readUshort(l,t);t+=2,t+=16;const o=r.readShort(l,t);t+=2;const h=r.readShort(l,t);t+=2;const a=r.readShort(l,t);t+=2;const u=r.readShort(l,t);return t+=2,t+=6,{unitsPerEm:n,xMin:o,yMin:h,xMax:a,yMax:u,indexToLocFormat:r.readShort(l,t)}}},zt={parseTab(l,t,i){const r=b;t+=4;const n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],o={};for(let h=0;h<n.length;h++){const a=n[h],u=a==="advanceWidthMax"||a==="numberOfHMetrics"?r.readUshort:r.readShort;o[a]=u(l,t+2*h)}return o}},Gt={parseTab(l,t,i,r){const n=b,o=[],h=[],a=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,g=0,d=0;for(;d<u;)f=n.readUshort(l,t+(d<<2)),g=n.readShort(l,t+(d<<2)+2),o.push(f),h.push(g),d++;for(;d<a;)o.push(f),h.push(g),d++;return{aWidth:o,lsBearing:h}}},ot={cmap:It,head:Nt,hhea:zt,maxp:{parseTab(l,t,i){const r=b;return r.readUint(l,t),t+=4,{numGlyphs:r.readUshort(l,t)}}},hmtx:Gt,loca:{parseTab(l,t,i,r){const n=b,o=[],h=r.head.indexToLocFormat,a=r.maxp.numGlyphs+1;if(h===0)for(let u=0;u<a;u++)o.push(n.readUshort(l,t+(u<<1))<<1);else if(h===1)for(let u=0;u<a;u++)o.push(n.readUint(l,t+(u<<2)));return o}},glyf:{parseTab(l,t,i,r){const n=[],o=r.maxp.numGlyphs;for(let h=0;h<o;h++)n.push(null);return n},Qe(l,t){const i=b,r=l.Je,n=l.loca;if(n[t]===n[t+1])return null;const o=D.findTable(r,"glyf",l.ti);if(!o)return null;let h=o[0]+n[t];const a={};if(a.noc=i.readShort(r,h),h+=2,a.xMin=i.readShort(r,h),h+=2,a.yMin=i.readShort(r,h),h+=2,a.xMax=i.readShort(r,h),h+=2,a.yMax=i.readShort(r,h),h+=2,a.xMin>=a.xMax||a.yMin>=a.yMax)return null;if(a.noc>0){a.endPts=[];for(let p=0;p<a.noc;p++)a.endPts.push(i.readUshort(r,h)),h+=2;const u=i.readUshort(r,h);if(h+=2,r.length-h<u)return null;h+=u;const f=a.endPts[a.noc-1]+1;a.flags=[];for(let p=0;p<f;p++){const y=r[h];if(h++,a.flags.push(y),8&y){const A=r[h];h++;for(let m=0;m<A;m++)a.flags.push(y),p++}}a.xs=[];for(let p=0;p<f;p++){const y=a.flags[p],A=!!(16&y);2&y?(a.xs.push(A?r[h]:-r[h]),h++):A?a.xs.push(0):(a.xs.push(i.readShort(r,h)),h+=2)}a.ys=[];for(let p=0;p<f;p++){const y=a.flags[p],A=!!(32&y);4&y?(a.ys.push(A?r[h]:-r[h]),h++):A?a.ys.push(0):(a.ys.push(i.readShort(r,h)),h+=2)}let g=0,d=0;for(let p=0;p<f;p++)g+=a.xs[p],d+=a.ys[p],a.xs[p]=g,a.ys[p]=d}else a.parts=[],a.endPts=[],a.flags=[],a.xs=[],a.ys=[];return a}}},D={parse(l){const t=new Uint8Array(l),i=b.readASCII(t,0,4);if(i==="wOFF")l=Bt(l);else if(i==="wOF2")throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");return[((r,n,o,h)=>{const a=ot,u={Je:r,si:n,ti:o};for(const f in a){const g=f,d=D.findTable(r,g,o);if(d){const[p,y]=d;let A=h[p];A==null&&(A=a[g].parseTab(r,p,y,u),h[p]=A),u[g]=A}}return u})(new Uint8Array(l),0,0,{})]},findTable(l,t,i){const r=b,n=r.readUshort(l,i+4);let o=i+12;for(let h=0;h<n;h++){const a=r.readASCII(l,o,4);r.readUint(l,o+4);const u=r.readUint(l,o+8),f=r.readUint(l,o+12);if(a===t)return[u,f];o+=16}return null},T:ot,B:b};class Ht{ei(t){var r;const i=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(n=>{if(n.format===4){const o=this.ii(n);i.push(...o)}else if(n.format===12){const o=this.ri(n);i.push(...o)}}),[...new Set(i)]):[]}ni(t){return t.filter(i=>this.oi(i))}ii(t){const i=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return i;for(let r=0;r<t.startCount.length;r++){const n=t.startCount[r],o=t.endCount[r];if(n!==65535||o!==65535){for(let h=n;h<=o;h++)if(this.hi(t,h,r)>0)try{const a=String.fromCodePoint(h);i.push(a)}catch{}}}return i}ri(t){const i=[];if(!t.groups)return i;for(let r=0;r<t.groups.length;r+=3){const n=t.groups[r],o=t.groups[r+1],h=t.groups[r+2];for(let a=n;a<=o;a++)if(h+(a-n)>0)try{const u=String.fromCodePoint(a);i.push(u)}catch{}}return i}hi(t,i,r){if(t.idRangeOffset[r]===0)return i+t.idDelta[r]&65535;{const n=t.idRangeOffset[r]/2+(i-t.startCount[r])-(t.startCount.length-r);if(n>=0&&t.glyphIdArray&&n<t.glyphIdArray.length){const o=t.glyphIdArray[n];if(o!==0)return o+t.idDelta[r]&65535}}return 0}oi(t){const i=t.codePointAt(0)||0;return!(i>=0&&i<=31&&i!==9&&i!==10&&i!==13||i>=127&&i<=159)}}class et{constructor(){c(this,"ai",new Map);c(this,"ci",new Map)}li(t,i){const r=`${this.ui(t)}_${i}`;if(this.ai.has(r))return this.ai.get(r);const n=t.cmap;if(!n||!n.tables)return this.ai.set(r,0),0;let o=0;for(const h of n.tables)if(h.format===4?o=this.fi(i,h):h.format===12&&(o=this.di(i,h)),o>0)break;return this.ai.set(r,o),o}pi(t,i){const r=i.codePointAt(0);return r===void 0?0:this.li(t,r)}_i(t,i){const r=t.hmtx;return r&&r.aWidth&&r.aWidth.length!==0?i<r.aWidth.length?r.aWidth[i]:r.aWidth[r.aWidth.length-1]:0}mi(t,i){const r=i/t.head.unitsPerEm,n=t.hhea.ascender*r,o=t.hhea.descender*r,h=t.hhea.lineGap*r;return{ascender:n,descender:o,lineGap:h,lineHeight:n-o+h,unitsPerEm:t.head.unitsPerEm,scale:r}}gi(){this.ai.clear(),this.ci.clear()}ui(t){return`${t.ti}_${t.Je.length}`}fi(t,i){const r=i.endCount.length;let n=-1;for(let o=0;o<r;o++)if(t<=i.endCount[o]){n=o;break}if(n===-1||t<i.startCount[n])return 0;if(i.idRangeOffset[n]===0)return t+i.idDelta[n]&65535;{const o=i.idRangeOffset[n]/2+(t-i.startCount[n])-(r-n);if(o>=0&&o<i.glyphIdArray.length){const h=i.glyphIdArray[o];return h===0?0:h+i.idDelta[n]&65535}}return 0}di(t,i){const r=i.groups.length/3;for(let n=0;n<r;n++){const o=i.groups[3*n],h=i.groups[3*n+1],a=i.groups[3*n+2];if(t>=o&&t<=h)return a+(t-o)}return 0}}class Xt{constructor(t){c(this,"yi");c(this,"Ai");c(this,"xt");c(this,"Ci");this.xt=t,this.Ci=new et,this.yi=document.createElement("canvas"),this.Ai=this.yi.getContext("2d",{willReadFrequently:!0,alpha:!0})}createTextureAtlas(t,i,r,n){const o=t.length,h=Math.ceil(Math.sqrt(o)),a=Math.ceil(o/h),u=i.width*h,f=i.height*a,g=typeof n=="object"?n:null;this.wi(u,f),this.bi(t,i,h,r,g);const d=this.xt.Ye(u,f,1,{filter:"nearest"});return d.Tt(this.yi),{framebuffer:d,columns:h,rows:a}}wi(t,i){this.yi.width=t,this.yi.height=i,this.yi.style.width=t+"px",this.yi.style.height=i+"px",this.Ai.imageSmoothingEnabled=!1,this.yi.style.imageRendering="pixelated",this.Ai.clearRect(0,0,t,i),this.Ai.textBaseline="top",this.Ai.textAlign="left",this.Ai.fillStyle="white"}bi(t,i,r,n,o){const h=n/o.head.unitsPerEm;for(let a=0;a<t.length;a++){const u=a%r,f=Math.floor(a/r),g=t[a].character,d=this.xi(o,g);if(!d)continue;const p=g.codePointAt(0)||0,y=this.Ci.li(o,p),A=this.Mi(o,y)*h,m=u*i.width,x=f*i.height,v=m+.5*i.width,T=x+.5*i.height,E=Math.round(v-.5*i.width),O=Math.round(T-.5*n),U=E+.5*(i.width-A),P=O+o.hhea.ascender*h;this.Fi(d,U,P,h)}}xi(t,i){const r=i.codePointAt(0)||0,n=this.Ci.li(t,r);if(n===0)return null;if(t.glyf&&t.glyf[n]!==null)return t.glyf[n];if(D&&D.T&&D.T.glyf){const o=D.T.glyf.Qe(t,n);return t.glyf&&o&&(t.glyf[n]=o),o}return null}Mi(t,i){const r=t.hmtx;return r&&r.aWidth?i<r.aWidth.length?r.aWidth[i]:r.aWidth[r.aWidth.length-1]:0}Fi(t,i,r,n){if(!t||!t.xs||t.noc===0)return;const{xs:o,ys:h,endPts:a,flags:u}=t;if(!(o&&h&&a&&u))return;this.Ai.beginPath();let f=0;for(let g=0;g<a.length;g++){const d=a[g];if(!(d<f)){if(d>=f){const p=i+o[f]*n,y=r-h[f]*n;this.Ai.moveTo(p,y);let A=f+1;for(;A<=d;)if(1&u[A]){const m=i+o[A]*n,x=r-h[A]*n;this.Ai.lineTo(m,x),A++}else{const m=i+o[A]*n,x=r-h[A]*n;let v=A+1>d?f:A+1;if(1&u[v]){const T=i+o[v]*n,E=r-h[v]*n;this.Ai.quadraticCurveTo(m,x,T,E),A=v+1}else{const T=(m+(i+o[v]*n))/2,E=(x+(r-h[v]*n))/2;this.Ai.quadraticCurveTo(m,x,T,E),A=v}}this.Ai.closePath()}f=d+1}}this.Ai.fill()}}class Yt{constructor(){c(this,"zi");this.zi=new et}Ri(t,i,r){let n=0;const o=this.zi.mi(r,i),h=o.lineHeight;for(const a of t){const u=this.zi.pi(r,a);if(u===0)continue;const f=this.zi._i(r,u)*o.scale;n=Math.max(n,f)}return{width:Math.ceil(n),height:Math.ceil(h)}}gi(){this.zi.gi()}}class Wt{constructor(){c(this,"Ci");this.Ci=new et}createCharacterObjects(t,i){return t.map((r,n)=>{const o=r.codePointAt(0)||0,h=this.Ti(n);let a=0;if(i.hmtx&&i.hmtx.aWidth){const u=this.Ci.li(i,o);u>0&&i.hmtx.aWidth[u]!==void 0&&(a=i.hmtx.aWidth[u])}return{character:r,unicode:o,color:h,advanceWidth:a}})}Ti(t){return[t%256/255,Math.floor(t/256)%256/255,Math.floor(t/65536)%256/255]}Pi(t,i){if(!X.v(typeof t=="string","Character must be a string.",{method:"getCharacterColor",providedValue:t}))return[0,0,0];const r=i.find(n=>n.character===t);return r?r.color:[0,0,0]}Si(t,i){return X.v(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",providedValue:t})?Array.from(t).map(r=>this.Pi(r,i)||[0,0,0]):[[0,0,0]]}}class ht{constructor(t,i=16){c(this,"$i");c(this,"Ei",[]);c(this,"Di");c(this,"ki",16);c(this,"Bi",0);c(this,"Li",0);c(this,"Oi",{width:0,height:0});c(this,"Hi");c(this,"Gi",new Map);c(this,"Ii");c(this,"Ni");c(this,"Xi");c(this,"Wi");this.ki=i,this.Ii=new Ht,this.Ni=new Xt(t),this.Xi=new Yt,this.Wi=new Wt}async Ki(t){let i;if(t){const r=await fetch(t);if(!r.ok)throw new R(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}else i=await(await fetch("data:font/woff;base64,d09GRgABAAAAABbwAAoAAAAAfywAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABjbWFwAAAA9AAAAbsAAAkgIO8lSWdseWYAAAKwAAAOfgAAaLS4ctN0aGVhZAAAETAAAAAsAAAAOCi8/PVoaGVhAAARXAAAABkAAAAkCwEFAmhtdHgAABF4AAAAhQAABAQEAIOAbG9jYQAAEgAAAAKUAAAECAAy54BtYXhwAAAUlAAAABgAAAAgASIAgm5hbWUAABSsAAAB5wAAA6RWz85KT1MvMgAAFpQAAABFAAAAYM+QEyRwb3N0AAAW3AAAABQAAAAgAGkANHja7dRPSFRRFMfx38wdXblw4cJC7M0bz60gWlULGUFctWgR0UIQQkmDyn27kpAQaaEO2jhWJuafiQFtcDJtSqGhiFZtot5x3jzEVQQhlRJcOb0khiRc1+J94R64uw8cOADCAJT/avwZAiIpRCK3/P999KAS9biOSUxhBhlksYjnWMFrvME7vMca1vEF37ANAwkNqYRKqkk1rdLqscqpVVVQryzbils3rJnocHTWPmgfso/ap+0OuysWjlXHogQKUxVVUw3VUh010DE6QXHqph7qpT66TQmaoAxlaZnyVKC39FHHdbNu0e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vzz/xrywD21ScoLK9N3ktW5E3hDl6hL7zG7HvhLrMfhNfxGonwBjUnwj2uz8JbzH4R3sZbPArvIMV34T28wQ+6qG6Puz5+Civyb+EOO/4Ir6GvOsJdaLUrvI53KhXeoGYs3MOu+iq8hai+CW/jo/olvIOiA+E97HeKw/xIp8M0nYQ6O/MunpvZwmbhafv01JK/MKGee6ePB8N/JCFzN6dO+8o4bee5cbnRM+NMyKyuFqHytdHR3MXSF0ZfNQOn93rVORoNm4l64ua3NMjsdYxVfZIkeTBZZC73ZeldPfBhllSLKR0KX2ZzlzyY4BO2JmNjrdeXPtjiAIfIcQTNbz/knWKCgBoZzuDhEHEOgxkWsMyFF9Xne/1Mf8Fdo5i3dY1jDOjz/ymB0eEGp63ao2J/Q5YT8pabqOnQsGn1lvuKjoHRc05Tj4x3jCUzRZu5Wp1winvGl54jruHqjI3C0fVW3qDxuWZ/pEvNPzjhylkxrETR5fQoW09HzYDPwJMm7emm8g5Fq8nIjpWHdronLV0TjJmxXJ4nuGwnWPYcAH8BoeumrAB42mNgYmFgnMDAysDCxMDEAAIQGoiNGc6A+CwMENDAwNDNwFDwGMpliHT00WNwYFBQy4aogJCMgSCSGcJTYGAAAEBYBpIAAAB42mNgZoCANAZjIMnIgAYADecAng==")).arrayBuffer();await this.ji(i),this.$i=D.parse(i)[0],await this.Yi()}Vi(t){if(t===void 0)return this.ki;this.ki=t,this.Oi=this.Xi.Ri(this.Ei.map(r=>r.character),this.ki,this.$i);const i=this.Ni.createTextureAtlas(this.Ei,this.Oi,this.ki,this.$i);this.Di=i.framebuffer,this.Bi=i.columns,this.Li=i.rows}async qi(t){try{const i=await fetch(t);if(!i.ok)throw new R(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.ji(r);const n=D.parse(r);if(!n||n.length===0)throw Error("Failed to parse font file");this.$i=n[0],await this.Yi()}catch(i){throw new R("Failed to load font: "+(i instanceof Error?i.message:"Unknown error"),i)}}async ji(t){const i=Date.now();this.Hi=new FontFace("CustomFont_"+i,t),await this.Hi.load(),document.fonts.add(this.Hi)}async Yi(){const t=this.Ii.ei(this.$i),i=this.Ii.ni(t);this.Gi.clear(),this.Ei=this.Wi.createCharacterObjects(i,this.$i),this.Oi=this.Xi.Ri(i,this.ki,this.$i);const r=this.Ni.createTextureAtlas(this.Ei,this.Oi,this.ki,this.$i);this.Di=r.framebuffer,this.Bi=r.columns,this.Li=r.rows}Pi(t){return this.Wi.Pi(t,this.Ei)}Si(t){return this.Wi.Si(t,this.Ei)}getGlyphData(t){if(!Number.isFinite(t))return null;const i=this.Gi.get(t);if(i!==void 0)return i;const r=this.Zi(t);if(r<0)return this.Gi.set(t,null),null;const n=this.$i.glyf;if(!n)return this.Gi.set(t,null),null;let o=n[r]??null;return o==null&&(o=D.T.glyf.Qe(this.$i,r)??null,n[r]=o),this.Gi.set(t,o),o}Zi(t){const i=this.$i.cmap;for(const r of i.tables)if(r.format===4){const n=r;for(let o=0;o<n.startCount.length;o++)if(t>=n.startCount[o]&&t<=n.endCount[o]){if(n.idRangeOffset[o]===0)return t+n.idDelta[o]&65535;{const h=n.idRangeOffset[o]/2+(t-n.startCount[o])-(n.startCount.length-o);if(h>=0&&h<n.glyphIdArray.length){const a=n.glyphIdArray[h];if(a!==0)return a+n.idDelta[o]&65535}}}}else if(r.format===12){const n=r;for(let o=0;o<n.groups.length;o+=3){const h=n.groups[o],a=n.groups[o+1],u=n.groups[o+2];if(t>=h&&t<=a)return u+(t-h)}}return 0}Dt(){this.Di.Dt(),document.fonts.delete(this.Hi)}get fontFramebuffer(){return this.Di}get characters(){return this.Ei}get textureColumns(){return this.Bi}get textureRows(){return this.Li}get maxGlyphDimensions(){return this.Oi}get fontSize(){return this.ki}get font(){return this.$i}}class at{constructor(t,i,r){c(this,"Qi");c(this,"Ji");c(this,"dt");c(this,"_t");c(this,"tr");c(this,"sr");c(this,"er");c(this,"ir");c(this,"rr");this.er=t,this.ir=i,this.rr=r,this.nr()}nr(){this.Qi=Math.floor(this.er.width/this.ir),this.Ji=Math.floor(this.er.height/this.rr),this.dt=this.Qi*this.ir,this._t=this.Ji*this.rr,this.tr=Math.floor((this.er.width-this.dt)/2),this.sr=Math.floor((this.er.height-this._t)/2)}hr(t,i){this.ir=t,this.rr=i,this.nr()}get cellWidth(){return this.ir}get cellHeight(){return this.rr}get cols(){return this.Qi}get rows(){return this.Ji}get width(){return this.dt}get height(){return this._t}get offsetX(){return this.tr}get offsetY(){return this.sr}}class ct{constructor(t={}){c(this,"er");c(this,"ar",null);c(this,"cr",!1);c(this,"lr");c(this,"ur");this.cr=t.overlay??!1,this.cr&&t.canvas?(this.ar=t.canvas,this.er=this.dr(),this.ur=!0,this.pr()):t.canvas?(this.er=t.canvas,this.ur=!1):(this.er=this._r(t.width,t.height),this.ur=!0),this.er.style.imageRendering="pixelated"}_r(t,i){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=i||600,document.body.appendChild(r),r}dr(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.ar.getBoundingClientRect();let r=Math.round(i.width),n=Math.round(i.height);if(this.ar instanceof HTMLVideoElement){const a=this.ar;(r===0||n===0)&&a.videoWidth>0&&a.videoHeight>0&&(r=a.videoWidth,n=a.videoHeight)}t.width=r,t.height=n,t.style.position="absolute",t.style.pointerEvents="none";const o=window.getComputedStyle(this.ar);let h=parseInt(o.zIndex||"0",10);return isNaN(h)&&(h=0),t.style.zIndex=""+(h+1),t}pr(){var t;this.mr(),(t=this.ar.parentNode)==null||t.insertBefore(this.er,this.ar.nextSibling),window.ResizeObserver&&(this.lr=new ResizeObserver(()=>{this.vr()}),this.lr.observe(this.ar)),window.addEventListener("resize",()=>{this.vr()})}mr(){if(!this.ar)return;const t=this.ar.getBoundingClientRect();let i=this.ar.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.er.style.top=t.top-r.top+"px",this.er.style.left=t.left-r.left+"px"}else this.er.style.top=t.top+window.scrollY+"px",this.er.style.left=t.left+window.scrollX+"px"}vr(t,i){if(this.cr){const r=this.ar.getBoundingClientRect();let n=Math.round(r.width),o=Math.round(r.height);if(this.ar instanceof HTMLVideoElement){const h=this.ar;(n===0||o===0)&&h.videoWidth>0&&h.videoHeight>0&&(n=h.videoWidth,o=h.videoHeight)}this.er.width=n,this.er.height=o,this.mr()}else this.er.width=t??this.er.width,this.er.height=i??this.er.height}gr(){const t=this.er.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance"});if(!t)throw new R("`textmode.js` requires WebGL2 support.");return t}Dt(){this.lr&&this.lr.disconnect();const t=this.er.getContext("webgl")||this.er.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i&&i.loseContext()}this.ur&&this.er.parentNode&&this.er.parentNode.removeChild(this.er)}get canvas(){return this.er}get targetCanvas(){return this.ar}get width(){return this.er.width}get height(){return this.er.height}}class H{constructor(t,i,r,n){c(this,"yr");c(this,"dt");c(this,"_t");c(this,"gt");c(this,"k",0);c(this,"K",0);c(this,"j",0);c(this,"L",[0,0]);c(this,"Ar","sampled");c(this,"Cr","fixed");c(this,"V",[1,1,1,1]);c(this,"q",[0,0,0,1]);c(this,"wr",[0,0,0,1]);c(this,"br",[[.1,0,0]]);c(this,"Mr");this.gt=t,this.yr=i,this.dt=r,this._t=n}Dt(){this.gt.deleteTexture(this.yr)}Fr(t){return typeof t=="boolean"?t?1:0:(t==null?0:Number(t))>0?1:0}invert(t=!0){return this.k=this.Fr(t),this}flipX(t=!0){return this.K=this.Fr(t),this}flipY(t=!0){return this.j=this.Fr(t),this}charRotation(t){const i=255*t/360,r=Math.floor(i)/255,n=Math.round(i-Math.floor(i));return this.L=[r,n],this}Ge(){return{texture:this.yr,invert:this.k,flipX:this.K,flipY:this.j,charRotation:this.L,charColorFixed:this.Ar==="fixed",charColor:this.V,cellColorFixed:this.Cr==="fixed",cellColor:this.q,backgroundColor:this.wr,charCount:this.br.length,charList:this.br}}charColorMode(t){return this.Ar=t,this}cellColorMode(t){return this.Cr=t,this}charColor(t,i,r,n){return this.V=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}cellColor(t,i,r,n){return this.q=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}background(t,i,r,n){return this.wr=[(t??0)/255,(i??t??0)/255,(r??t??0)/255,(n??255)/255],this}characters(t){const i=this.Mr(t).filter(r=>Array.isArray(r)).slice(0,64);return this.br=i,this}static zr(t,i,r){const n=t.context,o=n.createTexture();n.bindTexture(n.TEXTURE_2D,o),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,1),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,i),n.bindTexture(n.TEXTURE_2D,null);const h=i.naturalWidth??i.width??i.videoWidth??0,a=i.naturalHeight??i.height??i.videoHeight??0,u=new H(n,o,h,a);return u.Mr=r,u}get texture(){return this.yr}get width(){return this.dt}get height(){return this._t}}class kt{constructor(t=60){c(this,"Rr");c(this,"Tr");c(this,"Pr",null);c(this,"Sr",0);c(this,"$r",!0);c(this,"Er",0);c(this,"Dr",0);c(this,"kr",[]);c(this,"Br",10);c(this,"Lr",0);this.Rr=t,this.Tr=1e3/t}start(t){if(!this.$r)return;this.Sr=performance.now();const i=r=>{if(!this.$r)return void(this.Pr=null);const n=r-this.Sr;n>=this.Tr&&(t(),this.Sr=r-n%this.Tr),this.$r&&(this.Pr=requestAnimationFrame(i))};this.Pr=requestAnimationFrame(i)}stop(){this.Pr&&(cancelAnimationFrame(this.Pr),this.Pr=null)}pause(){this.$r&&(this.$r=!1,this.stop())}resume(t){this.$r||(this.$r=!0,this.start(t))}frameRate(t,i){if(t===void 0)return this.Er;this.Rr=t,this.Tr=1e3/t,this.$r&&i&&(this.stop(),this.start(i))}measureFrameRate(){const t=performance.now();if(this.Dr>0){const i=t-this.Dr;this.kr.push(i),this.kr.length>this.Br&&this.kr.shift();const r=this.kr.reduce((n,o)=>n+o,0)/this.kr.length;this.Er=1e3/r}this.Dr=t}get isLooping(){return this.$r}get frameRateLimit(){return this.Rr}get currentFrameRate(){return this.Er}get frameCount(){return this.Lr}set frameCount(t){this.Lr=t}incrementFrame(){this.Lr++}resetFrameCount(){this.Lr=0}}class lt{constructor(t){c(this,"er");c(this,"Or");c(this,"Hr",{x:-1,y:-1});c(this,"Gr",{x:-1,y:-1});c(this,"Ir",null);c(this,"Nr",0);c(this,"Xr");c(this,"Wr");c(this,"Kr");c(this,"jr");c(this,"Yr");c(this,"Vr");c(this,"qr",!1);c(this,"Zr");c(this,"Qr");c(this,"Jr");c(this,"tn");c(this,"sn");this.er=t}en(t){const i=performance.now()+Math.max(0,t);i>this.Nr&&(this.Nr=i)}rn(){return performance.now()<this.Nr}nn(t){const i=this.er.canvas;i.style.cursor=t==null||t===""?"":t}Ki(t){this.Or=t,this.hn()}an(){if(this.qr)return;const t=this.er.canvas;this.Xr=i=>{this.cn(i),this.ln(i)},this.Wr=()=>{this.Gr={...this.Hr},this.Hr.x=-1,this.Hr.y=-1,this.Ir=null},this.Kr=i=>{this.cn(i),this.un(i)},this.jr=i=>{this.cn(i),this.fn(i)},this.Yr=i=>{this.cn(i),this.dn(i)},this.Vr=i=>{this.cn(i),this.pn(i)},t.addEventListener("mousemove",this.Xr,{passive:!0}),t.addEventListener("mouseleave",this.Wr,{passive:!0}),t.addEventListener("mousedown",this.Kr,{passive:!0}),t.addEventListener("mouseup",this.jr,{passive:!0}),t.addEventListener("click",this.Yr,{passive:!0}),t.addEventListener("wheel",this.Vr,{passive:!1}),this.qr=!0}_n(){if(!this.qr)return;const t=this.er.canvas;t.removeEventListener("mousemove",this.Xr),t.removeEventListener("mouseleave",this.Wr),t.removeEventListener("mousedown",this.Kr),t.removeEventListener("mouseup",this.jr),t.removeEventListener("click",this.Yr),t.removeEventListener("wheel",this.Vr),this.qr=!1}hn(){if(this.qr)try{if(this.Ir){const t=new MouseEvent("mousemove",{clientX:this.Ir.x,clientY:this.Ir.y,bubbles:!1,cancelable:!1});this.cn(t)}else this.Hr.x!==-1&&this.Hr.y!==-1&&(this.Hr.x>=this.Or.cols||this.Hr.y>=this.Or.rows)&&(this.Hr.x=-1,this.Hr.y=-1)}catch{this.Hr.x=-1,this.Hr.y=-1}}mn(t){this.Zr=t}vn(t){this.Qr=t}gn(t){this.Jr=t}yn(t){this.tn=t}An(t){this.sn=t}Cn(){return{x:this.Hr.x,y:this.Hr.y}}ln(t){if(this.tn&&!this.rn()){const i={position:{...this.Hr},previousPosition:{...this.Gr},originalEvent:t};this.tn(i)}}un(t){if(this.Qr&&!this.rn()){const i={position:{...this.Hr},previousPosition:{...this.Gr},button:t.button,originalEvent:t};this.Qr(i)}}fn(t){if(this.Jr&&!this.rn()){const i={position:{...this.Hr},previousPosition:{...this.Gr},button:t.button,originalEvent:t};this.Jr(i)}}dn(t){if(this.Zr&&!this.rn()){const i={position:{...this.Hr},previousPosition:{...this.Gr},button:t.button,originalEvent:t};this.Zr(i)}}pn(t){if(this.sn&&!this.rn()){const i={position:{...this.Hr},previousPosition:{...this.Gr},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.sn(i)}}cn(t){const i=this.er.canvas;this.Gr={...this.Hr},this.Ir={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),n=t.clientX-r.left,o=t.clientY-r.top,h=i.width/r.width,a=o*(i.height/r.height),u=n*h-this.Or.offsetX,f=a-this.Or.offsetY,g=Math.floor(u/this.Or.cellWidth),d=Math.floor(f/this.Or.cellHeight);g>=0&&g<this.Or.cols&&d>=0&&d<this.Or.rows?(this.Hr.x=g,this.Hr.y=d):(this.Hr.x=-1,this.Hr.y=-1)}}const Vt=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:lt},Symbol.toStringTag,{value:"Module"}));class ut{constructor(){c(this,"wn",new Map);c(this,"bn",null);c(this,"xn",null);c(this,"Mn");c(this,"Fn");c(this,"qr",!1);c(this,"zn");c(this,"Rn");c(this,"Tn",{ArrowUp:"UP_ARROW",ArrowDown:"DOWN_ARROW",ArrowLeft:"LEFT_ARROW",ArrowRight:"RIGHT_ARROW",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",Enter:"ENTER",Return:"RETURN",Tab:"TAB",Escape:"ESCAPE",Backspace:"BACKSPACE",Delete:"DELETE",Insert:"INSERT",Home:"HOME",End:"END",PageUp:"PAGE_UP",PageDown:"PAGE_DOWN",Shift:"SHIFT",Control:"CONTROL",Alt:"ALT",Meta:"META"," ":"SPACE"})}an(){this.qr||(this.Mn=t=>{this.Pn(t)},this.Fn=t=>{this.Sn(t)},window.addEventListener("keydown",this.Mn,{passive:!1}),window.addEventListener("keyup",this.Fn,{passive:!1}),this.qr=!0)}_n(){this.qr&&(window.removeEventListener("keydown",this.Mn),window.removeEventListener("keyup",this.Fn),this.qr=!1,this.wn.clear(),this.bn=null,this.xn=null)}vn(t){this.zn=t}gn(t){this.Rn=t}$n(t){const i=this.En(t),r=this.wn.get(t)||this.wn.get(i);return(r==null?void 0:r.isPressed)||!1}Dn(){return this.bn}kn(){return this.xn}Bn(){const t=[];for(const[i,r]of this.wn)r.isPressed&&t.push(i);return t}Ln(){return{ctrl:this.$n("Control"),shift:this.$n("Shift"),alt:this.$n("Alt"),meta:this.$n("Meta")}}On(){this.wn.clear(),this.bn=null,this.xn=null}Pn(t){const i=t.key,r=Date.now();this.wn.has(i)||this.wn.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.wn.get(i);if(!n.isPressed&&(n.isPressed=!0,n.lastPressTime=r,this.bn=i,this.zn)){const o={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.zn(o)}}Sn(t){const i=t.key,r=Date.now();this.wn.has(i)||this.wn.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const n=this.wn.get(i);if(n.isPressed=!1,n.lastReleaseTime=r,this.xn=i,this.Rn){const o={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.Rn(o)}}En(t){return this.Tn[t]||t.toLowerCase()}}const qt=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:ut},Symbol.toStringTag,{value:"Module"}));class ft{constructor(t,i){c(this,"er");c(this,"Hn");c(this,"Or");c(this,"Gn",new Map);c(this,"In",new Map);c(this,"Nn",new Map);c(this,"Xn",null);c(this,"Wn");c(this,"Kn");c(this,"jn");c(this,"Yn");c(this,"Vn");c(this,"qn");c(this,"qr",!1);c(this,"Zn");c(this,"Qn");c(this,"Jn");c(this,"so");c(this,"eo");c(this,"io");c(this,"ro");c(this,"no");c(this,"oo");c(this,"ho");c(this,"ao",320);c(this,"co",350);c(this,"lo",10);c(this,"uo",550);c(this,"fo",14);c(this,"do",48);c(this,"po",650);c(this,"_o",.02);c(this,"mo",2);c(this,"vo",600);c(this,"yo",0);c(this,"Ao",null);this.er=t,this.Hn=i;const r=this.er.canvas;this.Wn=r.style.touchAction,this.Kn=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}Ki(t){this.Or=t,this.Co()}an(){if(this.qr)return;const t=this.er.canvas;this.jn=i=>{this.wo(i)},this.Yn=i=>{this.bo(i)},this.Vn=i=>{this.xo(i)},this.qn=i=>{this.Mo(i)},t.addEventListener("touchstart",this.jn,{passive:!1}),t.addEventListener("touchmove",this.Yn,{passive:!1}),t.addEventListener("touchend",this.Vn,{passive:!1}),t.addEventListener("touchcancel",this.qn,{passive:!1}),this.qr=!0}_n(){if(!this.qr)return;const t=this.er.canvas;t.removeEventListener("touchstart",this.jn),t.removeEventListener("touchmove",this.Yn),t.removeEventListener("touchend",this.Vn),t.removeEventListener("touchcancel",this.qn),this.qr=!1,this.Xn=null,this.Gn.clear(),this.In.clear(),this.Nn.forEach(i=>{i.longPressTimer!==null&&window.clearTimeout(i.longPressTimer)}),this.Nn.clear(),this.Ao=null,this.yo=0,t.style.touchAction=this.Wn,t.style.userSelect=this.Kn}Co(){if(!this.Or||this.Gn.size===0)return;const t=new Map;for(const i of this.Gn.values()){const r=this.Fo(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Gn=t}zo(){return Array.from(this.Gn.values()).map(t=>({...t}))}Ro(t){this.Zn=t}yn(t){this.Qn=t}To(t){this.Jn=t}Po(t){this.so=t}So(t){this.eo=t}$o(t){this.io=t}Eo(t){this.ro=t}Do(t){this.no=t}ko(t){this.oo=t}Bo(t){this.ho=t}wo(t){var n;if(!this.Or)return;t.preventDefault(),(n=this.Hn)==null||n.en(this.vo);const i=performance.now(),r=this.Lo(t.changedTouches);for(const o of r){const h=this.Gn.get(o.id);h&&this.In.set(o.id,this.Oo(h)),this.Gn.set(o.id,o);const a={id:o.id,startPosition:o,lastPosition:o,startTime:i,lastTime:i,longPressTimer:null,longPressFired:!1};this.ro&&(a.longPressTimer=window.setTimeout(()=>{const u=this.Gn.get(o.id);u&&(a.longPressFired=!0,this.ro({touch:this.Oo(u),duration:performance.now()-a.startTime,originalEvent:t}))},this.uo)),this.Nn.set(o.id,a),this.Zn&&this.Zn(this.Ho(o,t,void 0,i))}this.Gn.size===2&&this.Go()}bo(t){var n;if(!this.Or)return;t.preventDefault(),(n=this.Hn)==null||n.en(this.vo);const i=performance.now(),r=this.Lo(t.changedTouches);for(const o of r){const h=this.Gn.get(o.id),a=h?this.Oo(h):void 0;a&&this.In.set(o.id,a),this.Gn.set(o.id,o);const u=this.Nn.get(o.id);u&&(u.lastPosition=o,u.lastTime=i,a)&&this.Io(a,o,!0)>this.fo&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.Qn&&this.Qn(this.Ho(o,t,a,i))}this.Gn.size===2?this.No(t):this.Xn=null}xo(t){if(!this.Or)return;t.preventDefault();const i=performance.now(),r=this.Lo(t.changedTouches);for(const n of r){const o=this.Gn.get(n.id),h=o?this.Oo(o):void 0,a=this.Nn.get(n.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.Jn&&this.Jn(this.Ho(n,t,h,i)),a&&this.Xo(a,t),this.Nn.delete(n.id),this.In.delete(n.id),this.Gn.delete(n.id)}this.Gn.size<2&&(this.Xn=null)}Mo(t){if(!this.Or)return;t.preventDefault();const i=performance.now(),r=this.Lo(t.changedTouches);for(const n of r){const o=this.Gn.get(n.id),h=o?this.Oo(o):void 0,a=this.Nn.get(n.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.so&&this.so(this.Ho(n,t,h,i)),this.Nn.delete(n.id),this.In.delete(n.id),this.Gn.delete(n.id)}this.Gn.size<2&&(this.Xn=null)}Lo(t){const i=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&i.push(this.Wo(n))}return i}Wo(t){return this.Fo(t.clientX,t.clientY,t.identifier,{id:t.identifier,x:-1,y:-1,clientX:t.clientX,clientY:t.clientY,pressure:t.force,radiusX:t.radiusX,radiusY:t.radiusY,rotationAngle:t.rotationAngle})}Fo(t,i,r,n){const o=this.er.canvas,h=o.getBoundingClientRect(),a=t-h.left,u=i-h.top,f=o.width/h.width,g=u*(o.height/h.height),d=a*f-this.Or.offsetX,p=g-this.Or.offsetY,y=Math.floor(d/this.Or.cellWidth),A=Math.floor(p/this.Or.cellHeight),m=y>=0&&y<this.Or.cols&&A>=0&&A<this.Or.rows;return{id:r,x:m?y:-1,y:m?A:-1,clientX:t,clientY:i,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Ho(t,i,r,n){const o=this.Nn.get(t.id),h=Array.from(this.In.values()).map(f=>this.Oo(f)),a=Array.from(this.Gn.values()).map(f=>this.Oo(f)),u=this.Lo(i.changedTouches);return{touch:this.Oo(t),previousTouch:r?this.Oo(r):void 0,touches:a,previousTouches:h,changedTouches:u,deltaTime:o?n-o.lastTime:0,originalEvent:i}}Go(){if(this.Gn.size!==2)return void(this.Xn=null);const t=Array.from(this.Gn.values()),[i,r]=t,n=this.Io(i,r,!1),o=this.Ko(i,r);this.Xn={ids:[i.id,r.id],initialDistance:Math.max(n,1e-4),initialAngle:o,lastScale:1,lastRotation:0}}No(t){if(this.Xn||this.Go(),!this.Xn)return;const[i,r]=this.Xn.ids,n=this.Gn.get(i),o=this.Gn.get(r);if(!n||!o)return;const h=this.Io(n,o,!1)/this.Xn.initialDistance,a=h-this.Xn.lastScale;this.oo&&Math.abs(a)>this._o&&(this.oo({touches:[this.Oo(n),this.Oo(o)],scale:h,deltaScale:a,center:this.jo(n,o),originalEvent:t}),this.Xn.lastScale=h);let u=this.Ko(n,o)-this.Xn.initialAngle;u=(u+180)%360-180;const f=u-this.Xn.lastRotation;this.ho&&Math.abs(f)>this.mo&&(this.ho({touches:[this.Oo(n),this.Oo(o)],rotation:u,deltaRotation:f,center:this.jo(n,o),originalEvent:t}),this.Xn.lastRotation=u)}jo(t,i){const r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,o=this.Fo(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:o.x,y:o.y}}Xo(t,i){const r=performance.now(),n=r-t.startTime,o=this.Io(t.startPosition,t.lastPosition,!0);if(!t.longPressFired&&n<=this.ao&&o<=this.lo)this.Yo(t.lastPosition,r)&&this.io?this.io({touch:this.Oo(t.lastPosition),taps:2,originalEvent:i}):this.eo&&this.eo({touch:this.Oo(t.lastPosition),taps:1,originalEvent:i});else if(!t.longPressFired&&n<=this.po&&o>=this.do){const h={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},a=Math.max(Math.hypot(h.x,h.y),1e-4),u={x:h.x/a,y:h.y/a},f={x:h.x/n,y:h.y/n};this.no&&this.no({touch:this.Oo(t.lastPosition),direction:u,distance:a,velocity:f,originalEvent:i})}this.yo=r,this.Ao=this.Oo(t.lastPosition)}Yo(t,i){return!!this.Ao&&!(i-this.yo>this.co)&&this.Io(t,this.Ao,!0)<=this.lo}Oo(t){return{...t}}Io(t,i,r){return r?Math.hypot(t.clientX-i.clientX,t.clientY-i.clientY):Math.hypot(t.x-i.x,t.y-i.y)}Ko(t,i){return 180*Math.atan2(i.clientY-t.clientY,i.clientX-t.clientX)/Math.PI}}const Kt=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:ft},Symbol.toStringTag,{value:"Module"})),jt=l=>class extends l{rotate(t=0,i=0,r=0){this.xt.state.st(t),this.xt.state.et(i),this.xt.state.it(r)}rotateX(t){this.xt.state.st(t)}rotateY(t){this.xt.state.et(t)}rotateZ(t){this.xt.state.it(t)}push(){this.xt.state.G()}pop(){this.xt.state.Z()}rect(t,i,r=1,n=1){this.xt.Ne(t,i,r,n)}point(t,i){this.xt.Ne(t,i,1,1)}line(t,i,r,n){this.xt.Xe(t,i,r,n)}lineWeight(t){this.xt.state.tt(t)}background(t,i=t,r=t,n=255){this.xt.qe(t,i,r,n)}char(t){this.xt.state.rt(this.$i.Pi(t))}charColor(t,i,r,n=255){this.xt.state.nt(t,i,r,n)}cellColor(t,i,r,n=255){this.xt.state.ot(t,i,r,n)}flipX(t){this.xt.state.ht(t)}flipY(t){this.xt.state.ct(t)}charRotation(t){this.xt.state.ut(t)}invert(t){this.xt.state.lt(t)}clear(){this.xt.qe(0,0,0,0)}ellipse(t,i,r,n){this.xt.We(t,i,r/2,n/2)}triangle(t,i,r,n,o,h){this.xt.Ke(t,i,r,n,o,h)}bezierCurve(t,i,r,n,o,h,a,u){this.xt.je(t,i,r,n,o,h,a,u)}arc(t,i,r,n,o,h){this.xt.Ve(t,i,r,n,o,h)}shader(t){this.xt.Be(t)}setUniform(t,i){this.xt.Kt(t,i)}setUniforms(t){this.xt.Le(t)}createFilterShader(t){return this.xt.hs(t)}createFramebuffer(t){return this.xt.Ye(t.width,t.height,5,{filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte"})}image(t,i,r,n,o){if(t.textures){const h=t;this.xt.Oe(h,i,r,n??h.width,o??h.height)}else{const h=t;this.xt.He(h,i,r,n??Math.floor(this.Or.cols/2),o??Math.floor(this.Or.rows/2))}}async loadImage(t){if(typeof t!="string")return H.zr(this.xt,t,n=>this.$i.Si(n));const i=t,r=await new Promise((n,o)=>{const h=new Image;h.crossOrigin="anonymous",h.onload=()=>n(h),h.onerror=a=>o(a),h.src=i});return H.zr(this.xt,r,n=>this.$i.Si(n))}},Zt=l=>class extends l{async loadFont(t){return this.$i.qi(t).then(()=>{const i=this.$i.maxGlyphDimensions;this.Or.hr(i.width,i.height),this.Vo.resize(this.Or.cols,this.Or.rows),this.xt.Ze(),this.Hn.hn()})}fontSize(t){if(!X.v(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.$i.fontSize===t)return;this.$i.Vi(t);const i=this.$i.maxGlyphDimensions;this.Or.hr(i.width,i.height),this.Vo.resize(this.Or.cols,this.Or.rows),this.xt.Ze(),this.Hn.hn()}glyphColor(t){return this.$i.Pi(t)}glyphColors(t){return this.$i.Si(t)}},Qt=l=>class extends l{get frameCount(){return this.qo.frameCount}set frameCount(t){this.qo.frameCount=t}frameRate(t){return t===void 0?this.qo.currentFrameRate:this.qo.frameRate(t,()=>this.Zo())}noLoop(){this.qo.pause()}loop(){this.qo.resume(()=>this.Zo())}redraw(t=1){if(X.v(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",providedValue:t}))for(let i=0;i<t;i++)this.Zo()}isLooping(){return this.qo.isLooping}},Jt=l=>class extends l{constructor(...t){super(...t)}mouseClicked(t){this.Hn.mn(t)}mousePressed(t){this.Hn.vn(t)}mouseReleased(t){this.Hn.gn(t)}mouseMoved(t){this.Hn.yn(t)}mouseScrolled(t){this.Hn.An(t)}get mouse(){return this.Hn.Cn()}cursor(t){this.Hn.nn(t)}},$t=l=>class extends l{constructor(...t){super(...t)}touchStarted(t){this.Qo.Ro(t)}touchMoved(t){this.Qo.yn(t)}touchEnded(t){this.Qo.To(t)}touchCancelled(t){this.Qo.Po(t)}tap(t){this.Qo.So(t)}doubleTap(t){this.Qo.$o(t)}longPress(t){this.Qo.Eo(t)}swipe(t){this.Qo.Do(t)}pinch(t){this.Qo.ko(t)}rotateGesture(t){this.Qo.Bo(t)}get touches(){return this.Qo.zo()}},te=l=>class extends l{constructor(...t){super(...t)}keyPressed(t){this.Jo.vn(t)}keyReleased(t){this.Jo.gn(t)}isKeyPressed(t){return this.Jo.$n(t)}get lastKeyPressed(){return this.Jo.Dn()}get lastKeyReleased(){return this.Jo.kn()}get pressedKeys(){return this.Jo.Bn()}get modifierState(){return this.Jo.Ln()}};class ee{constructor(t){c(this,"th");c(this,"sh",new Map);c(this,"eh",[]);c(this,"ih",new Map);c(this,"rh",new Map);this.th=t}async nh(t){for(const i of t){if(this.sh.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.oh(i.name);try{await i.install(this.th,r)}catch(n){throw this.hh(i.name),n}this.sh.set(i.name,i),this.eh.push(i.name)}}async ah(t){const i=this.sh.get(t);if(!i)return;const r=this.oh(t);if(i.uninstall)try{await i.uninstall(this.th,r)}catch(n){console.error(`[textmode.js] Error while uninstalling plugin "${t}":`,n)}this.sh.delete(t),this.eh.splice(this.eh.indexOf(t),1),this.hh(t)}runPreDrawHooks(){this.uh(this.ih,"preDraw")}runPostDrawHooks(){this.uh(this.rh,"postDraw")}async fh(){const t=[...this.sh.keys()];for(const i of t)await this.ah(i)}oh(t){return{...this.th.dh(),registerPreDrawHook:i=>this.ph(this.ih,t,i),registerPostDrawHook:i=>this.ph(this.rh,t,i)}}ph(t,i,r){const n=t.get(i)??new Set;return n.add(r),t.set(i,n),()=>{const o=t.get(i);o&&(o.delete(r),o.size===0&&t.delete(i))}}hh(t){this.ih.delete(t),this.rh.delete(t)}uh(t,i){for(const r of this.eh){const n=t.get(r);if(n)for(const o of n)try{o()}catch(h){console.error(`[textmode.js] Plugin "${r}" ${i} hook failed:`,h)}}}}class ie{constructor(){c(this,"xt");c(this,"$i");c(this,"er");c(this,"Or");c(this,"qo");c(this,"Hn");c(this,"Qo");c(this,"Jo");c(this,"_h");c(this,"Vo");c(this,"mh");c(this,"gh");c(this,"yh")}Zo(){}}class dt extends function(i,...r){return r.reduce((n,o)=>o(n),i)}(ie,jt,Zt,Qt,Jt,$t,te){constructor(i={}){super();c(this,"Ah");c(this,"Ch",!1);c(this,"wh",()=>{});c(this,"bh",()=>{});c(this,"xh",()=>{});c(this,"Mh");c(this,"lr");c(this,"cr",!1);c(this,"Fh");this.Ah=new ee(this),this.cr=i.overlay??!1,this.er=new ct(i),this.xt=new Lt(this.er.gr()),this.$i=new ht(this.xt,i.fontSize??16),this.qo=new kt(i.frameRate??60),this.Hn=new lt(this.er),this.Qo=new ft(this.er,this.Hn),this.Jo=new ut,this._h=this.xt.Pt(),this.mh=this.xt.rs(),this.zh(i)}async zh(i){await this.$i.Ki(i.fontSource);const r=this.$i.maxGlyphDimensions;this.Or=new at(this.er.canvas,r.width,r.height),this.Hn.Ki(this.Or),this.Qo.Ki(this.Or),this.Vo=this.xt.Ye(this.Or.cols,this.Or.rows,5),this.gh=this.xt.Ye(this.Or.width,this.Or.height,1),this.cr&&(this.Fh=H.zr(this.xt,this.er.targetCanvas,n=>this.$i.Si(n))),this.yh=this.xt.cs(rt,"precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"),this.Rh(),await this.Ah.nh(i.plugins??[]),this.wh(),this.qo.start(()=>this.Zo())}dh(){return{renderer:this.xt,font:this.$i,grid:this.Or,canvas:this.er,drawFramebuffer:this.Vo,asciiFramebuffer:this.gh,flushDrawCommands:()=>{this.xt.St(this._h)}}}Rh(){this.Mh=()=>{this.cr&&this.resizeCanvas(this.er.targetCanvas.width,this.er.targetCanvas.height),this.xh()},window.addEventListener("resize",this.Mh),this.Hn.an(),this.Qo.an(),this.Jo.an(),window.addEventListener("blur",()=>{this.Jo.On()}),window.ResizeObserver&&this.cr&&(this.lr=new ResizeObserver(()=>{this.resizeCanvas(this.er.targetCanvas.width,this.er.targetCanvas.height)}),this.lr.observe(this.er.targetCanvas))}Zo(){if(this.qo.measureFrameRate(),this.qo.incrementFrame(),this.Ch)return;if(this.cr){const r=this.xt.context;r.bindTexture(r.TEXTURE_2D,this.Fh.texture),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.er.targetCanvas),r.bindTexture(r.TEXTURE_2D,null)}this.Ah.runPreDrawHooks(),this.Vo.begin(),this.xt.ke(this._h),this.bh(),this.xt.St(this._h),this.Vo.end(),this.gh.begin(),this.xt.ke(this.mh),this.mh.Wt({U0:this.$i.fontFramebuffer,U1:[this.$i.textureColumns,this.$i.textureRows],U2:this.Vo.textures[0],U3:this.Vo.textures[1],U4:this.Vo.textures[2],U5:this.Vo.textures[4],U6:this.Vo.textures[3],U7:[this.Or.cols,this.Or.rows],U8:[this.gh.width,this.gh.height],U9:this.gh.width/this.gh.height}),this.xt.Ie(0,0,this.er.width,this.er.height),this.gh.end();const i=this.xt.state.canvasBackgroundColor;this.xt.Ys(i[0],i[1],i[2],i[3]),this.xt.ke(this.yh),this.yh.Wt({Ua:this.gh.textures[0],Ub:[this.gh.width,this.gh.height],Uc:[this.Or.offsetX,this.Or.offsetY],Ud:[this.Or.width,this.Or.height]}),this.xt.Ie(this.Or.offsetX,this.Or.offsetY,this.Or.width,this.Or.height),this.Ah.runPostDrawHooks()}setup(i){this.wh=i}draw(i){this.bh=i}windowResized(i){this.xh=i}resizeCanvas(i,r){this.er.vr(i,r),this.Or.nr(),this.Vo.resize(this.Or.cols,this.Or.rows),this.gh.resize(this.Or.width,this.Or.height),this.xt.Ze(),this.Hn.hn(),this.Qo.Co(),this.Zo()}destroy(){this.Ch||(this.qo.stop(),this.Ah.fh().catch(i=>{console.error("[textmode.js] Error while disposing plugins:",i)}),window.removeEventListener("resize",this.Mh),this.Hn._n(),this.Qo._n(),this.Jo._n(),this.$i.Dt(),this.xt.Dt(),this.gh.Dt(),this.yh.Dt(),this.Fh&&this.Fh.Dt(),this.Ch=!0)}get grid(){return this.Or}get font(){return this.$i}get width(){return this.er.width}get height(){return this.er.height}get canvas(){return this.er.canvas}get drawFramebuffer(){return this.Vo}get isDisposed(){return this.Ch}get overlay(){return this.Fh}}class Q{constructor(){}static create(t={}){return new dt(t)}static setErrorLevel(t){X.A(t)}static get version(){return"0.4.0"}}const se=Object.freeze(Object.defineProperty({__proto__:null,keyboard:qt,mouse:Vt,touch:Kt},Symbol.toStringTag,{value:"Module"})),re=Q.create,ne=Q.setErrorLevel,oe=Q.version;C.TextmodeCanvas=ct,C.TextmodeErrorLevel=S,C.TextmodeFont=ht,C.TextmodeFramebuffer=q,C.TextmodeGrid=at,C.TextmodeImage=H,C.Textmodifier=dt,C.create=re,C.input=se,C.setErrorLevel=ne,C.textmode=Q,C.version=oe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):e((s=typeof globalThis<"u"?globalThis:s||self).textmode={});
|
|
7
|
+
`}static i(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(i=>R.i(i)).join(", ")}]`:`[${t.slice(0,3).map(i=>R.i(i)).join(", ")}, ... +${t.length-3} more]`;if(typeof t=="object"){const i=Object.keys(t);return i.length===0?"{}":i.length<=3?`{ ${i.map(r=>`${r}: ${R.i(t[r])}`).join(", ")} }`:`{ ${i.slice(0,2).map(r=>`${r}: ${R.i(t[r])}`).join(", ")}, ... +${i.length-2} more }`}return String(t)}}var z=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(z||{});const S=class S{constructor(){l(this,"h",{l:3})}static u(){return S.o||(S.o=new S),S.o}p(t,i){const r="%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.",h="color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";switch(this.h.l){case 0:return!1;case 1:return console.group(r,h),console.warn(R.t(t,i)),console.groupEnd(),!1;case 2:return console.group(r,h),console.error(R.t(t,i)),console.groupEnd(),!1;default:throw new R(t,i)}}v(t,i,r){return!!t||(this.p(i,r),!1)}m(t){this.h.l=t}};l(S,"o",null);let ft=S;const W=ft.u();class Z{constructor(t,i,r){l(this,"A");l(this,"_");l(this,"C",new Map);l(this,"M",new Map);l(this,"F",0);this.A=t,this._=this.T(i,r),this.U()}U(){const t=this.A.getProgramParameter(this._,this.A.ACTIVE_UNIFORMS);for(let i=0;i<t;i++){const r=this.A.getActiveUniform(this._,i);if(r){const h=r.name.replace(/\[0\]$/,""),n=this.A.getUniformLocation(this._,h);n&&(this.C.set(h,n),this.M.set(h,{type:r.type,size:r.size}))}}}T(t,i){const r=this.P(this.A.VERTEX_SHADER,t),h=this.P(this.A.FRAGMENT_SHADER,i),n=this.A.createProgram();if(this.A.attachShader(n,r),this.A.attachShader(n,h),this.A.linkProgram(n),!this.A.getProgramParameter(n,this.A.LINK_STATUS)){const a=this.A.getProgramInfoLog(n);throw new Error(`Shader program link error: ${a}`)}return this.A.deleteShader(r),this.A.deleteShader(h),n}P(t,i){const r=this.A.createShader(t);if(this.A.shaderSource(r,i),this.A.compileShader(r),!this.A.getShaderParameter(r,this.A.COMPILE_STATUS)){const h=this.A.getShaderInfoLog(r);throw this.A.deleteShader(r),new Error(`Shader compilation error: ${h}`)}return r}R(){this.A.useProgram(this._),this.$()}$(){this.F=0}S(t){for(const i in t)this.k(i,t[i])}k(t,i){var u,d;const r=this.C.get(t);if(!r)return;const h=this.M.get(t);if(!h)return;const{type:n,size:a}=h,c=this.A;if(i instanceof WebGLTexture){const f=this.F++;return c.uniform1i(r,f),c.activeTexture(c.TEXTURE0+f),void c.bindTexture(c.TEXTURE_2D,i)}if(i instanceof Q){const f=this.F++;return c.uniform1i(r,f),c.activeTexture(c.TEXTURE0+f),void c.bindTexture(c.TEXTURE_2D,i.I[0])}if(typeof i!="number")if(typeof i!="boolean")if(Array.isArray(i[0])){const f=i.flat(),p={[c.FLOAT_VEC2]:()=>c.uniform2fv(r,f),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,f),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,f)};(u=p[n])==null||u.call(p)}else{const f=i,p={[c.FLOAT]:()=>a>1?c.uniform1fv(r,f):c.uniform1f(r,f[0]),[c.FLOAT_VEC2]:()=>c.uniform2fv(r,f),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,f),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,f),[c.INT]:()=>a>1?c.uniform1iv(r,f):c.uniform1i(r,f[0]),[c.INT_VEC2]:()=>c.uniform2iv(r,f),[c.INT_VEC3]:()=>c.uniform3iv(r,f),[c.INT_VEC4]:()=>c.uniform4iv(r,f),[c.BOOL]:()=>c.uniform1iv(r,f),[c.FLOAT_MAT2]:()=>c.uniformMatrix2fv(r,!1,f),[c.FLOAT_MAT3]:()=>c.uniformMatrix3fv(r,!1,f),[c.FLOAT_MAT4]:()=>c.uniformMatrix4fv(r,!1,f)};(d=p[n])==null||d.call(p)}else c.uniform1i(r,i?1:0);else n===c.INT||n===c.BOOL?c.uniform1i(r,i):c.uniform1f(r,i)}get O(){return this._}D(){this.A.deleteProgram(this._)}}function xt(o,t,i,r){return 180*Math.atan2(r-t,i-o)/Math.PI}function q(o,t,i,r){return Math.hypot(i-o,r-t)}function bt(o){return(o%360+360)%360/360}function Ft(o,t,i){o.bindTexture(o.TEXTURE_2D,t),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,i),o.bindTexture(o.TEXTURE_2D,null)}function et(o,t,i,r,h){o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,h)}function dt(o,t,i,r,h,n=0,a=WebGL2RenderingContext.FLOAT,c=!1){o.enableVertexAttribArray(t),o.vertexAttribPointer(t,i,a,c,r,h),o.vertexAttribDivisor(t,n)}function Rt(o,t,i,r,h){o.bindBuffer(t,i),o.bufferData(t,r,h),o.bindBuffer(t,null)}const st=`#version 300 es
|
|
8
|
+
in vec2 A0;in vec2 A1;in vec2 A2;in vec2 A3;in vec3 A4;in vec4 A5;in vec4 A6;in vec4 A7;in vec3 A8;in vec3 A9;in vec4 Aa;in vec4 Ab;in vec3 Ac;uniform vec2 Ut;uniform float Uu;uniform float Uv;out vec2 v_uv;out vec3 v_glyphIndex;out vec4 v_glyphColor;out vec4 v_cellColor;out vec4 v_glyphFlags;out vec3 v_worldPosition;out vec3 v_normal;out float v_geometryType;const float A=6.28318530718f;const int B=2;const int C=3;const int D=4;vec2 E(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float M=L*K;float N=F*F;float O=N*F;return M*G+3.0f*L*F*H+3.0f*K*N*I+O*J;}vec2 P(float F,vec2 G,vec2 H,vec2 I,vec2 J){float K=1.0f-F;float L=K*K;float N=F*F;return-3.0f*L*G+3.0f*(L-2.0f*K*F)*H+3.0f*(2.0f*K*F-N)*I+3.0f*N*J;}vec3 Q(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x,R.y*T-R.z*U,R.y*U+R.z*T);}vec3 V(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T+R.z*U,R.y,-R.x*U+R.z*T);}vec3 W(vec3 R,float S){float T=cos(S);float U=sin(S);return vec3(R.x*T-R.y*U,R.x*U+R.y*T,R.z);}vec3 X(vec3 R,vec3 Y){vec3 Z=R;if(Y.z!=0.0f){Z=W(Z,Y.z);}if(Y.y!=0.0f){Z=V(Z,Y.y);}if(Y.x!=0.0f){Z=Q(Z,Y.x);}return Z;}void main(){v_uv=A1;v_glyphIndex=A4;v_glyphColor=A5;v_cellColor=A6;v_glyphFlags=A7;vec4 a=Aa;vec4 b=Ab;vec2 c=A3;vec2 d=A2;float e=Ac.x;float f=Ac.y;int g=int(Ac.z);vec2 h=d;vec2 i=h+c*0.5f;float j=f+e*0.5f;vec3 k=vec3(i,j);vec3 l;if(g==D){float F=clamp(A0.x,0.0f,1.0f);vec2 G=b.xy;vec2 H=a.xy;vec2 I=a.zw;vec2 J=b.zw;vec2 m=E(F,G,H,I,J);vec2 n=P(F,G,H,I,J);float o=length(n);vec2 p=o>0.0f?n/o:vec2(1.0f,0.0f);vec2 q=vec2(-p.y,p.x);vec2 r=m;vec2 s=r+q*A0.y*c.y;l=vec3(s,f);}else if(g==C){float t=mod(a.x,A);if(t<0.0f){t+=A;}float u=mod(a.y,A);if(u<0.0f){u+=A;}float v=t-u;if(v<=0.0f){v+=A;}float S=t-A0.x*v;vec2 w=vec2(cos(S),sin(S))*A0.y;vec2 s=w*c+h;l=vec3(s,f);}else if(g==B){vec2 s=A0.xy*c+h;l=vec3(s,f);}vec3 x=X(l,A9);vec3 y=x+A8;vec3 z=vec3(0.0f,0.0f,1.0f);v_worldPosition=y;v_normal=z;v_geometryType=float(g);vec2 AA=(y.xy/Ut)*2.0f;AA.y=-AA.y;float AB=y.z/Ut.y;float AC=clamp(-AB*Uu,-0.99f,0.99f);if(Uv>0.5f){gl_Position=vec4(AA,AC,1.0f);}else{float AD=0.5f;float AE=1.0f/(1.0f-AB*AD);AA*=AE;gl_Position=vec4(AA,AC,1.0f);}}`,_=class _{constructor(t,i,r=i,h=1,n={},a){l(this,"L");l(this,"B");l(this,"h");l(this,"A");l(this,"H");l(this,"G",[]);l(this,"N",null);l(this,"X");l(this,"Y");l(this,"K",null);l(this,"j",new Map);var c,u,d;this.L=i,this.B=r,this.A=t,this.X=(c=h,u=1,d=8,Math.min(Math.max(c,u),d)),this.Y=a,this.h={filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte",Z:!0,...n},_.W||(_.W=new Z(t,st,`#version 300 es
|
|
9
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Ud;uniform sampler2D Ue;uniform sampler2D Uf;uniform vec2 Ug;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Ug;vec2 C=(floor(B)+0.5f)/Ug;vec4 D=texture(Ud,C);vec4 E=texture(Ue,C);if(E.a==0.){discard;}vec4 F=texture(Uf,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const f=t.getParameter(t.MAX_DRAW_BUFFERS),p=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.X=Math.min(this.X,f,p),this.H=t.createFramebuffer(),this.q(),this.V(),this.h.Z&&this.J()}q(){const t=this.A,i=this.h.filter==="linear"?t.LINEAR:t.NEAREST,r=this.h.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,h=this.h.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,n=h===t.FLOAT?t.RGBA32F:t.RGBA8,a=t.RGBA;for(let c=0;c<this.X;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),et(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,n,this.L,this.B,0,a,h,null),this.G.push(u)}t.bindTexture(t.TEXTURE_2D,null)}V(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.H),this.X===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.G[0],0);else{const i=[];for(let r=0;r<this.X;r++){const h=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,h,t.TEXTURE_2D,this.G[r],0),i.push(h)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}J(){const t=this.A;this.N=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.N),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.L,this.B),t.bindFramebuffer(t.FRAMEBUFFER,this.H),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.N),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}tt(t){Ft(this.A,this.G[0],t)}resize(t,i){this.L=t,this.B=i,this.j.clear();const r=this.A,h=this.h.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,n=h===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.G)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,n,this.L,this.B,0,a,h,null);r.bindTexture(r.TEXTURE_2D,null),this.N&&(r.bindRenderbuffer(r.RENDERBUFFER,this.N),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.L,this.B),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.j.get(t);if(i)return i;const r=this.A,h=this.L,n=this.B,a=new Uint8Array(h*n*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.H),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,h,n,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.READ_FRAMEBUFFER,c);const u=4*h,d=new Uint8Array(a.length);for(let f=0;f<n;f++){const p=(n-1-f)*u,A=f*u;d.set(a.subarray(p,p+u),A)}return this.j.set(t,d),d}st(){const t=this.A;this.j.clear(),this.Y.et(),this.Y.it(this.H,this.L,this.B),this.h.Z&&t.clear(t.DEPTH_BUFFER_BIT),this.Y.state.rt()}end(){this.Y.state.nt(),this.Y.ot();const t=this.Y.ht();this.Y.it(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.K||this.lt(),this.K}lt(){if(!this.Y)return;const t={ut:this.G[0],ft:this.G[1],dt:this.G[2],gt:[this.L,this.B]},i=_.W;this.K=this.Y.At.vt(i,t,!0)}D(){const t=this.A;t.deleteFramebuffer(this.H);for(const i of this.G)t.deleteTexture(i);this.N&&t.deleteRenderbuffer(this.N)}get width(){return this.L}get height(){return this.B}get I(){return this.G}get _t(){return this.X}};l(_,"W",null);let Q=_;const Mt=new WeakMap;function pt(o,t){Mt.set(o,t)}function Lt(o){return Mt.get(o)}function k(o,t,i,r,h=255){o[0]=t/255,o[1]=(i??t)/255,o[2]=(r??t)/255,o[3]=h/255}class rt{constructor(){l(this,"yt",1);l(this,"wt",0);l(this,"bt",0);l(this,"Ct",0);l(this,"Mt",0);l(this,"xt",0);l(this,"Ft",0);l(this,"Tt",[0,0,0]);l(this,"Ut",[1,1,1,1]);l(this,"Pt",[0,0,0,1]);l(this,"Et",!1);l(this,"Rt",!1);l(this,"$t",!1);l(this,"St",0);l(this,"kt",[0,0,0,1]);l(this,"zt",!1);l(this,"It",[]);l(this,"Ot",[])}static Dt(){return{Lt:1,Bt:0,Ht:0,Gt:0,Mt:0,xt:0,Ft:0,St:0,Nt:!1,Xt:!1,$t:!1,zt:!1,Yt:[0,0,0],Kt:[1,1,1,1],jt:[0,0,0,1]}}Wt(t){t.Lt=this.yt,t.Bt=this.wt,t.Ht=this.bt,t.Gt=this.Ct,t.Mt=this.Mt,t.xt=this.xt,t.Ft=this.Ft,t.Nt=this.Et,t.Xt=this.Rt,t.$t=this.$t,t.St=this.St,t.zt=this.zt,t.Yt[0]=this.Tt[0],t.Yt[1]=this.Tt[1],t.Yt[2]=this.Tt[2],t.Kt[0]=this.Ut[0],t.Kt[1]=this.Ut[1],t.Kt[2]=this.Ut[2],t.Kt[3]=this.Ut[3],t.jt[0]=this.Pt[0],t.jt[1]=this.Pt[1],t.jt[2]=this.Pt[2],t.jt[3]=this.Pt[3]}Zt(t){this.yt=t.Lt,this.wt=t.Bt,this.bt=t.Ht,this.Ct=t.Gt,this.Mt=t.Mt,this.xt=t.xt,this.Ft=t.Ft,this.Et=t.Nt,this.Rt=t.Xt,this.$t=t.$t,this.St=t.St,this.zt=t.zt,this.Tt[0]=t.Yt[0],this.Tt[1]=t.Yt[1],this.Tt[2]=t.Yt[2],this.Ut[0]=t.Kt[0],this.Ut[1]=t.Kt[1],this.Ut[2]=t.Kt[2],this.Ut[3]=t.Kt[3],this.Pt[0]=t.jt[0],this.Pt[1]=t.jt[1],this.Pt[2]=t.jt[2],this.Pt[3]=t.jt[3]}rt(){let t=this.Ot.pop();t||(t=rt.Dt()),this.Wt(t),this.It.push(t)}nt(){const t=this.It.pop();t?(this.Zt(t),this.Ot.push(t)):console.warn("pop() called without matching push()")}qt(t){this.Wt(t)}Vt(t){this.yt=Math.abs(t)}Qt(){this.wt=0,this.bt=0,this.Ct=0,this.Mt=0,this.xt=0,this.Ft=0,this.zt=!1}Jt(t){t!==0&&(this.Mt+=t*Math.PI/180)}ts(t){t!==0&&(this.xt+=t*Math.PI/180)}ss(t){t!==0&&(this.Ft+=t*Math.PI/180)}es(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.wt+=t,this.bt+=i,this.Ct+=r)}rs(t){this.es(t,0,0)}ns(t){this.es(0,t,0)}hs(t){this.es(0,0,t)}cs(t){this.Tt[0]=t[0],this.Tt[1]=t[1],this.Tt[2]=t[2]}ls(t,i,r,h=255){k(this.Ut,t,i,r,h)}us(t,i,r,h=255){k(this.Pt,t,i,r,h)}fs(t){this.Et=t}ds(t){this.Rt=t}ps(t){this.$t=t}gs(t){this.St=bt(t)}vs(t,i,r,h){k(this.kt,t,i,r,h)}As(t){this.zt=t}get _s(){return this.kt}get ys(){return this.zt}get ws(){return this.Mt}get bs(){return this.xt}get Cs(){return this.Ft}}const At=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,-.5,.5,0,1,-.5,.5,0,1,.5,-.5,1,0,.5,.5,1,1]),H={Ms:16,xs:WebGL2RenderingContext.TRIANGLES,Fs:{Ts:{size:2,offset:0},Us:{size:2,offset:8}}};class Kt{constructor(t){l(this,"A");l(this,"Ps");l(this,"Es");this.A=t,this.Ps=t.createBuffer(),this.Es=new Float32Array(At.length)}Rs(t,i,r,h){const n=this.A,a=Lt(this.A),c=a[2],u=a[3],d=t/c*2-1,f=(t+r)/c*2-1,p=1-(i+h)/u*2,A=1-i/u*2,g=At,v=this.Es;for(let w=0;w<g.length;w+=4){const m=g[w],T=g[w+1],y=g[w+2],E=g[w+3],x=d+(m+.5)*(f-d),b=p+(T+.5)*(A-p);v[w]=x,v[w+1]=b,v[w+2]=y,v[w+3]=E}n.bindBuffer(n.ARRAY_BUFFER,this.Ps),n.bufferData(n.ARRAY_BUFFER,v,n.DYNAMIC_DRAW),n.enableVertexAttribArray(0),n.vertexAttribPointer(0,2,n.FLOAT,!1,16,0),n.drawArrays(n.TRIANGLES,0,6),n.disableVertexAttribArray(0),n.bindBuffer(n.ARRAY_BUFFER,null)}D(){this.A.deleteBuffer(this.Ps)}}var Y=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(Y||{});const jt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class _t{constructor(t){l(this,"A");l(this,"$s",new Map);this.A=t}Ss(t,i,r,h){const n=this.A;let a=this.$s.get(t);a||(a=new Map,this.$s.set(t,a));let c=a.get(i)||null;if(!c){c=n.createVertexArray(),a.set(i,c),n.bindVertexArray(c),n.bindBuffer(n.ARRAY_BUFFER,h);const u=n.getAttribLocation(t,"A0");u!==-1&&dt(n,u,r.Fs.Ts.size,r.Ms,r.Fs.Ts.offset,0,n.FLOAT,!1);const d=n.getAttribLocation(t,"A1");d!==-1&&dt(n,d,r.Fs.Us.size,r.Ms,r.Fs.Us.offset,0,n.FLOAT,!1)}n.bindVertexArray(c)}ks(){this.A.bindVertexArray(null)}D(){for(const[,t]of this.$s)for(const[,i]of t)i&&this.A.deleteVertexArray(i)}}const X=class X{static Os(t,i,r=0){const h=i||new Float32Array(X.Is);let n=r;h[n++]=t.Ts[0],h[n++]=t.Ts[1],h[n++]=t.Ds[0],h[n++]=t.Ds[1],h[n++]=t.Yt[0],h[n++]=t.Yt[1],h[n++]=t.Yt[2],h[n++]=t.Kt[0],h[n++]=t.Kt[1],h[n++]=t.Kt[2],h[n++]=t.Kt[3],h[n++]=t.jt[0],h[n++]=t.jt[1],h[n++]=t.jt[2],h[n++]=t.jt[3],h[n++]=t.Ls[0],h[n++]=t.Ls[1],h[n++]=t.Ls[2],h[n++]=t.St;const a=t.Bs;h[n++]=(a==null?void 0:a[0])??0,h[n++]=(a==null?void 0:a[1])??0,h[n++]=(a==null?void 0:a[2])??0;const c=t.Hs;h[n++]=(c==null?void 0:c[0])??0,h[n++]=(c==null?void 0:c[1])??0,h[n++]=(c==null?void 0:c[2])??0;const u=t.Gs,d=t.Ns,f=t.Xs,p=t.Ys,A=t.Ks,g=!(!d||!f);return g?(h[n++]=(p==null?void 0:p[0])??0,h[n++]=(p==null?void 0:p[1])??0,h[n++]=(A==null?void 0:A[0])??0,h[n++]=(A==null?void 0:A[1])??0,h[n++]=d[0],h[n++]=d[1],h[n++]=f[0],h[n++]=f[1]):!g&&!!u?(h[n++]=u[0],h[n++]=u[1],h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0):(h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0,h[n++]=0),h[n++]=t.js??0,h[n++]=t.Ws??0,h[n++]=t.Zs??0,h}static qs(t,i){const r=t.length*X.Is,h=i||new Float32Array(r);for(let n=0;n<t.length;n++){const a=n*X.Is;X.Os(t[n],h,a)}return h}};l(X,"zs",144),l(X,"Is",36);let O=X;const D=class D{};l(D,"Vs",O.zs),l(D,"Qs",{Js:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:0,divisor:1},ee:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:8,divisor:1},ie:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:16,divisor:1},re:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:28,divisor:1},ne:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:44,divisor:1},oe:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:60,divisor:1},he:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:76,divisor:1},ae:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:88,divisor:1},ce:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:100,divisor:1},le:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:116,divisor:1},ue:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:D.Vs,offset:132,divisor:1}});let J=D;class Vt{constructor(t=1e3,i=1.5){l(this,"fe");l(this,"de");l(this,"pe");l(this,"ge",0);l(this,"ve",0);this.de=t,this.pe=i;const r=t*O.Is;this.fe=new Float32Array(r)}me(t){if(t<=this.de)return;const i=Math.ceil(t*this.pe),r=this.de;this.de=i;const h=i*O.Is,n=new Float32Array(h),a=r*O.Is;n.set(this.fe.subarray(0,Math.min(a,this.ge))),this.fe=n}Ae(){return{buffer:this.fe,offset:this.ge}}_e(t){this.ge+=t,this.ve++}reset(){this.ge=0,this.ve=0}subarray(t=0,i){return this.fe.subarray(t,i??this.ge)}get ye(){return this.ve}get we(){return this.de}get be(){return this.ge}get Ce(){return this.ve===0}}class Wt{constructor(t){l(this,"fe");this.fe=t}Me(t){this.fe.me(this.fe.ye+1);const{buffer:i,offset:r}=this.fe.Ae();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.xe,i[r+5]=t.Fe,i[r+6]=t.Te,i[r+7]=t.r1,i[r+8]=t.Ue,i[r+9]=t.Pe,i[r+10]=t.Ee,i[r+11]=t.r2,i[r+12]=t.Re,i[r+13]=t.$e,i[r+14]=t.Se,i[r+15]=t.ke,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.ze,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.Ie,i[r+22]=t.ws,i[r+23]=t.bs,i[r+24]=t.Cs;const h=t.Oe,n=t.De;return i[r+25]=h[0],i[r+26]=h[1],i[r+27]=h[2],i[r+28]=h[3],i[r+29]=n[0],i[r+30]=n[1],i[r+31]=n[2],i[r+32]=n[3],i[r+33]=t.Z,i[r+34]=t.Le,i[r+35]=t.Be,this.fe._e(O.Is),this.fe.ye-1}get ye(){return this.fe.ye}}class Zt{constructor(t,i=1e3){l(this,"A");l(this,"He",null);l(this,"Ge",0);l(this,"Ne",new Map);this.A=t,this.Xe(i)}Xe(t){const i=this.A;this.He&&i.deleteBuffer(this.He),this.He=i.createBuffer();const r=t*O.zs;Rt(i,i.ARRAY_BUFFER,this.He,r,i.DYNAMIC_DRAW),this.Ge=t}Ye(t){this.Xe(t)}get we(){return this.Ge}upload(t,i){if(i===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.He);const h=i*O.Is;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,h)}Ke(t){let i=this.Ne.get(t);if(!i){i=new Map;const r=this.A;for(const h in J.Qs){const n=r.getAttribLocation(t,h);n!==-1&&i.set(h,n)}this.Ne.set(t,i)}return i}je(t){const i=this.A,r=t.O,h=this.Ke(r);for(const[n,a]of h){const c=J.Qs[n];c&&dt(i,a,c.size,c.se,c.offset,c.divisor,c.type,c.te)}}We(t){const i=this.A,r=this.Ke(t.O);for(const[h,n]of r)J.Qs[h]&&(i.disableVertexAttribArray(n),i.vertexAttribDivisor(n,0))}dispose(){this.He&&(this.A.deleteBuffer(this.He),this.He=null),this.Ne.clear()}}class qt{constructor(t,i=1e3,r=1.5){l(this,"A");l(this,"fe");l(this,"Ze");l(this,"qe");this.A=t,this.fe=new Vt(i,r),this.Ze=new Wt(this.fe),this.qe=new Zt(t,i)}Ve(t){var h,n,a,c,u,d,f,p,A,g;const i=[0,0,0,0],r=[0,0,0,0];return t.Ns&&t.Xs?(i[0]=((h=t.Ys)==null?void 0:h[0])??0,i[1]=((n=t.Ys)==null?void 0:n[1])??0,i[2]=((a=t.Ks)==null?void 0:a[0])??0,i[3]=((c=t.Ks)==null?void 0:c[1])??0,r[0]=t.Ns[0],r[1]=t.Ns[1],r[2]=t.Xs[0],r[3]=t.Xs[1]):t.Gs&&(i[0]=t.Gs[0],i[1]=t.Gs[1]),this.Qe({x:t.Ts[0],y:t.Ts[1],width:t.Ds[0],height:t.Ds[1],xe:t.Yt[0],Fe:t.Yt[1],Te:t.Yt[2],r1:t.Kt[0],Ue:t.Kt[1],Pe:t.Kt[2],Ee:t.Kt[3],r2:t.jt[0],Re:t.jt[1],$e:t.jt[2],Se:t.jt[3],ke:t.Ls[0],flipX:t.Ls[1],flipY:t.Ls[2],ze:t.St,translationX:((u=t.Bs)==null?void 0:u[0])??0,translationY:((d=t.Bs)==null?void 0:d[1])??0,Ie:((f=t.Bs)==null?void 0:f[2])??0,ws:((p=t.Hs)==null?void 0:p[0])??0,bs:((A=t.Hs)==null?void 0:A[1])??0,Cs:((g=t.Hs)==null?void 0:g[2])??0,Oe:i,De:r,Z:t.js||0,Le:t.Ws||0,Be:t.Zs||0})}Qe(t){const i=this.Ze.Me(t);return this.fe.we>this.qe.we&&this.qe.Ye(this.fe.we),i}get count(){return this.fe.ye}get Ce(){return this.fe.Ce}clear(){this.fe.reset()}Je(t){const i=this.fe.ye;if(i===0)return;const r=this.fe.subarray();this.qe.upload(r,i),this.qe.je(t)}ti(t){this.qe.We(t)}Rs(t,i){const r=this.fe.ye;r!==0&&this.A.drawArraysInstanced(t,0,i,r)}D(){this.qe.dispose()}}class G{constructor(t,i,r,h){l(this,"A");l(this,"si");l(this,"ei");l(this,"ii");l(this,"ri",null);this.A=t,this.si=i,this.ei=r,this.ii=h;const n=this.A.createBuffer();Rt(this.A,this.A.ARRAY_BUFFER,n,this.ii.ni,this.A.STATIC_DRAW),this.ri=n}get type(){return this.ei}get oi(){return this.ii}get hi(){return this.ri}get ai(){return this.si}ci(){this.si.clear()}li(){return!this.si.Ce}D(){this.si.D(),this.A.deleteBuffer(this.ri)}ui(t,i,r){return this.si.Ve(t)}fi(t,i,r,h,n,a){const c=n.Bt??0,u=n.Ht??0,d=n.Gt??0,f=n.Mt??0,p=n.xt??0,A=n.Ft??0,g=[0,0,0,0],v=[0,0,0,0];a&&(a.di!==void 0&&a.pi!==void 0&&a.gi!==void 0&&a.mi!==void 0?(g[0]=a.Ai??0,g[1]=a._i??0,g[2]=a.yi??0,g[3]=a.wi??0,v[0]=a.di??0,v[1]=a.pi??0,v[2]=a.gi??0,v[3]=a.mi??0):a.bi===void 0&&a.Ci===void 0||(g[0]=a.bi??0,g[1]=a.Ci??0));const w={x:t,y:i,width:r,height:h,xe:n.Yt[0],Fe:n.Yt[1],Te:n.Yt[2],r1:n.Kt[0],Ue:n.Kt[1],Pe:n.Kt[2],Ee:n.Kt[3],r2:n.jt[0],Re:n.jt[1],$e:n.jt[2],Se:n.jt[3],ke:n.$t?1:0,flipX:n.Nt?1:0,flipY:n.Xt?1:0,ze:n.St,translationX:c,translationY:u,Ie:d,ws:f,bs:p,Cs:A,Oe:g,De:v,Z:(a==null?void 0:a.Z)??0,Le:(a==null?void 0:a.Le)??0,Be:jt[this.ei]??0};return this.si.Qe(w)}}const Qt={ni:At,Mi:6,...H},Jt={ni:new Float32Array([0,-.5,0,0,1,-.5,1,0,0,.5,0,1,0,.5,0,1,1,-.5,1,0,1,.5,1,1]),Mi:6,...H},$t={ni:function(o=32){const t=[],i=2*Math.PI/o;for(let r=0;r<o;r++){const h=r*i,n=(r+1)%o*i,a=Math.cos(h),c=Math.sin(h),u=.5*(a+1),d=.5*(c+1),f=Math.cos(n),p=Math.sin(n),A=.5*(f+1),g=.5*(p+1);t.push(0,0,.5,.5,a,c,u,d,f,p,A,g)}return new Float32Array(t)}(32),Mi:96,...H};let ti={ni:function(o){const t=[];for(let i=0;i<o;i++){const r=i/o,h=(i+1)/o;t.push(r,0,r,0,r,1,r,1,h,1,h,1)}return new Float32Array(t)}(32),Mi:96,...H};const ii={ni:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Mi:3,...H},ei={ni:function(o=16){const t=[];for(let i=0;i<o;i++){const r=i/o,h=(i+1)/o;t.push(r,-.5,r,0,h,-.5,h,0,r,.5,r,1,r,.5,r,1,h,-.5,h,0,h,.5,h,1)}return new Float32Array(t)}(16),Mi:96,...H},si={[Y.RECTANGLE]:class extends G{constructor(o,t){super(o,t,Y.RECTANGLE,Qt)}Ve(o,t){return this.fi(0,0,o.width,o.height,t)}},[Y.LINE]:class extends G{constructor(o,t){super(o,t,Y.LINE,Jt)}Ve(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,h=Math.hypot(i,r),n=t.Lt||1,a=o.x1+i/2-h/2,c=o.y1+r/2;return this.fi(a,c,h,n,t)}},[Y.ELLIPSE]:class extends G{constructor(o,t){super(o,t,Y.ELLIPSE,$t)}Ve(o,t){return this.fi(0,0,o.width,o.height,t)}},[Y.ARC]:class extends G{constructor(o,t){super(o,t,Y.ARC,ti)}Ve(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.fi(0,0,o.width,o.height,t,{bi:i,Ci:r})}},[Y.TRIANGLE]:class extends G{constructor(o,t){super(o,t,Y.TRIANGLE,ii)}Ve(o,t){const i=Math.min(o.x1,o.x2,o.xi),r=Math.max(o.x1,o.x2,o.xi),h=Math.min(o.y1,o.y2,o.Fi),n=r-i,a=Math.max(o.y1,o.y2,o.Fi)-h;return this.fi(i,h,n,a,t)}},[Y.BEZIER_CURVE]:class extends G{constructor(o,t){super(o,t,Y.BEZIER_CURVE,ei)}Ve(o,t){return this.fi(0,0,1,t.Lt||1,t,{Ai:o.Ai,_i:o._i,yi:o.yi,wi:o.wi,di:o.x1,pi:o.y1,gi:o.x2,mi:o.y2})}}};class ri{constructor(t){l(this,"A");l(this,"Ti");l(this,"Ui");this.A=t,this.Ui=new _t(t),this.Ti=new Map;for(const i of Object.values(Y)){const r=new qt(t),h=new si[i](t,r);this.Ti.set(i,h)}}Pi(t){const i=this.Ei(t);for(const r of i)this.Ri(r)}Ei(t){const i=[];let r=null,h=null,n=null;for(const a of t)h!==a.$i||n!==a.type?(r&&r.length>0&&i.push({$i:h,type:n,commands:r}),r=[a],h=a.$i,n=a.type):r.push(a);return r&&r.length>0&&i.push({$i:h,type:n,commands:r}),i}Ri(t){const{$i:i,type:r,commands:h}=t,n=this.Ti.get(r);i.Si.R(),i.Si.S(i.ki);const a=Lt(this.A),c=h.length>0&&h[0].state.zt;i.Si.S({zi:a[2]/a[3],Ii:[a[2],a[3]],Oi:1,Di:c?1:0}),n.ci();for(const u of h)n.Ve(u.Li,u.state);if(n.li()){const u=n.oi,d=n.hi;try{this.Ui.Ss(i.Si.O,String(r),u,d),n.ai.Je(i.Si),n.ai.Rs(u.xs,u.Mi)}finally{n.ai.ti(i.Si),this.Ui.ks(),n.ci()}}}D(){for(const t of this.Ti.values())t.D();this.Ti.clear(),this.Ui.D()}}function Yt(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Ct(o){return Yt(String(o))}function $(o,t){return(o<<5)-o+t}class ni{constructor(t){l(this,"A");l(this,"Bi",0);l(this,"Hi");l(this,"Gi");l(this,"Ni",new Map);this.A=t,this.Hi=new Z(t,st,`#version 300 es
|
|
10
|
+
precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellColor;in vec4 v_glyphFlags;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;void main(){int A=int(v_glyphFlags.r>0.5?1:0);int B=int(v_glyphFlags.g>0.5?1:0);int C=int(v_glyphFlags.b>0.5?1:0);float D=float(A|(B<<1)|(C<<2))/255.;o_character=vec4(v_glyphIndex.xy,D,clamp(v_glyphFlags.a,0.,1.));o_primaryColor=vec4(v_glyphColor.rgb,v_glyphColor.a);o_secondaryColor=vec4(v_cellColor.rgb,v_cellColor.a);}`),this.Gi={id:this.Bi++,Si:this.Hi,ki:Object.freeze({}),hash:this.Xi(this.Hi,{}),Yi:!0}}get Ki(){return this.Gi}vt(t,i={},r=!1){const h=this.Xi(t,i),n=this.Ni.get(h);if(n)return n;const a={id:this.Bi++,Si:t,ki:Object.freeze({...i}),hash:h,Yi:r};return this.Ni.set(h,a),a}ji(t,i={}){return{id:this.Bi++,Si:t,ki:Object.freeze({...i}),hash:0,Yi:!1}}Xi(t,i){const r=Ct(t.O),h=function(n,a){let c=0;const u=Object.keys(n).sort();for(const d of u)c=$(c,Yt(d)),c=$(c,a(n[d]));return c}(i,this.Wi.bind(this));return $(r,h)}Wi(t){return typeof t=="number"||typeof t=="boolean"?function(i){return typeof i=="boolean"?i?1:0:Math.floor(i)}(t):Array.isArray(t)?function(i){let r=0;const h=Array.isArray(i[0])?i.flat():i;for(const n of h)r=$(r,typeof n=="number"?n:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(i){let r=0;const h=Math.min(i.length,16);for(let n=0;n<h;n++)r=$(r,i[n]);return r}(t):t instanceof WebGLTexture?Ct(t):0}D(){this.Hi!=this.Hi&&this.Hi.D(),this.Hi.D(),this.Ni.clear()}}class hi{constructor(){l(this,"Zi",[]);l(this,"qi",1);l(this,"Ds",0)}Vi(t,i){if(this.Ds>=this.Zi.length){const h={id:this.qi++,type:t,Li:{},state:rt.Dt(),$i:i};this.Zi.push(h)}const r=this.Zi[this.Ds];return r.id=this.qi++,r.type=t,r.$i=i,this.Ds++,r}Qi(t,i,r){const h=this.Vi(Y.RECTANGLE,r),n=h.Li;return n.width=t.width,n.height=t.height,i.qt(h.state),h.id}Ji(t,i,r){const h=this.Vi(Y.LINE,r),n=h.Li;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.tr=t.tr,i.qt(h.state),h.id}sr(t,i,r){const h=this.Vi(Y.ELLIPSE,r),n=h.Li;return n.width=t.width,n.height=t.height,n.er=t.er,n.ir=t.ir,n.rr=t.rr,i.qt(h.state),h.id}nr(t,i,r){const h=this.Vi(Y.ARC,r),n=h.Li;return n.width=t.width,n.height=t.height,n.start=t.start,n.stop=t.stop,i.qt(h.state),h.id}hr(t,i,r){const h=this.Vi(Y.TRIANGLE,r),n=h.Li;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.xi=t.xi,n.Fi=t.Fi,i.qt(h.state),h.id}ar(t,i,r){const h=this.Vi(Y.BEZIER_CURVE,r),n=h.Li;return n.x1=t.x1,n.y1=t.y1,n.Ai=t.Ai,n._i=t._i,n.yi=t.yi,n.wi=t.wi,n.x2=t.x2,n.y2=t.y2,n.tr=t.tr,n.rr=t.rr,i.qt(h.state),h.id}cr(){this.Ds=0}[Symbol.iterator](){let t=0;const i=this.Ds,r=this.Zi;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class oi{constructor(t){l(this,"A");l(this,"lr",null);l(this,"ur");l(this,"At");l(this,"dr");l(this,"pr");l(this,"gr");l(this,"vr",null);l(this,"mr",{});l(this,"Ar",[]);l(this,"_r",[]);l(this,"yr",null);l(this,"wr",[0,0,0,0]);this.A=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.dr=new rt,this.At=new ni(t),this.pr=new hi,this.ur=new ri(t),this.gr=new Kt(t);const i=[0,0,t.canvas.width,t.canvas.height];pt(t,i),this.Ar.push(null),this._r.push(i),this.yr=null,this.wr=i}et(){this.Ar.push(this.yr),this._r.push([...this.wr])}ht(){return{framebuffer:this.Ar.pop()??null,viewport:this._r.pop()??[0,0,this.A.canvas.width,this.A.canvas.height]}}it(t,i,r){const h=this.A;this.yr!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.yr=t);const n=[0,0,i,r];this.wr[0]===n[0]&&this.wr[1]===n[1]&&this.wr[2]===n[2]&&this.wr[3]===n[3]||(h.viewport(...n),pt(h,n),this.wr=n)}br(t){this.lr!==t&&(this.lr=t,t.R())}Cr(t,i){return new Z(this.A,t,i)}Mr(t){this.vr=t,t&&(this.mr={})}k(t,i){this.mr[t]=i}Fr(t){Object.assign(this.mr,t)}Tr(t){return new Z(this.A,st,t)}Ur(t,i,r){this.pr.Qi({width:i??t.width,height:r??t.height},this.dr,t.ct())}Pr(t,i,r,h){this.gr.Rs(t,i,r,h)}Er(t,i){if(this.vr){const r=this.At.ji(this.vr,this.mr);this.pr.Qi({width:t,height:i},this.dr,r),this.vr=null,this.mr={}}else this.pr.Qi({width:t,height:i},this.dr,this.At.Ki)}Rr(t,i,r,h){this.pr.Ji({x1:t,y1:i,x2:r,y2:h},this.dr,this.At.Ki)}$r(t,i){this.pr.sr({width:t,height:i},this.dr,this.At.Ki)}Sr(t,i,r,h,n,a){this.pr.hr({x1:t,y1:i,x2:r,y2:h,xi:n,Fi:a},this.dr,this.At.Ki)}kr(t,i,r,h,n,a,c,u){this.pr.ar({x1:t,y1:i,Ai:r,_i:h,yi:n,wi:a,x2:c,y2:u},this.dr,this.At.Ki)}zr(t,i,r,h){this.pr.nr({width:t,height:i,start:r,stop:h},this.dr,this.At.Ki)}Ir(t,i,r=1,h={}){return new Q(this.A,t,i,r,h,this)}Or(t,i=t,r=t,h=255){this.dr.vs(t,i??t,r??t,h);const[n,a,c,u]=this.dr._s;this.cr(n,a,c,u)}cr(t=0,i=0,r=0,h=0){this.A.clearColor(t,i,r,h),this.A.clear(this.A.COLOR_BUFFER_BIT)}Dr(){this.A.viewport(0,0,this.A.canvas.width,this.A.canvas.height),pt(this.A,[0,0,this.A.canvas.width,this.A.canvas.height])}ot(){const t=this.pr;this.ur.Pi(t),t.cr()}D(){this.At.D(),this.ur.D(),this.gr.D()}get context(){return this.A}get state(){return this.dr}}const C={Lr:(o,t)=>(C.Br.uint16[0]=o[t]<<8|o[t+1],C.Br.int16[0]),Hr:(o,t)=>o[t]<<8|o[t+1],Gr(o,t,i){const r=[];for(let h=0;h<i;h++)r.push(C.Hr(o,t+2*h));return r},Nr(o,t){const i=C.Br.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],C.Br.uint32[0]},Xr(o,t,i){let r="";for(let h=0;h<i;h++)r+=String.fromCharCode(o[t+h]);return r},Br:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function nt(o){return o+3&-4}function ht(o,t,i){o[t]=i>>>8&255,o[t+1]=255&i}function P(o,t,i){o[t]=i>>>24&255,o[t+1]=i>>>16&255,o[t+2]=i>>>8&255,o[t+3]=255&i}function ai(o,t,i){for(let r=0;r<i.length;r++)o[t+r]=255&i.charCodeAt(r)}function gt(o,t,i){const r=t+i;let h=0;const n=C.Br;for(let a=t;a<r;a+=4)n.uint8[3]=o[a]||0,n.uint8[2]=o[a+1]||0,n.uint8[1]=o[a+2]||0,n.uint8[0]=o[a+3]||0,h=h+(n.uint32[0]>>>0)>>>0;return h>>>0}class ci{constructor(t){l(this,"b");l(this,"Yr",0);l(this,"Kr",0);l(this,"jr",0);this.b=t}Wr(t){for(;this.jr<t;){const r=this.b[this.Yr++]||0;this.Kr|=r<<this.jr,this.jr+=8}const i=this.Kr&(1<<t)-1;return this.Kr>>>=t,this.jr-=t,i}Zr(){this.Kr=0,this.jr=0}get offset(){return this.Yr}}function tt(o){let t=32,i=0;for(const c of o)c&&(c<t&&(t=c),c>i&&(i=c));if(i===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(i+1);for(const c of o)c&&r[c]++;const h=new Uint32Array(i+1);let n=0;r[0]=0;for(let c=1;c<=i;c++)n=n+r[c-1]<<1,h[c]=n;const a=new Map;for(let c=0;c<o.length;c++){const u=o[c];if(!u)continue;const d=h[u]++;let f=a.get(u);f||(f=[],a.set(u,f)),f[li(d,u)]=c}return{min:t,max:i,table:a}}function vt(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.Wr(1)<<r-1;const h=t.table.get(r);if(h&&i<h.length){const n=h[i];if(n!==void 0)return n}}throw new Error("Invalid Huffman code")}function li(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function ui(o){if(o.length<2)throw new Error("ZLIB data too short");const t=o[0],i=o[1];if((15&t)!=8)throw new Error("Unsupported ZLIB compression method");if(((t<<8)+i)%31!=0)throw new Error("Bad ZLIB header check");let r=2;32&i&&(r+=4);const h=[];return function(n,a){const c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],u=[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],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],f=[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];let p=0;for(;!p;){p=n.Wr(1);const A=n.Wr(2);if(A===0){n.Zr();const g=n.Wr(16);if((65535&(65535^g))!==n.Wr(16))throw new Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<g;v++)a.push(n.Wr(8))}else{if(A!==1&&A!==2)throw new Error("Unsupported DEFLATE type");{let g,v;if(A===1){const w=new Array(288).fill(0);for(let m=0;m<=143;m++)w[m]=8;for(let m=144;m<=255;m++)w[m]=9;for(let m=256;m<=279;m++)w[m]=7;for(let m=280;m<=287;m++)w[m]=8;g=tt(w),v=tt(new Array(32).fill(5))}else{const w=n.Wr(5)+257,m=n.Wr(5)+1,T=n.Wr(4)+4,y=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E=new Array(19).fill(0);for(let M=0;M<T;M++)E[y[M]]=n.Wr(3);const x=tt(E),b=[];for(;b.length<w+m;){const M=vt(n,x);if(M<=15)b.push(M);else if(M===16){const I=n.Wr(2)+3,B=b[b.length-1]||0;for(let ut=0;ut<I;ut++)b.push(B)}else if(M===17){const I=n.Wr(3)+3;for(let B=0;B<I;B++)b.push(0)}else{if(M!==18)throw new Error("Invalid code length symbol");{const I=n.Wr(7)+11;for(let B=0;B<I;B++)b.push(0)}}}const F=b.slice(0,w),U=b.slice(w,w+m);g=tt(F),v=tt(U)}for(;;){const w=vt(n,g);if(w<256)a.push(w);else{if(w===256)break;if(w>256&&w<286){const m=w-257;let T=c[m];const y=u[m];y&&(T+=n.Wr(y));const E=vt(n,v);if(E>=30)throw new Error("Invalid distance symbol");let x=d[E];const b=f[E];b&&(x+=n.Wr(b));const F=a.length-x;if(F<0)throw new Error("Invalid distance");for(let U=0;U<T;U++)a.push(a[F+U]||0)}else if(w===286||w===287)throw new Error("Reserved length symbol")}}}}}}(new ci(o.subarray(r)),h),new Uint8Array(h)}function fi(o){const t=C,i=new Uint8Array(o);if(t.Xr(i,0,4)!=="wOFF")throw new Error("Invalid WOFF signature");const r=t.Nr(i,4),h=t.Hr(i,12),n=t.Nr(i,16),a=[];let c=44;for(let y=0;y<h;y++){const E=t.Xr(i,c,4),x=t.Nr(i,c+4),b=t.Nr(i,c+8),F=t.Nr(i,c+12),U=t.Nr(i,c+16);a.push({tag:E,offset:x,qr:b,Vr:F,Qr:U}),c+=20}for(const y of a){const E=new Uint8Array(i.buffer,y.offset,y.qr);if(y.qr===y.Vr)y.data=new Uint8Array(E);else if(y.data=ui(E),y.data.length!==y.Vr)if(y.data.length<y.Vr){const x=new Uint8Array(y.Vr);x.set(y.data),y.data=x}else y.data=y.data.subarray(0,y.Vr)}const u=h;let d=1,f=0;for(;d<<1<=u;)d<<=1,f++;const p=16*d,A=16*u-p;let g=12+16*u;const v={};for(const y of a)v[y.tag]=g,g=nt(g+y.data.length);const w=Math.max(n||0,g),m=new Uint8Array(w);P(m,0,r),ht(m,4,u),ht(m,6,p),ht(m,8,f),ht(m,10,A);let T=12;for(const y of a){ai(m,T,y.tag),T+=4;let E=y.data;if(y.tag==="head"&&E.length>=12){const x=new Uint8Array(E);P(x,8,0),P(m,T,gt(x,0,nt(x.length))),T+=4}else P(m,T,gt(E,0,nt(E.length))),T+=4;P(m,T,v[y.tag]),T+=4,P(m,T,y.data.length),T+=4}for(const y of a){const E=v[y.tag];m.set(y.data,E)}if(a.find(y=>y.tag==="head")){const y=v.head,E=function(x,b){const F=b+8,U=[x[F],x[F+1],x[F+2],x[F+3]];P(x,F,0);const M=2981146554-(gt(x,0,nt(x.length))>>>0)>>>0;return x[F]=U[0],x[F+1]=U[1],x[F+2]=U[2],x[F+3]=U[3],M>>>0}(m,y);P(m,y+8,E)}return m.buffer}const di={Jr(o,t,i){const r={tn:[],sn:{},off:t};o=new Uint8Array(o.buffer,t,i),t=0;const h=C,n=h.Hr,a=n(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const d=n(o,t),f=n(o,t+=2);t+=2;const p=h.Nr(o,t);t+=4;const A=`p${d}e${f}`;let g=c.indexOf(p);if(g===-1){let v;g=r.tn.length,c.push(p);const w=n(o,p);v=w===4?this.en(o,p):w===12?this.rn(o,p):{format:w},r.tn.push(v)}r.sn[A]=g}return r},en(o,t){const i=C,r=i.Hr,h=i.Gr,n=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,nn:r(o,t+=2),hn:0,an:0,cn:[],ln:[],un:[],fn:[],dn:[]};t+=2,u.hn=r(o,t),t+=2,u.an=r(o,t),t+=2,u.cn=h(o,t,c),t+=2*c,t+=2,u.ln=h(o,t,c),t+=2*c;for(let d=0;d<c;d++)u.un.push(i.Lr(o,t)),t+=2;return u.fn=h(o,t,c),t+=2*c,u.dn=h(o,t,n+a-t>>1),u},rn(o,t){const i=C.Nr;i(o,t+=4),i(o,t+=4);const r=i(o,t+=4);t+=4;const h=new Uint32Array(3*r);for(let n=0;n<3*r;n+=3)h[n]=i(o,t+(n<<2)),h[n+1]=i(o,t+(n<<2)+4),h[n+2]=i(o,t+(n<<2)+8);return{format:12,groups:h}}},pi={Jr(o,t,i){const r=C;t+=18;const h=r.Hr(o,t);t+=2,t+=16;const n=r.Lr(o,t);t+=2;const a=r.Lr(o,t);t+=2;const c=r.Lr(o,t);t+=2;const u=r.Lr(o,t);return t+=2,t+=6,{pn:h,gn:n,vn:a,mn:c,An:u,_n:r.Lr(o,t)}}},Ai={Jr(o,t,i){const r=C;t+=4;const h=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],n={};for(let a=0;a<h.length;a++){const c=h[a],u=c==="advanceWidthMax"||c==="numberOfHMetrics"?r.Hr:r.Lr;n[c]=u(o,t+2*a)}return n}},gi={Jr(o,t,i,r){const h=C,n=[],a=[],c=r.wn.yn,u=r.Cn.bn;let d=0,f=0,p=0;for(;p<u;)d=h.Hr(o,t+(p<<2)),f=h.Lr(o,t+(p<<2)+2),n.push(d),a.push(f),p++;for(;p<c;)n.push(d),a.push(f),p++;return{Mn:n,xn:a}}},Ut={Fn:di,head:pi,Cn:Ai,wn:{Jr(o,t,i){const r=C;return r.Nr(o,t),t+=4,{yn:r.Hr(o,t)}}},Tn:gi,Un:{Jr(o,t,i,r){const h=C,n=[],a=r.head._n,c=r.wn.yn+1;if(a===0)for(let u=0;u<c;u++)n.push(h.Hr(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)n.push(h.Nr(o,t+(u<<2)));return n}},Pn:{Jr(o,t,i,r){const h=[],n=r.wn.yn;for(let a=0;a<n;a++)h.push(null);return h},En(o,t){const i=C,r=o.Rn,h=o.Un;if(h[t]===h[t+1])return null;const n=K.$n(r,"glyf",o.Sn);if(!n)return null;let a=n[0]+h[t];const c={};if(c.kn=i.Lr(r,a),a+=2,c.gn=i.Lr(r,a),a+=2,c.vn=i.Lr(r,a),a+=2,c.mn=i.Lr(r,a),a+=2,c.An=i.Lr(r,a),a+=2,c.gn>=c.mn||c.vn>=c.An)return null;if(c.kn>0){c.zn=[];for(let A=0;A<c.kn;A++)c.zn.push(i.Hr(r,a)),a+=2;const u=i.Hr(r,a);if(a+=2,r.length-a<u)return null;a+=u;const d=c.zn[c.kn-1]+1;c.flags=[];for(let A=0;A<d;A++){const g=r[a];if(a++,c.flags.push(g),8&g){const v=r[a];a++;for(let w=0;w<v;w++)c.flags.push(g),A++}}c.In=[];for(let A=0;A<d;A++){const g=c.flags[A],v=!!(16&g);2&g?(c.In.push(v?r[a]:-r[a]),a++):v?c.In.push(0):(c.In.push(i.Lr(r,a)),a+=2)}c.On=[];for(let A=0;A<d;A++){const g=c.flags[A],v=!!(32&g);4&g?(c.On.push(v?r[a]:-r[a]),a++):v?c.On.push(0):(c.On.push(i.Lr(r,a)),a+=2)}let f=0,p=0;for(let A=0;A<d;A++)f+=c.In[A],p+=c.On[A],c.In[A]=f,c.On[A]=p}else c.Dn=[],c.zn=[],c.flags=[],c.In=[],c.On=[];return c}}},K={parse(o){const t=new Uint8Array(o);C.Xr(t,0,4)==="wOFF"&&(o=fi(o));const i=new Uint8Array(o),r=Ut,h={},n={Rn:i,Ln:0,Sn:0};for(const a in r){const c=a,u=K.$n(i,c,0);if(u){const[d,f]=u;let p=h[d];p==null&&(p=r[c].Jr(i,d,f,n),h[d]=p),n[c]=p}}return[n]},$n(o,t,i){const r=C,h=r.Hr(o,i+4);let n=i+12;for(let a=0;a<h;a++){const c=r.Xr(o,n,4);r.Nr(o,n+4);const u=r.Nr(o,n+8),d=r.Nr(o,n+12);if(c===t)return[u,d];n+=16}return null},Bn:Ut,Hn:C};class vi{Gn(t){var r;const i=[];return(r=t.Fn)!=null&&r.tn?(t.Fn.tn.forEach(h=>{if(h.format===4){const n=this.Nn(h);i.push(...n)}else if(h.format===12){const n=this.Xn(h);i.push(...n)}}),[...new Set(i)]):[]}Nn(t){const i=[];if(!(t.ln&&t.cn&&t.fn&&t.un))return i;for(let r=0;r<t.ln.length;r++){const h=t.ln[r],n=t.cn[r];if(h!==65535||n!==65535){for(let a=h;a<=n;a++)if(this.Yn(t,a,r)>0)try{const c=String.fromCodePoint(a);i.push(c)}catch{}}}return i}Xn(t){const i=[];if(!t.groups)return i;for(let r=0;r<t.groups.length;r+=3){const h=t.groups[r],n=t.groups[r+1],a=t.groups[r+2];for(let c=h;c<=n;c++)if(a+(c-h)>0)try{const u=String.fromCodePoint(c);i.push(u)}catch{}}return i}Yn(t,i,r){if(t.fn[r]===0)return i+t.un[r]&65535;{const h=t.fn[r]/2+(i-t.ln[r])-(t.ln.length-r);if(h>=0&&t.dn&&h<t.dn.length){const n=t.dn[h];if(n!==0)return n+t.un[r]&65535}}return 0}}class mt{constructor(){l(this,"Kn",new Map);l(this,"jn",new Map)}Wn(t,i){const r=`${this.Zn(t)}_${i}`;if(this.Kn.has(r))return this.Kn.get(r);const h=t.Fn;if(!h||!h.tn)return this.Kn.set(r,0),0;let n=0;for(const a of h.tn)if(a.format===4?n=this.qn(i,a):a.format===12&&(n=this.Vn(i,a)),n>0)break;return this.Kn.set(r,n),n}Qn(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Wn(t,r)}Jn(t,i){const r=t.Tn;return r&&r.Mn&&r.Mn.length!==0?i<r.Mn.length?r.Mn[i]:r.Mn[r.Mn.length-1]:0}so(t,i){const r=i/t.head.pn,h=t.Cn.eo*r,n=t.Cn.io*r,a=t.Cn.ro*r;return{eo:h,io:n,ro:a,lineHeight:h-n+a,pn:t.head.pn,scale:r}}no(){this.Kn.clear(),this.jn.clear()}Zn(t){return`${t.Sn}_${t.Rn.length}`}qn(t,i){const r=i.cn.length;let h=-1;for(let n=0;n<r;n++)if(t<=i.cn[n]){h=n;break}if(h===-1||t<i.ln[h])return 0;if(i.fn[h]===0)return t+i.un[h]&65535;{const n=i.fn[h]/2+(t-i.ln[h])-(r-h);if(n>=0&&n<i.dn.length){const a=i.dn[n];return a===0?0:a+i.un[h]&65535}}return 0}Vn(t,i){const r=i.groups.length/3;for(let h=0;h<r;h++){const n=i.groups[3*h],a=i.groups[3*h+1],c=i.groups[3*h+2];if(t>=n&&t<=a)return c+(t-n)}return 0}}class mi{constructor(t){l(this,"oo");l(this,"ho");l(this,"Y");l(this,"ao");this.Y=t,this.ao=new mt,this.oo=document.createElement("canvas"),this.ho=this.oo.getContext("2d",{co:!0,alpha:!0})}lo(t,i,r,h){const n=t.length,a=Math.ceil(Math.sqrt(n)),c=Math.ceil(n/a),u=i.width*a,d=i.height*c;this.uo(u,d),this.fo(t,i,a,r,h);const f=this.Y.Ir(u,d,1,{filter:"nearest"});return f.tt(this.oo),{framebuffer:f,columns:a,rows:c}}uo(t,i){this.oo.width=t,this.oo.height=i,this.oo.style.width=t+"px",this.oo.style.height=i+"px",this.ho.imageSmoothingEnabled=!1,this.oo.style.imageRendering="pixelated",this.ho.clearRect(0,0,t,i),this.ho.textBaseline="top",this.ho.textAlign="left",this.ho.fillStyle="white"}fo(t,i,r,h,n){const a=h/n.head.pn;for(let c=0;c<t.length;c++){const u=c%r,d=Math.floor(c/r),f=t[c].do,p=this.po(n,f);if(!p)continue;const A=f.codePointAt(0)||0,g=this.ao.Wn(n,A),v=this.ao.Jn(n,g)*a,w=u*i.width,m=d*i.height,T=w+.5*i.width,y=m+.5*i.height,E=Math.round(T-.5*i.width),x=Math.round(y-.5*h),b=E+.5*(i.width-v),F=x+n.Cn.eo*a;this.vo(p,b,F,a)}}po(t,i){const r=i.codePointAt(0)||0,h=this.ao.Wn(t,r);return h===0?null:K.Bn.Pn.En(t,h)}vo(t,i,r,h){if(!t||!t.In||t.kn===0)return;let{In:n,On:a,zn:c,flags:u}=t;if(!(n&&a&&c&&u))return;this.ho.beginPath();let d=0;for(let f=0;f<c.length;f++){const p=c[f];if(!(p<d)){if(p>=d){const A=i+n[d]*h,g=r-a[d]*h;this.ho.moveTo(A,g);let v=d+1;for(;v<=p;)if(1&u[v]){const w=i+n[v]*h,m=r-a[v]*h;this.ho.lineTo(w,m),v++}else{const w=i+n[v]*h,m=r-a[v]*h;if(v+1>p){const y=i+n[d]*h,E=r-a[d]*h;if(1&u[d])this.ho.quadraticCurveTo(w,m,y,E);else{const x=(w+y)/2,b=(m+E)/2;this.ho.quadraticCurveTo(w,m,x,b)}break}const T=v+1;if(1&u[T]){const y=i+n[T]*h,E=r-a[T]*h;this.ho.quadraticCurveTo(w,m,y,E),v=T+1}else{const y=(w+(i+n[T]*h))/2,E=(m+(r-a[T]*h))/2;this.ho.quadraticCurveTo(w,m,y,E),v=T}}this.ho.closePath()}d=p+1}}this.ho.fill()}}class wi{constructor(){l(this,"mo");this.mo=new mt}Ao(t,i,r){let h=0;const n=this.mo.so(r,i),a=n.lineHeight;for(const c of t){const u=this.mo.Qn(r,c);if(u===0)continue;const d=this.mo.Jn(r,u)*n.scale;h=Math.max(h,d)}return{width:Math.ceil(h),height:Math.ceil(a)}}no(){this.mo.no()}}class yi{constructor(){l(this,"ao");this.ao=new mt}_o(t,i){return t.map((r,h)=>{const n=r.codePointAt(0)||0,a=this.yo(h);let c=0;if(i.Tn&&i.Tn.Mn){const u=this.ao.Wn(i,n);u>0&&i.Tn.Mn[u]!==void 0&&(c=i.Tn.Mn[u])}return{do:r,unicode:n,color:a,wo:c}})}yo(t){return[t%256/255,Math.floor(t/256)%256/255,0]}bo(t,i){if(!W.v(typeof t=="string","Character must be a string.",{method:"getCharacterColor",Co:t}))return[0,0,0];const r=i.find(h=>h.do===t);return r?r.color:[0,0,0]}Mo(t,i){return W.v(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",Co:t})?Array.from(t).map(r=>this.bo(r,i)||[0,0,0]):[[0,0,0]]}}class wt{constructor(t,i=16){l(this,"xo");l(this,"Fo",[]);l(this,"To");l(this,"Uo",16);l(this,"Po",0);l(this,"Eo",0);l(this,"Ro",{width:0,height:0});l(this,"$o");l(this,"So",new Map);l(this,"ko");l(this,"zo");l(this,"Io");l(this,"Oo");this.Uo=i,this.ko=new vi,this.zo=new mi(t),this.Io=new wi,this.Oo=new yi}async Do(t){let i;if(t){const r=await fetch(t);if(!r.ok)throw new R(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}else i=await(await fetch("data:font/woff;base64,d09GRgABAAAAABbwAAoAAAAAfywAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABjbWFwAAAA9AAAAbsAAAkgIO8lSWdseWYAAAKwAAAOfgAAaLS4ctN0aGVhZAAAETAAAAAsAAAAOCi8/PVoaGVhAAARXAAAABkAAAAkCwEFAmhtdHgAABF4AAAAhQAABAQEAIOAbG9jYQAAEgAAAAKUAAAECAAy54BtYXhwAAAUlAAAABgAAAAgASI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o=K.parse(i)[0],await this.Bo()}Ho(t){if(t===void 0)return this.Uo;this.Uo=t,this.Ro=this.Io.Ao(this.Fo.map(r=>r.do),this.Uo,this.xo);const i=this.zo.lo(this.Fo,this.Ro,this.Uo,this.xo);this.To=i.framebuffer,this.Po=i.columns,this.Eo=i.rows}async Go(t){try{const i=await fetch(t);if(!i.ok)throw new R(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.Lo(r);const h=K.parse(r);if(!h||h.length===0)throw new Error("Failed to parse font file");this.xo=h[0],await this.Bo()}catch(i){throw new R(`Failed to load font: ${i instanceof Error?i.message:"Unknown error"}`,i)}}async Lo(t){const i=Date.now();this.$o=new FontFace(`CustomFont_${i}`,t),await this.$o.load(),document.fonts.add(this.$o)}async Bo(){const t=this.ko.Gn(this.xo);this.So.clear(),this.Fo=this.Oo._o(t,this.xo),this.Ro=this.Io.Ao(t,this.Uo,this.xo);const i=this.zo.lo(this.Fo,this.Ro,this.Uo,this.xo);this.To=i.framebuffer,this.Po=i.columns,this.Eo=i.rows}bo(t){return this.Oo.bo(t,this.Fo)}Mo(t){return this.Oo.Mo(t,this.Fo)}No(t){if(!Number.isFinite(t))return null;const i=this.So.get(t);if(i!==void 0)return i;const r=this.Xo(t);if(r<0)return this.So.set(t,null),null;const h=this.xo.Pn;if(!h)return this.So.set(t,null),null;let n=h[r]??null;return n==null&&(n=K.Bn.Pn.En(this.xo,r)??null,h[r]=n),this.So.set(t,n),n}Xo(t){const i=this.xo.Fn;for(const r of i.tn)if(r.format===4){const h=r;for(let n=0;n<h.ln.length;n++)if(t>=h.ln[n]&&t<=h.cn[n]){if(h.fn[n]===0)return t+h.un[n]&65535;{const a=h.fn[n]/2+(t-h.ln[n])-(h.ln.length-n);if(a>=0&&a<h.dn.length){const c=h.dn[a];if(c!==0)return c+h.un[n]&65535}}}}else if(r.format===12){const h=r;for(let n=0;n<h.groups.length;n+=3){const a=h.groups[n],c=h.groups[n+1],u=h.groups[n+2];if(t>=a&&t<=c)return u+(t-a)}}return 0}D(){this.To.D(),document.fonts.delete(this.$o)}get Yo(){return this.To}get Ko(){return this.Fo}get jo(){return this.Po}get Wo(){return this.Eo}get Zo(){return this.Ro}get fontSize(){return this.Uo}get font(){return this.xo}}class yt{constructor(t,i,r){l(this,"qo");l(this,"Vo");l(this,"L");l(this,"B");l(this,"Qo");l(this,"Jo");l(this,"th");l(this,"sh");l(this,"eh");this.th=t,this.sh=i,this.eh=r,this.ih()}ih(){this.qo=Math.floor(this.th.width/this.sh),this.Vo=Math.floor(this.th.height/this.eh),this.L=this.qo*this.sh,this.B=this.Vo*this.eh,this.Qo=Math.floor((this.th.width-this.L)/2),this.Jo=Math.floor((this.th.height-this.B)/2)}rh(t,i){this.sh=t,this.eh=i,this.ih()}get nh(){return this.sh}get oh(){return this.eh}get cols(){return this.qo}get rows(){return this.Vo}get width(){return this.L}get height(){return this.B}get offsetX(){return this.Qo}get offsetY(){return this.Jo}}const Ei=/^#([0-9a-f]{3,8})$/i,Ti=/^rgba?\(([^)]+)\)$/i;function Et(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function xi(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t||t==="transparent")return null;let i=null;return t.startsWith("#")?i=function(r){const h=Ei.exec(r.trim());if(!h)return null;const n=h[1];return n.length===3?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),255]:n.length===4?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)]:n.length===6||n.length===8?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),n.length===8?parseInt(n.slice(6,8),16):255]:null}(t):t.startsWith("rgb")&&(i=function(r){const h=Ti.exec(r.trim());if(!h)return null;const n=h[1].split(",").map(f=>f.trim());if(n.length<3)return null;const a=Et(parseFloat(n[0])),c=Et(parseFloat(n[1])),u=Et(parseFloat(n[2])),d=n[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(n[3]))):255;return[a,c,u,Math.round(d)]}(t)),i?i[3]===0?null:i:null}class Nt{constructor(t={}){l(this,"th");l(this,"hh",null);l(this,"ah",!1);l(this,"uh");this.ah=t.fh??!1,this.ah&&t.canvas?(this.hh=t.canvas,this.th=this.dh(),this.uh=!0,this.ph()):t.canvas?(this.th=t.canvas,this.uh=!1):(this.th=this.gh(t.width,t.height),this.uh=!0),this.th.style.imageRendering="pixelated"}gh(t,i){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=i||600,document.body.appendChild(r),r}dh(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.hh.getBoundingClientRect();let r=Math.round(i.width),h=Math.round(i.height);if(this.hh instanceof HTMLVideoElement){const c=this.hh;(r===0||h===0)&&c.videoWidth>0&&c.videoHeight>0&&(r=c.videoWidth,h=c.videoHeight)}t.width=r,t.height=h,t.style.position="absolute",t.style.pointerEvents="none";const n=window.getComputedStyle(this.hh);let a=parseInt(n.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=(a+1).toString(),t}ph(){var t;this.mh(),(t=this.hh.parentNode)==null||t.insertBefore(this.th,this.hh.nextSibling)}Ah(){const t=[];return this.ah&&this.hh instanceof HTMLElement&&(t.push(this.hh),this.hh.parentElement&&t.push(this.hh.parentElement)),this.th.parentElement&&t.push(this.th.parentElement),t.push(this.th),t.push(document.body),t.push(document.documentElement),t}_h(){const t=this.Ah();for(const i of t){if(!i)continue;const r=xi(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}mh(){if(!this.hh)return;const t=this.hh.getBoundingClientRect();let i=this.hh.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.th.style.top=t.top-r.top+"px",this.th.style.left=t.left-r.left+"px"}else this.th.style.top=t.top+window.scrollY+"px",this.th.style.left=t.left+window.scrollX+"px"}yh(t,i){if(this.ah){const r=this.hh.getBoundingClientRect();this.th.width=Math.round(r.width),this.th.height=Math.round(r.height),this.mh()}else this.th.width=t??this.th.width,this.th.height=i??this.th.height}wh(){const t=this.th.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,bh:!0,antialias:!1,Z:!0,Ch:!1,powerPreference:"high-performance"});if(!t)throw new R("`textmode.js` requires WebGL2 support.");return t}D(){const t=this.th.getContext("webgl")||this.th.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.Mh()}this.uh&&this.th.parentNode&&this.th.parentNode.removeChild(this.th)}get canvas(){return this.th}get xh(){return this.hh}get width(){return this.th.width}get height(){return this.th.height}}const bi=/^#|0x/gi;function it(o){return Number.isNaN(o)||!Number.isFinite(o)||o<=0?0:o>=255?255:Math.round(o)}function ot(o){return it(parseInt(o,16))}class N{constructor(t,i,r,h,n){l(this,"Fh");l(this,"Th");l(this,"Yt");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=it(t),this.g=it(i),this.b=it(r),this.a=it(h),this.Fh=[this.r,this.g,this.b,this.a],this.Th=[this.r/255,this.g/255,this.b/255,this.a/255],this.Yt=n?[...n]:void 0}static Uh(t,i,r,h=255){return new N(t,i,r,h)}static Ph(t,i=255){return new N(t,t,t,i)}static Eh(t){const[i,r,h,n]=function(a){const c=a.replace(bi,""),u=(d=c).length===3||d.length===4?d.split("").map(f=>f+f).join(""):d;var d;if(u.length!==6&&u.length!==8)throw new Error(`Invalid hex color: ${a}`);return[ot(u.slice(0,2)),ot(u.slice(2,4)),ot(u.slice(4,6)),u.length===8?ot(u.slice(6,8)):255]}(t);return new N(i,r,h,n)}static Rh(t){const[i,r,h]=t;return new N(255*i,255*r,255*h,255,t)}get $h(){return[this.r,this.g,this.b]}get Sh(){return[...this.Fh]}get te(){return[...this.Th]}get do(){return this.Yt?[...this.Yt]:void 0}static kh(t){return t instanceof N}}const V=class V{constructor(t,i,r,h,n,a,c){l(this,"A");l(this,"Y");l(this,"zh");l(this,"Ih");l(this,"Oh");l(this,"L");l(this,"B");l(this,"K",null);l(this,"$t",0);l(this,"Nt",0);l(this,"Xt",0);l(this,"St",0);l(this,"Dh","sampled");l(this,"Lh","fixed");l(this,"Kt",[1,1,1,1]);l(this,"jt",[0,0,0,1]);l(this,"Bh",[0,0,0,1]);l(this,"Hh",[[.1,0,0]]);l(this,"Gh");this.A=t,this.Y=i,this.zh=r,this.Ih=h,this.Oh=n,this.L=a,this.B=c}dispose(){this.A.deleteTexture(this.zh)}ke(t=!0){return this.$t=t?1:0,this.K=null,this}flipX(t=!0){return this.Nt=t?1:0,this.K=null,this}flipY(t=!0){return this.Xt=t?1:0,this.K=null,this}Xh(t){return this.St=bt(t),this.K=null,this}Yh(t){return this.Dh=t,this.K=null,this}Kh(t){return this.Lh=t,this.K=null,this}jh(t,i,r,h){return this.Wh(this.Kt,t,i,r,h),this.K=null,this}Zh(t,i,r,h){return this.Wh(this.jt,t,i,r,h),this.K=null,this}background(t,i,r,h){return this.Wh(this.Bh,t,i,r,h),this.K=null,this}Ko(t){if(!this.Gh)throw new Error("Glyph color resolver not initialized");const i=this.Gh(t).filter(r=>Array.isArray(r)).slice(0,64);return this.Hh=i,this.K=null,this}get texture(){return this.zh}get width(){return this.L}get height(){return this.B}get qh(){return this.Ih}get Vh(){return this.Oh}ct(){return this.K||this.lt(),this.K}Qh(){}lt(){this.Qh();const t=this.Jh(),i=this.ta();this.K=this.Y.At.ji(t,i)}Wh(t,i,r,h,n){if(N.kh(i))k(t,i.r,i.g,i.b,i.a);else{if(typeof i=="string"){const a=N.Eh(i);return void k(t,a.r,a.g,a.b,a.a)}k(t,i,r,h,n)}}Jh(){return V.Nh||(V.Nh=new Z(this.A,st,`#version 300 es
|
|
11
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Uh;uniform bool Ui;uniform bool Uj;uniform bool Uk;uniform float Ul;uniform bool Um;uniform vec4 Un;uniform bool Uo;uniform vec4 Up;uniform vec4 Uq;uniform int Ur;uniform vec3 Us[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uh,C);float E=A(D.rgb);vec2 F=vec2(0.);if(Ur>0){float G=float(Ur);float H=clamp(E*(G-1.0f),0.0f,G-1.0f);int I=int(floor(H+0.5f));vec3 J=Us[I];F=J.xy;}else{F=vec2(E,0.0f);}vec4 K=Um?Un:D;vec4 L=Uo?Up:D;if(D.a<0.01f){K=Uq;L=Uq;}else{}o_primaryColor=vec4(K.rgb,K.a);o_secondaryColor=vec4(L.rgb,L.a);int M=int(Ui?1:0);int N=int(Uj?1:0);int O=int(Uk?1:0);float P=float(M|(N<<1)|(O<<2))/255.;o_character=vec4(F,P,clamp(Ul,0.0f,1.0f));}`)),V.Nh}ta(){return{sa:this.ea(),ia:!!this.$t,ra:!!this.Nt,na:!!this.Xt,oa:this.St,ha:this.Dh==="fixed",aa:this.Kt,ca:this.Lh==="fixed",la:this.jt,ua:this.Bh,fa:this.Hh.length,da:this.Hh}}};l(V,"Nh",null);let at=V;class j extends at{constructor(t,i,r,h,n,a,c){const u=Math.min(a/h,c/n);super(t,i,r,h,n,Math.max(1,Math.floor(h*u)),Math.max(1,Math.floor(n*u)))}static pa(t,i,r,h,n){const a=t.context,c=a.createTexture();a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),et(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i),a.bindTexture(a.TEXTURE_2D,null);const u=i.naturalWidth??i.width??i.videoWidth??0,d=i.naturalHeight??i.height??i.videoHeight??0,f=new j(a,t,c,u,d,r,h);return f.Gh=n,f}ea(){return this.zh}}class Fi{constructor(t=60){l(this,"ga");l(this,"va",null);l(this,"ma",0);l(this,"Aa",!0);l(this,"_a",0);l(this,"ya",0);l(this,"wa",[]);l(this,"ba",10);l(this,"Ca",0);this.ga=1e3/t}Ma(t){if(!this.Aa)return;this.ma=performance.now();const i=r=>{if(!this.Aa)return void(this.va=null);const h=r-this.ma;h>=this.ga&&(t(),this.ma=r-h%this.ga),this.Aa&&(this.va=requestAnimationFrame(i))};this.va=requestAnimationFrame(i)}xa(){this.va&&(cancelAnimationFrame(this.va),this.va=null)}Fa(){this.Aa&&(this.Aa=!1,this.xa())}Ta(t){this.Aa||(this.Aa=!0,this.Ma(t))}Ua(t,i){if(t===void 0)return this._a;this.ga=1e3/t,this.Aa&&i&&(this.xa(),this.Ma(i))}Pa(){const t=performance.now();if(this.ya>0){const i=t-this.ya;this.wa.push(i),this.wa.length>this.ba&&this.wa.shift();const r=this.wa.reduce((h,n)=>h+n,0)/this.wa.length;this._a=1e3/r}this.ya=t}get Ea(){return this.Aa}get Ra(){return this._a}get $a(){return this.Ca}set $a(t){this.Ca=t}Sa(){this.Ca++}}class Dt{constructor(t){l(this,"th");l(this,"ka");l(this,"za",{x:-1,y:-1});l(this,"Ia",{x:-1,y:-1});l(this,"Oa",null);l(this,"Da",0);l(this,"La");l(this,"Ba");l(this,"Ha");l(this,"Ga");l(this,"Na");l(this,"Xa");l(this,"Ya",!1);l(this,"Ka");l(this,"ja");l(this,"Wa");l(this,"Za");l(this,"qa");this.th=t}Va(t){const i=performance.now()+Math.max(0,t);i>this.Da&&(this.Da=i)}Qa(){return performance.now()<this.Da}Ja(t){const i=this.th.canvas;i.style.cursor=t==null||t===""?"":t}Do(t){this.ka=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.La=i=>{this.ec(i),this.rc(i)},this.Ba=()=>{this.Ia={...this.za},this.za.x=-1,this.za.y=-1,this.Oa=null},this.Ha=i=>{this.ec(i),this.nc(i)},this.Ga=i=>{this.ec(i),this.oc(i)},this.Na=i=>{this.ec(i),this.hc(i)},this.Xa=i=>{this.ec(i),this.ac(i)},t.addEventListener("mousemove",this.La,{passive:!0}),t.addEventListener("mouseleave",this.Ba,{passive:!0}),t.addEventListener("mousedown",this.Ha,{passive:!0}),t.addEventListener("mouseup",this.Ga,{passive:!0}),t.addEventListener("click",this.Na,{passive:!0}),t.addEventListener("wheel",this.Xa,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("mousemove",this.La),t.removeEventListener("mouseleave",this.Ba),t.removeEventListener("mousedown",this.Ha),t.removeEventListener("mouseup",this.Ga),t.removeEventListener("click",this.Na),t.removeEventListener("wheel",this.Xa),this.Ya=!1}tc(){if(this.Ya)try{if(this.Oa){const t=new MouseEvent("mousemove",{clientX:this.Oa.x,clientY:this.Oa.y,bubbles:!1,cancelable:!1});this.ec(t)}else this.za.x!==-1&&this.za.y!==-1&&(this.za.x>=this.ka.cols||this.za.y>=this.ka.rows)&&(this.za.x=-1,this.za.y=-1)}catch{this.za.x=-1,this.za.y=-1}}lc(t){this.Ka=t}uc(t){this.ja=t}fc(t){this.Wa=t}dc(t){this.Za=t}gc(t){this.qa=t}vc(){return{x:this.za.x,y:this.za.y}}rc(t){if(this.Za&&!this.Qa()){const i={position:{...this.za},mc:{...this.Ia},Ac:t};this.Za(i)}}nc(t){if(this.ja&&!this.Qa()){const i={position:{...this.za},mc:{...this.Ia},button:t.button,Ac:t};this.ja(i)}}oc(t){if(this.Wa&&!this.Qa()){const i={position:{...this.za},mc:{...this.Ia},button:t.button,Ac:t};this.Wa(i)}}hc(t){if(this.Ka&&!this.Qa()){const i={position:{...this.za},mc:{...this.Ia},button:t.button,Ac:t};this.Ka(i)}}ac(t){if(this.qa&&!this.Qa()){const i={position:{...this.za},mc:{...this.Ia},delta:{x:t.deltaX,y:t.deltaY},Ac:t};this.qa(i)}}ec(t){const i=this.th.canvas;this.Ia={...this.za},this.Oa={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),h=t.clientX-r.left,n=t.clientY-r.top,a=i.width/r.width,c=n*(i.height/r.height),u=h*a-this.ka.offsetX,d=c-this.ka.offsetY,f=Math.floor(u/this.ka.nh),p=Math.floor(d/this.ka.oh);f>=0&&f<this.ka.cols&&p>=0&&p<this.ka.rows?(this.za.x=f,this.za.y=p):(this.za.x=-1,this.za.y=-1)}}const Ri=Object.freeze(Object.defineProperty({__proto__:null,_c:Dt},Symbol.toStringTag,{value:"Module"}));class Bt{constructor(){l(this,"yc",new Map);l(this,"wc",null);l(this,"bc",null);l(this,"Cc");l(this,"Mc");l(this,"Ya",!1);l(this,"xc");l(this,"Fc");l(this,"Tc",{ArrowUp:"UP_ARROW",ArrowDown:"DOWN_ARROW",ArrowLeft:"LEFT_ARROW",ArrowRight:"RIGHT_ARROW",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",Enter:"ENTER",Return:"RETURN",Tab:"TAB",Escape:"ESCAPE",Backspace:"BACKSPACE",Delete:"DELETE",Insert:"INSERT",Home:"HOME",End:"END",PageUp:"PAGE_UP",PageDown:"PAGE_DOWN",Shift:"SHIFT",Control:"CONTROL",Alt:"ALT",Meta:"META"," ":"SPACE"})}sc(){this.Ya||(this.Cc=t=>{this.Uc(t)},this.Mc=t=>{this.Pc(t)},window.addEventListener("keydown",this.Cc,{passive:!1}),window.addEventListener("keyup",this.Mc,{passive:!1}),this.Ya=!0)}cc(){this.Ya&&(window.removeEventListener("keydown",this.Cc),window.removeEventListener("keyup",this.Mc),this.Ya=!1,this.yc.clear(),this.wc=null,this.bc=null)}uc(t){this.xc=t}fc(t){this.Fc=t}Ec(t){const i=this.Rc(t),r=this.yc.get(t)||this.yc.get(i);return(r==null?void 0:r.$c)||!1}Sc(){return this.wc}kc(){return this.bc}zc(){const t=[];for(const[i,r]of this.yc)r.$c&&t.push(i);return t}Ic(){return{Oc:this.Ec("Control"),shift:this.Ec("Shift"),alt:this.Ec("Alt"),Dc:this.Ec("Meta")}}Lc(){this.yc.clear(),this.wc=null,this.bc=null}Uc(t){const i=t.key,r=Date.now();this.yc.has(i)||this.yc.set(i,{$c:!1,Bc:0,Hc:0});const h=this.yc.get(i);if(!h.$c&&(h.$c=!0,h.Bc=r,this.wc=i,this.xc)){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,$c:!0,Ac:t};this.xc(n)}}Pc(t){const i=t.key,r=Date.now();this.yc.has(i)||this.yc.set(i,{$c:!1,Bc:0,Hc:0});const h=this.yc.get(i);if(h.$c=!1,h.Hc=r,this.bc=i,this.Fc){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,$c:!1,Ac:t};this.Fc(n)}}Rc(t){return this.Tc[t]||t.toLowerCase()}}const Mi=Object.freeze(Object.defineProperty({__proto__:null,Gc:Bt},Symbol.toStringTag,{value:"Module"}));class Ot{constructor(t,i){l(this,"th");l(this,"Nc");l(this,"ka");l(this,"Xc",new Map);l(this,"Yc",new Map);l(this,"Kc",new Map);l(this,"jc",null);l(this,"Wc");l(this,"Zc");l(this,"qc");l(this,"Vc");l(this,"Qc");l(this,"Jc");l(this,"Ya",!1);l(this,"tl");l(this,"sl");l(this,"el");l(this,"il");l(this,"rl");l(this,"nl");l(this,"ol");l(this,"hl");l(this,"al");l(this,"cl");l(this,"ll",320);l(this,"ul",350);l(this,"fl",10);l(this,"dl",550);l(this,"pl",14);l(this,"gl",48);l(this,"vl",650);l(this,"ml",.02);l(this,"Al",2);l(this,"_l",600);l(this,"yl",0);l(this,"wl",null);this.th=t,this.Nc=i;const r=this.th.canvas;this.Wc=r.style.touchAction,this.Zc=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}Do(t){this.ka=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.qc=i=>{this.bl(i)},this.Vc=i=>{this.Cl(i)},this.Qc=i=>{this.Ml(i)},this.Jc=i=>{this.xl(i)},t.addEventListener("touchstart",this.qc,{passive:!1}),t.addEventListener("touchmove",this.Vc,{passive:!1}),t.addEventListener("touchend",this.Qc,{passive:!1}),t.addEventListener("touchcancel",this.Jc,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("touchstart",this.qc),t.removeEventListener("touchmove",this.Vc),t.removeEventListener("touchend",this.Qc),t.removeEventListener("touchcancel",this.Jc),this.Ya=!1,this.jc=null,this.Xc.clear(),this.Yc.clear(),this.Kc.forEach(i=>{i.Fl!==null&&window.clearTimeout(i.Fl)}),this.Kc.clear(),this.wl=null,this.yl=0,t.style.touchAction=this.Wc,t.style.userSelect=this.Zc}tc(){if(!this.ka||this.Xc.size===0)return;const t=new Map;for(const i of this.Xc.values()){const r=this.Tl(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Xc=t}Ul(){return Array.from(this.Xc.values()).map(t=>({...t}))}Pl(t){this.tl=t}dc(t){this.sl=t}El(t){this.el=t}Rl(t){this.il=t}$l(t){this.rl=t}Sl(t){this.nl=t}kl(t){this.ol=t}zl(t){this.hl=t}Il(t){this.al=t}Ol(t){this.cl=t}bl(t){var h;if(!this.ka)return;t.preventDefault(),(h=this.Nc)==null||h.Va(this._l);const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const a=this.Xc.get(n.id);a&&this.Yc.set(n.id,this.Ll(a)),this.Xc.set(n.id,n);const c={id:n.id,Bl:n,Hl:n,startTime:i,Gl:i,Fl:null,Nl:!1};this.ol&&(c.Fl=window.setTimeout(()=>{const u=this.Xc.get(n.id);u&&(c.Nl=!0,this.ol({Xl:this.Ll(u),duration:performance.now()-c.startTime,Ac:t}))},this.dl)),this.Kc.set(n.id,c),this.tl&&this.tl(this.Yl(n,t,void 0,i))}this.Xc.size===2&&this.Kl()}Cl(t){var h;if(!this.ka)return;t.preventDefault(),(h=this.Nc)==null||h.Va(this._l);const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const a=this.Xc.get(n.id),c=a?this.Ll(a):void 0;c&&this.Yc.set(n.id,c),this.Xc.set(n.id,n);const u=this.Kc.get(n.id);u&&(u.Hl=n,u.Gl=i,c)&&q(c.clientX,c.clientY,n.clientX,n.clientY)>this.pl&&u.Fl!==null&&(window.clearTimeout(u.Fl),u.Fl=null),this.sl&&this.sl(this.Yl(n,t,c,i))}this.Xc.size===2?this.jl(t):this.jc=null}Ml(t){if(!this.ka)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const n=this.Xc.get(h.id),a=n?this.Ll(n):void 0,c=this.Kc.get(h.id);c&&c.Fl!==null&&(window.clearTimeout(c.Fl),c.Fl=null),this.el&&this.el(this.Yl(h,t,a,i)),c&&this.Wl(c,t),this.Kc.delete(h.id),this.Yc.delete(h.id),this.Xc.delete(h.id)}this.Xc.size<2&&(this.jc=null)}xl(t){if(!this.ka)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const n=this.Xc.get(h.id),a=n?this.Ll(n):void 0,c=this.Kc.get(h.id);c&&c.Fl!==null&&(window.clearTimeout(c.Fl),c.Fl=null),this.il&&this.il(this.Yl(h,t,a,i)),this.Kc.delete(h.id),this.Yc.delete(h.id),this.Xc.delete(h.id)}this.Xc.size<2&&(this.jc=null)}Dl(t){const i=[];for(let r=0;r<t.length;r+=1){const h=t.item(r);h&&i.push(this.Zl(h))}return i}Zl(t){return this.Tl(t.clientX,t.clientY,t.identifier,{id:t.identifier,x:-1,y:-1,clientX:t.clientX,clientY:t.clientY,pressure:t.force,radiusX:t.radiusX,radiusY:t.radiusY,rotationAngle:t.rotationAngle})}Tl(t,i,r,h){const n=this.th.canvas,a=n.getBoundingClientRect(),c=t-a.left,u=i-a.top,d=n.width/a.width,f=u*(n.height/a.height),p=c*d-this.ka.offsetX,A=f-this.ka.offsetY,g=Math.floor(p/this.ka.nh),v=Math.floor(A/this.ka.oh),w=g>=0&&g<this.ka.cols&&v>=0&&v<this.ka.rows;return{id:r,x:w?g:-1,y:w?v:-1,clientX:t,clientY:i,pressure:h.pressure,radiusX:h.radiusX,radiusY:h.radiusY,rotationAngle:h.rotationAngle}}Yl(t,i,r,h){const n=this.Kc.get(t.id),a=Array.from(this.Yc.values()).map(d=>this.Ll(d)),c=Array.from(this.Xc.values()).map(d=>this.Ll(d)),u=this.Dl(i.changedTouches);return{Xl:this.Ll(t),ql:r?this.Ll(r):void 0,touches:c,Vl:a,changedTouches:u,Ql:n?h-n.Gl:0,Ac:i}}Kl(){if(this.Xc.size!==2)return void(this.jc=null);const t=Array.from(this.Xc.values()),[i,r]=t,h=q(i.x,i.y,r.x,r.y),n=xt(i.clientX,i.clientY,r.clientX,r.clientY);this.jc={sn:[i.id,r.id],Jl:Math.max(h,1e-4),tu:n,su:1,eu:0}}jl(t){if(this.jc||this.Kl(),!this.jc)return;const[i,r]=this.jc.sn,h=this.Xc.get(i),n=this.Xc.get(r);if(!h||!n)return;const a=q(h.x,h.y,n.x,n.y)/this.jc.Jl,c=a-this.jc.su;this.al&&Math.abs(c)>this.ml&&(this.al({touches:[this.Ll(h),this.Ll(n)],scale:a,iu:c,ru:this.nu(h,n),Ac:t}),this.jc.su=a);let u=xt(h.clientX,h.clientY,n.clientX,n.clientY)-this.jc.tu;u=(u+180)%360-180;const d=u-this.jc.eu;this.cl&&Math.abs(d)>this.Al&&(this.cl({touches:[this.Ll(h),this.Ll(n)],rotation:u,ou:d,ru:this.nu(h,n),Ac:t}),this.jc.eu=u)}nu(t,i){const r=(t.clientX+i.clientX)/2,h=(t.clientY+i.clientY)/2,n=this.Tl(r,h,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:h});return{x:n.x,y:n.y}}Wl(t,i){const r=performance.now(),h=r-t.startTime,n=q(t.Bl.clientX,t.Bl.clientY,t.Hl.clientX,t.Hl.clientY);if(!t.Nl&&h<=this.ll&&n<=this.fl)this.hu(t.Hl,r)&&this.nl?this.nl({Xl:this.Ll(t.Hl),au:2,Ac:i}):this.rl&&this.rl({Xl:this.Ll(t.Hl),au:1,Ac:i});else if(!t.Nl&&h<=this.vl&&n>=this.gl){const a={x:t.Hl.clientX-t.Bl.clientX,y:t.Hl.clientY-t.Bl.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},d={x:a.x/h,y:a.y/h};this.hl&&this.hl({Xl:this.Ll(t.Hl),direction:u,cu:c,lu:d,Ac:i})}this.yl=r,this.wl=this.Ll(t.Hl)}hu(t,i){return!!this.wl&&!(i-this.yl>this.ul)&&q(t.clientX,t.clientY,this.wl.clientX,this.wl.clientY)<=this.fl}Ll(t){return{...t}}}const Li=Object.freeze(Object.defineProperty({__proto__:null,uu:Ot},Symbol.toStringTag,{value:"Module"}));class ct extends at{constructor(i,r,h,n,a,c,u,d){const f=a/c;let p,A;f>1?(p=u,A=Math.round(u/f)):(A=d,p=Math.round(d*f));super(i,r,h,a,c,p,A);l(this,"fu");l(this,"du",!1);l(this,"pu",[]);l(this,"_a",null);l(this,"gu",0);l(this,"vu",0);l(this,"mu",-1);this.fu=n}dispose(){super.dispose();for(const i of this.pu)this.A.deleteTexture(i);this.pu=[],this.fu.pause(),this.fu.src="",this.fu.load()}Au(){if(!this.du&&this.fu.readyState>=this.fu.HAVE_CURRENT_DATA){const i=this.A;i.bindTexture(i.TEXTURE_2D,this.zh),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this.fu),i.bindTexture(i.TEXTURE_2D,null)}}ea(){if(this.du&&this.pu.length>0){const i=this.vu%this.pu.length;return this.pu[i]}return this.zh}ct(){return this.K=null,super.ct()}Qh(){this.Au()}async _u(i,r){var h;try{if(i<=0)throw new Error("Video preload requires a frameRate greater than 0.");const n=this.fu.duration;if(!isFinite(n)||n<=0)throw new Error("Video duration is invalid, cannot preload frames.");const a=Math.max(1,Math.ceil(n*i));if(this.yu(i,a),await this.wu(i,r))return void this.bu("captureStream",r);await this.Cu(i,r),this.bu("seeking",r)}catch(n){const a=n instanceof Error?n:new Error(String(n));throw(h=r==null?void 0:r.Mu)==null||h.call(r,a),a}}yu(i,r){this._a=i,this.gu=r,this.pu=[],this.du=!1,this.vu=0,this.mu=-1}bu(i,r){var h;if(this.pu.length===0)throw new Error(`Video preload via ${i} completed but produced 0 frames.`);this.gu=this.pu.length,this.du=!0,this.vu=0,this.mu=-1,this.fu.pause(),this.fu.currentTime=0,r!=null&&r.xu&&r.xu({percent:100,Fu:this.gu,totalFrames:this.gu,Tu:i}),(h=r==null?void 0:r.Uu)==null||h.call(r,{totalFrames:this.gu,Tu:i})}Pu(i){const r=this.A,h=r.createTexture();return r.bindTexture(r.TEXTURE_2D,h),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),et(r,r.LINEAR,r.LINEAR,r.CLAMP_TO_EDGE,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),r.bindTexture(r.TEXTURE_2D,null),h}Eu(i,r){if(!(r!=null&&r.xu)||this.gu===0)return;const h=Math.min(99,Math.floor(this.pu.length/this.gu*100)),n=10*Math.floor(h/10);n>this.mu&&(this.mu=n,r.xu({percent:h,Fu:this.pu.length,totalFrames:this.gu,Tu:i}))}async wu(i,r){const h=globalThis,n=h==null?void 0:h.MediaStreamTrackProcessor,a=this.fu.captureStream;if(typeof n!="function"||typeof a!="function")return!1;let c,u=null;try{const d=a.call(this.fu);if(c=d.getVideoTracks()[0],!c)return d.getTracks().forEach(A=>A.stop()),!1;if(u=new n({track:c}).readable.getReader(),this.fu.currentTime=0,this.fu.muted=!0,await this.fu.play().catch(()=>{}),this.fu.paused)return!1;const f=1e6/i;let p=0;for(;this.pu.length<this.gu;){const A=await u.read();if(A.done)break;const g=A.value;if(g)try{const v=typeof g.timestamp=="number"?g.timestamp:p;(this.pu.length===0||v>=p)&&(this.pu.push(this.Pu(g)),p=v+f,this.Eu("captureStream",r))}finally{g.close()}}return u.releaseLock(),c.stop(),u=null,c=void 0,this.fu.pause(),this.fu.currentTime=0,this.pu.length!==0}catch{return this.pu=[],this.mu=-1,!1}finally{if(u)try{await u.cancel()}catch{}c&&c.stop(),this.fu.pause(),this.fu.currentTime=0}}async Cu(i,r){const h=1/i,n=this.gu,a=this.fu;a.pause();for(let c=0;c<n;c++){const u=Math.min(a.duration,c*h);await this.Ru(u),this.pu.push(this.Pu(a)),this.Eu("seeking",r)}a.currentTime=0}Ru(i){return new Promise((r,h)=>{const n=this.fu,a=()=>{n.removeEventListener("seeked",c),n.removeEventListener("error",u)},c=()=>{a(),r()},u=()=>{a(),h(new Error("Video seek failed while preloading frames."))};n.addEventListener("seeked",c,{once:!0}),n.addEventListener("error",u,{once:!0});const d=isFinite(n.duration)?n.duration:i,f=Math.min(Math.max(i,0),d);if(Math.abs(n.currentTime-f)<1e-4)return a(),void r();n.currentTime=f})}frame(i){return this.du&&i!==void 0&&this.gu>0&&(this.vu=(i%this.gu+this.gu)%this.gu,this.K=null),this}static async pa(i,r,h,n,a,c){const u=i.context,d=c==null?void 0:c.$u;let f;if(typeof r=="string"){if(f=document.createElement("video"),f.crossOrigin="anonymous",f.loop=!0,f.muted=!0,f.playsInline=!0,await new Promise((w,m)=>{f.addEventListener("loadedmetadata",()=>w(),{once:!0}),f.addEventListener("error",T=>{var E;const y=T.target;m(new Error(`Failed to load video: ${((E=y.error)==null?void 0:E.message)||"Unknown error"}`))},{once:!0}),f.src=r}),!d)try{await f.play()}catch(w){console.warn("Video autoplay prevented - you may need to call video.play() after user interaction:",w)}}else f=r,f.readyState<f.HAVE_METADATA&&await new Promise((w,m)=>{f.addEventListener("loadedmetadata",()=>w(),{once:!0}),f.addEventListener("error",T=>{var y;return m(new Error(`Video error: ${(y=T.target.error)==null?void 0:y.message}`))},{once:!0})});const p=u.createTexture();u.bindTexture(u.TEXTURE_2D,p),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),et(u,u.LINEAR,u.LINEAR,u.CLAMP_TO_EDGE,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,f),u.bindTexture(u.TEXTURE_2D,null);const A=f.videoWidth,g=f.videoHeight,v=new ct(u,i,p,f,A,g,h,n);return v.Gh=a,d&&d>0&&await v._u(d,c),v}async play(){await this.fu.play()}pause(){this.fu.pause()}stop(){this.fu.pause(),this.fu.currentTime=0}speed(i){return this.fu.playbackRate=i,this}loop(i=!0){return this.fu.loop=i,this}time(i){return this.fu.currentTime=i,this}volume(i){return this.fu.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.zh}get width(){return this.L}get height(){return this.B}get qh(){return this.Ih}get Vh(){return this.Oh}get Su(){return this.fu}get currentTime(){return this.fu.currentTime}get duration(){return this.fu.duration}get ku(){return!this.fu.paused&&!this.fu.ended}get zu(){return this.du}get totalFrames(){return this.gu}get Iu(){return this._a}get Ou(){return this.vu}}const Yi=o=>class extends o{Du(t,i,r,h){if(N.kh(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,h);throw new Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.Y.state.Jt(t),this.Y.state.ts(i),this.Y.state.ss(r)}Lu(t){this.Y.state.Jt(t)}Bu(t){this.Y.state.ts(t)}Hu(t){this.Y.state.ss(t)}translate(t=0,i=0,r=0){this.Y.state.es(t,i,r)}Gu(t){this.Y.state.es(t,0,0)}Nu(t){this.Y.state.es(0,t,0)}Xu(t){this.Y.state.es(0,0,t)}push(){this.Y.state.rt()}pop(){this.Y.state.nt()}color(t,i,r,h){if(N.kh(t))return t;if(typeof t=="string"){const n=Array.from(t);if(n.length===1){const a=n[0],c=this.xo.bo(a);return N.Rh(c)}return N.Eh(t)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?N.Uh(t,i,r,h??255):typeof i=="number"&&r===void 0?N.Ph(t,i):N.Ph(t,h??255);throw new Error("Unsupported color input passed to color().")}rect(t=1,i=1){this.Y.Er(t,i)}Yu(){this.Y.Er(1,1)}line(t,i,r,h){this.Y.Rr(t,i,r,h)}Ku(t){this.Y.state.Vt(t)}background(t,i,r,h=255){const n=this.Du(t,i,r,h);this.Y.Or(n.r,n.g,n.b,n.a)}char(t){if(N.kh(t)){const r=t.do;return void(r&&this.Y.state.cs(r))}const i=Array.from(t);if(i.length===0)throw new Error("char() requires at least one character.");this.Y.state.cs(this.xo.bo(i[0]))}jh(t,i,r,h){const n=this.Du(t,i,r,h);this.Y.state.ls(n.r,n.g,n.b,n.a)}Zh(t,i,r,h){const n=this.Du(t,i,r,h);this.Y.state.us(n.r,n.g,n.b,n.a)}flipX(t){this.Y.state.fs(t)}flipY(t){this.Y.state.ds(t)}Xh(t){this.Y.state.gs(t)}ke(t){this.Y.state.ps(t)}clear(){this.Y.Or(0,0,0,0)}ellipse(t,i){this.Y.$r(t/2,i/2)}ju(t,i,r,h,n,a){this.Y.Sr(t,i,r,h,n,a)}Wu(t,i,r,h,n,a,c,u){this.Y.kr(t,i,r,h,n,a,c,u)}arc(t,i,r,h){this.Y.zr(t/2,i/2,r,h)}Si(t){this.Y.Mr(t)}Zu(t,i){this.Y.k(t,i)}qu(t){this.Y.Fr(t)}Vu(t){return this.Y.Tr(t)}createFramebuffer(t){return this.Y.Ir(t.width,t.height,3)}image(t,i,r){this.Y.Ur(t,i,r)}Qu(){this.Y.state.As(!0)}async Ju(t){if(typeof t!="string")return j.pa(this.Y,t,this.ka.cols,this.ka.rows,h=>this.xo.Mo(h));const i=t,r=await new Promise((h,n)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>h(a),a.onerror=c=>n(c),a.src=i});return j.pa(this.Y,r,this.ka.cols,this.ka.rows,h=>this.xo.Mo(h))}async tf(t,i){return ct.pa(this.Y,t,this.ka.cols,this.ka.rows,r=>this.xo.Mo(r),i)}},Ci=o=>class extends o{async sf(t){return this.xo.Go(t).then(()=>{const i=this.xo.Zo;this.ka.rh(i.width,i.height),this.ef.resize(this.ka.cols,this.ka.rows),this.Y.Dr(),this.Nc.tc(),this.if.tc()})}fontSize(t){if(!W.v(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",Co:t})||this.xo.fontSize===t)return;this.xo.Ho(t);const i=this.xo.Zo;this.ka.rh(i.width,i.height),this.ef.resize(this.ka.cols,this.ka.rows),this.Y.Dr(),this.Nc.tc(),this.if.tc()}},Ui=o=>class extends o{get frameCount(){return this.rf.$a}set frameCount(t){this.rf.$a=t}$u(t){return t===void 0?this.rf.Ra:this.rf.Ua(t,()=>this.nf())}hf(){this.rf.Fa()}loop(){this.rf.Ta(()=>this.nf())}af(t=1){if(W.v(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",Co:t}))for(let i=0;i<t;i++)this.nf()}cf(){return this.rf.Ea}},Ni=o=>class extends o{constructor(...t){super(...t)}lf(t){this.Nc.lc(t)}uf(t){this.Nc.uc(t)}ff(t){this.Nc.fc(t)}df(t){this.Nc.dc(t)}pf(t){this.Nc.gc(t)}get gf(){return this.Nc.vc()}cursor(t){this.Nc.Ja(t)}},Di=o=>class extends o{constructor(...t){super(...t)}vf(t){this.if.Pl(t)}mf(t){this.if.dc(t)}Af(t){this.if.El(t)}_f(t){this.if.Rl(t)}yf(t){this.if.$l(t)}wf(t){this.if.Sl(t)}bf(t){this.if.kl(t)}Cf(t){this.if.zl(t)}Mf(t){this.if.Il(t)}xf(t){this.if.Ol(t)}get touches(){return this.if.Ul()}},Bi=o=>class extends o{constructor(...t){super(...t)}Ff(t){this.Tf.uc(t)}Uf(t){this.Tf.fc(t)}Pf(t){return this.Tf.Ec(t)}get Ef(){return this.Tf.Sc()}get Rf(){return this.Tf.kc()}get $f(){return this.Tf.zc()}get Sf(){return this.Tf.Ic()}};class Oi{constructor(t){l(this,"kf");l(this,"zf",new Map);l(this,"If",[]);l(this,"Of",new Map);l(this,"Df",new Map);this.kf=t}async Lf(t){for(const i of t){if(this.zf.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.Bf(i.name);try{await i.install(this.kf,r)}catch(h){throw this.Hf(i.name),h}this.zf.set(i.name,i),this.If.push(i.name)}}async Gf(t){const i=this.zf.get(t);if(!i)return;const r=this.Bf(t);i.Nf&&await i.Nf(this.kf,r),this.zf.delete(t),this.If.splice(this.If.indexOf(t),1),this.Hf(t)}Xf(){this.Yf(this.Of)}Kf(){this.Yf(this.Df)}async jf(){const t=[...this.zf.keys()];for(const i of t)await this.Gf(i)}Bf(t){return{Wf:this.kf.Y,font:this.kf.xo,grid:this.kf.ka,canvas:this.kf.th,Zf:this.kf.ef,qf:this.kf.Vf,Qf:i=>this.Jf(this.Of,t,i),td:i=>this.Jf(this.Df,t,i)}}Jf(t,i,r){const h=t.get(i)??new Set;return h.add(r),t.set(i,h),()=>{const n=t.get(i);n&&(n.delete(r),n.size===0&&t.delete(i))}}Hf(t){this.Of.delete(t),this.Df.delete(t)}Yf(t){for(const i of this.If){const r=t.get(i);r&&r.forEach(h=>h())}}}const It=`#version 300 es
|
|
12
|
+
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class Pt{constructor(){l(this,"sd",new Map);l(this,"ed",[]);l(this,"rd",0);l(this,"nd",0);l(this,"od")}get hd(){return this.rd}get ad(){if(this.rd===0)return 0;let t=0;for(const i of this.ed){const r=this.sd.get(i);r&&(t+=Math.min(1,Math.max(0,r.ad))*r.weight)}return Math.min(1,t/this.rd)}ld(t){this.od=t}ud(t,i=1){const r=`phase-${this.ed.length+1}-${Date.now()}`,h={id:r,label:t,weight:Math.max(.001,i),ad:0,status:"running"};return this.sd.set(r,h),this.ed.push(r),this.rd+=h.weight,r}fd(t,i){const r=this.sd.get(t);if(!r)return;r.ad=Math.max(0,Math.min(1,i)),r.status=r.ad>=1?"complete":"running";const h=this.ad;Math.abs(h-this.nd)>.001&&(this.nd=h,this.od&&this.od(h))}dd(t){const i=this.sd.get(t);i&&(i.ad=1,i.status="complete",this.fd(t,1))}pd(t){const i=this.sd.get(t);i&&(i.status="failed")}gd(){return this.ed.map(t=>{const i=this.sd.get(t);return i?{id:i.id,label:i.label,weight:i.weight,ad:i.ad,status:i.status}:{id:t,label:t,weight:1,ad:0,status:"pending"}})}}class Xt{constructor(t="active"){l(this,"vd");l(this,"md","");l(this,"Ad","");this.vd=t}get state(){return this.vd}get isEnabled(){return this.vd!=="disabled"}get _d(){return this.vd==="active"||this.vd==="transitioning"||this.vd==="error"}get yd(){return this.md}get wd(){return this.Ad}bd(){this.vd!=="done"&&this.vd!=="transitioning"||(this.vd="active")}finish(){this.vd!=="disabled"&&(this.vd="done")}Cd(){this.vd!=="disabled"&&(this.vd="transitioning")}Md(){this.vd==="transitioning"&&(this.vd="done")}xd(t){this.vd!=="disabled"&&(this.vd="error",t instanceof Error?(this.md=t.message,this.Ad=t.stack||""):(this.md=t,this.Ad=""))}disable(){this.vd="disabled"}}class zt{constructor(t,i){l(this,"Fd",0);l(this,"Td",1);l(this,"Ud");l(this,"Pd");this.Ud=t,this.Pd=i}get opacity(){return this.Td}get Ed(){return this.Td<1}start(){this.Ud!=="none"&&this.Pd>0&&(this.Fd=performance.now())}update(){if(this.Ud==="none"||this.Pd===0)return this.Td=1,!1;const t=performance.now()-this.Fd,i=Math.min(1,t/this.Pd);return i>=1?(this.Td=0,!0):(this.Td=1-i,!1)}reset(){this.Td=1,this.Fd=0}}function Tt(o,t){const i=o.tone??"auto";let r="dark";return i==="light"||i==="dark"?r=i:t&&(r=function(h){if(!h)return 0;const[n,a,c]=h.map(d=>d/255),u=d=>d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4);return .2126*u(n)+.7152*u(a)+.0722*u(c)}(t)>.5?"light":"dark"),{mode:r,background:t,Rd:r==="light"?"#1A1A1A":"#F8F8F8",$d:r==="light"?"#4A4A4A":"#C0C0C0"}}function St(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function kt(o,t){return o.length?o.map(i=>t.color(i)):[t.color("#FFFFFF")]}const Ii=({Sd:o,grid:t,ad:i,frameCount:r,message:h,palette:n,theme:a,kd:c,zd:u,Id:d,yd:f})=>{const p="|/-\\",A=Math.floor(r/6)%4,g=o.color(a.Rd),v=Math.floor(255*u),w=o.color(g.r,g.g,g.b,v);if(o.jh(w),o.Zh(0,0,0,0),d){const m=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",v);o.jh(m),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const T="SETUP ERROR",y=-Math.floor(T.length/2);o.push(),o.translate(y,0,0);for(const E of T)o.char(E),o.rect(1,1),o.Gu(1);if(o.pop(),f){const E=o.color(a.$d),x=o.color(E.r,E.g,E.b,v);o.jh(x);const b=Math.floor(.8*t.cols),F=f.split(" "),U=[];let M="";for(const B of F)(M+" "+B).length<=b?M=M?M+" "+B:B:(M&&U.push(M),M=B);M&&U.push(M);const I=U.slice(0,3);U.length>3&&(I[2]=I[2].substring(0,b-3)+"..."),I.forEach((B,ut)=>{const ji=-Math.floor(B.length/2);o.push(),o.translate(ji,3+ut,0);for(const _i of B)o.char(_i),o.rect(1,1),o.Gu(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(p[A]),o.rect(1,1),o.pop(),i>0||c.some(m=>m.status!=="pending")){const m=Math.max(6,Math.floor(.6*t.cols)),T=-Math.floor(m/2),y=Math.floor(m*i),E=n.length?n:[o.color("#FFFFFF")];o.push(),o.translate(T,3,0);for(let x=0;x<m;x++){const b=x<y?"*":".",F=E[x%E.length],U=o.color(F.r,F.g,F.b,v);o.jh(U),o.char(b),o.rect(1,1),o.Gu(1)}o.pop()}if(h){const m=o.color(a.$d),T=o.color(m.r,m.g,m.b,v);o.jh(T);const y=-Math.floor(h.toUpperCase().length/2);o.push(),o.translate(y,5,0);for(const E of h.toUpperCase())o.char(E),o.rect(1,1),o.Gu(1);o.pop()}},Pi={message:"loading...",tone:"auto",transition:"fade",transitionDuration:500};class Xi{constructor(t,i,r){this.Od=t,this.id=i,this.label=r}Dd(t){this.Od.fd(this.id,t)}complete(){this.Od.dd(this.id)}Ld(t){this.Od.pd(this.id)}async track(t){try{const i=typeof t=="function"?await t():await t;return this.complete(),i}catch(i){throw this.Ld(),i}}}class Ht{constructor(t,i,r){l(this,"kf");l(this,"h");l(this,"Bd");l(this,"Od");l(this,"Hd");l(this,"Y");l(this,"Gd",[]);l(this,"Nd");l(this,"Xd",performance.now());l(this,"Wd");this.kf=t,this.h={...Pi,...i??{}},this.Bd=new Xt("active"),this.Od=new Pt,this.Hd=new zt(this.h.transition,this.h.transitionDuration),this.Nd=Tt(this.h,r);const h=St(this.Nd);this.Gd=kt(h,this.kf),this.Y=this.Yd(),this.Od.ld(n=>{n>=.999&&this.finish()})}get _d(){return this.Bd._d}get ad(){return this.Od.ad}message(t){return typeof t=="string"&&(this.h.message=t),this.h.message}Kd(t,i=1){this.Bd.bd();const r=this.Od.ud(t,i);return new Xi(this.Od,r,t)}finish(){this.h.transition!=="none"&&this.h.transitionDuration>0?(this.Bd.Cd(),this.Hd.start()):(this.Bd.finish(),this.jd())}jd(){this.Wd&&this.Wd()}Zd(t){this.Wd=t}error(t){this.Bd.xd(t)}qd(t){if(!this._d)return;const i=this.kf.Vd;if(i){if(this.Bd.state==="transitioning"&&this.Hd.update())return this.Bd.Md(),void this.jd();this.kf.clear(),this.kf.push();try{const r={Sd:this.kf,grid:i,ad:this.ad,Qd:performance.now()-this.Xd,frameCount:t,message:this.h.message,palette:this.Gd,theme:this.Nd,kd:this.Od.gd(),zd:this.Hd.opacity,Id:this.Bd.state==="error",yd:this.Bd.yd||void 0,wd:this.Bd.wd||void 0};this.Y(r)}finally{this.kf.pop()}}}Jd(t){this.Nd=Tt(this.h,t)}Yd(){const t=this.h.Wf||Ii;return i=>{t(i),this.tp(i)}}tp(t){const{Sd:i,grid:r,frameCount:h,theme:n,zd:a}=t,c=[116,101,120,116,109,111,100,101,46,106,115].map(p=>String.fromCharCode(p)).join(""),u=(r.rows+1>>1)-2,d=2-(r.cols+1>>1),f=n.mode==="light"?[[255,107,107],[78,205,196],[69,183,209],[255,160,122],[152,216,200]]:[[255,107,157],[199,128,250],[78,205,196],[255,217,61],[107,207,127]];i.push(),i.translate(d,u,0);for(let p=0;p<c.length;p++){const A=c[p],g=Math.floor(.1*h+.5*p)%f.length,[v,w,m]=f[g],T=Math.floor(255*a),y=i.color(v,w,m,T);i.jh(y),i.char(A),i.rect(1,1),i.Gu(1)}i.pop()}}class Gt extends function(i,...r){return r.reduce((h,n)=>n(h),i)}(class{},Yi,Ci,Ui,Ni,Di,Bi){constructor(i={}){super();l(this,"Y");l(this,"xo");l(this,"sp");l(this,"th");l(this,"ka");l(this,"Vd");l(this,"rf");l(this,"Nc");l(this,"if");l(this,"Tf");l(this,"ef");l(this,"ep");l(this,"ip");l(this,"Vf");l(this,"rp");l(this,"np");l(this,"op");l(this,"hp");l(this,"ap",!1);l(this,"cp",!1);l(this,"lp",!1);l(this,"up",!1);l(this,"fp",()=>{});l(this,"dp",()=>{});l(this,"pp",()=>{});l(this,"gp");l(this,"vp");l(this,"ah",!1);l(this,"mp");this.op=new Oi(this),this.ah=i.fh??!1,this.th=new Nt(i),this.Y=new oi(this.th.wh()),this.xo=new wt(this.Y,i.fontSize??16),this.sp=new wt(this.Y,16),this.rf=new Fi(i.$u??60),this.hp=new Ht(this,i.Ap,this.th._h()),this.hp.Zd(()=>{this.rf.$a=0,this.up=!0}),this.Nc=new Dt(this.th),this.if=new Ot(this.th,this.Nc),this.Tf=new Bt,this.ip=this.Y.Cr(It,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U2;uniform vec2 U5;uniform vec2 U6;uniform vec4 U8;in vec2 v_uv;out vec4 fragColor;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U6;vec2 F=E*U5;vec2 G=floor(F);vec2 H=(G+0.5)/U5;vec4 I=texture(U3,H);vec4 J=texture(U4,H);vec4 K=texture(U2,H);int L=int(K.b*255.+0.5);bool M=(L&1)!=0;bool N=(L&2)!=0;bool O=(L&4)!=0;int P=int(K.r*255.+0.5)+int(K.g*255.+0.5)*256;int Q=int(U1.x);int R=P/Q;int S=P-(R*Q);float T=(U1.y-1.)-float(R);vec2 U=1./U1;vec2 V=vec2(float(S),T)*U;vec2 W=V+U;float X=-K.a*360.*0.017453292;vec2 Y=fract(F)-0.5f;vec2 Z=vec2(N?-1.:1.,O?-1.:1.);Y*=Z;Y=A(X)*Y+0.5;vec2 a=V+clamp(Y,0.,1.)*U;const float b=0.0001;if(any(lessThan(a,V-b))||any(greaterThan(a,W+b))){fragColor=M?I:J;return;}vec4 c=texture(U0,a);if(M)c.rgb=mix(c.rgb,1.-c.rgb,float(M));vec4 d=mix(U8,J,J.a);fragColor=mix(d,I,c);}`),this._p(i)}async _p(i){await Promise.all([this.xo.Do(i.yp),this.sp.Do(i.yp)]);const r=this.xo.Zo;this.ka=new yt(this.th.canvas,r.width,r.height);const h=this.sp.Zo;this.Vd=new yt(this.th.canvas,h.width,h.height),this.Nc.Do(this.ka),this.if.Do(this.ka),this.ef=this.Y.Ir(this.ka.cols,this.ka.rows,3),this.ep=this.Y.Ir(this.Vd.cols,this.Vd.rows,3),this.Vf=this.Y.Ir(this.ka.width,this.ka.height,1),this.rp=this.Y.Ir(this.Vd.width,this.Vd.height,1),this.ah&&(this.mp=j.pa(this.Y,this.th.xh,this.ka.cols,this.ka.rows,n=>this.xo.Mo(n))),this.np=this.Y.Cr(It,`#version 300 es
|
|
14
|
+
precision highp float;uniform sampler2D U9;uniform vec2 Ua;uniform vec2 Ub;uniform vec2 Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-Ub;vec2 B=A*(Ua/Uc);vec2 C=(floor(B)+0.5)/Ua;fragColor=texture(U9,C);}`),this.wp(),this.rf.Ma(()=>this.nf()),await this.op.Lf(i.plugins??[]);try{await this.fp(),this.hp.finish()}catch(n){console.error("Error during setup:",n),this.hp.error(n)}}wp(){this.gp=()=>{this.ah&&this.bp(this.th.xh.width,this.th.xh.height),this.pp()},window.addEventListener("resize",this.gp),this.Nc.sc(),this.if.sc(),this.Tf.sc(),window.addEventListener("blur",()=>{this.Tf.Lc()}),this.ah&&(this.vp=new ResizeObserver(()=>{this.bp(this.th.xh.width,this.th.xh.height)}),this.vp.observe(this.th.xh))}nf(){this.cp=!0;try{this.rf.Pa(),this.rf.Sa(),this.ah&&Ft(this.Y.context,this.mp.texture,this.th.xh);const i=this.hp._d,r=this.up&&!i;r&&this.op.Xf(),this.Y.state.Qt();const h=i?this.ep:this.ef,n=i?this.sp:this.xo,a=i?this.Vd:this.ka,c=i?this.rp:this.Vf;h.st(),i?this.hp.qd(this.rf.$a):r&&this.dp(),h.end(),c.st(),this.Y.br(this.ip),this.ip.S({Cp:n.Yo,Mp:[n.jo,n.Wo],xp:h.I[0],Fp:h.I[1],Tp:h.I[2],Up:[a.cols,a.rows],Pp:[c.width,c.height],zi:c.width/c.height,Ep:this.Y.state._s}),this.Y.Pr(0,0,this.th.width,this.th.height),c.end(),this.Y.cr(...this.Y.state._s),this.Y.br(this.np),this.np.S({Rp:c.I[0],$p:[c.width,c.height],Sp:[a.offsetX,a.offsetY],kp:[a.width,a.height]}),this.Y.Pr(a.offsetX,a.offsetY,a.width,a.height),r&&this.op.Kf()}finally{this.cp=!1,this.ap&&!this.lp&&this.zp()}}bp(i,r){this.th.yh(i,r),this.hp.Jd(this.th._h()),this.ka.ih(),this.Vd.ih(),this.ef.resize(this.ka.cols,this.ka.rows),this.Vf.resize(this.ka.width,this.ka.height),this.ep.resize(this.Vd.cols,this.Vd.rows),this.rp.resize(this.Vd.width,this.Vd.height),this.Y.Dr(),this.Nc.tc(),this.if.tc(),this.nf()}destroy(){this.lp||this.ap||(this.ap=!0,this.rf.Fa(),this.cp||this.zp())}zp(){var i,r;this.ap=!1,this.op.jf(),window.removeEventListener("resize",this.gp),(i=this.vp)==null||i.disconnect(),this.Nc.cc(),this.if.cc(),this.Tf.cc(),this.ef.D(),this.ep.D(),this.ip.D(),this.xo.D(),this.sp.D(),this.Y.D(),this.Vf.D(),this.rp.D(),this.np.D(),(r=this.mp)==null||r.dispose(),this.th.D(),this.lp=!0}Ip(i){this.fp=i}draw(i){this.dp=i}Op(i){this.pp=i}get grid(){return this.ka}get font(){return this.xo}get width(){return this.th.width}get height(){return this.th.height}get canvas(){return this.th.canvas}get Zf(){return this.ef}get Dp(){return this.lp}get fh(){return this.mp}get loading(){return this.hp}}class lt{constructor(){}static create(t={}){return new Gt(t)}static Lp(t){W.m(t)}static get version(){return"0.6.0-beta.1"}}const zi=Object.freeze(Object.defineProperty({__proto__:null,Bp:Pt,Hp:Ht,Gp:Xt,Np:zt,Xp:kt,Yp:St,Kp:Tt},Symbol.toStringTag,{value:"Module"})),Si=Object.freeze(Object.defineProperty({__proto__:null,jp:wt,Wp:j,Zp:ct},Symbol.toStringTag,{value:"Module"})),ki=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Mi,gf:Ri,Xl:Li},Symbol.toStringTag,{value:"Module"})),Hi=lt.create,Gi=lt.Lp,Ki=lt.version;L.qp=Nt,L.Vp=N,L.Qp=z,L.Jp=Q,L.tg=yt,L.sg=Gt,L.create=Hi,L.input=ki,L.eg=Si,L.loading=zi,L.Lp=Gi,L.ig=lt,L.version=Ki,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):e((s=typeof globalThis<"u"?globalThis:s||self).ig={});
|