textmode.js 0.6.0-beta.3 → 0.6.0-beta.4
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/README.md +59 -19
- package/dist/textmode.esm.js +1669 -1594
- package/dist/textmode.umd.js +10 -10
- package/dist/types/index.d.ts +3 -1
- package/dist/types/rendering/webgl/core/Renderer.d.ts +4 -2
- package/dist/types/textmode/TextmodeColor.d.ts +16 -1
- package/dist/types/textmode/Textmodifier.d.ts +4 -0
- package/dist/types/textmode/conversion/ConversionRegistry.d.ts +21 -0
- package/dist/types/textmode/conversion/index.d.ts +1 -0
- package/dist/types/textmode/conversion/strategies/brightness.d.ts +2 -0
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +5 -0
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +2 -1
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +36 -5
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +3 -2
- package/dist/types/textmode/loadables/index.d.ts +3 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +3 -2
- package/dist/types/utils/color.d.ts +1 -0
- package/package.json +2 -3
- package/dist/textmode.esm.min.js +0 -3490
- package/dist/textmode.umd.min.js +0 -14
package/dist/textmode.umd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Qe=Object.defineProperty;var qe=(x,P,O)=>P in x?Qe(x,P,{enumerable:!0,configurable:!0,writable:!0,value:O}):x[P]=O;var l=(x,P,O)=>qe(x,typeof P!="symbol"?P+"":P,O);var s,e;s=this,e=function(x){class P extends Error{constructor(t,i={}){super(P.i(t,i)),this.name="TextmodeError"}static i(t,i){return`${t}${i&&Object.keys(i).length>0?`
|
|
2
2
|
|
|
3
3
|
📋 Context:`+Object.entries(i).map(([r,h])=>`
|
|
4
|
-
- ${r}: ${
|
|
4
|
+
- ${r}: ${P.o(h)}`).join(""):""}
|
|
5
5
|
|
|
6
6
|
${"↓".repeat(24)}
|
|
7
|
-
`}static o(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 t+"";if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(i=>
|
|
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
|
|
9
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Uc;uniform sampler2D Ud;uniform sampler2D Ue;uniform vec2 Uf;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*Uf;vec2 C=(floor(B)+0.5f)/Uf;vec4 D=texture(Uc,C);vec4 E=texture(Ud,C);if(E.a==0.){discard;}vec4 F=texture(Ue,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const u=t.getParameter(t.MAX_DRAW_BUFFERS),f=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,u,f),this.N=t.createFramebuffer(),this.V(),this.J(),this.l.depth&&this.tt()}V(){const t=this.A,i=this.l.filter==="linear"?t.LINEAR:t.NEAREST,r=this.l.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,h=this.l.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,n=h===t.FLOAT?t.RGBA32F:t.RGBA8,a=t.RGBA;for(let c=0;c<this.K;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),it(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,n,this.H,this.G,0,a,h,null),this.X.push(u)}t.bindTexture(t.TEXTURE_2D,null)}J(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.N),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.X[0],0);else{const i=[];for(let r=0;r<this.K;r++){const h=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,h,t.TEXTURE_2D,this.X[r],0),i.push(h)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}tt(){const t=this.A;this.Y=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.Y),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.H,this.G),t.bindFramebuffer(t.FRAMEBUFFER,this.N),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.Y),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}st(t){Rt(this.A,this.X[0],t)}resize(t,i){this.H=t,this.G=i,this.W.clear();const r=this.A,h=this.l.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,n=h===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.X)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,n,this.H,this.G,0,a,h,null);r.bindTexture(r.TEXTURE_2D,null),this.Y&&(r.bindRenderbuffer(r.RENDERBUFFER,this.Y),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.H,this.G),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.W.get(t);if(i)return i;const r=this.A,h=this.H,n=this.G,a=new Uint8Array(h*n*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.N),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,f=new Uint8Array(a.length);for(let d=0;d<n;d++){const g=(n-1-d)*u,p=d*u;f.set(a.subarray(g,g+u),p)}return this.W.set(t,f),f}begin(){const t=this.A;this.W.clear(),this.j.et(),this.j.it(this.N,this.H,this.G),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.j.state.rt()}end(){this.j.state.nt(),this.j.ot();const t=this.j.ht();this.j.it(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.Z||this.lt(),this.Z}lt(){if(!this.j)return;const t={Uc:this.X[0],Ud:this.X[1],Ue:this.X[2],Uf:[this.H,this.G]},i=K.q;this.Z=this.j.ft.ut(i,t,!0)}D(){const t=this.A;t.deleteFramebuffer(this.N);for(const i of this.X)t.deleteTexture(i);this.Y&&t.deleteRenderbuffer(this.Y)}get width(){return this.H}get height(){return this.G}get textures(){return this.X}get attachmentCount(){return this.K}};l(K,"q",null);let Q=K;const Pt=new WeakMap;function gt(o,t){Pt.set(o,t)}function Ct(o){return Pt.get(o)}function Y(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 st{constructor(){l(this,"dt",1);l(this,"gt",0);l(this,"vt",0);l(this,"_t",0);l(this,"At",0);l(this,"yt",0);l(this,"wt",0);l(this,"bt",[0,0,0]);l(this,"Ct",[1,1,1,1]);l(this,"Mt",[0,0,0,1]);l(this,"xt",!1);l(this,"Ft",!1);l(this,"$t",!1);l(this,"Tt",0);l(this,"Pt",[0,0,0,1]);l(this,"Et",!1);l(this,"Rt",[]);l(this,"St",[])}static kt(){return{zt:1,It:0,Ot:0,Lt:0,At:0,yt:0,wt:0,Tt:0,Dt:!1,Bt:!1,$t:!1,Et:!1,Ht:[0,0,0],Gt:[1,1,1,1],Nt:[0,0,0,1]}}Xt(t){t.zt=this.dt,t.It=this.gt,t.Ot=this.vt,t.Lt=this._t,t.At=this.At,t.yt=this.yt,t.wt=this.wt,t.Dt=this.xt,t.Bt=this.Ft,t.$t=this.$t,t.Tt=this.Tt,t.Et=this.Et,t.Ht[0]=this.bt[0],t.Ht[1]=this.bt[1],t.Ht[2]=this.bt[2],t.Gt[0]=this.Ct[0],t.Gt[1]=this.Ct[1],t.Gt[2]=this.Ct[2],t.Gt[3]=this.Ct[3],t.Nt[0]=this.Mt[0],t.Nt[1]=this.Mt[1],t.Nt[2]=this.Mt[2],t.Nt[3]=this.Mt[3]}Yt(t){this.dt=t.zt,this.gt=t.It,this.vt=t.Ot,this._t=t.Lt,this.At=t.At,this.yt=t.yt,this.wt=t.wt,this.xt=t.Dt,this.Ft=t.Bt,this.$t=t.$t,this.Tt=t.Tt,this.Et=t.Et,this.bt[0]=t.Ht[0],this.bt[1]=t.Ht[1],this.bt[2]=t.Ht[2],this.Ct[0]=t.Gt[0],this.Ct[1]=t.Gt[1],this.Ct[2]=t.Gt[2],this.Ct[3]=t.Gt[3],this.Mt[0]=t.Nt[0],this.Mt[1]=t.Nt[1],this.Mt[2]=t.Nt[2],this.Mt[3]=t.Nt[3]}rt(){let t=this.St.pop();t||(t=st.kt()),this.Xt(t),this.Rt.push(t)}nt(){const t=this.Rt.pop();t?(this.Yt(t),this.St.push(t)):console.warn("pop() called without matching push()")}Kt(t){this.Xt(t)}jt(t){this.dt=Math.abs(t)}Zt(){this.gt=0,this.vt=0,this._t=0,this.At=0,this.yt=0,this.wt=0,this.Et=!1}Wt(t){t!==0&&(this.At+=t*Math.PI/180)}qt(t){t!==0&&(this.yt+=t*Math.PI/180)}Vt(t){t!==0&&(this.wt+=t*Math.PI/180)}Qt(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.gt+=t,this.vt+=i,this._t+=r)}Jt(t){this.Qt(t,0,0)}ts(t){this.Qt(0,t,0)}ss(t){this.Qt(0,0,t)}es(t){this.bt[0]=t[0],this.bt[1]=t[1],this.bt[2]=t[2]}rs(t,i,r,h=255){Y(this.Ct,t,i,r,h)}ns(t,i,r,h=255){Y(this.Mt,t,i,r,h)}hs(t){this.xt=t}cs(t){this.Ft=t}ls(t){this.$t=t}us(t){this.Tt=xt(t)}fs(t,i,r,h){Y(this.Pt,t,i,r,h)}ds(t){this.Et=t}get canvasBackgroundColor(){return this.Pt}get useOrtho(){return this.Et}get rotationX(){return this.At}get rotationY(){return this.yt}get rotationZ(){return this.wt}}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]),j={ps:16,gs:WebGL2RenderingContext.TRIANGLES,vs:{_s:{size:2,offset:0},As:{size:2,offset:8}}};class kt{constructor(t){l(this,"A");l(this,"ws");l(this,"bs");this.A=t,this.ws=t.createBuffer(),this.bs=new Float32Array(At.length)}Cs(t,i,r,h){const n=this.A,a=Ct(this.A),c=a[2],u=a[3],f=t/c*2-1,d=(t+r)/c*2-1,g=1-(i+h)/u*2,p=1-i/u*2,m=At,v=this.bs;for(let A=0;A<m.length;A+=4){const E=m[A],y=m[A+1],T=m[A+2],w=m[A+3],R=f+(E+.5)*(d-f),b=g+(y+.5)*(p-g);v[A]=R,v[A+1]=b,v[A+2]=T,v[A+3]=w}n.bindBuffer(n.ARRAY_BUFFER,this.ws),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.ws)}}var P=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(P||{});const Kt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class Wt{constructor(t){l(this,"A");l(this,"Ms",new Map);this.A=t}Fs(t,i,r,h){const n=this.A;let a=this.Ms.get(t);a||(a=new Map,this.Ms.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.vs._s.size,r.ps,r.vs._s.offset,0,n.FLOAT,!1);const f=n.getAttribLocation(t,"A1");f!==-1&&dt(n,f,r.vs.As.size,r.ps,r.vs.As.offset,0,n.FLOAT,!1)}n.bindVertexArray(c)}$s(){this.A.bindVertexArray(null)}D(){for(const[,t]of this.Ms)for(const[,i]of t)i&&this.A.deleteVertexArray(i)}}const O=class O{static Ts(t,i,r=0){const h=i||new Float32Array(O.FLOATS_PER_INSTANCE);let n=r;h[n++]=t._s[0],h[n++]=t._s[1],h[n++]=t.Ps[0],h[n++]=t.Ps[1],h[n++]=t.Ht[0],h[n++]=t.Ht[1],h[n++]=t.Ht[2],h[n++]=t.Gt[0],h[n++]=t.Gt[1],h[n++]=t.Gt[2],h[n++]=t.Gt[3],h[n++]=t.Nt[0],h[n++]=t.Nt[1],h[n++]=t.Nt[2],h[n++]=t.Nt[3],h[n++]=t.Es[0],h[n++]=t.Es[1],h[n++]=t.Es[2],h[n++]=t.Tt;const a=t.Rs;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.Ss;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.ks,f=t.zs,d=t.Is,g=t.Os,p=t.Ls,m=!(!f||!d);return m?(h[n++]=(g==null?void 0:g[0])??0,h[n++]=(g==null?void 0:g[1])??0,h[n++]=(p==null?void 0:p[0])??0,h[n++]=(p==null?void 0:p[1])??0,h[n++]=f[0],h[n++]=f[1],h[n++]=d[0],h[n++]=d[1]):!m&&!!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.Ds??0,h[n++]=t.Bs??0,h[n++]=t.Hs??0,h}static Gs(t,i){const r=t.length*O.FLOATS_PER_INSTANCE,h=i||new Float32Array(r);for(let n=0;n<t.length;n++){const a=n*O.FLOATS_PER_INSTANCE;O.Ts(t[n],h,a)}return h}};l(O,"BYTES_PER_INSTANCE",144),l(O,"FLOATS_PER_INSTANCE",36);let L=O;const U=class U{};l(U,"STRIDE",L.BYTES_PER_INSTANCE),l(U,"ATTRIBUTES",{A2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:0,divisor:1},A3:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:8,divisor:1},A4:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:16,divisor:1},A5:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:28,divisor:1},A6:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:44,divisor:1},A7:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:60,divisor:1},A8:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:76,divisor:1},A9:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:88,divisor:1},Aa:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:100,divisor:1},Ab:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:116,divisor:1},Ac:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:U.STRIDE,offset:132,divisor:1}});let J=U;class Zt{constructor(t=1e3,i=1.5){l(this,"Ns");l(this,"Xs");l(this,"Ys");l(this,"Ks",0);l(this,"js",0);this.Xs=t,this.Ys=i;const r=t*L.FLOATS_PER_INSTANCE;this.Ns=new Float32Array(r)}Zs(t){if(t<=this.Xs)return;const i=Math.ceil(t*this.Ys),r=this.Xs;this.Xs=i;const h=i*L.FLOATS_PER_INSTANCE,n=new Float32Array(h),a=r*L.FLOATS_PER_INSTANCE;n.set(this.Ns.subarray(0,Math.min(a,this.Ks))),this.Ns=n}Ws(){return{buffer:this.Ns,offset:this.Ks}}qs(t){this.Ks+=t,this.js++}Vs(){this.Ks=0,this.js=0}Qs(t=0,i){return this.Ns.subarray(t,i??this.Ks)}get Js(){return this.js}get te(){return this.Xs}get se(){return this.Ks}get ee(){return this.js===0}}class Vt{constructor(t){l(this,"Ns");this.Ns=t}ie(t){this.Ns.Zs(this.Ns.Js+1);const{buffer:i,offset:r}=this.Ns.Ws();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.char0,i[r+5]=t.char1,i[r+6]=t.char2,i[r+7]=t.r1,i[r+8]=t.g1,i[r+9]=t.b1,i[r+10]=t.a1,i[r+11]=t.r2,i[r+12]=t.g2,i[r+13]=t.b2,i[r+14]=t.a2,i[r+15]=t.invert,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.charRot,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.translationZ,i[r+22]=t.rotationX,i[r+23]=t.rotationY,i[r+24]=t.rotationZ;const h=t.curveParams0,n=t.curveParams1;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.depth,i[r+34]=t.baseZ,i[r+35]=t.geometryType,this.Ns.qs(L.FLOATS_PER_INSTANCE),this.Ns.Js-1}get Js(){return this.Ns.Js}}class qt{constructor(t,i=1e3){l(this,"A");l(this,"re",null);l(this,"ne",0);l(this,"oe",new Map);this.A=t,this.he(i)}he(t){const i=this.A;this.re&&i.deleteBuffer(this.re),this.re=i.createBuffer();const r=t*L.BYTES_PER_INSTANCE;Ft(i,i.ARRAY_BUFFER,this.re,r,i.DYNAMIC_DRAW),this.ne=t}ae(t){this.he(t)}get te(){return this.ne}ce(t,i){if(i===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.re);const h=i*L.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,h)}le(t){let i=this.oe.get(t);if(!i){i=new Map;const r=this.A;for(const h in J.ATTRIBUTES){const n=r.getAttribLocation(t,h);n!==-1&&i.set(h,n)}this.oe.set(t,i)}return i}ue(t){const i=this.A,r=t.L,h=this.le(r);for(const[n,a]of h){const c=J.ATTRIBUTES[n];c&&dt(i,a,c.size,c.stride,c.offset,c.divisor,c.type,c.normalized)}}fe(t){const i=this.A,r=this.le(t.L);for(const[h,n]of r)J.ATTRIBUTES[h]&&(i.disableVertexAttribArray(n),i.vertexAttribDivisor(n,0))}D(){this.re&&(this.A.deleteBuffer(this.re),this.re=null),this.oe.clear()}}class Qt{constructor(t,i=1e3,r=1.5){l(this,"A");l(this,"Ns");l(this,"de");l(this,"pe");this.A=t,this.Ns=new Zt(i,r),this.de=new Vt(this.Ns),this.pe=new qt(t,i)}ge(t){var h,n,a,c,u,f,d,g,p,m;const i=[0,0,0,0],r=[0,0,0,0];return t.zs&&t.Is?(i[0]=((h=t.Os)==null?void 0:h[0])??0,i[1]=((n=t.Os)==null?void 0:n[1])??0,i[2]=((a=t.Ls)==null?void 0:a[0])??0,i[3]=((c=t.Ls)==null?void 0:c[1])??0,r[0]=t.zs[0],r[1]=t.zs[1],r[2]=t.Is[0],r[3]=t.Is[1]):t.ks&&(i[0]=t.ks[0],i[1]=t.ks[1]),this.ie({x:t._s[0],y:t._s[1],width:t.Ps[0],height:t.Ps[1],char0:t.Ht[0],char1:t.Ht[1],char2:t.Ht[2],r1:t.Gt[0],g1:t.Gt[1],b1:t.Gt[2],a1:t.Gt[3],r2:t.Nt[0],g2:t.Nt[1],b2:t.Nt[2],a2:t.Nt[3],invert:t.Es[0],flipX:t.Es[1],flipY:t.Es[2],charRot:t.Tt,translationX:((u=t.Rs)==null?void 0:u[0])??0,translationY:((f=t.Rs)==null?void 0:f[1])??0,translationZ:((d=t.Rs)==null?void 0:d[2])??0,rotationX:((g=t.Ss)==null?void 0:g[0])??0,rotationY:((p=t.Ss)==null?void 0:p[1])??0,rotationZ:((m=t.Ss)==null?void 0:m[2])??0,curveParams0:i,curveParams1:r,depth:t.Ds||0,baseZ:t.Bs||0,geometryType:t.Hs||0})}ie(t){const i=this.de.ie(t);return this.Ns.te>this.pe.te&&this.pe.ae(this.Ns.te),i}get ve(){return this.Ns.Js}get ee(){return this.Ns.ee}me(){this.Ns.Vs()}ue(t){const i=this.Ns.Js;if(i===0)return;const r=this.Ns.Qs();this.pe.ce(r,i),this.pe.ue(t)}fe(t){this.pe.fe(t)}Cs(t,i){const r=this.Ns.Js;r!==0&&this.A.drawArraysInstanced(t,0,i,r)}D(){this.pe.D()}}class _{constructor(t,i,r,h){l(this,"A");l(this,"_e");l(this,"Ae");l(this,"ye");l(this,"we",null);this.A=t,this._e=i,this.Ae=r,this.ye=h;const n=this.A.createBuffer();Ft(this.A,this.A.ARRAY_BUFFER,n,this.ye.be,this.A.STATIC_DRAW),this.we=n}get type(){return this.Ae}get unitGeometry(){return this.ye}get unitBuffer(){return this.we}get batch(){return this._e}Ce(){this._e.me()}Me(){return!this._e.ee}D(){this._e.D(),this.A.deleteBuffer(this.we)}xe(t,i,r){return this._e.ge(t)}Fe(t,i,r,h,n,a){const c=n.It??0,u=n.Ot??0,f=n.Lt??0,d=n.At??0,g=n.yt??0,p=n.wt??0,m=[0,0,0,0],v=[0,0,0,0];a&&(a.bezStartX!==void 0&&a.bezStartY!==void 0&&a.bezEndX!==void 0&&a.bezEndY!==void 0?(m[0]=a.cp1x??0,m[1]=a.cp1y??0,m[2]=a.cp2x??0,m[3]=a.cp2y??0,v[0]=a.bezStartX??0,v[1]=a.bezStartY??0,v[2]=a.bezEndX??0,v[3]=a.bezEndY??0):a.arcStart===void 0&&a.arcStop===void 0||(m[0]=a.arcStart??0,m[1]=a.arcStop??0));const A={x:t,y:i,width:r,height:h,char0:n.Ht[0],char1:n.Ht[1],char2:n.Ht[2],r1:n.Gt[0],g1:n.Gt[1],b1:n.Gt[2],a1:n.Gt[3],r2:n.Nt[0],g2:n.Nt[1],b2:n.Nt[2],a2:n.Nt[3],invert:n.$t?1:0,flipX:n.Dt?1:0,flipY:n.Bt?1:0,charRot:n.Tt,translationX:c,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:p,curveParams0:m,curveParams1:v,depth:(a==null?void 0:a.depth)??0,baseZ:(a==null?void 0:a.baseZ)??0,geometryType:Kt[this.Ae]??0};return this._e.ie(A)}}const Jt={be:At,$e:6,...j},$t={be: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]),$e:6,...j},te={be: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),f=.5*(c+1),d=Math.cos(n),g=Math.sin(n),p=.5*(d+1),m=.5*(g+1);t.push(0,0,.5,.5,a,c,u,f,d,g,p,m)}return new Float32Array(t)}(32),$e:96,...j};let ee={be: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),$e:96,...j};const ie={be:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),$e:3,...j},re={be: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),$e:96,...j},se={[P.RECTANGLE]:class extends _{constructor(o,t){super(o,t,P.RECTANGLE,Jt)}ge(o,t){return this.Fe(0,0,o.width,o.height,t)}},[P.LINE]:class extends _{constructor(o,t){super(o,t,P.LINE,$t)}ge(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,h=Math.hypot(i,r),n=Math.atan2(r,i),a=t.zt||1,c=o.x1+i/2-h/2,u=o.y1+r/2,f={...t,wt:(t.wt||0)+n};return this.Fe(c,u,h,a,f)}},[P.ELLIPSE]:class extends _{constructor(o,t){super(o,t,P.ELLIPSE,te)}ge(o,t){return this.Fe(0,0,o.width,o.height,t)}},[P.ARC]:class extends _{constructor(o,t){super(o,t,P.ARC,ee)}ge(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Fe(0,0,o.width,o.height,t,{arcStart:i,arcStop:r})}},[P.TRIANGLE]:class extends _{constructor(o,t){super(o,t,P.TRIANGLE,ie)}ge(o,t){const i=Math.min(o.x1,o.x2,o.x3),r=Math.max(o.x1,o.x2,o.x3),h=Math.min(o.y1,o.y2,o.y3),n=r-i,a=Math.max(o.y1,o.y2,o.y3)-h;return this.Fe(i,h,n,a,t)}},[P.BEZIER_CURVE]:class extends _{constructor(o,t){super(o,t,P.BEZIER_CURVE,re)}ge(o,t){return this.Fe(0,0,1,t.zt||1,t,{cp1x:o.cp1x,cp1y:o.cp1y,cp2x:o.cp2x,cp2y:o.cp2y,bezStartX:o.x1,bezStartY:o.y1,bezEndX:o.x2,bezEndY:o.y2})}}};class ne{constructor(t){l(this,"A");l(this,"Te");l(this,"Pe");this.A=t,this.Pe=new Wt(t),this.Te=new Map;for(const i of Object.values(P)){const r=new Qt(t),h=new se[i](t,r);this.Te.set(i,h)}}Ee(t){const i=this.Re(t);for(const r of i)this.Se(r)}Re(t){const i=[];let r=null,h=null,n=null;for(const a of t)h!==a.material||n!==a.type?(r&&r.length>0&&i.push({material:h,type:n,commands:r}),r=[a],h=a.material,n=a.type):r.push(a);return r&&r.length>0&&i.push({material:h,type:n,commands:r}),i}Se(t){const{material:i,type:r,commands:h}=t,n=this.Te.get(r);i.shader.S(),i.shader.I(i.uniforms);const a=Ct(this.A),c=h.length>0&&h[0].state.Et;i.shader.I({Uv:a[2]/a[3],Us:[a[2],a[3]],Ut:1,Uu:c?1:0}),n.Ce();for(const u of h)n.ge(u.params,u.state);if(n.Me()){const u=n.unitGeometry,f=n.unitBuffer;try{this.Pe.Fs(i.shader.L,r+"",u,f),n.batch.ue(i.shader),n.batch.Cs(u.gs,u.$e)}finally{n.batch.fe(i.shader),this.Pe.$s(),n.Ce()}}}D(){for(const t of this.Te.values())t.D();this.Te.clear(),this.Pe.D()}}function Mt(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Nt(o){return Mt(o+"")}function $(o,t){return(o<<5)-o+t}class he{constructor(t){l(this,"A");l(this,"ke",0);l(this,"ze");l(this,"Ie");l(this,"Oe",new Map);this.A=t,this.ze=new V(t,rt,`#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.Ie={id:this.ke++,shader:this.ze,uniforms:Object.freeze({}),hash:this.Le(this.ze,{}),isBuiltIn:!0}}get De(){return this.Ie}ut(t,i={},r=!1){const h=this.Le(t,i),n=this.Oe.get(h);if(n)return n;const a={id:this.ke++,shader:t,uniforms:Object.freeze({...i}),hash:h,isBuiltIn:r};return this.Oe.set(h,a),a}Be(t,i={}){return{id:this.ke++,shader:t,uniforms:Object.freeze({...i}),hash:0,isBuiltIn:!1}}Le(t,i){const r=Nt(t.L),h=function(n,a){let c=0;const u=Object.keys(n).sort();for(const f of u)c=$(c,Mt(f)),c=$(c,a(n[f]));return c}(i,this.He.bind(this));return $(r,h)}He(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?Nt(t):0}D(){this.ze!=this.ze&&this.ze.D(),this.ze.D(),this.Oe.clear()}}class oe{constructor(){l(this,"Ge",[]);l(this,"Ne",1);l(this,"Ps",0)}Xe(t,i){if(this.Ps>=this.Ge.length){const h={id:this.Ne++,type:t,params:{},state:st.kt(),material:i};this.Ge.push(h)}const r=this.Ge[this.Ps];return r.id=this.Ne++,r.type=t,r.material=i,this.Ps++,r}Ye(t,i,r){const h=this.Xe(P.RECTANGLE,r),n=h.params;return n.width=t.width,n.height=t.height,i.Kt(h.state),h.id}Ke(t,i,r){const h=this.Xe(P.LINE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.thickness=t.thickness,i.Kt(h.state),h.id}je(t,i,r){const h=this.Xe(P.ELLIPSE,r),n=h.params;return n.width=t.width,n.height=t.height,n.startAngle=t.startAngle,n.endAngle=t.endAngle,n.segments=t.segments,i.Kt(h.state),h.id}Ze(t,i,r){const h=this.Xe(P.ARC,r),n=h.params;return n.width=t.width,n.height=t.height,n.start=t.start,n.stop=t.stop,i.Kt(h.state),h.id}We(t,i,r){const h=this.Xe(P.TRIANGLE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.x3=t.x3,n.y3=t.y3,i.Kt(h.state),h.id}qe(t,i,r){const h=this.Xe(P.BEZIER_CURVE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.cp1x=t.cp1x,n.cp1y=t.cp1y,n.cp2x=t.cp2x,n.cp2y=t.cp2y,n.x2=t.x2,n.y2=t.y2,n.thickness=t.thickness,n.segments=t.segments,i.Kt(h.state),h.id}me(){this.Ps=0}[Symbol.iterator](){let t=0;const i=this.Ps,r=this.Ge;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ae{constructor(t){l(this,"A");l(this,"Ve",null);l(this,"Qe");l(this,"ft");l(this,"Je");l(this,"ti");l(this,"si");l(this,"ei",null);l(this,"ii",{});l(this,"ri",[]);l(this,"ni",[]);l(this,"oi",null);l(this,"hi",[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.Je=new st,this.ft=new he(t),this.ti=new oe,this.Qe=new ne(t),this.si=new kt(t);const i=[0,0,t.canvas.width,t.canvas.height];gt(t,i),this.ri.push(null),this.ni.push(i),this.oi=null,this.hi=i}et(){this.ri.push(this.oi),this.ni.push([...this.hi])}ht(){return{framebuffer:this.ri.pop()??null,viewport:this.ni.pop()??[0,0,this.A.canvas.width,this.A.canvas.height]}}it(t,i,r){const h=this.A;this.oi!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.oi=t);const n=[0,0,i,r];this.hi[0]===n[0]&&this.hi[1]===n[1]&&this.hi[2]===n[2]&&this.hi[3]===n[3]||(h.viewport(...n),gt(h,n),this.hi=n)}ai(t){this.Ve!==t&&(this.Ve=t,t.S())}ci(t,i){return new V(this.A,t,i)}li(t){this.ei=t,t&&(this.ii={})}O(t,i){this.ii[t]=i}ui(t){Object.assign(this.ii,t)}fi(t){return new V(this.A,rt,t)}di(t,i,r){this.ti.Ye({width:i??t.width,height:r??t.height},this.Je,t.ct())}pi(t,i,r,h){this.si.Cs(t,i,r,h)}gi(t,i){if(this.ei){const r=this.ft.Be(this.ei,this.ii);this.ti.Ye({width:t,height:i},this.Je,r),this.ei=null,this.ii={}}else this.ti.Ye({width:t,height:i},this.Je,this.ft.De)}mi(t,i,r,h){this.ti.Ke({x1:t,y1:i,x2:r,y2:h},this.Je,this.ft.De)}_i(t,i){this.ti.je({width:t,height:i},this.Je,this.ft.De)}Ai(t,i,r,h,n,a){this.ti.We({x1:t,y1:i,x2:r,y2:h,x3:n,y3:a},this.Je,this.ft.De)}yi(t,i,r,h,n,a,c,u){this.ti.qe({x1:t,y1:i,cp1x:r,cp1y:h,cp2x:n,cp2y:a,x2:c,y2:u},this.Je,this.ft.De)}wi(t,i,r,h){this.ti.Ze({width:t,height:i,start:r,stop:h},this.Je,this.ft.De)}bi(t,i,r=1,h={}){return new Q(this.A,t,i,r,h,this)}Ci(t,i=t,r=t,h=255){this.Je.fs(t,i??t,r??t,h);const[n,a,c,u]=this.Je.canvasBackgroundColor;this.me(n,a,c,u)}me(t=0,i=0,r=0,h=0){this.A.clearColor(t,i,r,h),this.A.clear(this.A.COLOR_BUFFER_BIT)}Mi(){const t=[0,0,this.A.canvas.width,this.A.canvas.height];this.A.viewport(...t),gt(this.A,t),this.hi=t,this.ni.length>0&&(this.ni[0]=t)}ot(){const t=this.ti;this.Qe.Ee(t),t.me()}D(){this.ft.D(),this.Qe.D(),this.si.D()}get context(){return this.A}get state(){return this.Je}}const C={readShort:(o,t)=>(C.t.uint16[0]=o[t]<<8|o[t+1],C.t.int16[0]),readUshort:(o,t)=>o[t]<<8|o[t+1],readUshorts(o,t,i){const r=[];for(let h=0;h<i;h++)r.push(C.readUshort(o,t+2*h));return r},readUint(o,t){const i=C.t.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],C.t.uint32[0]},readASCII(o,t,i){let r="";for(let h=0;h<i;h++)r+=String.fromCharCode(o[t+h]);return r},t:(()=>{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 S(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 ce(o,t,i){for(let r=0;r<i.length;r++)o[t+r]=255&i.charCodeAt(r)}function pt(o,t,i){const r=t+i;let h=0;const n=C.t;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 le{constructor(t){l(this,"b");l(this,"p",0);l(this,"bitbuf",0);l(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 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 f=h[u]++;let d=a.get(u);d||(d=[],a.set(u,d)),d[ue(f,u)]=c}return{min:t,max:i,table:a}}function mt(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.readBits(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 Error("Invalid Huffman code")}function ue(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function fe(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],i=o[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 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],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],d=[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 g=0;for(;!g;){g=n.readBits(1);const p=n.readBits(2);if(p===0){n.alignToByte();const m=n.readBits(16);if((65535&(65535^m))!==n.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<m;v++)a.push(n.readBits(8))}else{if(p!==1&&p!==2)throw Error("Unsupported DEFLATE type");{let m,v;if(p===1){const A=Array(288).fill(0);for(let E=0;E<=143;E++)A[E]=8;for(let E=144;E<=255;E++)A[E]=9;for(let E=256;E<=279;E++)A[E]=7;for(let E=280;E<=287;E++)A[E]=8;m=tt(A),v=tt(Array(32).fill(5))}else{const A=n.readBits(5)+257,E=n.readBits(5)+1,y=n.readBits(4)+4,T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],w=Array(19).fill(0);for(let N=0;N<y;N++)w[T[N]]=n.readBits(3);const R=tt(w),b=[];for(;b.length<A+E;){const N=mt(n,R);if(N<=15)b.push(N);else if(N===16){const B=n.readBits(2)+3,D=b[b.length-1]||0;for(let ut=0;ut<B;ut++)b.push(D)}else if(N===17){const B=n.readBits(3)+3;for(let D=0;D<B;D++)b.push(0)}else{if(N!==18)throw Error("Invalid code length symbol");{const B=n.readBits(7)+11;for(let D=0;D<B;D++)b.push(0)}}}const M=b.slice(0,A),z=b.slice(A,A+E);m=tt(M),v=tt(z)}for(;;){const A=mt(n,m);if(A<256)a.push(A);else{if(A===256)break;if(A>256&&A<286){const E=A-257;let y=c[E];const T=u[E];T&&(y+=n.readBits(T));const w=mt(n,v);if(w>=30)throw Error("Invalid distance symbol");let R=f[w];const b=d[w];b&&(R+=n.readBits(b));const M=a.length-R;if(M<0)throw Error("Invalid distance");for(let z=0;z<y;z++)a.push(a[M+z]||0)}else if(A===286||A===287)throw Error("Reserved length symbol")}}}}}}(new le(o.subarray(r)),h),new Uint8Array(h)}function de(o){const t=C,i=new Uint8Array(o);if(t.readASCII(i,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(i,4),h=t.readUshort(i,12),n=t.readUint(i,16),a=[];let c=44;for(let y=0;y<h;y++){const T=t.readASCII(i,c,4),w=t.readUint(i,c+4),R=t.readUint(i,c+8),b=t.readUint(i,c+12),M=t.readUint(i,c+16);a.push({tag:T,offset:w,compLength:R,origLength:b,checksum:M}),c+=20}for(const y of a){const T=new Uint8Array(i.buffer,y.offset,y.compLength);if(y.compLength===y.origLength)y.data=new Uint8Array(T);else if(y.data=fe(T),y.data.length!==y.origLength)if(y.data.length<y.origLength){const w=new Uint8Array(y.origLength);w.set(y.data),y.data=w}else y.data=y.data.subarray(0,y.origLength)}const u=h;let f=1,d=0;for(;f<<1<=u;)f<<=1,d++;const g=16*f,p=16*u-g;let m=12+16*u;const v={};for(const y of a)v[y.tag]=m,m=nt(m+y.data.length);const A=new Uint8Array(Math.max(n||0,m));S(A,0,r),ht(A,4,u),ht(A,6,g),ht(A,8,d),ht(A,10,p);let E=12;for(const y of a){ce(A,E,y.tag),E+=4;let T=y.data;if(y.tag==="head"&&T.length>=12){const w=new Uint8Array(T);S(w,8,0),S(A,E,pt(w,0,nt(w.length))),E+=4}else S(A,E,pt(T,0,nt(T.length))),E+=4;S(A,E,v[y.tag]),E+=4,S(A,E,y.data.length),E+=4}for(const y of a){const T=v[y.tag];A.set(y.data,T)}if(a.find(y=>y.tag==="head")){const y=v.head,T=function(w,R){const b=R+8,M=[w[b],w[b+1],w[b+2],w[b+3]];S(w,b,0);const z=2981146554-(pt(w,0,nt(w.length))>>>0)>>>0;return w[b]=M[0],w[b+1]=M[1],w[b+2]=M[2],w[b+3]=M[3],z>>>0}(A,y);S(A,y+8,T)}return A.buffer}const ge={parseTab(o,t,i){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,i),t=0;const h=C,n=h.readUshort,a=n(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const f=n(o,t),d=n(o,t+=2);t+=2;const g=h.readUint(o,t);t+=4;const p=`p${f}e${d}`;let m=c.indexOf(g);if(m===-1){let v;m=r.tables.length,c.push(g);const A=n(o,g);v=A===4?this.parse4(o,g):A===12?this.parse12(o,g):{format:A},r.tables.push(v)}r.ids[p]=m}return r},parse4(o,t){const i=C,r=i.readUshort,h=i.readUshorts,n=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,searchRange:r(o,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(o,t),t+=2,u.rangeShift=r(o,t),t+=2,u.endCount=h(o,t,c),t+=2*c,t+=2,u.startCount=h(o,t,c),t+=2*c;for(let f=0;f<c;f++)u.idDelta.push(i.readShort(o,t)),t+=2;return u.idRangeOffset=h(o,t,c),t+=2*c,u.glyphIdArray=h(o,t,n+a-t>>1),u},parse12(o,t){const i=C.readUint;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}}},Ae={parseTab(o,t,i){const r=C;t+=18;const h=r.readUshort(o,t);t+=2,t+=16;const n=r.readShort(o,t);t+=2;const a=r.readShort(o,t);t+=2;const c=r.readShort(o,t);t+=2;const u=r.readShort(o,t);return t+=2,t+=6,{unitsPerEm:h,xMin:n,yMin:a,xMax:c,yMax:u,indexToLocFormat:r.readShort(o,t)}}},pe={parseTab(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.readUshort:r.readShort;n[c]=u(o,t+2*a)}return n}},me={parseTab(o,t,i,r){const h=C,n=[],a=[],c=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,d=0,g=0;for(;g<u;)f=h.readUshort(o,t+(g<<2)),d=h.readShort(o,t+(g<<2)+2),n.push(f),a.push(d),g++;for(;g<c;)n.push(f),a.push(d),g++;return{aWidth:n,lsBearing:a}}},It={cmap:ge,head:Ae,hhea:pe,maxp:{parseTab(o,t,i){const r=C;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:me,loca:{parseTab(o,t,i,r){const h=C,n=[],a=r.head.indexToLocFormat,c=r.maxp.numGlyphs+1;if(a===0)for(let u=0;u<c;u++)n.push(h.readUshort(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)n.push(h.readUint(o,t+(u<<2)));return n}},glyf:{parseTab(o,t,i,r){const h=[],n=r.maxp.numGlyphs;for(let a=0;a<n;a++)h.push(null);return h},xi(o,t){const i=C,r=o.Fi,h=o.loca;if(h[t]===h[t+1])return null;const n=H.findTable(r,"glyf",o.$i);if(!n)return null;let a=n[0]+h[t];const c={};if(c.noc=i.readShort(r,a),a+=2,c.xMin=i.readShort(r,a),a+=2,c.yMin=i.readShort(r,a),a+=2,c.xMax=i.readShort(r,a),a+=2,c.yMax=i.readShort(r,a),a+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(let p=0;p<c.noc;p++)c.endPts.push(i.readUshort(r,a)),a+=2;const u=i.readUshort(r,a);if(a+=2,r.length-a<u)return null;a+=u;const f=c.endPts[c.noc-1]+1;c.flags=[];for(let p=0;p<f;p++){const m=r[a];if(a++,c.flags.push(m),8&m){const v=r[a];a++;for(let A=0;A<v;A++)c.flags.push(m),p++}}c.xs=[];for(let p=0;p<f;p++){const m=c.flags[p],v=!!(16&m);2&m?(c.xs.push(v?r[a]:-r[a]),a++):v?c.xs.push(0):(c.xs.push(i.readShort(r,a)),a+=2)}c.ys=[];for(let p=0;p<f;p++){const m=c.flags[p],v=!!(32&m);4&m?(c.ys.push(v?r[a]:-r[a]),a++):v?c.ys.push(0):(c.ys.push(i.readShort(r,a)),a+=2)}let d=0,g=0;for(let p=0;p<f;p++)d+=c.xs[p],g+=c.ys[p],c.xs[p]=d,c.ys[p]=g}else c.parts=[],c.endPts=[],c.flags=[],c.xs=[],c.ys=[];return c}}},H={parse(o){const t=new Uint8Array(o);C.readASCII(t,0,4)==="wOFF"&&(o=de(o));const i=new Uint8Array(o),r=It,h={},n={Fi:i,Ti:0,$i:0};for(const a in r){const c=a,u=H.findTable(i,c,0);if(u){const[f,d]=u;let g=h[f];g==null&&(g=r[c].parseTab(i,f,d,n),h[f]=g),n[c]=g}}return[n]},findTable(o,t,i){const r=C,h=r.readUshort(o,i+4);let n=i+12;for(let a=0;a<h;a++){const c=r.readASCII(o,n,4);r.readUint(o,n+4);const u=r.readUint(o,n+8),f=r.readUint(o,n+12);if(c===t)return[u,f];n+=16}return null},T:It,B:C};class ve{Pi(t){var r;const i=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(h=>{if(h.format===4){const n=this.Ei(h);i.push(...n)}else if(h.format===12){const n=this.Ri(h);i.push(...n)}}),[...new Set(i)]):[]}Ei(t){const i=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return i;for(let r=0;r<t.startCount.length;r++){const h=t.startCount[r],n=t.endCount[r];if(h!==65535||n!==65535){for(let a=h;a<=n;a++)if(this.Si(t,a,r)>0)try{const c=String.fromCodePoint(a);i.push(c)}catch{}}}return i}Ri(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}Si(t,i,r){if(t.idRangeOffset[r]===0)return i+t.idDelta[r]&65535;{const h=t.idRangeOffset[r]/2+(i-t.startCount[r])-(t.startCount.length-r);if(h>=0&&t.glyphIdArray&&h<t.glyphIdArray.length){const n=t.glyphIdArray[h];if(n!==0)return n+t.idDelta[r]&65535}}return 0}}class vt{constructor(){l(this,"ki",new Map);l(this,"zi",new Map)}Ii(t,i){const r=`${this.Oi(t)}_${i}`;if(this.ki.has(r))return this.ki.get(r);const h=t.cmap;if(!h||!h.tables)return this.ki.set(r,0),0;let n=0;for(const a of h.tables)if(a.format===4?n=this.Li(i,a):a.format===12&&(n=this.Di(i,a)),n>0)break;return this.ki.set(r,n),n}Bi(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Ii(t,r)}Hi(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}Gi(t,i){const r=i/t.head.unitsPerEm,h=t.hhea.ascender*r,n=t.hhea.descender*r,a=t.hhea.lineGap*r;return{ascender:h,descender:n,lineGap:a,lineHeight:h-n+a,unitsPerEm:t.head.unitsPerEm,scale:r}}Ni(){this.ki.clear(),this.zi.clear()}Oi(t){return`${t.$i}_${t.Fi.length}`}Li(t,i){const r=i.endCount.length;let h=-1;for(let n=0;n<r;n++)if(t<=i.endCount[n]){h=n;break}if(h===-1||t<i.startCount[h])return 0;if(i.idRangeOffset[h]===0)return t+i.idDelta[h]&65535;{const n=i.idRangeOffset[h]/2+(t-i.startCount[h])-(r-h);if(n>=0&&n<i.glyphIdArray.length){const a=i.glyphIdArray[n];return a===0?0:a+i.idDelta[h]&65535}}return 0}Di(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 ye{constructor(t){l(this,"Xi");l(this,"Yi");l(this,"j");l(this,"Ki");this.j=t,this.Ki=new vt,this.Xi=document.createElement("canvas"),this.Yi=this.Xi.getContext("2d",{willReadFrequently:!0,alpha:!0})}ji(t,i,r,h){const n=t.length,a=Math.ceil(Math.sqrt(n)),c=Math.ceil(n/a),u=i.width*a,f=i.height*c;this.Zi(u,f),this.Wi(t,i,a,r,h);const d=this.j.bi(u,f,1,{filter:"nearest"});return d.st(this.Xi),{framebuffer:d,columns:a,rows:c}}Zi(t,i){this.Xi.width=t,this.Xi.height=i,this.Xi.style.width=t+"px",this.Xi.style.height=i+"px",this.Yi.imageSmoothingEnabled=!1,this.Xi.style.imageRendering="pixelated",this.Yi.clearRect(0,0,t,i),this.Yi.textBaseline="top",this.Yi.textAlign="left",this.Yi.fillStyle="white"}Wi(t,i,r,h,n){const a=h/n.head.unitsPerEm;for(let c=0;c<t.length;c++){const u=c%r,f=Math.floor(c/r),d=t[c].character,g=this.qi(n,d);if(!g)continue;const p=d.codePointAt(0)||0,m=this.Ki.Ii(n,p),v=this.Ki.Hi(n,m)*a,A=u*i.width,E=f*i.height,y=A+.5*i.width,T=E+.5*i.height,w=Math.round(y-.5*i.width),R=Math.round(T-.5*h),b=w+.5*(i.width-v),M=R+n.hhea.ascender*a;this.Vi(g,b,M,a)}}qi(t,i){const r=i.codePointAt(0)||0,h=this.Ki.Ii(t,r);return h===0?null:H.T.glyf.xi(t,h)}Vi(t,i,r,h){if(!t||!t.xs||t.noc===0)return;let{xs:n,ys:a,endPts:c,flags:u}=t;if(!(n&&a&&c&&u))return;this.Yi.beginPath();let f=0;for(let d=0;d<c.length;d++){const g=c[d];if(!(g<f)){if(g>=f){const p=i+n[f]*h,m=r-a[f]*h;this.Yi.moveTo(p,m);let v=f+1;for(;v<=g;)if(1&u[v]){const A=i+n[v]*h,E=r-a[v]*h;this.Yi.lineTo(A,E),v++}else{const A=i+n[v]*h,E=r-a[v]*h;if(v+1>g){const T=i+n[f]*h,w=r-a[f]*h;if(1&u[f])this.Yi.quadraticCurveTo(A,E,T,w);else{const R=(A+T)/2,b=(E+w)/2;this.Yi.quadraticCurveTo(A,E,R,b)}break}const y=v+1;if(1&u[y]){const T=i+n[y]*h,w=r-a[y]*h;this.Yi.quadraticCurveTo(A,E,T,w),v=y+1}else{const T=(A+(i+n[y]*h))/2,w=(E+(r-a[y]*h))/2;this.Yi.quadraticCurveTo(A,E,T,w),v=y}}this.Yi.closePath()}f=g+1}}this.Yi.fill()}}class Ee{constructor(){l(this,"Qi");this.Qi=new vt}Ji(t,i,r){let h=0;const n=this.Qi.Gi(r,i),a=n.lineHeight;for(const c of t){const u=this.Qi.Bi(r,c);if(u===0)continue;const f=this.Qi.Hi(r,u)*n.scale;h=Math.max(h,f)}return{width:Math.ceil(h),height:Math.ceil(a)}}Ni(){this.Qi.Ni()}}class we{constructor(){l(this,"Ki");this.Ki=new vt}createCharacterObjects(t,i){return t.map((r,h)=>{const n=r.codePointAt(0)||0,a=this.tr(h);let c=0;if(i.hmtx&&i.hmtx.aWidth){const u=this.Ki.Ii(i,n);u>0&&i.hmtx.aWidth[u]!==void 0&&(c=i.hmtx.aWidth[u])}return{character:r,unicode:n,color:a,advanceWidth:c}})}tr(t){return[t%256/255,Math.floor(t/256)%256/255,0]}sr(t,i){if(!Z.m(typeof t=="string","Character must be a string.",{method:"getCharacterColor",providedValue:t}))return[0,0,0];const r=i.find(h=>h.character===t);return r?r.color:[0,0,0]}er(t,i){return Z.m(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.sr(r,i)||[0,0,0]):[[0,0,0]]}}class yt{constructor(t,i=16){l(this,"ir");l(this,"rr",[]);l(this,"nr");l(this,"hr",16);l(this,"ar",0);l(this,"cr",0);l(this,"lr",{width:0,height:0});l(this,"ur");l(this,"dr",new Map);l(this,"pr");l(this,"gr");l(this,"vr");l(this,"mr");this.hr=i,this.pr=new ve,this.gr=new ye(t),this.vr=new Ee,this.mr=new we}async _r(t){let i;if(t){const r=await fetch(t);if(!r.ok)throw new x(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}else i=await(await fetch("data:font/woff;base64,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")).arrayBuffer();await this.Ar(i),this.ir=H.parse(i)[0],await this.yr()}wr(t){if(t===void 0)return this.hr;this.hr=t,this.lr=this.vr.Ji(this.rr.map(r=>r.character),this.hr,this.ir);const i=this.gr.ji(this.rr,this.lr,this.hr,this.ir);this.nr=i.framebuffer,this.ar=i.columns,this.cr=i.rows}async br(t){try{const i=await fetch(t);if(!i.ok)throw new x(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.Ar(r);const h=H.parse(r);if(!h||h.length===0)throw Error("Failed to parse font file");this.ir=h[0],await this.yr()}catch(i){throw new x("Failed to load font: "+(i instanceof Error?i.message:"Unknown error"),i)}}async Ar(t){const i=Date.now();this.ur=new FontFace("CustomFont_"+i,t),await this.ur.load(),document.fonts.add(this.ur)}async yr(){const t=this.pr.Pi(this.ir);this.dr.clear(),this.rr=this.mr.createCharacterObjects(t,this.ir),this.lr=this.vr.Ji(t,this.hr,this.ir);const i=this.gr.ji(this.rr,this.lr,this.hr,this.ir);this.nr=i.framebuffer,this.ar=i.columns,this.cr=i.rows}sr(t){return this.mr.sr(t,this.rr)}er(t){return this.mr.er(t,this.rr)}getGlyphData(t){if(!Number.isFinite(t))return null;const i=this.dr.get(t);if(i!==void 0)return i;const r=this.Cr(t);if(r<0)return this.dr.set(t,null),null;const h=this.ir.glyf;if(!h)return this.dr.set(t,null),null;let n=h[r]??null;return n==null&&(n=H.T.glyf.xi(this.ir,r)??null,h[r]=n),this.dr.set(t,n),n}Cr(t){const i=this.ir.cmap;for(const r of i.tables)if(r.format===4){const h=r;for(let n=0;n<h.startCount.length;n++)if(t>=h.startCount[n]&&t<=h.endCount[n]){if(h.idRangeOffset[n]===0)return t+h.idDelta[n]&65535;{const a=h.idRangeOffset[n]/2+(t-h.startCount[n])-(h.startCount.length-n);if(a>=0&&a<h.glyphIdArray.length){const c=h.glyphIdArray[a];if(c!==0)return c+h.idDelta[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.nr.D(),document.fonts.delete(this.ur)}get fontFramebuffer(){return this.nr}get characters(){return this.rr}get textureColumns(){return this.ar}get textureRows(){return this.cr}get maxGlyphDimensions(){return this.lr}get fontSize(){return this.hr}get font(){return this.ir}}class Et{constructor(t,i,r){l(this,"Mr");l(this,"Fr");l(this,"H");l(this,"G");l(this,"$r");l(this,"Tr");l(this,"Pr");l(this,"Er");l(this,"Rr");this.Pr=t,this.Er=i,this.Rr=r,this.Vs()}Vs(){this.Mr=Math.floor(this.Pr.width/this.Er),this.Fr=Math.floor(this.Pr.height/this.Rr),this.H=this.Mr*this.Er,this.G=this.Fr*this.Rr,this.$r=Math.floor((this.Pr.width-this.H)/2),this.Tr=Math.floor((this.Pr.height-this.G)/2)}Sr(t,i){this.Er=t,this.Rr=i,this.Vs()}get cellWidth(){return this.Er}get cellHeight(){return this.Rr}get cols(){return this.Mr}get rows(){return this.Fr}get width(){return this.H}get height(){return this.G}get offsetX(){return this.$r}get offsetY(){return this.Tr}}const Te=/^#([0-9a-f]{3,8})$/i,be=/^rgba?\(([^)]+)\)$/i;function wt(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function xe(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=Te.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=be.exec(r.trim());if(!h)return null;const n=h[1].split(",").map(d=>d.trim());if(n.length<3)return null;const a=wt(parseFloat(n[0])),c=wt(parseFloat(n[1])),u=wt(parseFloat(n[2])),f=n[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(n[3]))):255;return[a,c,u,Math.round(f)]}(t)),i?i[3]===0?null:i:null}class Ut{constructor(t={}){l(this,"Pr");l(this,"kr",null);l(this,"zr",!1);l(this,"Ir");this.zr=t.overlay??!1,this.zr&&t.canvas?(this.kr=t.canvas,this.Pr=this.Or(),this.Ir=!0,this.Lr()):t.canvas?(this.Pr=t.canvas,this.Ir=!1):(this.Pr=this.Dr(t.width,t.height),this.Ir=!0),this.Pr.style.imageRendering="pixelated"}Dr(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}Or(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.kr.getBoundingClientRect();let r=Math.round(i.width),h=Math.round(i.height);if(this.kr instanceof HTMLVideoElement){const c=this.kr;(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.kr);let a=parseInt(n.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=""+(a+1),t}Lr(){var t;this.Br(),(t=this.kr.parentNode)==null||t.insertBefore(this.Pr,this.kr.nextSibling)}Hr(){const t=[];return this.zr&&this.kr instanceof HTMLElement&&(t.push(this.kr),this.kr.parentElement&&t.push(this.kr.parentElement)),this.Pr.parentElement&&t.push(this.Pr.parentElement),t.push(this.Pr),t.push(document.body),t.push(document.documentElement),t}Gr(){const t=this.Hr();for(const i of t){if(!i)continue;const r=xe(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}Br(){if(!this.kr)return;const t=this.kr.getBoundingClientRect();let i=this.kr.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.Pr.style.top=t.top-r.top+"px",this.Pr.style.left=t.left-r.left+"px"}else this.Pr.style.top=t.top+window.scrollY+"px",this.Pr.style.left=t.left+window.scrollX+"px"}Nr(t,i){if(this.zr){const r=this.kr.getBoundingClientRect();this.Pr.width=Math.round(r.width),this.Pr.height=Math.round(r.height),this.Br()}else this.Pr.width=t??this.Pr.width,this.Pr.height=i??this.Pr.height}Xr(){const t=this.Pr.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new x("`textmode.js` requires WebGL2 support.");return t}D(){const t=this.Pr.getContext("webgl")||this.Pr.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.loseContext()}this.Ir&&this.Pr.parentNode&&this.Pr.parentNode.removeChild(this.Pr)}get canvas(){return this.Pr}get targetCanvas(){return this.kr}get width(){return this.Pr.width}get height(){return this.Pr.height}}const Re=/^#|0x/gi;function et(o){return Number.isNaN(o)||!Number.isFinite(o)||o<=0?0:o>=255?255:Math.round(o)}function ot(o){return et(parseInt(o,16))}class I{constructor(t,i,r,h,n){l(this,"Yr");l(this,"Kr");l(this,"Ht");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=et(t),this.g=et(i),this.b=et(r),this.a=et(h),this.Yr=[this.r,this.g,this.b,this.a],this.Kr=[this.r/255,this.g/255,this.b/255,this.a/255],this.Ht=n?[...n]:void 0}static jr(t,i,r,h=255){return new I(t,i,r,h)}static Zr(t,i=255){return new I(t,t,t,i)}static Wr(t){const[i,r,h,n]=function(a){const c=a.replace(Re,""),u=(f=c).length===3||f.length===4?f.split("").map(d=>d+d).join(""):f;var f;if(u.length!==6&&u.length!==8)throw 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 I(i,r,h,n)}static qr(t){const[i,r,h]=t;return new I(255*i,255*r,255*h,255,t)}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.Yr]}get normalized(){return[...this.Kr]}get character(){return this.Ht?[...this.Ht]:void 0}static Vr(t){return t instanceof I}}const W=class W{constructor(t,i,r,h,n,a,c){l(this,"A");l(this,"j");l(this,"Qr");l(this,"Jr");l(this,"tn");l(this,"H");l(this,"G");l(this,"Z",null);l(this,"$t",0);l(this,"Dt",0);l(this,"Bt",0);l(this,"Tt",0);l(this,"sn","sampled");l(this,"en","fixed");l(this,"Gt",[1,1,1,1]);l(this,"Nt",[0,0,0,1]);l(this,"rn",[0,0,0,1]);l(this,"nn",[[.1,0,0]]);l(this,"hn");this.A=t,this.j=i,this.Qr=r,this.Jr=h,this.tn=n,this.H=a,this.G=c}D(){this.A.deleteTexture(this.Qr)}invert(t=!0){return this.$t=t?1:0,this.Z=null,this}flipX(t=!0){return this.Dt=t?1:0,this.Z=null,this}flipY(t=!0){return this.Bt=t?1:0,this.Z=null,this}charRotation(t){return this.Tt=xt(t),this.Z=null,this}charColorMode(t){return this.sn=t,this.Z=null,this}cellColorMode(t){return this.en=t,this.Z=null,this}charColor(t,i,r,h){return this.cn(this.Gt,t,i,r,h),this.Z=null,this}cellColor(t,i,r,h){return this.cn(this.Nt,t,i,r,h),this.Z=null,this}background(t,i,r,h){return this.cn(this.rn,t,i,r,h),this.Z=null,this}characters(t){if(!this.hn)throw Error("Glyph color resolver not initialized");const i=this.hn(t).filter(r=>Array.isArray(r)).slice(0,64);return this.nn=i,this.Z=null,this}get texture(){return this.Qr}get width(){return this.H}get height(){return this.G}get originalWidth(){return this.Jr}get originalHeight(){return this.tn}ct(){return this.Z||this.lt(),this.Z}ln(){}lt(){this.ln();const t=this.un(),i=this.fn();this.Z=this.j.ft.Be(t,i)}cn(t,i,r,h,n){if(I.Vr(i))Y(t,i.r,i.g,i.b,i.a);else{if(typeof i=="string"){const a=I.Wr(i);return void Y(t,a.r,a.g,a.b,a.a)}Y(t,i,r,h,n)}}un(){return W.an||(W.an=new V(this.A,rt,`#version 300 es
|
|
11
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Ug;uniform bool Uh;uniform bool Ui;uniform bool Uj;uniform float Uk;uniform bool Ul;uniform vec4 Um;uniform bool Un;uniform vec4 Uo;uniform vec4 Up;uniform int Uq;uniform vec3 Ur[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(Ug,C);float E=A(D.rgb);vec2 F=vec2(0.);if(Uq>0){float G=float(Uq);float H=clamp(E*(G-1.0f),0.0f,G-1.0f);int I=int(floor(H+0.5f));vec3 J=Ur[I];F=J.xy;}else{F=vec2(E,0.0f);}vec4 K=Ul?Um:D;vec4 L=Un?Uo:D;if(D.a<0.01f){K=Up;L=Up;}else{}o_primaryColor=vec4(K.rgb,K.a);o_secondaryColor=vec4(L.rgb,L.a);int M=int(Uh?1:0);int N=int(Ui?1:0);int O=int(Uj?1:0);float P=float(M|(N<<1)|(O<<2))/255.;o_character=vec4(F,P,clamp(Uk,0.0f,1.0f));}`)),W.an}fn(){return{Ug:this.dn(),Uh:!!this.$t,Ui:!!this.Dt,Uj:!!this.Bt,Uk:this.Tt,Ul:this.sn==="fixed",Um:this.Gt,Un:this.en==="fixed",Uo:this.Nt,Up:this.rn,Uq:this.nn.length,Ur:this.nn}}};l(W,"an",null);let at=W;class k 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 pn(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),it(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,f=i.naturalHeight??i.height??i.videoHeight??0,d=new k(a,t,c,u,f,r,h);return d.hn=n,d}dn(){return this.Qr}}class Dt{constructor(t=60){l(this,"gn");l(this,"vn",null);l(this,"mn",0);l(this,"_n",!0);l(this,"An",0);l(this,"yn",0);l(this,"wn",[]);l(this,"bn",10);l(this,"Cn",0);this.gn=1e3/t}Mn(t){if(!this._n)return;this.mn=performance.now();const i=r=>{if(!this._n)return void(this.vn=null);const h=r-this.mn;h>=this.gn&&(t(),this.mn=r-h%this.gn),this._n&&(this.vn=requestAnimationFrame(i))};this.vn=requestAnimationFrame(i)}xn(){this.vn&&(cancelAnimationFrame(this.vn),this.vn=null)}Fn(){this._n&&(this._n=!1,this.xn())}$n(t){this._n||(this._n=!0,this.Mn(t))}Tn(t,i){if(t===void 0)return this.An;this.gn=1e3/t,this._n&&i&&(this.xn(),this.Mn(i))}Pn(){const t=performance.now();if(this.yn>0){const i=t-this.yn;this.wn.push(i),this.wn.length>this.bn&&this.wn.shift();const r=this.wn.reduce((h,n)=>h+n,0)/this.wn.length;this.An=1e3/r}this.yn=t}get En(){return this._n}get Rn(){return this.An}get Sn(){return this.Cn}set Sn(t){this.Cn=t}kn(){this.Cn++}}class zt{constructor(t){l(this,"Pr");l(this,"zn");l(this,"In",{x:-1,y:-1});l(this,"On",{x:-1,y:-1});l(this,"Ln",null);l(this,"Dn",0);l(this,"Bn");l(this,"Hn");l(this,"Gn");l(this,"Nn");l(this,"Xn");l(this,"Yn");l(this,"Kn",!1);l(this,"jn");l(this,"Zn");l(this,"Wn");l(this,"qn");l(this,"Vn");this.Pr=t}Qn(t){const i=performance.now()+Math.max(0,t);i>this.Dn&&(this.Dn=i)}Jn(){return performance.now()<this.Dn}so(t){const i=this.Pr.canvas;i.style.cursor=t==null||t===""?"":t}_r(t){this.zn=t,this.eo()}io(){if(this.Kn)return;const t=this.Pr.canvas;this.Bn=i=>{this.ro(i),this.no(i)},this.Hn=()=>{this.On={...this.In},this.In.x=-1,this.In.y=-1,this.Ln=null},this.Gn=i=>{this.ro(i),this.oo(i)},this.Nn=i=>{this.ro(i),this.ho(i)},this.Xn=i=>{this.ro(i),this.ao(i)},this.Yn=i=>{this.ro(i),this.co(i)},t.addEventListener("mousemove",this.Bn,{passive:!0}),t.addEventListener("mouseleave",this.Hn,{passive:!0}),t.addEventListener("mousedown",this.Gn,{passive:!0}),t.addEventListener("mouseup",this.Nn,{passive:!0}),t.addEventListener("click",this.Xn,{passive:!0}),t.addEventListener("wheel",this.Yn,{passive:!1}),this.Kn=!0}lo(){if(!this.Kn)return;const t=this.Pr.canvas;t.removeEventListener("mousemove",this.Bn),t.removeEventListener("mouseleave",this.Hn),t.removeEventListener("mousedown",this.Gn),t.removeEventListener("mouseup",this.Nn),t.removeEventListener("click",this.Xn),t.removeEventListener("wheel",this.Yn),this.Kn=!1}eo(){if(this.Kn)try{if(this.Ln){const t=new MouseEvent("mousemove",{clientX:this.Ln.x,clientY:this.Ln.y,bubbles:!1,cancelable:!1});this.ro(t)}else this.In.x!==-1&&this.In.y!==-1&&(this.In.x>=this.zn.cols||this.In.y>=this.zn.rows)&&(this.In.x=-1,this.In.y=-1)}catch{this.In.x=-1,this.In.y=-1}}uo(t){this.jn=t}fo(t){this.Zn=t}do(t){this.Wn=t}po(t){this.qn=t}vo(t){this.Vn=t}mo(){return{x:this.In.x,y:this.In.y}}no(t){if(this.qn&&!this.Jn()){const i={position:{...this.In},previousPosition:{...this.On},originalEvent:t};this.qn(i)}}oo(t){if(this.Zn&&!this.Jn()){const i={position:{...this.In},previousPosition:{...this.On},button:t.button,originalEvent:t};this.Zn(i)}}ho(t){if(this.Wn&&!this.Jn()){const i={position:{...this.In},previousPosition:{...this.On},button:t.button,originalEvent:t};this.Wn(i)}}ao(t){if(this.jn&&!this.Jn()){const i={position:{...this.In},previousPosition:{...this.On},button:t.button,originalEvent:t};this.jn(i)}}co(t){if(this.Vn&&!this.Jn()){const i={position:{...this.In},previousPosition:{...this.On},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.Vn(i)}}ro(t){const i=this.Pr.canvas;this.On={...this.In},this.Ln={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.zn.offsetX,f=c-this.zn.offsetY,d=Math.floor(u/this.zn.cellWidth),g=Math.floor(f/this.zn.cellHeight);d>=0&&d<this.zn.cols&&g>=0&&g<this.zn.rows?(this.In.x=d,this.In.y=g):(this.In.x=-1,this.In.y=-1)}}const Fe=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:zt},Symbol.toStringTag,{value:"Module"}));class Lt{constructor(){l(this,"_o",new Map);l(this,"Ao",null);l(this,"yo",null);l(this,"wo");l(this,"bo");l(this,"Kn",!1);l(this,"Co");l(this,"Mo");l(this,"xo",{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"})}io(){this.Kn||(this.wo=t=>{this.Fo(t)},this.bo=t=>{this.$o(t)},window.addEventListener("keydown",this.wo,{passive:!1}),window.addEventListener("keyup",this.bo,{passive:!1}),this.Kn=!0)}lo(){this.Kn&&(window.removeEventListener("keydown",this.wo),window.removeEventListener("keyup",this.bo),this.Kn=!1,this._o.clear(),this.Ao=null,this.yo=null)}fo(t){this.Co=t}do(t){this.Mo=t}To(t){const i=this.Po(t),r=this._o.get(t)||this._o.get(i);return(r==null?void 0:r.isPressed)||!1}Eo(){return this.Ao}Ro(){return this.yo}So(){const t=[];for(const[i,r]of this._o)r.isPressed&&t.push(i);return t}ko(){return{ctrl:this.To("Control"),shift:this.To("Shift"),alt:this.To("Alt"),meta:this.To("Meta")}}zo(){this._o.clear(),this.Ao=null,this.yo=null}Fo(t){const i=t.key,r=Date.now();this._o.has(i)||this._o.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this._o.get(i);if(!h.isPressed&&(h.isPressed=!0,h.lastPressTime=r,this.Ao=i,this.Co)){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.Co(n)}}$o(t){const i=t.key,r=Date.now();this._o.has(i)||this._o.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this._o.get(i);if(h.isPressed=!1,h.lastReleaseTime=r,this.yo=i,this.Mo){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.Mo(n)}}Po(t){return this.xo[t]||t.toLowerCase()}}const Pe=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:Lt},Symbol.toStringTag,{value:"Module"}));class Bt{constructor(t,i){l(this,"Pr");l(this,"Io");l(this,"zn");l(this,"Oo",new Map);l(this,"Lo",new Map);l(this,"Do",new Map);l(this,"Bo",null);l(this,"Ho");l(this,"Go");l(this,"No");l(this,"Xo");l(this,"Yo");l(this,"Ko");l(this,"Kn",!1);l(this,"jo");l(this,"Zo");l(this,"Wo");l(this,"qo");l(this,"Vo");l(this,"Qo");l(this,"Jo");l(this,"th");l(this,"sh");l(this,"eh");l(this,"ih",320);l(this,"rh",350);l(this,"nh",10);l(this,"oh",550);l(this,"hh",14);l(this,"ah",48);l(this,"uh",650);l(this,"fh",.02);l(this,"dh",2);l(this,"ph",600);l(this,"gh",0);l(this,"mh",null);this.Pr=t,this.Io=i;const r=this.Pr.canvas;this.Ho=r.style.touchAction,this.Go=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}_r(t){this.zn=t,this.eo()}io(){if(this.Kn)return;const t=this.Pr.canvas;this.No=i=>{this._h(i)},this.Xo=i=>{this.Ah(i)},this.Yo=i=>{this.yh(i)},this.Ko=i=>{this.wh(i)},t.addEventListener("touchstart",this.No,{passive:!1}),t.addEventListener("touchmove",this.Xo,{passive:!1}),t.addEventListener("touchend",this.Yo,{passive:!1}),t.addEventListener("touchcancel",this.Ko,{passive:!1}),this.Kn=!0}lo(){if(!this.Kn)return;const t=this.Pr.canvas;t.removeEventListener("touchstart",this.No),t.removeEventListener("touchmove",this.Xo),t.removeEventListener("touchend",this.Yo),t.removeEventListener("touchcancel",this.Ko),this.Kn=!1,this.Bo=null,this.Oo.clear(),this.Lo.clear(),this.Do.forEach(i=>{i.longPressTimer!==null&&window.clearTimeout(i.longPressTimer)}),this.Do.clear(),this.mh=null,this.gh=0,t.style.touchAction=this.Ho,t.style.userSelect=this.Go}eo(){if(!this.zn||this.Oo.size===0)return;const t=new Map;for(const i of this.Oo.values()){const r=this.bh(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Oo=t}Ch(){return Array.from(this.Oo.values()).map(t=>({...t}))}Mh(t){this.jo=t}po(t){this.Zo=t}xh(t){this.Wo=t}Fh(t){this.qo=t}$h(t){this.Vo=t}Th(t){this.Qo=t}Ph(t){this.Jo=t}Eh(t){this.th=t}Rh(t){this.sh=t}Sh(t){this.eh=t}_h(t){var h;if(!this.zn)return;t.preventDefault(),(h=this.Io)==null||h.Qn(this.ph);const i=performance.now(),r=this.kh(t.changedTouches);for(const n of r){const a=this.Oo.get(n.id);a&&this.Lo.set(n.id,this.zh(a)),this.Oo.set(n.id,n);const c={id:n.id,startPosition:n,lastPosition:n,startTime:i,lastTime:i,longPressTimer:null,longPressFired:!1};this.Jo&&(c.longPressTimer=window.setTimeout(()=>{const u=this.Oo.get(n.id);u&&(c.longPressFired=!0,this.Jo({touch:this.zh(u),duration:performance.now()-c.startTime,originalEvent:t}))},this.oh)),this.Do.set(n.id,c),this.jo&&this.jo(this.Ih(n,t,void 0,i))}this.Oo.size===2&&this.Oh()}Ah(t){var h;if(!this.zn)return;t.preventDefault(),(h=this.Io)==null||h.Qn(this.ph);const i=performance.now(),r=this.kh(t.changedTouches);for(const n of r){const a=this.Oo.get(n.id),c=a?this.zh(a):void 0;c&&this.Lo.set(n.id,c),this.Oo.set(n.id,n);const u=this.Do.get(n.id);u&&(u.lastPosition=n,u.lastTime=i,c)&&q(c.clientX,c.clientY,n.clientX,n.clientY)>this.hh&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.Zo&&this.Zo(this.Ih(n,t,c,i))}this.Oo.size===2?this.Lh(t):this.Bo=null}yh(t){if(!this.zn)return;t.preventDefault();const i=performance.now(),r=this.kh(t.changedTouches);for(const h of r){const n=this.Oo.get(h.id),a=n?this.zh(n):void 0,c=this.Do.get(h.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.Wo&&this.Wo(this.Ih(h,t,a,i)),c&&this.Dh(c,t),this.Do.delete(h.id),this.Lo.delete(h.id),this.Oo.delete(h.id)}this.Oo.size<2&&(this.Bo=null)}wh(t){if(!this.zn)return;t.preventDefault();const i=performance.now(),r=this.kh(t.changedTouches);for(const h of r){const n=this.Oo.get(h.id),a=n?this.zh(n):void 0,c=this.Do.get(h.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.qo&&this.qo(this.Ih(h,t,a,i)),this.Do.delete(h.id),this.Lo.delete(h.id),this.Oo.delete(h.id)}this.Oo.size<2&&(this.Bo=null)}kh(t){const i=[];for(let r=0;r<t.length;r+=1){const h=t.item(r);h&&i.push(this.Bh(h))}return i}Bh(t){return this.bh(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})}bh(t,i,r,h){const n=this.Pr.canvas,a=n.getBoundingClientRect(),c=t-a.left,u=i-a.top,f=n.width/a.width,d=u*(n.height/a.height),g=c*f-this.zn.offsetX,p=d-this.zn.offsetY,m=Math.floor(g/this.zn.cellWidth),v=Math.floor(p/this.zn.cellHeight),A=m>=0&&m<this.zn.cols&&v>=0&&v<this.zn.rows;return{id:r,x:A?m:-1,y:A?v:-1,clientX:t,clientY:i,pressure:h.pressure,radiusX:h.radiusX,radiusY:h.radiusY,rotationAngle:h.rotationAngle}}Ih(t,i,r,h){const n=this.Do.get(t.id),a=Array.from(this.Lo.values()).map(f=>this.zh(f)),c=Array.from(this.Oo.values()).map(f=>this.zh(f)),u=this.kh(i.changedTouches);return{touch:this.zh(t),previousTouch:r?this.zh(r):void 0,touches:c,previousTouches:a,changedTouches:u,deltaTime:n?h-n.lastTime:0,originalEvent:i}}Oh(){if(this.Oo.size!==2)return void(this.Bo=null);const t=Array.from(this.Oo.values()),[i,r]=t,h=q(i.x,i.y,r.x,r.y),n=bt(i.clientX,i.clientY,r.clientX,r.clientY);this.Bo={ids:[i.id,r.id],initialDistance:Math.max(h,1e-4),initialAngle:n,lastScale:1,lastRotation:0}}Lh(t){if(this.Bo||this.Oh(),!this.Bo)return;const[i,r]=this.Bo.ids,h=this.Oo.get(i),n=this.Oo.get(r);if(!h||!n)return;const a=q(h.x,h.y,n.x,n.y)/this.Bo.initialDistance,c=a-this.Bo.lastScale;this.sh&&Math.abs(c)>this.fh&&(this.sh({touches:[this.zh(h),this.zh(n)],scale:a,deltaScale:c,center:this.Hh(h,n),originalEvent:t}),this.Bo.lastScale=a);let u=bt(h.clientX,h.clientY,n.clientX,n.clientY)-this.Bo.initialAngle;u=(u+180)%360-180;const f=u-this.Bo.lastRotation;this.eh&&Math.abs(f)>this.dh&&(this.eh({touches:[this.zh(h),this.zh(n)],rotation:u,deltaRotation:f,center:this.Hh(h,n),originalEvent:t}),this.Bo.lastRotation=u)}Hh(t,i){const r=(t.clientX+i.clientX)/2,h=(t.clientY+i.clientY)/2,n=this.bh(r,h,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:h});return{x:n.x,y:n.y}}Dh(t,i){const r=performance.now(),h=r-t.startTime,n=q(t.startPosition.clientX,t.startPosition.clientY,t.lastPosition.clientX,t.lastPosition.clientY);if(!t.longPressFired&&h<=this.ih&&n<=this.nh)this.Gh(t.lastPosition,r)&&this.Qo?this.Qo({touch:this.zh(t.lastPosition),taps:2,originalEvent:i}):this.Vo&&this.Vo({touch:this.zh(t.lastPosition),taps:1,originalEvent:i});else if(!t.longPressFired&&h<=this.uh&&n>=this.ah){const a={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},f={x:a.x/h,y:a.y/h};this.th&&this.th({touch:this.zh(t.lastPosition),direction:u,distance:c,velocity:f,originalEvent:i})}this.gh=r,this.mh=this.zh(t.lastPosition)}Gh(t,i){return!!this.mh&&!(i-this.gh>this.rh)&&q(t.clientX,t.clientY,this.mh.clientX,this.mh.clientY)<=this.nh}zh(t){return{...t}}}const Ce=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:Bt},Symbol.toStringTag,{value:"Module"}));class ct extends at{constructor(i,r,h,n,a,c,u,f){const d=a/c;let g,p;d>1?(g=u,p=Math.round(u/d)):(p=f,g=Math.round(f*d));super(i,r,h,a,c,g,p);l(this,"Nh");l(this,"Xh",!1);l(this,"Yh",[]);l(this,"An",null);l(this,"Kh",0);l(this,"jh",0);l(this,"Zh",-1);this.Nh=n}D(){super.D();for(const i of this.Yh)this.A.deleteTexture(i);this.Yh=[],this.Nh.pause(),this.Nh.src="",this.Nh.load()}Wh(){if(!this.Xh&&this.Nh.readyState>=this.Nh.HAVE_CURRENT_DATA){const i=this.A;i.bindTexture(i.TEXTURE_2D,this.Qr),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this.Nh),i.bindTexture(i.TEXTURE_2D,null)}}dn(){if(this.Xh&&this.Yh.length>0){const i=this.jh%this.Yh.length;return this.Yh[i]}return this.Qr}ct(){return this.Z=null,super.ct()}ln(){this.Wh()}async qh(i,r){var h;try{if(i<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Nh.duration;if(!isFinite(n)||n<=0)throw Error("Video duration is invalid, cannot preload frames.");const a=Math.max(1,Math.ceil(n*i));if(this.Vh(i,a),await this.Qh(i,r))return void this.Jh("captureStream",r);await this.ta(i,r),this.Jh("seeking",r)}catch(n){const a=n instanceof Error?n:Error(n+"");throw(h=r==null?void 0:r.onError)==null||h.call(r,a),a}}Vh(i,r){this.An=i,this.Kh=r,this.Yh=[],this.Xh=!1,this.jh=0,this.Zh=-1}Jh(i,r){var h;if(this.Yh.length===0)throw Error(`Video preload via ${i} completed but produced 0 frames.`);this.Kh=this.Yh.length,this.Xh=!0,this.jh=0,this.Zh=-1,this.Nh.pause(),this.Nh.currentTime=0,r!=null&&r.onProgress&&r.onProgress({percent:100,loadedFrames:this.Kh,totalFrames:this.Kh,strategy:i}),(h=r==null?void 0:r.onComplete)==null||h.call(r,{totalFrames:this.Kh,strategy:i})}sa(i){const r=this.A,h=r.createTexture();return r.bindTexture(r.TEXTURE_2D,h),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),it(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}ea(i,r){if(!(r!=null&&r.onProgress)||this.Kh===0)return;const h=Math.min(99,Math.floor(this.Yh.length/this.Kh*100)),n=10*Math.floor(h/10);n>this.Zh&&(this.Zh=n,r.onProgress({percent:h,loadedFrames:this.Yh.length,totalFrames:this.Kh,strategy:i}))}async Qh(i,r){const h=globalThis,n=h==null?void 0:h.MediaStreamTrackProcessor,a=this.Nh.captureStream;if(typeof n!="function"||typeof a!="function")return!1;let c,u=null;try{const f=a.call(this.Nh);if(c=f.getVideoTracks()[0],!c)return f.getTracks().forEach(p=>p.stop()),!1;if(u=new n({track:c}).readable.getReader(),this.Nh.currentTime=0,this.Nh.muted=!0,await this.Nh.play().catch(()=>{}),this.Nh.paused)return!1;const d=1e6/i;let g=0;for(;this.Yh.length<this.Kh;){const p=await u.read();if(p.done)break;const m=p.value;if(m)try{const v=typeof m.timestamp=="number"?m.timestamp:g;(this.Yh.length===0||v>=g)&&(this.Yh.push(this.sa(m)),g=v+d,this.ea("captureStream",r))}finally{m.close()}}return u.releaseLock(),c.stop(),u=null,c=void 0,this.Nh.pause(),this.Nh.currentTime=0,this.Yh.length!==0}catch{return this.Yh=[],this.Zh=-1,!1}finally{if(u)try{await u.cancel()}catch{}c&&c.stop(),this.Nh.pause(),this.Nh.currentTime=0}}async ta(i,r){const h=1/i,n=this.Kh,a=this.Nh;a.pause();for(let c=0;c<n;c++){const u=Math.min(a.duration,c*h);await this.ia(u),this.Yh.push(this.sa(a)),this.ea("seeking",r)}a.currentTime=0}ia(i){return new Promise((r,h)=>{const n=this.Nh,a=()=>{n.removeEventListener("seeked",c),n.removeEventListener("error",u)},c=()=>{a(),r()},u=()=>{a(),h(Error("Video seek failed while preloading frames."))};n.addEventListener("seeked",c,{once:!0}),n.addEventListener("error",u,{once:!0});const f=isFinite(n.duration)?n.duration:i,d=Math.min(Math.max(i,0),f);if(Math.abs(n.currentTime-d)<1e-4)return a(),void r();n.currentTime=d})}frame(i){return this.Xh&&i!==void 0&&this.Kh>0&&(this.jh=(i%this.Kh+this.Kh)%this.Kh,this.Z=null),this}static async pn(i,r,h,n,a,c){const u=i.context,f=c==null?void 0:c.frameRate;let d;typeof r=="string"?(d=document.createElement("video"),d.crossOrigin="anonymous",d.loop=!0,d.muted=!0,d.playsInline=!0,await new Promise((A,E)=>{d.addEventListener("loadedmetadata",()=>A(),{once:!0}),d.addEventListener("error",y=>{var w;const T=y.target;E(Error("Failed to load video: "+(((w=T.error)==null?void 0:w.message)||"Unknown error")))},{once:!0}),d.src=r})):(d=r,d.readyState<d.HAVE_METADATA&&await new Promise((A,E)=>{d.addEventListener("loadedmetadata",()=>A(),{once:!0}),d.addEventListener("error",y=>{var T;return E(Error("Video error: "+((T=y.target.error)==null?void 0:T.message)))},{once:!0})}));const g=u.createTexture();u.bindTexture(u.TEXTURE_2D,g),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),it(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,d),u.bindTexture(u.TEXTURE_2D,null);const p=d.videoWidth,m=d.videoHeight,v=new ct(u,i,g,d,p,m,h,n);return v.hn=a,f&&f>0&&await v.qh(f,c),v}async play(){await this.Nh.play()}pause(){this.Nh.pause()}stop(){this.Nh.pause(),this.Nh.currentTime=0}speed(i){return this.Nh.playbackRate=i,this}loop(i=!0){return this.Nh.loop=i,this}time(i){return this.Nh.currentTime=i,this}volume(i){return this.Nh.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.Qr}get width(){return this.H}get height(){return this.G}get originalWidth(){return this.Jr}get originalHeight(){return this.tn}get videoElement(){return this.Nh}get currentTime(){return this.Nh.currentTime}get duration(){return this.Nh.duration}get isPlaying(){return!this.Nh.paused&&!this.Nh.ended}get isPreloaded(){return this.Xh}get totalFrames(){return this.Kh}get preloadFrameRate(){return this.An}get currentFrameIndex(){return this.jh}}const Me=o=>class extends o{ra(t,i,r,h){if(I.Vr(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,h);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.j.state.Wt(t),this.j.state.qt(i),this.j.state.Vt(r)}rotateX(t){this.j.state.Wt(t)}rotateY(t){this.j.state.qt(t)}rotateZ(t){this.j.state.Vt(t)}translate(t=0,i=0,r=0){this.j.state.Qt(t,i,r)}translateX(t){this.j.state.Qt(t,0,0)}translateY(t){this.j.state.Qt(0,t,0)}translateZ(t){this.j.state.Qt(0,0,t)}push(){this.j.state.rt()}pop(){this.j.state.nt()}color(t,i,r,h){if(I.Vr(t))return t;if(typeof t=="string"){const n=Array.from(t);if(n.length===1){const a=n[0],c=this.ir.sr(a);return I.qr(c)}return I.Wr(t)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?I.jr(t,i,r,h??255):typeof i=="number"&&r===void 0?I.Zr(t,i):I.Zr(t,h??255);throw Error("Unsupported color input passed to color().")}rect(t=1,i=1){this.j.gi(t,i)}point(){this.j.gi(1,1)}line(t,i,r,h){this.j.mi(t,i,r,h)}lineWeight(t){this.j.state.jt(t)}background(t,i,r,h=255){const n=this.ra(t,i,r,h);this.j.Ci(n.r,n.g,n.b,n.a)}char(t){if(I.Vr(t)){const r=t.character;return void(r&&this.j.state.es(r))}const i=Array.from(t);if(i.length===0)throw Error("char() requires at least one character.");this.j.state.es(this.ir.sr(i[0]))}charColor(t,i,r,h){const n=this.ra(t,i,r,h);this.j.state.rs(n.r,n.g,n.b,n.a)}cellColor(t,i,r,h){const n=this.ra(t,i,r,h);this.j.state.ns(n.r,n.g,n.b,n.a)}flipX(t){this.j.state.hs(t)}flipY(t){this.j.state.cs(t)}charRotation(t){this.j.state.us(t)}invert(t){this.j.state.ls(t)}clear(){this.j.Ci(0,0,0,0)}ellipse(t,i){this.j._i(t/2,i/2)}triangle(t,i,r,h,n,a){this.j.Ai(t,i,r,h,n,a)}bezierCurve(t,i,r,h,n,a,c,u){this.j.yi(t,i,r,h,n,a,c,u)}arc(t,i,r,h){this.j.wi(t/2,i/2,r,h)}shader(t){this.j.li(t)}setUniform(t,i){this.j.O(t,i)}setUniforms(t){this.j.ui(t)}async createFilterShader(t){if(typeof t=="string"&&(t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const i=await fetch(t);if(!i.ok)throw Error(`Failed to load shader from ${t}: ${i.statusText}`);const r=await i.text();return this.j.fi(r)}return this.j.fi(t)}createFramebuffer(t){return this.j.bi(t.width??this.grid.cols,t.height??this.grid.rows,3)}image(t,i,r){this.j.di(t,i,r)}ortho(){this.j.state.ds(!0)}async loadImage(t){if(typeof t!="string")return k.pn(this.j,t,this.zn.cols,this.zn.rows,h=>this.ir.er(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 k.pn(this.j,r,this.zn.cols,this.zn.rows,h=>this.ir.er(h))}async loadVideo(t,i){return ct.pn(this.j,t,this.zn.cols,this.zn.rows,r=>this.ir.er(r),i)}},Ne=o=>class extends o{async loadFont(t){return this.ir.br(t).then(()=>{const i=this.ir.maxGlyphDimensions;this.zn.Sr(i.width,i.height),this.na.resize(this.zn.cols,this.zn.rows),this.j.Mi(),this.Io.eo(),this.oa.eo()})}fontSize(t){if(!Z.m(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.ir.fontSize===t)return;this.ir.wr(t);const i=this.ir.maxGlyphDimensions;this.zn.Sr(i.width,i.height),this.na.resize(this.zn.cols,this.zn.rows),this.j.Mi(),this.Io.eo(),this.oa.eo()}},Ie=o=>class extends o{get frameCount(){return this.ha.Sn}set frameCount(t){this.ha.Sn=t}frameRate(t){return t===void 0?this.ha.Rn:this.ha.Tn(t,()=>this.aa())}noLoop(){this.ha.Fn()}loop(){this.ha.$n(()=>this.aa())}redraw(t=1){if(Z.m(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.aa()}isLooping(){return this.ha.En}},Ue=o=>class extends o{constructor(...t){super(...t)}mouseClicked(t){this.Io.uo(t)}mousePressed(t){this.Io.fo(t)}mouseReleased(t){this.Io.do(t)}mouseMoved(t){this.Io.po(t)}mouseScrolled(t){this.Io.vo(t)}get mouse(){return this.Io.mo()}cursor(t){this.Io.so(t)}},De=o=>class extends o{constructor(...t){super(...t)}touchStarted(t){this.oa.Mh(t)}touchMoved(t){this.oa.po(t)}touchEnded(t){this.oa.xh(t)}touchCancelled(t){this.oa.Fh(t)}tap(t){this.oa.$h(t)}doubleTap(t){this.oa.Th(t)}longPress(t){this.oa.Ph(t)}swipe(t){this.oa.Eh(t)}pinch(t){this.oa.Rh(t)}rotateGesture(t){this.oa.Sh(t)}get touches(){return this.oa.Ch()}},ze=o=>class extends o{constructor(...t){super(...t)}keyPressed(t){this.ca.fo(t)}keyReleased(t){this.ca.do(t)}isKeyPressed(t){return this.ca.To(t)}get lastKeyPressed(){return this.ca.Eo()}get lastKeyReleased(){return this.ca.Ro()}get pressedKeys(){return this.ca.So()}get modifierState(){return this.ca.ko()}};class Le{constructor(t){l(this,"la");l(this,"ua",new Map);l(this,"fa",[]);l(this,"da",new Map);l(this,"pa",new Map);this.la=t}async ga(t){for(const i of t){if(this.ua.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.va(i.name);try{await i.install(this.la,r)}catch(h){throw this.ma(i.name),h}this.ua.set(i.name,i),this.fa.push(i.name)}}async _a(t){const i=this.ua.get(t);if(!i)return;const r=this.va(t);i.uninstall&&await i.uninstall(this.la,r),this.ua.delete(t),this.fa.splice(this.fa.indexOf(t),1),this.ma(t)}ya(){this.wa(this.da)}ba(){this.wa(this.pa)}async Ca(){const t=[...this.ua.keys()];for(const i of t)await this._a(i)}va(t){return{renderer:this.la.j,font:this.la.ir,grid:this.la.zn,canvas:this.la.Pr,drawFramebuffer:this.la.na,asciiFramebuffer:this.la.Ma,registerPreDrawHook:i=>this.xa(this.da,t,i),registerPostDrawHook:i=>this.xa(this.pa,t,i)}}xa(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))}}ma(t){this.da.delete(t),this.pa.delete(t)}wa(t){for(const i of this.fa){const r=t.get(i);r&&r.forEach(h=>h())}}}const St=`#version 300 es
|
|
12
|
-
|
|
13
|
-
precision highp float;uniform sampler2D
|
|
14
|
-
precision highp float;uniform sampler2D
|
|
7
|
+
`}static o(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 t+"";if(Array.isArray(t))return t.length===0?"[]":t.length<=5?`[${t.map(i=>P.o(i)).join(", ")}]`:`[${t.slice(0,3).map(i=>P.o(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}: ${P.o(t[r])}`).join(", ")} }`:`{ ${i.slice(0,2).map(r=>`${r}: ${P.o(t[r])}`).join(", ")}, ... +${i.length-2} more }`}return t+""}}var O=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(O||{});const G=class G{constructor(){l(this,"l",{globalLevel:3})}static u(){return G.h||(G.h=new G),G.h}v(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.l.globalLevel){case 0:return!1;case 1:return console.group(r,h),console.warn(P.i(t,i)),console.groupEnd(),!1;case 2:return console.group(r,h),console.error(P.i(t,i)),console.groupEnd(),!1;default:throw new P(t,i)}}m(t,i,r){return!!t||(this.v(i,r),!1)}_(t){this.l.globalLevel=t}};l(G,"h",null);let lt=G;const Z=lt.u();class j{constructor(t,i,r){l(this,"A");l(this,"C");l(this,"M",new Map);l(this,"F",new Map);l(this,"U",0);this.A=t,this.C=this.$(i,r),this.P()}P(){const t=this.A.getProgramParameter(this.C,this.A.ACTIVE_UNIFORMS);for(let i=0;i<t;i++){const r=this.A.getActiveUniform(this.C,i);if(r){const h=r.name.replace(/\[0\]$/,""),n=this.A.getUniformLocation(this.C,h);n&&(this.M.set(h,n),this.F.set(h,{type:r.type,size:r.size}))}}}$(t,i){const r=this.R(this.A.VERTEX_SHADER,t),h=this.R(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 c=this.A.getProgramInfoLog(n);throw Error("Shader program link error: "+c)}return this.A.deleteShader(r),this.A.deleteShader(h),n}R(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),Error("Shader compilation error: "+h)}return r}S(){this.A.useProgram(this.C),this.k()}k(){this.U=0}I(t){for(const i in t)this.O(i,t[i])}O(t,i){var u,f;const r=this.M.get(t);if(!r)return;const h=this.F.get(t);if(!h)return;const{type:n,size:c}=h,a=this.A;if(i instanceof WebGLTexture){const d=this.U++;return a.uniform1i(r,d),a.activeTexture(a.TEXTURE0+d),void a.bindTexture(a.TEXTURE_2D,i)}if(i instanceof Q){const d=this.U++;return a.uniform1i(r,d),a.activeTexture(a.TEXTURE0+d),void a.bindTexture(a.TEXTURE_2D,i.textures[0])}if(typeof i!="number")if(typeof i!="boolean")if(Array.isArray(i[0])){const d=i.flat(),g={[a.FLOAT_VEC2]:()=>a.uniform2fv(r,d),[a.FLOAT_VEC3]:()=>a.uniform3fv(r,d),[a.FLOAT_VEC4]:()=>a.uniform4fv(r,d)};(u=g[n])==null||u.call(g)}else{const d=i,g={[a.FLOAT]:()=>c>1?a.uniform1fv(r,d):a.uniform1f(r,d[0]),[a.FLOAT_VEC2]:()=>a.uniform2fv(r,d),[a.FLOAT_VEC3]:()=>a.uniform3fv(r,d),[a.FLOAT_VEC4]:()=>a.uniform4fv(r,d),[a.INT]:()=>c>1?a.uniform1iv(r,d):a.uniform1i(r,d[0]),[a.INT_VEC2]:()=>a.uniform2iv(r,d),[a.INT_VEC3]:()=>a.uniform3iv(r,d),[a.INT_VEC4]:()=>a.uniform4iv(r,d),[a.BOOL]:()=>a.uniform1iv(r,d),[a.FLOAT_MAT2]:()=>a.uniformMatrix2fv(r,!1,d),[a.FLOAT_MAT3]:()=>a.uniformMatrix3fv(r,!1,d),[a.FLOAT_MAT4]:()=>a.uniformMatrix4fv(r,!1,d)};(f=g[n])==null||f.call(g)}else a.uniform1i(r,i?1:0);else n===a.INT||n===a.BOOL?a.uniform1i(r,i):a.uniform1f(r,i)}get L(){return this.C}D(){this.A.deleteProgram(this.C)}}function xt(o,t,i,r){return 180*Math.atan2(r-t,i-o)/Math.PI}function V(o,t,i,r){return Math.hypot(i-o,r-t)}function z(o,t,i){return Math.min(Math.max(o,t),i)}function Rt(o){return(o%360+360)%360/360}function Pt(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 tt(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 ut(o,t,i,r,h,n=0,c=WebGL2RenderingContext.FLOAT,a=!1){o.enableVertexAttribArray(t),o.vertexAttribPointer(t,i,c,a,r,h),o.vertexAttribDivisor(t,n)}function Ct(o,t,i,r,h){o.bindBuffer(t,i),o.bufferData(t,r,h),o.bindBuffer(t,null)}const et=`#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 Ug;uniform float Uh;uniform float Ui;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/Ug)*2.0f;AA.y=-AA.y;float AB=y.z/Ug.y;float AC=clamp(-AB*Uh,-0.99f,0.99f);if(Ui>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);}}`,W=class W{constructor(t,i,r=i,h=1,n={},c){l(this,"H");l(this,"G");l(this,"l");l(this,"A");l(this,"N");l(this,"X",[]);l(this,"Y",null);l(this,"K");l(this,"j");l(this,"W",null);l(this,"Z",new Map);this.H=i,this.G=r,this.A=t,this.K=z(h,1,8),this.j=c,this.l={filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte",depth:!0,...n},W.V||(W.V=new j(t,et,`#version 300 es
|
|
9
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Uc;uniform sampler2D Ud;uniform sampler2D Ue;uniform vec2 Uf;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*Uf;vec2 C=(floor(B)+0.5f)/Uf;vec4 D=texture(Uc,C);vec4 E=texture(Ud,C);if(E.a==0.){discard;}vec4 F=texture(Ue,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const a=t.getParameter(t.MAX_DRAW_BUFFERS),u=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,a,u),this.N=t.createFramebuffer(),this.q(),this.J(),this.l.depth&&this.tt()}q(){const t=this.A,i=this.l.filter==="linear"?t.LINEAR:t.NEAREST,r=this.l.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,h=this.l.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,n=h===t.FLOAT?t.RGBA32F:t.RGBA8,c=t.RGBA;for(let a=0;a<this.K;a++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),tt(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,n,this.H,this.G,0,c,h,null),this.X.push(u)}t.bindTexture(t.TEXTURE_2D,null)}J(){const t=this.A;if(t.bindFramebuffer(t.FRAMEBUFFER,this.N),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.X[0],0);else{const i=[];for(let r=0;r<this.K;r++){const h=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,h,t.TEXTURE_2D,this.X[r],0),i.push(h)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}tt(){const t=this.A;this.Y=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.Y),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.H,this.G),t.bindFramebuffer(t.FRAMEBUFFER,this.N),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.Y),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}st(t){Pt(this.A,this.X[0],t)}resize(t,i){this.H=t,this.G=i,this.Z.clear();const r=this.A,h=this.l.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,n=h===r.FLOAT?r.RGBA32F:r.RGBA8,c=r.RGBA;for(const a of this.X)r.bindTexture(r.TEXTURE_2D,a),r.texImage2D(r.TEXTURE_2D,0,n,this.H,this.G,0,c,h,null);r.bindTexture(r.TEXTURE_2D,null),this.Y&&(r.bindRenderbuffer(r.RENDERBUFFER,this.Y),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.H,this.G),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.Z.get(t);if(i)return i;const r=this.A,h=this.H,n=this.G,c=new Uint8Array(h*n*4),a=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.N),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,h,n,r.RGBA,r.UNSIGNED_BYTE,c),r.bindFramebuffer(r.READ_FRAMEBUFFER,a);const u=4*h,f=new Uint8Array(c.length);for(let d=0;d<n;d++){const g=(n-1-d)*u,m=d*u;f.set(c.subarray(g,g+u),m)}return this.Z.set(t,f),f}begin(){const t=this.A;this.Z.clear(),this.j.et(),this.j.it(this.N,this.H,this.G),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.j.state.rt()}end(){this.j.state.nt(),this.j.ot();const t=this.j.ht();this.j.it(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.W||this.lt(),this.W}lt(){if(!this.j)return;const t={Uc:this.X[0],Ud:this.X[1],Ue:this.X[2],Uf:[this.H,this.G]},i=W.V;this.W=this.j.ft.ut(i,t,!0)}D(){const t=this.A;t.deleteFramebuffer(this.N);for(const i of this.X)t.deleteTexture(i);this.Y&&t.deleteRenderbuffer(this.Y)}get width(){return this.H}get height(){return this.G}get textures(){return this.X}get attachmentCount(){return this.K}};l(W,"V",null);let Q=W;const Ft=new WeakMap;function ft(o,t){Ft.set(o,t)}function Mt(o){return Ft.get(o)}function it(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,"dt",1);l(this,"gt",0);l(this,"vt",0);l(this,"_t",0);l(this,"At",0);l(this,"yt",0);l(this,"wt",0);l(this,"bt",[0,0,0]);l(this,"Ct",[1,1,1,1]);l(this,"Mt",[0,0,0,1]);l(this,"xt",!1);l(this,"Ft",!1);l(this,"$t",!1);l(this,"Tt",0);l(this,"Pt",[0,0,0,1]);l(this,"Et",!1);l(this,"Rt",[]);l(this,"St",[])}static kt(){return{zt:1,It:0,Ot:0,Lt:0,At:0,yt:0,wt:0,Tt:0,Dt:!1,Ht:!1,$t:!1,Et:!1,Bt:[0,0,0],Gt:[1,1,1,1],Nt:[0,0,0,1]}}Xt(t){t.zt=this.dt,t.It=this.gt,t.Ot=this.vt,t.Lt=this._t,t.At=this.At,t.yt=this.yt,t.wt=this.wt,t.Dt=this.xt,t.Ht=this.Ft,t.$t=this.$t,t.Tt=this.Tt,t.Et=this.Et,t.Bt[0]=this.bt[0],t.Bt[1]=this.bt[1],t.Bt[2]=this.bt[2],t.Gt[0]=this.Ct[0],t.Gt[1]=this.Ct[1],t.Gt[2]=this.Ct[2],t.Gt[3]=this.Ct[3],t.Nt[0]=this.Mt[0],t.Nt[1]=this.Mt[1],t.Nt[2]=this.Mt[2],t.Nt[3]=this.Mt[3]}Yt(t){this.dt=t.zt,this.gt=t.It,this.vt=t.Ot,this._t=t.Lt,this.At=t.At,this.yt=t.yt,this.wt=t.wt,this.xt=t.Dt,this.Ft=t.Ht,this.$t=t.$t,this.Tt=t.Tt,this.Et=t.Et,this.bt[0]=t.Bt[0],this.bt[1]=t.Bt[1],this.bt[2]=t.Bt[2],this.Ct[0]=t.Gt[0],this.Ct[1]=t.Gt[1],this.Ct[2]=t.Gt[2],this.Ct[3]=t.Gt[3],this.Mt[0]=t.Nt[0],this.Mt[1]=t.Nt[1],this.Mt[2]=t.Nt[2],this.Mt[3]=t.Nt[3]}rt(){let t=this.St.pop();t||(t=rt.kt()),this.Xt(t),this.Rt.push(t)}nt(){const t=this.Rt.pop();t?(this.Yt(t),this.St.push(t)):console.warn("pop() called without matching push()")}Kt(t){this.Xt(t)}jt(t){this.dt=Math.abs(t)}Wt(){this.gt=0,this.vt=0,this._t=0,this.At=0,this.yt=0,this.wt=0,this.Et=!1}Zt(t){t!==0&&(this.At+=t*Math.PI/180)}Vt(t){t!==0&&(this.yt+=t*Math.PI/180)}qt(t){t!==0&&(this.wt+=t*Math.PI/180)}Qt(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.gt+=t,this.vt+=i,this._t+=r)}Jt(t){this.Qt(t,0,0)}ts(t){this.Qt(0,t,0)}ss(t){this.Qt(0,0,t)}es(t){this.bt[0]=t[0],this.bt[1]=t[1],this.bt[2]=t[2]}rs(t,i,r,h=255){it(this.Ct,t,i,r,h)}ns(t,i,r,h=255){it(this.Mt,t,i,r,h)}hs(t){this.xt=t}cs(t){this.Ft=t}ls(t){this.$t=t}us(t){this.Tt=Rt(t)}fs(t,i,r,h){it(this.Pt,t,i,r,h)}ds(t){this.Et=t}get canvasBackgroundColor(){return this.Pt}get useOrtho(){return this.Et}get rotationX(){return this.At}get rotationY(){return this.yt}get rotationZ(){return this.wt}}const dt=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]),_={ps:16,gs:WebGL2RenderingContext.TRIANGLES,vs:{_s:{size:2,offset:0},As:{size:2,offset:8}}};class Zt{constructor(t){l(this,"A");l(this,"ws");l(this,"bs");this.A=t,this.ws=t.createBuffer(),this.bs=new Float32Array(dt.length)}Cs(t,i,r,h){const n=this.A,c=Mt(this.A),a=c[2],u=c[3],f=t/a*2-1,d=(t+r)/a*2-1,g=1-(i+h)/u*2,m=1-i/u*2,p=dt,v=this.bs;for(let A=0;A<p.length;A+=4){const E=p[A],y=p[A+1],b=p[A+2],w=p[A+3],R=f+(E+.5)*(d-f),T=g+(y+.5)*(m-g);v[A]=R,v[A+1]=T,v[A+2]=b,v[A+3]=w}n.bindBuffer(n.ARRAY_BUFFER,this.ws),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.ws)}}var C=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(C||{});const Vt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class Qt{constructor(t){l(this,"A");l(this,"Ms",new Map);this.A=t}Fs(t,i,r,h){const n=this.A;let c=this.Ms.get(t);c||(c=new Map,this.Ms.set(t,c));let a=c.get(i)||null;if(!a){a=n.createVertexArray(),c.set(i,a),n.bindVertexArray(a),n.bindBuffer(n.ARRAY_BUFFER,h);const u=n.getAttribLocation(t,"A0");u!==-1&&ut(n,u,r.vs._s.size,r.ps,r.vs._s.offset,0,n.FLOAT,!1);const f=n.getAttribLocation(t,"A1");f!==-1&&ut(n,f,r.vs.As.size,r.ps,r.vs.As.offset,0,n.FLOAT,!1)}n.bindVertexArray(a)}$s(){this.A.bindVertexArray(null)}D(){for(const[,t]of this.Ms)for(const[,i]of t)i&&this.A.deleteVertexArray(i)}}const Y=class Y{static Ts(t,i,r=0){const h=i||new Float32Array(Y.FLOATS_PER_INSTANCE);let n=r;h[n++]=t._s[0],h[n++]=t._s[1],h[n++]=t.Ps[0],h[n++]=t.Ps[1],h[n++]=t.Bt[0],h[n++]=t.Bt[1],h[n++]=t.Bt[2],h[n++]=t.Gt[0],h[n++]=t.Gt[1],h[n++]=t.Gt[2],h[n++]=t.Gt[3],h[n++]=t.Nt[0],h[n++]=t.Nt[1],h[n++]=t.Nt[2],h[n++]=t.Nt[3],h[n++]=t.Es[0],h[n++]=t.Es[1],h[n++]=t.Es[2],h[n++]=t.Tt;const c=t.Rs;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 a=t.Ss;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 u=t.ks,f=t.zs,d=t.Is,g=t.Os,m=t.Ls,p=!(!f||!d);return p?(h[n++]=(g==null?void 0:g[0])??0,h[n++]=(g==null?void 0:g[1])??0,h[n++]=(m==null?void 0:m[0])??0,h[n++]=(m==null?void 0:m[1])??0,h[n++]=f[0],h[n++]=f[1],h[n++]=d[0],h[n++]=d[1]):!p&&!!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.Ds??0,h[n++]=t.Hs??0,h[n++]=t.Bs??0,h}static Gs(t,i){const r=t.length*Y.FLOATS_PER_INSTANCE,h=i||new Float32Array(r);for(let n=0;n<t.length;n++){const c=n*Y.FLOATS_PER_INSTANCE;Y.Ts(t[n],h,c)}return h}};l(Y,"BYTES_PER_INSTANCE",144),l(Y,"FLOATS_PER_INSTANCE",36);let L=Y;const S=class S{};l(S,"STRIDE",L.BYTES_PER_INSTANCE),l(S,"ATTRIBUTES",{A2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:0,divisor:1},A3:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:8,divisor:1},A4:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:16,divisor:1},A5:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:28,divisor:1},A6:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:44,divisor:1},A7:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:60,divisor:1},A8:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:76,divisor:1},A9:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:88,divisor:1},Aa:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:100,divisor:1},Ab:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:116,divisor:1},Ac:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:S.STRIDE,offset:132,divisor:1}});let q=S;class qt{constructor(t=1e3,i=1.5){l(this,"Ns");l(this,"Xs");l(this,"Ys");l(this,"Ks",0);l(this,"js",0);this.Xs=t,this.Ys=i;const r=t*L.FLOATS_PER_INSTANCE;this.Ns=new Float32Array(r)}Ws(t){if(t<=this.Xs)return;const i=Math.ceil(t*this.Ys),r=this.Xs;this.Xs=i;const h=i*L.FLOATS_PER_INSTANCE,n=new Float32Array(h),c=r*L.FLOATS_PER_INSTANCE;n.set(this.Ns.subarray(0,Math.min(c,this.Ks))),this.Ns=n}Zs(){return{buffer:this.Ns,offset:this.Ks}}Vs(t){this.Ks+=t,this.js++}qs(){this.Ks=0,this.js=0}Qs(t=0,i){return this.Ns.subarray(t,i??this.Ks)}get Js(){return this.js}get te(){return this.Xs}get se(){return this.Ks}get ee(){return this.js===0}}class Jt{constructor(t){l(this,"Ns");this.Ns=t}ie(t){this.Ns.Ws(this.Ns.Js+1);const{buffer:i,offset:r}=this.Ns.Zs();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.char0,i[r+5]=t.char1,i[r+6]=t.char2,i[r+7]=t.r1,i[r+8]=t.g1,i[r+9]=t.b1,i[r+10]=t.a1,i[r+11]=t.r2,i[r+12]=t.g2,i[r+13]=t.b2,i[r+14]=t.a2,i[r+15]=t.invert,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.charRot,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.translationZ,i[r+22]=t.rotationX,i[r+23]=t.rotationY,i[r+24]=t.rotationZ;const h=t.curveParams0,n=t.curveParams1;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.depth,i[r+34]=t.baseZ,i[r+35]=t.geometryType,this.Ns.Vs(L.FLOATS_PER_INSTANCE),this.Ns.Js-1}get Js(){return this.Ns.Js}}class $t{constructor(t,i=1e3){l(this,"A");l(this,"re",null);l(this,"ne",0);l(this,"oe",new Map);this.A=t,this.he(i)}he(t){const i=this.A;this.re&&i.deleteBuffer(this.re),this.re=i.createBuffer();const r=t*L.BYTES_PER_INSTANCE;Ct(i,i.ARRAY_BUFFER,this.re,r,i.DYNAMIC_DRAW),this.ne=t}ae(t){this.he(t)}get te(){return this.ne}ce(t,i){if(i===0)return;const r=this.A;r.bindBuffer(r.ARRAY_BUFFER,this.re);const h=i*L.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,h)}le(t){let i=this.oe.get(t);if(!i){i=new Map;const r=this.A;for(const h in q.ATTRIBUTES){const n=r.getAttribLocation(t,h);n!==-1&&i.set(h,n)}this.oe.set(t,i)}return i}ue(t){const i=this.A,r=t.L,h=this.le(r);for(const[n,c]of h){const a=q.ATTRIBUTES[n];a&&ut(i,c,a.size,a.stride,a.offset,a.divisor,a.type,a.normalized)}}fe(t){const i=this.A,r=this.le(t.L);for(const[h,n]of r)q.ATTRIBUTES[h]&&(i.disableVertexAttribArray(n),i.vertexAttribDivisor(n,0))}D(){this.re&&(this.A.deleteBuffer(this.re),this.re=null),this.oe.clear()}}class te{constructor(t,i=1e3,r=1.5){l(this,"A");l(this,"Ns");l(this,"de");l(this,"pe");this.A=t,this.Ns=new qt(i,r),this.de=new Jt(this.Ns),this.pe=new $t(t,i)}ge(t){var h,n,c,a,u,f,d,g,m,p;const i=[0,0,0,0],r=[0,0,0,0];return t.zs&&t.Is?(i[0]=((h=t.Os)==null?void 0:h[0])??0,i[1]=((n=t.Os)==null?void 0:n[1])??0,i[2]=((c=t.Ls)==null?void 0:c[0])??0,i[3]=((a=t.Ls)==null?void 0:a[1])??0,r[0]=t.zs[0],r[1]=t.zs[1],r[2]=t.Is[0],r[3]=t.Is[1]):t.ks&&(i[0]=t.ks[0],i[1]=t.ks[1]),this.ie({x:t._s[0],y:t._s[1],width:t.Ps[0],height:t.Ps[1],char0:t.Bt[0],char1:t.Bt[1],char2:t.Bt[2],r1:t.Gt[0],g1:t.Gt[1],b1:t.Gt[2],a1:t.Gt[3],r2:t.Nt[0],g2:t.Nt[1],b2:t.Nt[2],a2:t.Nt[3],invert:t.Es[0],flipX:t.Es[1],flipY:t.Es[2],charRot:t.Tt,translationX:((u=t.Rs)==null?void 0:u[0])??0,translationY:((f=t.Rs)==null?void 0:f[1])??0,translationZ:((d=t.Rs)==null?void 0:d[2])??0,rotationX:((g=t.Ss)==null?void 0:g[0])??0,rotationY:((m=t.Ss)==null?void 0:m[1])??0,rotationZ:((p=t.Ss)==null?void 0:p[2])??0,curveParams0:i,curveParams1:r,depth:t.Ds||0,baseZ:t.Hs||0,geometryType:t.Bs||0})}ie(t){const i=this.de.ie(t);return this.Ns.te>this.pe.te&&this.pe.ae(this.Ns.te),i}get ve(){return this.Ns.Js}get ee(){return this.Ns.ee}me(){this.Ns.qs()}ue(t){const i=this.Ns.Js;if(i===0)return;const r=this.Ns.Qs();this.pe.ce(r,i),this.pe.ue(t)}fe(t){this.pe.fe(t)}Cs(t,i){const r=this.Ns.Js;r!==0&&this.A.drawArraysInstanced(t,0,i,r)}D(){this.pe.D()}}class H{constructor(t,i,r,h){l(this,"A");l(this,"_e");l(this,"Ae");l(this,"ye");l(this,"we",null);this.A=t,this._e=i,this.Ae=r,this.ye=h;const n=this.A.createBuffer();Ct(this.A,this.A.ARRAY_BUFFER,n,this.ye.be,this.A.STATIC_DRAW),this.we=n}get type(){return this.Ae}get unitGeometry(){return this.ye}get unitBuffer(){return this.we}get batch(){return this._e}Ce(){this._e.me()}Me(){return!this._e.ee}D(){this._e.D(),this.A.deleteBuffer(this.we)}xe(t,i,r){return this._e.ge(t)}Fe(t,i,r,h,n,c){const a=n.It??0,u=n.Ot??0,f=n.Lt??0,d=n.At??0,g=n.yt??0,m=n.wt??0,p=[0,0,0,0],v=[0,0,0,0];c&&(c.bezStartX!==void 0&&c.bezStartY!==void 0&&c.bezEndX!==void 0&&c.bezEndY!==void 0?(p[0]=c.cp1x??0,p[1]=c.cp1y??0,p[2]=c.cp2x??0,p[3]=c.cp2y??0,v[0]=c.bezStartX??0,v[1]=c.bezStartY??0,v[2]=c.bezEndX??0,v[3]=c.bezEndY??0):c.arcStart===void 0&&c.arcStop===void 0||(p[0]=c.arcStart??0,p[1]=c.arcStop??0));const A={x:t,y:i,width:r,height:h,char0:n.Bt[0],char1:n.Bt[1],char2:n.Bt[2],r1:n.Gt[0],g1:n.Gt[1],b1:n.Gt[2],a1:n.Gt[3],r2:n.Nt[0],g2:n.Nt[1],b2:n.Nt[2],a2:n.Nt[3],invert:n.$t?1:0,flipX:n.Dt?1:0,flipY:n.Ht?1:0,charRot:n.Tt,translationX:a,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:m,curveParams0:p,curveParams1:v,depth:(c==null?void 0:c.depth)??0,baseZ:(c==null?void 0:c.baseZ)??0,geometryType:Vt[this.Ae]??0};return this._e.ie(A)}}const ee={be:dt,$e:6,..._},ie={be: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]),$e:6,..._},re={be: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,c=Math.cos(h),a=Math.sin(h),u=.5*(c+1),f=.5*(a+1),d=Math.cos(n),g=Math.sin(n),m=.5*(d+1),p=.5*(g+1);t.push(0,0,.5,.5,c,a,u,f,d,g,m,p)}return new Float32Array(t)}(32),$e:96,..._};let se={be: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),$e:96,..._};const ne={be:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),$e:3,..._},he={be: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),$e:96,..._},oe={[C.RECTANGLE]:class extends H{constructor(o,t){super(o,t,C.RECTANGLE,ee)}ge(o,t){return this.Fe(0,0,o.width,o.height,t)}},[C.LINE]:class extends H{constructor(o,t){super(o,t,C.LINE,ie)}ge(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,h=Math.hypot(i,r),n=Math.atan2(r,i),c=t.zt||1,a=o.x1+i/2-h/2,u=o.y1+r/2,f={...t,wt:(t.wt||0)+n};return this.Fe(a,u,h,c,f)}},[C.ELLIPSE]:class extends H{constructor(o,t){super(o,t,C.ELLIPSE,re)}ge(o,t){return this.Fe(0,0,o.width,o.height,t)}},[C.ARC]:class extends H{constructor(o,t){super(o,t,C.ARC,se)}ge(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Fe(0,0,o.width,o.height,t,{arcStart:i,arcStop:r})}},[C.TRIANGLE]:class extends H{constructor(o,t){super(o,t,C.TRIANGLE,ne)}ge(o,t){const i=Math.min(o.x1,o.x2,o.x3),r=Math.max(o.x1,o.x2,o.x3),h=Math.min(o.y1,o.y2,o.y3),n=r-i,c=Math.max(o.y1,o.y2,o.y3)-h;return this.Fe(i,h,n,c,t)}},[C.BEZIER_CURVE]:class extends H{constructor(o,t){super(o,t,C.BEZIER_CURVE,he)}ge(o,t){return this.Fe(0,0,1,t.zt||1,t,{cp1x:o.cp1x,cp1y:o.cp1y,cp2x:o.cp2x,cp2y:o.cp2y,bezStartX:o.x1,bezStartY:o.y1,bezEndX:o.x2,bezEndY:o.y2})}}};class ae{constructor(t){l(this,"A");l(this,"Te");l(this,"Pe");this.A=t,this.Pe=new Qt(t),this.Te=new Map;for(const i of Object.values(C)){const r=new te(t),h=new oe[i](t,r);this.Te.set(i,h)}}Ee(t){const i=this.Re(t);for(const r of i)this.Se(r)}Re(t){const i=[];let r=null,h=null,n=null;for(const c of t)h!==c.material||n!==c.type?(r&&r.length>0&&i.push({material:h,type:n,commands:r}),r=[c],h=c.material,n=c.type):r.push(c);return r&&r.length>0&&i.push({material:h,type:n,commands:r}),i}Se(t){const{material:i,type:r,commands:h}=t,n=this.Te.get(r);i.shader.S(),i.shader.I(i.uniforms);const c=Mt(this.A),a=h.length>0&&h[0].state.Et;i.shader.I({Uy:c[2]/c[3],Ug:[c[2],c[3]],Uh:1,Ui:a?1:0}),n.Ce();for(const u of h)n.ge(u.params,u.state);if(n.Me()){const u=n.unitGeometry,f=n.unitBuffer;try{this.Pe.Fs(i.shader.L,r+"",u,f),n.batch.ue(i.shader),n.batch.Cs(u.gs,u.$e)}finally{n.batch.fe(i.shader),this.Pe.$s(),n.Ce()}}}D(){for(const t of this.Te.values())t.D();this.Te.clear(),this.Pe.D()}}function Ut(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Xt(o){return Ut(o+"")}function J(o,t){return(o<<5)-o+t}class ce{constructor(t){l(this,"A");l(this,"ke",0);l(this,"ze");l(this,"Ie");l(this,"Oe",new Map);this.A=t,this.ze=new j(t,et,`#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.Ie={id:this.ke++,shader:this.ze,uniforms:Object.freeze({}),hash:this.Le(this.ze,{}),isBuiltIn:!0}}get De(){return this.Ie}ut(t,i={},r=!1){const h=this.Le(t,i),n=this.Oe.get(h);if(n)return n;const c={id:this.ke++,shader:t,uniforms:Object.freeze({...i}),hash:h,isBuiltIn:r};return this.Oe.set(h,c),c}He(t,i={}){return{id:this.ke++,shader:t,uniforms:Object.freeze({...i}),hash:0,isBuiltIn:!1}}Le(t,i){const r=Xt(t.L),h=function(n,c){let a=0;const u=Object.keys(n).sort();for(const f of u)a=J(a,Ut(f)),a=J(a,c(n[f]));return a}(i,this.Be.bind(this));return J(r,h)}Be(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=J(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=J(r,i[n]);return r}(t):t instanceof WebGLTexture?Xt(t):0}D(){this.ze!=this.ze&&this.ze.D(),this.ze.D(),this.Oe.clear()}}class le{constructor(){l(this,"Ge",[]);l(this,"Ne",1);l(this,"Ps",0)}Xe(t,i){if(this.Ps>=this.Ge.length){const h={id:this.Ne++,type:t,params:{},state:rt.kt(),material:i};this.Ge.push(h)}const r=this.Ge[this.Ps];return r.id=this.Ne++,r.type=t,r.material=i,this.Ps++,r}Ye(t,i,r){const h=this.Xe(C.RECTANGLE,r),n=h.params;return n.width=t.width,n.height=t.height,i.Kt(h.state),h.id}Ke(t,i,r){const h=this.Xe(C.LINE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.thickness=t.thickness,i.Kt(h.state),h.id}je(t,i,r){const h=this.Xe(C.ELLIPSE,r),n=h.params;return n.width=t.width,n.height=t.height,n.startAngle=t.startAngle,n.endAngle=t.endAngle,n.segments=t.segments,i.Kt(h.state),h.id}We(t,i,r){const h=this.Xe(C.ARC,r),n=h.params;return n.width=t.width,n.height=t.height,n.start=t.start,n.stop=t.stop,i.Kt(h.state),h.id}Ze(t,i,r){const h=this.Xe(C.TRIANGLE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.x2=t.x2,n.y2=t.y2,n.x3=t.x3,n.y3=t.y3,i.Kt(h.state),h.id}Ve(t,i,r){const h=this.Xe(C.BEZIER_CURVE,r),n=h.params;return n.x1=t.x1,n.y1=t.y1,n.cp1x=t.cp1x,n.cp1y=t.cp1y,n.cp2x=t.cp2x,n.cp2y=t.cp2y,n.x2=t.x2,n.y2=t.y2,n.thickness=t.thickness,n.segments=t.segments,i.Kt(h.state),h.id}me(){this.Ps=0}[Symbol.iterator](){let t=0;const i=this.Ps,r=this.Ge;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ue{constructor(t){l(this,"A");l(this,"qe",null);l(this,"Qe");l(this,"ft");l(this,"Je");l(this,"ti");l(this,"si");l(this,"ei",null);l(this,"ii",{});l(this,"ri",[]);l(this,"ni",[]);l(this,"oi",null);l(this,"hi",[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.Je=new rt,this.ft=new ce(t),this.ti=new le,this.Qe=new ae(t),this.si=new Zt(t);const i=[0,0,t.canvas.width,t.canvas.height];ft(t,i),this.ri.push(null),this.ni.push(i),this.oi=null,this.hi=i}et(){this.ri.push(this.oi),this.ni.push([...this.hi])}ht(){return{framebuffer:this.ri.pop()??null,viewport:this.ni.pop()??[0,0,this.A.canvas.width,this.A.canvas.height]}}it(t,i,r){const h=this.A;this.oi!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.oi=t);const n=[0,0,i,r];this.hi[0]===n[0]&&this.hi[1]===n[1]&&this.hi[2]===n[2]&&this.hi[3]===n[3]||(h.viewport(...n),ft(h,n),this.hi=n)}ai(t){this.qe!==t&&(this.qe=t,t.S())}ci(t,i){return new j(this.A,t,i)}li(t){this.ei=t,t&&(this.ii={})}O(t,i){this.ii[t]=i}ui(t){Object.assign(this.ii,t)}fi(t){return new j(this.A,et,t)}di(t,i,r){this.ti.Ye({width:i??t.width,height:r??t.height},this.Je,t.ct())}pi(t,i,r,h){this.si.Cs(t,i,r,h)}gi(t,i){if(this.ei){const r=this.ft.He(this.ei,this.ii);this.ti.Ye({width:t,height:i},this.Je,r),this.ei=null,this.ii={}}else this.ti.Ye({width:t,height:i},this.Je,this.ft.De)}mi(t,i,r,h){this.ti.Ke({x1:t,y1:i,x2:r,y2:h},this.Je,this.ft.De)}_i(t,i){this.ti.je({width:t,height:i},this.Je,this.ft.De)}Ai(t,i,r,h,n,c){this.ti.Ze({x1:t,y1:i,x2:r,y2:h,x3:n,y3:c},this.Je,this.ft.De)}yi(t,i,r,h,n,c,a,u){this.ti.Ve({x1:t,y1:i,cp1x:r,cp1y:h,cp2x:n,cp2y:c,x2:a,y2:u},this.Je,this.ft.De)}wi(t,i,r,h){this.ti.We({width:t,height:i,start:r,stop:h},this.Je,this.ft.De)}bi(t,i,r=1,h={}){return new Q(this.A,t,i,r,h,this)}Ci(t,i=t,r=t,h=255){this.Je.fs(t,i??t,r??t,h);const[n,c,a,u]=this.Je.canvasBackgroundColor;this.me(n,c,a,u)}me(t=0,i=0,r=0,h=0){this.A.clearColor(t,i,r,h),this.A.clear(this.A.COLOR_BUFFER_BIT)}Mi(){const t=[0,0,this.A.canvas.width,this.A.canvas.height];this.A.viewport(...t),ft(this.A,t),this.hi=t,this.ni.length>0&&(this.ni[0]=t)}ot(){const t=this.ti;this.Qe.Ee(t),t.me()}D(){this.ft.D(),this.Qe.D(),this.si.D()}get context(){return this.A}get state(){return this.Je}get materialManager(){return this.ft}}const F={readShort:(o,t)=>(F.t.uint16[0]=o[t]<<8|o[t+1],F.t.int16[0]),readUshort:(o,t)=>o[t]<<8|o[t+1],readUshorts(o,t,i){const r=[];for(let h=0;h<i;h++)r.push(F.readUshort(o,t+2*h));return r},readUint(o,t){const i=F.t.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],F.t.uint32[0]},readASCII(o,t,i){let r="";for(let h=0;h<i;h++)r+=String.fromCharCode(o[t+h]);return r},t:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function st(o){return o+3&-4}function nt(o,t,i){o[t]=i>>>8&255,o[t+1]=255&i}function B(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 fe(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=F.t;for(let c=t;c<r;c+=4)n.uint8[3]=o[c]||0,n.uint8[2]=o[c+1]||0,n.uint8[1]=o[c+2]||0,n.uint8[0]=o[c+3]||0,h=h+(n.uint32[0]>>>0)>>>0;return h>>>0}class de{constructor(t){l(this,"b");l(this,"p",0);l(this,"bitbuf",0);l(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 $(o){let t=32,i=0;for(const a of o)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 o)a&&r[a]++;const h=new Uint32Array(i+1);let n=0;r[0]=0;for(let a=1;a<=i;a++)n=n+r[a-1]<<1,h[a]=n;const c=new Map;for(let a=0;a<o.length;a++){const u=o[a];if(!u)continue;const f=h[u]++;let d=c.get(u);d||(d=[],c.set(u,d)),d[ge(f,u)]=a}return{min:t,max:i,table:c}}function At(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.readBits(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 Error("Invalid Huffman code")}function ge(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function Ae(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],i=o[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 h=[];return function(n,c){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],d=[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 g=0;for(;!g;){g=n.readBits(1);const m=n.readBits(2);if(m===0){n.alignToByte();const p=n.readBits(16);if((65535&(65535^p))!==n.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<p;v++)c.push(n.readBits(8))}else{if(m!==1&&m!==2)throw Error("Unsupported DEFLATE type");{let p,v;if(m===1){const A=Array(288).fill(0);for(let E=0;E<=143;E++)A[E]=8;for(let E=144;E<=255;E++)A[E]=9;for(let E=256;E<=279;E++)A[E]=7;for(let E=280;E<=287;E++)A[E]=8;p=$(A),v=$(Array(32).fill(5))}else{const A=n.readBits(5)+257,E=n.readBits(5)+1,y=n.readBits(4)+4,b=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],w=Array(19).fill(0);for(let X=0;X<y;X++)w[b[X]]=n.readBits(3);const R=$(w),T=[];for(;T.length<A+E;){const X=At(n,R);if(X<=15)T.push(X);else if(X===16){const I=n.readBits(2)+3,N=T[T.length-1]||0;for(let ct=0;ct<I;ct++)T.push(N)}else if(X===17){const I=n.readBits(3)+3;for(let N=0;N<I;N++)T.push(0)}else{if(X!==18)throw Error("Invalid code length symbol");{const I=n.readBits(7)+11;for(let N=0;N<I;N++)T.push(0)}}}const U=T.slice(0,A),D=T.slice(A,A+E);p=$(U),v=$(D)}for(;;){const A=At(n,p);if(A<256)c.push(A);else{if(A===256)break;if(A>256&&A<286){const E=A-257;let y=a[E];const b=u[E];b&&(y+=n.readBits(b));const w=At(n,v);if(w>=30)throw Error("Invalid distance symbol");let R=f[w];const T=d[w];T&&(R+=n.readBits(T));const U=c.length-R;if(U<0)throw Error("Invalid distance");for(let D=0;D<y;D++)c.push(c[U+D]||0)}else if(A===286||A===287)throw Error("Reserved length symbol")}}}}}}(new de(o.subarray(r)),h),new Uint8Array(h)}function pe(o){const t=F,i=new Uint8Array(o);if(t.readASCII(i,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(i,4),h=t.readUshort(i,12),n=t.readUint(i,16),c=[];let a=44;for(let y=0;y<h;y++){const b=t.readASCII(i,a,4),w=t.readUint(i,a+4),R=t.readUint(i,a+8),T=t.readUint(i,a+12),U=t.readUint(i,a+16);c.push({tag:b,offset:w,compLength:R,origLength:T,checksum:U}),a+=20}for(const y of c){const b=new Uint8Array(i.buffer,y.offset,y.compLength);if(y.compLength===y.origLength)y.data=new Uint8Array(b);else if(y.data=Ae(b),y.data.length!==y.origLength)if(y.data.length<y.origLength){const w=new Uint8Array(y.origLength);w.set(y.data),y.data=w}else y.data=y.data.subarray(0,y.origLength)}const u=h;let f=1,d=0;for(;f<<1<=u;)f<<=1,d++;const g=16*f,m=16*u-g;let p=12+16*u;const v={};for(const y of c)v[y.tag]=p,p=st(p+y.data.length);const A=new Uint8Array(Math.max(n||0,p));B(A,0,r),nt(A,4,u),nt(A,6,g),nt(A,8,d),nt(A,10,m);let E=12;for(const y of c){fe(A,E,y.tag),E+=4;let b=y.data;if(y.tag==="head"&&b.length>=12){const w=new Uint8Array(b);B(w,8,0),B(A,E,gt(w,0,st(w.length))),E+=4}else B(A,E,gt(b,0,st(b.length))),E+=4;B(A,E,v[y.tag]),E+=4,B(A,E,y.data.length),E+=4}for(const y of c){const b=v[y.tag];A.set(y.data,b)}if(c.find(y=>y.tag==="head")){const y=v.head,b=function(w,R){const T=R+8,U=[w[T],w[T+1],w[T+2],w[T+3]];B(w,T,0);const D=2981146554-(gt(w,0,st(w.length))>>>0)>>>0;return w[T]=U[0],w[T+1]=U[1],w[T+2]=U[2],w[T+3]=U[3],D>>>0}(A,y);B(A,y+8,b)}return A.buffer}const me={parseTab(o,t,i){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,i),t=0;const h=F,n=h.readUshort,c=n(o,t+=2);t+=2;const a=[];for(let u=0;u<c;u++){const f=n(o,t),d=n(o,t+=2);t+=2;const g=h.readUint(o,t);t+=4;const m=`p${f}e${d}`;let p=a.indexOf(g);if(p===-1){let v;p=r.tables.length,a.push(g);const A=n(o,g);v=A===4?this.parse4(o,g):A===12?this.parse12(o,g):{format:A},r.tables.push(v)}r.ids[m]=p}return r},parse4(o,t){const i=F,r=i.readUshort,h=i.readUshorts,n=t,c=r(o,t+=2);t+=2;const a=r(o,t+=2)>>>1,u={format:4,searchRange:r(o,t+=2),entrySelector:0,rangeShift:0,endCount:[],startCount:[],idDelta:[],idRangeOffset:[],glyphIdArray:[]};t+=2,u.entrySelector=r(o,t),t+=2,u.rangeShift=r(o,t),t+=2,u.endCount=h(o,t,a),t+=2*a,t+=2,u.startCount=h(o,t,a),t+=2*a;for(let f=0;f<a;f++)u.idDelta.push(i.readShort(o,t)),t+=2;return u.idRangeOffset=h(o,t,a),t+=2*a,u.glyphIdArray=h(o,t,n+c-t>>1),u},parse12(o,t){const i=F.readUint;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}}},ve={parseTab(o,t,i){const r=F;t+=18;const h=r.readUshort(o,t);t+=2,t+=16;const n=r.readShort(o,t);t+=2;const c=r.readShort(o,t);t+=2;const a=r.readShort(o,t);t+=2;const u=r.readShort(o,t);return t+=2,t+=6,{unitsPerEm:h,xMin:n,yMin:c,xMax:a,yMax:u,indexToLocFormat:r.readShort(o,t)}}},ye={parseTab(o,t,i){const r=F;t+=4;const h=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],n={};for(let c=0;c<h.length;c++){const a=h[c],u=a==="advanceWidthMax"||a==="numberOfHMetrics"?r.readUshort:r.readShort;n[a]=u(o,t+2*c)}return n}},Ee={parseTab(o,t,i,r){const h=F,n=[],c=[],a=r.maxp.numGlyphs,u=r.hhea.numberOfHMetrics;let f=0,d=0,g=0;for(;g<u;)f=h.readUshort(o,t+(g<<2)),d=h.readShort(o,t+(g<<2)+2),n.push(f),c.push(d),g++;for(;g<a;)n.push(f),c.push(d),g++;return{aWidth:n,lsBearing:c}}},St={cmap:me,head:ve,hhea:ye,maxp:{parseTab(o,t,i){const r=F;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:Ee,loca:{parseTab(o,t,i,r){const h=F,n=[],c=r.head.indexToLocFormat,a=r.maxp.numGlyphs+1;if(c===0)for(let u=0;u<a;u++)n.push(h.readUshort(o,t+(u<<1))<<1);else if(c===1)for(let u=0;u<a;u++)n.push(h.readUint(o,t+(u<<2)));return n}},glyf:{parseTab(o,t,i,r){const h=[],n=r.maxp.numGlyphs;for(let c=0;c<n;c++)h.push(null);return h},xi(o,t){const i=F,r=o.Fi,h=o.loca;if(h[t]===h[t+1])return null;const n=k.findTable(r,"glyf",o.$i);if(!n)return null;let c=n[0]+h[t];const a={};if(a.noc=i.readShort(r,c),c+=2,a.xMin=i.readShort(r,c),c+=2,a.yMin=i.readShort(r,c),c+=2,a.xMax=i.readShort(r,c),c+=2,a.yMax=i.readShort(r,c),c+=2,a.xMin>=a.xMax||a.yMin>=a.yMax)return null;if(a.noc>0){a.endPts=[];for(let m=0;m<a.noc;m++)a.endPts.push(i.readUshort(r,c)),c+=2;const u=i.readUshort(r,c);if(c+=2,r.length-c<u)return null;c+=u;const f=a.endPts[a.noc-1]+1;a.flags=[];for(let m=0;m<f;m++){const p=r[c];if(c++,a.flags.push(p),8&p){const v=r[c];c++;for(let A=0;A<v;A++)a.flags.push(p),m++}}a.xs=[];for(let m=0;m<f;m++){const p=a.flags[m],v=!!(16&p);2&p?(a.xs.push(v?r[c]:-r[c]),c++):v?a.xs.push(0):(a.xs.push(i.readShort(r,c)),c+=2)}a.ys=[];for(let m=0;m<f;m++){const p=a.flags[m],v=!!(32&p);4&p?(a.ys.push(v?r[c]:-r[c]),c++):v?a.ys.push(0):(a.ys.push(i.readShort(r,c)),c+=2)}let d=0,g=0;for(let m=0;m<f;m++)d+=a.xs[m],g+=a.ys[m],a.xs[m]=d,a.ys[m]=g}else a.parts=[],a.endPts=[],a.flags=[],a.xs=[],a.ys=[];return a}}},k={parse(o){const t=new Uint8Array(o);F.readASCII(t,0,4)==="wOFF"&&(o=pe(o));const i=new Uint8Array(o),r=St,h={},n={Fi:i,Ti:0,$i:0};for(const c in r){const a=c,u=k.findTable(i,a,0);if(u){const[f,d]=u;let g=h[f];g==null&&(g=r[a].parseTab(i,f,d,n),h[f]=g),n[a]=g}}return[n]},findTable(o,t,i){const r=F,h=r.readUshort(o,i+4);let n=i+12;for(let c=0;c<h;c++){const a=r.readASCII(o,n,4);r.readUint(o,n+4);const u=r.readUint(o,n+8),f=r.readUint(o,n+12);if(a===t)return[u,f];n+=16}return null},T:St,B:F};class we{Pi(t){var r;const i=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(h=>{if(h.format===4){const n=this.Ei(h);i.push(...n)}else if(h.format===12){const n=this.Ri(h);i.push(...n)}}),[...new Set(i)]):[]}Ei(t){const i=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return i;for(let r=0;r<t.startCount.length;r++){const h=t.startCount[r],n=t.endCount[r];if(h!==65535||n!==65535){for(let c=h;c<=n;c++)if(this.Si(t,c,r)>0)try{const a=String.fromCodePoint(c);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 h=t.groups[r],n=t.groups[r+1],c=t.groups[r+2];for(let a=h;a<=n;a++)if(c+(a-h)>0)try{const u=String.fromCodePoint(a);i.push(u)}catch{}}return i}Si(t,i,r){if(t.idRangeOffset[r]===0)return i+t.idDelta[r]&65535;{const h=t.idRangeOffset[r]/2+(i-t.startCount[r])-(t.startCount.length-r);if(h>=0&&t.glyphIdArray&&h<t.glyphIdArray.length){const n=t.glyphIdArray[h];if(n!==0)return n+t.idDelta[r]&65535}}return 0}}class pt{constructor(){l(this,"ki",new Map);l(this,"zi",new Map)}Ii(t,i){const r=`${this.Oi(t)}_${i}`;if(this.ki.has(r))return this.ki.get(r);const h=t.cmap;if(!h||!h.tables)return this.ki.set(r,0),0;let n=0;for(const c of h.tables)if(c.format===4?n=this.Li(i,c):c.format===12&&(n=this.Di(i,c)),n>0)break;return this.ki.set(r,n),n}Hi(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Ii(t,r)}Bi(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}Gi(t,i){const r=i/t.head.unitsPerEm,h=t.hhea.ascender*r,n=t.hhea.descender*r,c=t.hhea.lineGap*r;return{ascender:h,descender:n,lineGap:c,lineHeight:h-n+c,unitsPerEm:t.head.unitsPerEm,scale:r}}Ni(){this.ki.clear(),this.zi.clear()}Oi(t){return`${t.$i}_${t.Fi.length}`}Li(t,i){const r=i.endCount.length;let h=-1;for(let n=0;n<r;n++)if(t<=i.endCount[n]){h=n;break}if(h===-1||t<i.startCount[h])return 0;if(i.idRangeOffset[h]===0)return t+i.idDelta[h]&65535;{const n=i.idRangeOffset[h]/2+(t-i.startCount[h])-(r-h);if(n>=0&&n<i.glyphIdArray.length){const c=i.glyphIdArray[n];return c===0?0:c+i.idDelta[h]&65535}}return 0}Di(t,i){const r=i.groups.length/3;for(let h=0;h<r;h++){const n=i.groups[3*h],c=i.groups[3*h+1],a=i.groups[3*h+2];if(t>=n&&t<=c)return a+(t-n)}return 0}}class be{constructor(t){l(this,"Xi");l(this,"Yi");l(this,"j");l(this,"Ki");this.j=t,this.Ki=new pt,this.Xi=document.createElement("canvas"),this.Yi=this.Xi.getContext("2d",{willReadFrequently:!0,alpha:!0})}ji(t,i,r,h){const n=t.length,c=Math.ceil(Math.sqrt(n)),a=Math.ceil(n/c),u=i.width*c,f=i.height*a;this.Wi(u,f),this.Zi(t,i,c,r,h);const d=this.j.bi(u,f,1,{filter:"nearest"});return d.st(this.Xi),{framebuffer:d,columns:c,rows:a}}Wi(t,i){this.Xi.width=t,this.Xi.height=i,this.Xi.style.width=t+"px",this.Xi.style.height=i+"px",this.Yi.imageSmoothingEnabled=!1,this.Xi.style.imageRendering="pixelated",this.Yi.clearRect(0,0,t,i),this.Yi.textBaseline="top",this.Yi.textAlign="left",this.Yi.fillStyle="white"}Zi(t,i,r,h,n){const c=h/n.head.unitsPerEm;for(let a=0;a<t.length;a++){const u=a%r,f=Math.floor(a/r),d=t[a].character,g=this.Vi(n,d);if(!g)continue;const m=d.codePointAt(0)||0,p=this.Ki.Ii(n,m),v=this.Ki.Bi(n,p)*c,A=u*i.width,E=f*i.height,y=A+.5*i.width,b=E+.5*i.height,w=Math.round(y-.5*i.width),R=Math.round(b-.5*h),T=w+.5*(i.width-v),U=R+n.hhea.ascender*c;this.qi(g,T,U,c)}}Vi(t,i){const r=i.codePointAt(0)||0,h=this.Ki.Ii(t,r);return h===0?null:k.T.glyf.xi(t,h)}qi(t,i,r,h){if(!t||!t.xs||t.noc===0)return;let{xs:n,ys:c,endPts:a,flags:u}=t;if(!(n&&c&&a&&u))return;this.Yi.beginPath();let f=0;for(let d=0;d<a.length;d++){const g=a[d];if(!(g<f)){if(g>=f){const m=i+n[f]*h,p=r-c[f]*h;this.Yi.moveTo(m,p);let v=f+1;for(;v<=g;)if(1&u[v]){const A=i+n[v]*h,E=r-c[v]*h;this.Yi.lineTo(A,E),v++}else{const A=i+n[v]*h,E=r-c[v]*h;if(v+1>g){const b=i+n[f]*h,w=r-c[f]*h;if(1&u[f])this.Yi.quadraticCurveTo(A,E,b,w);else{const R=(A+b)/2,T=(E+w)/2;this.Yi.quadraticCurveTo(A,E,R,T)}break}const y=v+1;if(1&u[y]){const b=i+n[y]*h,w=r-c[y]*h;this.Yi.quadraticCurveTo(A,E,b,w),v=y+1}else{const b=(A+(i+n[y]*h))/2,w=(E+(r-c[y]*h))/2;this.Yi.quadraticCurveTo(A,E,b,w),v=y}}this.Yi.closePath()}f=g+1}}this.Yi.fill()}}class Te{constructor(){l(this,"Qi");this.Qi=new pt}Ji(t,i,r){let h=0;const n=this.Qi.Gi(r,i),c=n.lineHeight;for(const a of t){const u=this.Qi.Hi(r,a);if(u===0)continue;const f=this.Qi.Bi(r,u)*n.scale;h=Math.max(h,f)}return{width:Math.ceil(h),height:Math.ceil(c)}}Ni(){this.Qi.Ni()}}class xe{constructor(){l(this,"Ki");this.Ki=new pt}createCharacterObjects(t,i){return t.map((r,h)=>{const n=r.codePointAt(0)||0,c=this.tr(h);let a=0;if(i.hmtx&&i.hmtx.aWidth){const u=this.Ki.Ii(i,n);u>0&&i.hmtx.aWidth[u]!==void 0&&(a=i.hmtx.aWidth[u])}return{character:r,unicode:n,color:c,advanceWidth:a}})}tr(t){return[t%256/255,Math.floor(t/256)%256/255,0]}sr(t,i){if(!Z.m(typeof t=="string","Character must be a string.",{method:"getCharacterColor",providedValue:t}))return[0,0,0];const r=i.find(h=>h.character===t);return r?r.color:[0,0,0]}er(t,i){return Z.m(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.sr(r,i)||[0,0,0]):[[0,0,0]]}}class mt{constructor(t,i=16){l(this,"ir");l(this,"rr",[]);l(this,"nr");l(this,"hr",16);l(this,"ar",0);l(this,"cr",0);l(this,"lr",{width:0,height:0});l(this,"ur");l(this,"dr",new Map);l(this,"pr");l(this,"gr");l(this,"vr");l(this,"mr");this.hr=i,this.pr=new we,this.gr=new be(t),this.vr=new Te,this.mr=new xe}async _r(t){let i;if(t){const r=await fetch(t);if(!r.ok)throw new P(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}else i=await(await fetch("data:font/woff;base64,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")).arrayBuffer();await this.Ar(i),this.ir=k.parse(i)[0],await this.yr()}wr(t){if(t===void 0)return this.hr;this.hr=t,this.lr=this.vr.Ji(this.rr.map(r=>r.character),this.hr,this.ir);const i=this.gr.ji(this.rr,this.lr,this.hr,this.ir);this.nr=i.framebuffer,this.ar=i.columns,this.cr=i.rows}async br(t){try{const i=await fetch(t);if(!i.ok)throw new P(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.Ar(r);const h=k.parse(r);if(!h||h.length===0)throw Error("Failed to parse font file");this.ir=h[0],await this.yr()}catch(i){throw new P("Failed to load font: "+(i instanceof Error?i.message:"Unknown error"),i)}}async Ar(t){const i=Date.now();this.ur=new FontFace("CustomFont_"+i,t),await this.ur.load(),document.fonts.add(this.ur)}async yr(){const t=this.pr.Pi(this.ir);this.dr.clear(),this.rr=this.mr.createCharacterObjects(t,this.ir),this.lr=this.vr.Ji(t,this.hr,this.ir);const i=this.gr.ji(this.rr,this.lr,this.hr,this.ir);this.nr=i.framebuffer,this.ar=i.columns,this.cr=i.rows}sr(t){return this.mr.sr(t,this.rr)}er(t){return this.mr.er(t,this.rr)}getGlyphData(t){if(!Number.isFinite(t))return null;const i=this.dr.get(t);if(i!==void 0)return i;const r=this.Cr(t);if(r<0)return this.dr.set(t,null),null;const h=this.ir.glyf;if(!h)return this.dr.set(t,null),null;let n=h[r]??null;return n==null&&(n=k.T.glyf.xi(this.ir,r)??null,h[r]=n),this.dr.set(t,n),n}Cr(t){const i=this.ir.cmap;for(const r of i.tables)if(r.format===4){const h=r;for(let n=0;n<h.startCount.length;n++)if(t>=h.startCount[n]&&t<=h.endCount[n]){if(h.idRangeOffset[n]===0)return t+h.idDelta[n]&65535;{const c=h.idRangeOffset[n]/2+(t-h.startCount[n])-(h.startCount.length-n);if(c>=0&&c<h.glyphIdArray.length){const a=h.glyphIdArray[c];if(a!==0)return a+h.idDelta[n]&65535}}}}else if(r.format===12){const h=r;for(let n=0;n<h.groups.length;n+=3){const c=h.groups[n],a=h.groups[n+1],u=h.groups[n+2];if(t>=c&&t<=a)return u+(t-c)}}return 0}D(){this.nr.D(),document.fonts.delete(this.ur)}get fontFramebuffer(){return this.nr}get characters(){return this.rr}get textureColumns(){return this.ar}get textureRows(){return this.cr}get maxGlyphDimensions(){return this.lr}get fontSize(){return this.hr}get font(){return this.ir}}class vt{constructor(t,i,r){l(this,"Mr");l(this,"Fr");l(this,"H");l(this,"G");l(this,"$r");l(this,"Tr");l(this,"Pr");l(this,"Er");l(this,"Rr");this.Pr=t,this.Er=i,this.Rr=r,this.qs()}qs(){this.Mr=Math.floor(this.Pr.width/this.Er),this.Fr=Math.floor(this.Pr.height/this.Rr),this.H=this.Mr*this.Er,this.G=this.Fr*this.Rr,this.$r=Math.floor((this.Pr.width-this.H)/2),this.Tr=Math.floor((this.Pr.height-this.G)/2)}Sr(t,i){this.Er=t,this.Rr=i,this.qs()}get cellWidth(){return this.Er}get cellHeight(){return this.Rr}get cols(){return this.Mr}get rows(){return this.Fr}get width(){return this.H}get height(){return this.G}get offsetX(){return this.$r}get offsetY(){return this.Tr}}const Re=/^#([0-9a-f]{3,8})$/i,Pe=/^rgba?\(([^)]+)\)$/i;function yt(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function Ce(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=Re.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=Pe.exec(r.trim());if(!h)return null;const n=h[1].split(",").map(d=>d.trim());if(n.length<3)return null;const c=yt(parseFloat(n[0])),a=yt(parseFloat(n[1])),u=yt(parseFloat(n[2])),f=n[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(n[3]))):255;return[c,a,u,Math.round(f)]}(t)),i?i[3]===0?null:i:null}class Nt{constructor(t={}){l(this,"Pr");l(this,"kr",null);l(this,"zr",!1);l(this,"Ir");this.zr=t.overlay??!1,this.zr&&t.canvas?(this.kr=t.canvas,this.Pr=this.Or(),this.Ir=!0,this.Lr()):t.canvas?(this.Pr=t.canvas,this.Ir=!1):(this.Pr=this.Dr(t.width,t.height),this.Ir=!0),this.Pr.style.imageRendering="pixelated"}Dr(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}Or(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.kr.getBoundingClientRect();let r=Math.round(i.width),h=Math.round(i.height);if(this.kr instanceof HTMLVideoElement){const a=this.kr;(r===0||h===0)&&a.videoWidth>0&&a.videoHeight>0&&(r=a.videoWidth,h=a.videoHeight)}t.width=r,t.height=h,t.style.position="absolute",t.style.pointerEvents="none";const n=window.getComputedStyle(this.kr);let c=parseInt(n.zIndex||"0",10);return isNaN(c)&&(c=0),t.style.zIndex=""+(c+1),t}Lr(){var t;this.Hr(),(t=this.kr.parentNode)==null||t.insertBefore(this.Pr,this.kr.nextSibling)}Br(){const t=[];return this.zr&&this.kr instanceof HTMLElement&&(t.push(this.kr),this.kr.parentElement&&t.push(this.kr.parentElement)),this.Pr.parentElement&&t.push(this.Pr.parentElement),t.push(this.Pr),t.push(document.body),t.push(document.documentElement),t}Gr(){const t=this.Br();for(const i of t){if(!i)continue;const r=Ce(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}Hr(){if(!this.kr)return;const t=this.kr.getBoundingClientRect();let i=this.kr.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.Pr.style.top=t.top-r.top+"px",this.Pr.style.left=t.left-r.left+"px"}else this.Pr.style.top=t.top+window.scrollY+"px",this.Pr.style.left=t.left+window.scrollX+"px"}Nr(t,i){if(this.zr){const r=this.kr.getBoundingClientRect();this.Pr.width=Math.round(r.width),this.Pr.height=Math.round(r.height),this.Hr()}else this.Pr.width=t??this.Pr.width,this.Pr.height=i??this.Pr.height}Xr(){const t=this.Pr.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new P("`textmode.js` requires WebGL2 support.");return t}D(){const t=this.Pr.getContext("webgl")||this.Pr.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.loseContext()}this.Ir&&this.Pr.parentNode&&this.Pr.parentNode.removeChild(this.Pr)}get canvas(){return this.Pr}get targetCanvas(){return this.kr}get width(){return this.Pr.width}get height(){return this.Pr.height}}function ht(o){return z(parseInt(o,16),0,255)}class M{constructor(t,i,r,h,n){l(this,"Yr");l(this,"Kr");l(this,"Bt");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=z(t,0,255),this.g=z(i,0,255),this.b=z(r,0,255),this.a=z(h,0,255),this.Yr=[this.r,this.g,this.b,this.a],this.Kr=[this.r/255,this.g/255,this.b/255,this.a/255],this.Bt=n?[...n]:void 0}static jr(t,i,r,h){if(M.Wr(t))return t;if(Array.isArray(t))return function(n){if(n.length<3)throw Error("Component tuples must include at least RGB values.");const[c,a,u]=n,f=n.length===4?n[3]:255;return M.Zr(c,a,u,f)}(t);if(typeof t=="string"){const n=t.trim();if(n.length===0)throw Error("Color strings cannot be empty.");if(typeof i=="function"&&Array.from(n).length===1){const c=function(a,u){const f=u(a);if(!Array.isArray(f)||f.length===0)return null;const d=f[0];return!Array.isArray(d)||d.length<3?null:[d[0],d[1],d[2]]}(n,i);if(c)return M.Vr(c)}return M.qr(n)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?M.Zr(t,i,r,h??255):M.Qr(t);throw Error("Unsupported color input passed to TextmodeColor.$from.")}static Zr(t,i,r,h=255){return new M(t,i,r,h)}static Qr(t,i=255){return new M(t,t,t,i)}static qr(t){return new M(...function(i){const r=i.replace(/^#|0x/gi,""),h=(n=r).length===3||n.length===4?n.split("").map(c=>c+c).join(""):n;var n;if(h.length!==6&&h.length!==8)throw Error("Invalid hex color: "+i);return[ht(h.slice(0,2)),ht(h.slice(2,4)),ht(h.slice(4,6)),h.length===8?ht(h.slice(6,8)):255]}(t))}static Vr(t){const[i,r,h]=t;return new M(255*i,255*r,255*h,255,t)}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.Yr]}get normalized(){return[...this.Kr]}get character(){return this.Bt?[...this.Bt]:void 0}withAlpha(t){return new M(this.r,this.g,this.b,t,this.Bt)}static Wr(t){return t instanceof M}}const Et=new Map;function Dt(o){Et.set(o.id,o)}function Lt(o){return Et.get(o)}class wt{constructor(t,i,r,h,n,c,a,u){l(this,"A");l(this,"j");l(this,"Jr");l(this,"tn");l(this,"sn");l(this,"H");l(this,"G");l(this,"W",null);l(this,"ir");l(this,"en","brightness");l(this,"rn",null);l(this,"$t",0);l(this,"Dt",0);l(this,"Ht",0);l(this,"Tt",0);l(this,"nn","sampled");l(this,"hn","fixed");l(this,"Gt",[1,1,1,1]);l(this,"Nt",[0,0,0,1]);l(this,"an",[0,0,0,1]);l(this,"cn",[[.1,0,0]]);l(this,"ln");l(this,"un",null);l(this,"fn",new Set);l(this,"dn",[[0,0,0,0]]);l(this,"pn",0);this.A=t,this.j=i,this.Jr=r,this.ir=h,this.tn=n,this.sn=c,this.H=a,this.G=u}conversionMode(t){return this.en=t,this.rn=null,this.W=null,this}D(){this.A.deleteTexture(this.Jr);for(const t of this.fn)t();this.fn.clear()}gn(t){this.fn.add(t)}invert(t=!0){return this.$t=t?1:0,this.W=null,this}flipX(t=!0){return this.Dt=t?1:0,this.W=null,this}flipY(t=!0){return this.Ht=t?1:0,this.W=null,this}charRotation(t){return this.Tt=Rt(t),this.W=null,this}charColorMode(t){return this.nn=t,this.W=null,this}cellColorMode(t){return this.hn=t,this.W=null,this}charColor(t,i,r,h){return this.vn(this.Gt,t,i,r,h),this.W=null,this}cellColor(t,i,r,h){return this.vn(this.Nt,t,i,r,h),this.W=null,this}background(t,i,r,h){return this.vn(this.an,t,i,r,h),this.W=null,this}colorFilter(t){if(!t||t.length===0)return this.pn=0,this.dn=[[0,0,0,0]],this.W=null,this;const i=[];for(const r of t){if(i.length>=64)break;let h=M.jr(r);i.push(h.normalized)}return this.dn=i,this.pn=i.length,this.W=null,this}characters(t){return this.un=t,this.mn(t),this.W=null,this}_n(t){this.ir=t,this.un&&this.mn(this.un),this.W=null}get texture(){return this.Jr}get width(){return this.H}get height(){return this.G}get originalWidth(){return this.tn}get originalHeight(){return this.sn}ct(){return this.W||this.lt(),this.W}An(){}lt(){this.An();const t=this.yn(),i=this.wn(),r=t.createShader(i),h=t.createUniforms(i);this.W=this.j.materialManager.He(r,h)}vn(t,i,r,h,n){const c=M.jr(i,r,h,n);it(t,c.r,c.g,c.b,c.a)}mn(t){const i=this.ln(t).filter(r=>Array.isArray(r)).slice(0,255);this.cn=i.length>0?i:this.cn}createBaseConversionUniforms(){const t=this.pn>0;return{Uj:this.bn(),Uk:!!this.$t,Ul:!!this.Dt,Um:!!this.Ht,Un:this.Tt,Uo:this.nn==="fixed",Up:this.Gt,Uq:this.hn==="fixed",Ur:this.Nt,Us:this.an,Ut:this.cn.length,Uu:this.cn,Uv:t,Uw:t?this.pn:0,Ux:this.dn}}yn(){if(this.rn&&this.rn.id===this.en)return this.rn;const t=Lt(this.en);if(!t)throw Error(`[textmode.js] Conversion mode "${this.en}" is not registered. If this mode is provided by an add-on, make sure its plugin is installed before loading sources.`);return this.rn=t,t}wn(){return{renderer:this.j,gl:this.A,font:this.ir,source:this,gridWidth:this.H,gridHeight:this.G}}}class K extends wt{constructor(t,i,r,h,n,c,a,u){const f=Math.min(a/n,u/c);super(t,i,r,h,n,c,Math.max(1,Math.floor(n*f)),Math.max(1,Math.floor(c*f)))}static Cn(t,i,r,h,n,c){const a=t.context,u=a.createTexture();a.bindTexture(a.TEXTURE_2D,u),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),tt(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,r),a.bindTexture(a.TEXTURE_2D,null);const f=r.naturalWidth??r.width??r.videoWidth??0,d=r.naturalHeight??r.height??r.videoHeight??0,g=new K(a,t,u,i,f,d,h,n);return g.ln=c,g}bn(){return this.Jr}}class It{constructor(t=60){l(this,"Mn");l(this,"xn",null);l(this,"Fn",0);l(this,"$n",!0);l(this,"Tn",0);l(this,"Pn",0);l(this,"En",[]);l(this,"Rn",10);l(this,"Sn",0);this.Mn=1e3/t}kn(t){if(!this.$n)return;this.Fn=performance.now();const i=r=>{if(!this.$n)return void(this.xn=null);const h=r-this.Fn;h>=this.Mn&&(t(),this.Fn=r-h%this.Mn),this.$n&&(this.xn=requestAnimationFrame(i))};this.xn=requestAnimationFrame(i)}zn(){this.xn&&(cancelAnimationFrame(this.xn),this.xn=null)}In(){this.$n&&(this.$n=!1,this.zn())}On(t){this.$n||(this.$n=!0,this.kn(t))}Ln(t,i){if(t===void 0)return this.Tn;this.Mn=1e3/t,this.$n&&i&&(this.zn(),this.kn(i))}Dn(){const t=performance.now();if(this.Pn>0){const i=t-this.Pn;this.En.push(i),this.En.length>this.Rn&&this.En.shift();const r=this.En.reduce((h,n)=>h+n,0)/this.En.length;this.Tn=1e3/r}this.Pn=t}get Hn(){return this.$n}get Bn(){return this.Tn}get Gn(){return this.Sn}set Gn(t){this.Sn=t}Nn(){this.Sn++}}class Bt{constructor(t){l(this,"Pr");l(this,"Xn");l(this,"Yn",{x:-1,y:-1});l(this,"Kn",{x:-1,y:-1});l(this,"jn",null);l(this,"Wn",0);l(this,"Zn");l(this,"Vn");l(this,"qn");l(this,"Qn");l(this,"Jn");l(this,"so");l(this,"eo",!1);l(this,"io");l(this,"ro");l(this,"no");l(this,"oo");l(this,"ho");this.Pr=t}ao(t){const i=performance.now()+Math.max(0,t);i>this.Wn&&(this.Wn=i)}co(){return performance.now()<this.Wn}lo(t){const i=this.Pr.canvas;i.style.cursor=t==null||t===""?"":t}_r(t){this.Xn=t,this.uo()}fo(){if(this.eo)return;const t=this.Pr.canvas;this.Zn=i=>{this.do(i),this.po(i)},this.Vn=()=>{this.Kn={...this.Yn},this.Yn.x=-1,this.Yn.y=-1,this.jn=null},this.qn=i=>{this.do(i),this.vo(i)},this.Qn=i=>{this.do(i),this.mo(i)},this.Jn=i=>{this.do(i),this._o(i)},this.so=i=>{this.do(i),this.Ao(i)},t.addEventListener("mousemove",this.Zn,{passive:!0}),t.addEventListener("mouseleave",this.Vn,{passive:!0}),t.addEventListener("mousedown",this.qn,{passive:!0}),t.addEventListener("mouseup",this.Qn,{passive:!0}),t.addEventListener("click",this.Jn,{passive:!0}),t.addEventListener("wheel",this.so,{passive:!1}),this.eo=!0}yo(){if(!this.eo)return;const t=this.Pr.canvas;t.removeEventListener("mousemove",this.Zn),t.removeEventListener("mouseleave",this.Vn),t.removeEventListener("mousedown",this.qn),t.removeEventListener("mouseup",this.Qn),t.removeEventListener("click",this.Jn),t.removeEventListener("wheel",this.so),this.eo=!1}uo(){if(this.eo)try{if(this.jn){const t=new MouseEvent("mousemove",{clientX:this.jn.x,clientY:this.jn.y,bubbles:!1,cancelable:!1});this.do(t)}else this.Yn.x!==-1&&this.Yn.y!==-1&&(this.Yn.x>=this.Xn.cols||this.Yn.y>=this.Xn.rows)&&(this.Yn.x=-1,this.Yn.y=-1)}catch{this.Yn.x=-1,this.Yn.y=-1}}wo(t){this.io=t}bo(t){this.ro=t}Co(t){this.no=t}Mo(t){this.oo=t}xo(t){this.ho=t}Fo(){return{x:this.Yn.x,y:this.Yn.y}}po(t){if(this.oo&&!this.co()){const i={position:{...this.Yn},previousPosition:{...this.Kn},originalEvent:t};this.oo(i)}}vo(t){if(this.ro&&!this.co()){const i={position:{...this.Yn},previousPosition:{...this.Kn},button:t.button,originalEvent:t};this.ro(i)}}mo(t){if(this.no&&!this.co()){const i={position:{...this.Yn},previousPosition:{...this.Kn},button:t.button,originalEvent:t};this.no(i)}}_o(t){if(this.io&&!this.co()){const i={position:{...this.Yn},previousPosition:{...this.Kn},button:t.button,originalEvent:t};this.io(i)}}Ao(t){if(this.ho&&!this.co()){const i={position:{...this.Yn},previousPosition:{...this.Kn},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.ho(i)}}do(t){const i=this.Pr.canvas;this.Kn={...this.Yn},this.jn={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),h=t.clientX-r.left,n=t.clientY-r.top,c=i.width/r.width,a=n*(i.height/r.height),u=h*c-this.Xn.offsetX,f=a-this.Xn.offsetY,d=Math.floor(u/this.Xn.cellWidth),g=Math.floor(f/this.Xn.cellHeight);d>=0&&d<this.Xn.cols&&g>=0&&g<this.Xn.rows?(this.Yn.x=d,this.Yn.y=g):(this.Yn.x=-1,this.Yn.y=-1)}}const Fe=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:Bt},Symbol.toStringTag,{value:"Module"}));class Yt{constructor(){l(this,"$o",new Map);l(this,"To",null);l(this,"Po",null);l(this,"Eo");l(this,"Ro");l(this,"eo",!1);l(this,"So");l(this,"ko");l(this,"zo",{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"})}fo(){this.eo||(this.Eo=t=>{this.Io(t)},this.Ro=t=>{this.Oo(t)},window.addEventListener("keydown",this.Eo,{passive:!1}),window.addEventListener("keyup",this.Ro,{passive:!1}),this.eo=!0)}yo(){this.eo&&(window.removeEventListener("keydown",this.Eo),window.removeEventListener("keyup",this.Ro),this.eo=!1,this.$o.clear(),this.To=null,this.Po=null)}bo(t){this.So=t}Co(t){this.ko=t}Lo(t){const i=this.Do(t),r=this.$o.get(t)||this.$o.get(i);return(r==null?void 0:r.isPressed)||!1}Ho(){return this.To}Bo(){return this.Po}Go(){const t=[];for(const[i,r]of this.$o)r.isPressed&&t.push(i);return t}No(){return{ctrl:this.Lo("Control"),shift:this.Lo("Shift"),alt:this.Lo("Alt"),meta:this.Lo("Meta")}}Xo(){this.$o.clear(),this.To=null,this.Po=null}Io(t){const i=t.key,r=Date.now();this.$o.has(i)||this.$o.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this.$o.get(i);if(!h.isPressed&&(h.isPressed=!0,h.lastPressTime=r,this.To=i,this.So)){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.So(n)}}Oo(t){const i=t.key,r=Date.now();this.$o.has(i)||this.$o.set(i,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this.$o.get(i);if(h.isPressed=!1,h.lastReleaseTime=r,this.Po=i,this.ko){const n={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.ko(n)}}Do(t){return this.zo[t]||t.toLowerCase()}}const Me=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:Yt},Symbol.toStringTag,{value:"Module"}));class Ot{constructor(t,i){l(this,"Pr");l(this,"Yo");l(this,"Xn");l(this,"Ko",new Map);l(this,"jo",new Map);l(this,"Wo",new Map);l(this,"Zo",null);l(this,"Vo");l(this,"qo");l(this,"Qo");l(this,"Jo");l(this,"th");l(this,"sh");l(this,"eo",!1);l(this,"eh");l(this,"ih");l(this,"rh");l(this,"nh");l(this,"oh");l(this,"hh");l(this,"ah");l(this,"uh");l(this,"fh");l(this,"dh");l(this,"ph",320);l(this,"gh",350);l(this,"mh",10);l(this,"_h",550);l(this,"Ah",14);l(this,"yh",48);l(this,"wh",650);l(this,"bh",.02);l(this,"Ch",2);l(this,"Mh",600);l(this,"xh",0);l(this,"Fh",null);this.Pr=t,this.Yo=i;const r=this.Pr.canvas;this.Vo=r.style.touchAction,this.qo=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}_r(t){this.Xn=t,this.uo()}fo(){if(this.eo)return;const t=this.Pr.canvas;this.Qo=i=>{this.$h(i)},this.Jo=i=>{this.Th(i)},this.th=i=>{this.Ph(i)},this.sh=i=>{this.Eh(i)},t.addEventListener("touchstart",this.Qo,{passive:!1}),t.addEventListener("touchmove",this.Jo,{passive:!1}),t.addEventListener("touchend",this.th,{passive:!1}),t.addEventListener("touchcancel",this.sh,{passive:!1}),this.eo=!0}yo(){if(!this.eo)return;const t=this.Pr.canvas;t.removeEventListener("touchstart",this.Qo),t.removeEventListener("touchmove",this.Jo),t.removeEventListener("touchend",this.th),t.removeEventListener("touchcancel",this.sh),this.eo=!1,this.Zo=null,this.Ko.clear(),this.jo.clear(),this.Wo.forEach(i=>{i.longPressTimer!==null&&window.clearTimeout(i.longPressTimer)}),this.Wo.clear(),this.Fh=null,this.xh=0,t.style.touchAction=this.Vo,t.style.userSelect=this.qo}uo(){if(!this.Xn||this.Ko.size===0)return;const t=new Map;for(const i of this.Ko.values()){const r=this.Rh(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Ko=t}Sh(){return Array.from(this.Ko.values()).map(t=>({...t}))}kh(t){this.eh=t}Mo(t){this.ih=t}zh(t){this.rh=t}Ih(t){this.nh=t}Oh(t){this.oh=t}Lh(t){this.hh=t}Dh(t){this.ah=t}Hh(t){this.uh=t}Bh(t){this.fh=t}Gh(t){this.dh=t}$h(t){var h;if(!this.Xn)return;t.preventDefault(),(h=this.Yo)==null||h.ao(this.Mh);const i=performance.now(),r=this.Nh(t.changedTouches);for(const n of r){const c=this.Ko.get(n.id);c&&this.jo.set(n.id,this.Xh(c)),this.Ko.set(n.id,n);const a={id:n.id,startPosition:n,lastPosition:n,startTime:i,lastTime:i,longPressTimer:null,longPressFired:!1};this.ah&&(a.longPressTimer=window.setTimeout(()=>{const u=this.Ko.get(n.id);u&&(a.longPressFired=!0,this.ah({touch:this.Xh(u),duration:performance.now()-a.startTime,originalEvent:t}))},this._h)),this.Wo.set(n.id,a),this.eh&&this.eh(this.Yh(n,t,void 0,i))}this.Ko.size===2&&this.Kh()}Th(t){var h;if(!this.Xn)return;t.preventDefault(),(h=this.Yo)==null||h.ao(this.Mh);const i=performance.now(),r=this.Nh(t.changedTouches);for(const n of r){const c=this.Ko.get(n.id),a=c?this.Xh(c):void 0;a&&this.jo.set(n.id,a),this.Ko.set(n.id,n);const u=this.Wo.get(n.id);u&&(u.lastPosition=n,u.lastTime=i,a)&&V(a.clientX,a.clientY,n.clientX,n.clientY)>this.Ah&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.ih&&this.ih(this.Yh(n,t,a,i))}this.Ko.size===2?this.jh(t):this.Zo=null}Ph(t){if(!this.Xn)return;t.preventDefault();const i=performance.now(),r=this.Nh(t.changedTouches);for(const h of r){const n=this.Ko.get(h.id),c=n?this.Xh(n):void 0,a=this.Wo.get(h.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.rh&&this.rh(this.Yh(h,t,c,i)),a&&this.Wh(a,t),this.Wo.delete(h.id),this.jo.delete(h.id),this.Ko.delete(h.id)}this.Ko.size<2&&(this.Zo=null)}Eh(t){if(!this.Xn)return;t.preventDefault();const i=performance.now(),r=this.Nh(t.changedTouches);for(const h of r){const n=this.Ko.get(h.id),c=n?this.Xh(n):void 0,a=this.Wo.get(h.id);a&&a.longPressTimer!==null&&(window.clearTimeout(a.longPressTimer),a.longPressTimer=null),this.nh&&this.nh(this.Yh(h,t,c,i)),this.Wo.delete(h.id),this.jo.delete(h.id),this.Ko.delete(h.id)}this.Ko.size<2&&(this.Zo=null)}Nh(t){const i=[];for(let r=0;r<t.length;r+=1){const h=t.item(r);h&&i.push(this.Zh(h))}return i}Zh(t){return this.Rh(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})}Rh(t,i,r,h){const n=this.Pr.canvas,c=n.getBoundingClientRect(),a=t-c.left,u=i-c.top,f=n.width/c.width,d=u*(n.height/c.height),g=a*f-this.Xn.offsetX,m=d-this.Xn.offsetY,p=Math.floor(g/this.Xn.cellWidth),v=Math.floor(m/this.Xn.cellHeight),A=p>=0&&p<this.Xn.cols&&v>=0&&v<this.Xn.rows;return{id:r,x:A?p:-1,y:A?v:-1,clientX:t,clientY:i,pressure:h.pressure,radiusX:h.radiusX,radiusY:h.radiusY,rotationAngle:h.rotationAngle}}Yh(t,i,r,h){const n=this.Wo.get(t.id),c=Array.from(this.jo.values()).map(f=>this.Xh(f)),a=Array.from(this.Ko.values()).map(f=>this.Xh(f)),u=this.Nh(i.changedTouches);return{touch:this.Xh(t),previousTouch:r?this.Xh(r):void 0,touches:a,previousTouches:c,changedTouches:u,deltaTime:n?h-n.lastTime:0,originalEvent:i}}Kh(){if(this.Ko.size!==2)return void(this.Zo=null);const t=Array.from(this.Ko.values()),[i,r]=t,h=V(i.x,i.y,r.x,r.y),n=xt(i.clientX,i.clientY,r.clientX,r.clientY);this.Zo={ids:[i.id,r.id],initialDistance:Math.max(h,1e-4),initialAngle:n,lastScale:1,lastRotation:0}}jh(t){if(this.Zo||this.Kh(),!this.Zo)return;const[i,r]=this.Zo.ids,h=this.Ko.get(i),n=this.Ko.get(r);if(!h||!n)return;const c=V(h.x,h.y,n.x,n.y)/this.Zo.initialDistance,a=c-this.Zo.lastScale;this.fh&&Math.abs(a)>this.bh&&(this.fh({touches:[this.Xh(h),this.Xh(n)],scale:c,deltaScale:a,center:this.Vh(h,n),originalEvent:t}),this.Zo.lastScale=c);let u=xt(h.clientX,h.clientY,n.clientX,n.clientY)-this.Zo.initialAngle;u=(u+180)%360-180;const f=u-this.Zo.lastRotation;this.dh&&Math.abs(f)>this.Ch&&(this.dh({touches:[this.Xh(h),this.Xh(n)],rotation:u,deltaRotation:f,center:this.Vh(h,n),originalEvent:t}),this.Zo.lastRotation=u)}Vh(t,i){const r=(t.clientX+i.clientX)/2,h=(t.clientY+i.clientY)/2,n=this.Rh(r,h,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:h});return{x:n.x,y:n.y}}Wh(t,i){const r=performance.now(),h=r-t.startTime,n=V(t.startPosition.clientX,t.startPosition.clientY,t.lastPosition.clientX,t.lastPosition.clientY);if(!t.longPressFired&&h<=this.ph&&n<=this.mh)this.qh(t.lastPosition,r)&&this.hh?this.hh({touch:this.Xh(t.lastPosition),taps:2,originalEvent:i}):this.oh&&this.oh({touch:this.Xh(t.lastPosition),taps:1,originalEvent:i});else if(!t.longPressFired&&h<=this.wh&&n>=this.yh){const c={x:t.lastPosition.clientX-t.startPosition.clientX,y:t.lastPosition.clientY-t.startPosition.clientY},a=Math.max(Math.hypot(c.x,c.y),1e-4),u={x:c.x/a,y:c.y/a},f={x:c.x/h,y:c.y/h};this.uh&&this.uh({touch:this.Xh(t.lastPosition),direction:u,distance:a,velocity:f,originalEvent:i})}this.xh=r,this.Fh=this.Xh(t.lastPosition)}qh(t,i){return!!this.Fh&&!(i-this.xh>this.gh)&&V(t.clientX,t.clientY,this.Fh.clientX,this.Fh.clientY)<=this.mh}Xh(t){return{...t}}}const Ue=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:Ot},Symbol.toStringTag,{value:"Module"}));class ot extends wt{constructor(i,r,h,n,c,a,u,f,d){const g=a/u;let m,p;g>1?(m=f,p=Math.round(f/g)):(p=d,m=Math.round(d*g));super(i,r,h,n,a,u,m,p);l(this,"Qh");l(this,"Jh",!1);l(this,"ta",[]);l(this,"Tn",null);l(this,"sa",0);l(this,"ea",0);l(this,"ia",-1);this.Qh=c}D(){super.D();for(const i of this.ta)this.A.deleteTexture(i);this.ta=[],this.Qh.pause(),this.Qh.src="",this.Qh.load()}ra(){if(!this.Jh&&this.Qh.readyState>=this.Qh.HAVE_CURRENT_DATA){const i=this.A;i.bindTexture(i.TEXTURE_2D,this.Jr),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this.Qh),i.bindTexture(i.TEXTURE_2D,null)}}bn(){if(this.Jh&&this.ta.length>0){const i=this.ea%this.ta.length;return this.ta[i]}return this.Jr}ct(){return this.W=null,super.ct()}An(){this.ra()}async na(i,r){var h;try{if(i<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Qh.duration;if(!isFinite(n)||n<=0)throw Error("Video duration is invalid, cannot preload frames.");const c=Math.max(1,Math.ceil(n*i));if(this.oa(i,c),await this.ha(i,r))return void this.aa("captureStream",r);await this.ca(i,r),this.aa("seeking",r)}catch(n){const c=n instanceof Error?n:Error(n+"");throw(h=r==null?void 0:r.onError)==null||h.call(r,c),c}}oa(i,r){this.Tn=i,this.sa=r,this.ta=[],this.Jh=!1,this.ea=0,this.ia=-1}aa(i,r){var h;if(this.ta.length===0)throw Error(`Video preload via ${i} completed but produced 0 frames.`);this.sa=this.ta.length,this.Jh=!0,this.ea=0,this.ia=-1,this.Qh.pause(),this.Qh.currentTime=0,r!=null&&r.onProgress&&r.onProgress({percent:100,loadedFrames:this.sa,totalFrames:this.sa,strategy:i}),(h=r==null?void 0:r.onComplete)==null||h.call(r,{totalFrames:this.sa,strategy:i})}la(i){const r=this.A,h=r.createTexture();return r.bindTexture(r.TEXTURE_2D,h),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),tt(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}ua(i,r){if(!(r!=null&&r.onProgress)||this.sa===0)return;const h=Math.min(99,Math.floor(this.ta.length/this.sa*100)),n=10*Math.floor(h/10);n>this.ia&&(this.ia=n,r.onProgress({percent:h,loadedFrames:this.ta.length,totalFrames:this.sa,strategy:i}))}async ha(i,r){const h=globalThis,n=h==null?void 0:h.MediaStreamTrackProcessor,c=this.Qh.captureStream;if(typeof n!="function"||typeof c!="function")return!1;let a,u=null;try{const f=c.call(this.Qh);if(a=f.getVideoTracks()[0],!a)return f.getTracks().forEach(m=>m.stop()),!1;if(u=new n({track:a}).readable.getReader(),this.Qh.currentTime=0,this.Qh.muted=!0,await this.Qh.play().catch(()=>{}),this.Qh.paused)return!1;const d=1e6/i;let g=0;for(;this.ta.length<this.sa;){const m=await u.read();if(m.done)break;const p=m.value;if(p)try{const v=typeof p.timestamp=="number"?p.timestamp:g;(this.ta.length===0||v>=g)&&(this.ta.push(this.la(p)),g=v+d,this.ua("captureStream",r))}finally{p.close()}}return u.releaseLock(),a.stop(),u=null,a=void 0,this.Qh.pause(),this.Qh.currentTime=0,this.ta.length!==0}catch{return this.ta=[],this.ia=-1,!1}finally{if(u)try{await u.cancel()}catch{}a&&a.stop(),this.Qh.pause(),this.Qh.currentTime=0}}async ca(i,r){const h=1/i,n=this.sa,c=this.Qh;c.pause();for(let a=0;a<n;a++){const u=Math.min(c.duration,a*h);await this.fa(u),this.ta.push(this.la(c)),this.ua("seeking",r)}c.currentTime=0}fa(i){return new Promise((r,h)=>{const n=this.Qh,c=()=>{n.removeEventListener("seeked",a),n.removeEventListener("error",u)},a=()=>{c(),r()},u=()=>{c(),h(Error("Video seek failed while preloading frames."))};n.addEventListener("seeked",a,{once:!0}),n.addEventListener("error",u,{once:!0});const f=isFinite(n.duration)?n.duration:i,d=Math.min(Math.max(i,0),f);if(Math.abs(n.currentTime-d)<1e-4)return c(),void r();n.currentTime=d})}frame(i){return this.Jh&&i!==void 0&&this.sa>0&&(this.ea=(i%this.sa+this.sa)%this.sa,this.W=null),this}static async Cn(i,r,h,n,c,a,u){const f=i.context,d=u==null?void 0:u.frameRate;let g;typeof h=="string"?(g=document.createElement("video"),g.crossOrigin="anonymous",g.loop=!0,g.muted=!0,g.playsInline=!0,await new Promise((E,y)=>{g.addEventListener("loadedmetadata",()=>E(),{once:!0}),g.addEventListener("error",b=>{var R;const w=b.target;y(Error("Failed to load video: "+(((R=w.error)==null?void 0:R.message)||"Unknown error")))},{once:!0}),g.src=h})):(g=h,g.readyState<g.HAVE_METADATA&&await new Promise((E,y)=>{g.addEventListener("loadedmetadata",()=>E(),{once:!0}),g.addEventListener("error",b=>{var w;return y(Error("Video error: "+((w=b.target.error)==null?void 0:w.message)))},{once:!0})}));const m=f.createTexture();f.bindTexture(f.TEXTURE_2D,m),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,1),tt(f,f.LINEAR,f.LINEAR,f.CLAMP_TO_EDGE,f.CLAMP_TO_EDGE),f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,g),f.bindTexture(f.TEXTURE_2D,null);const p=g.videoWidth,v=g.videoHeight,A=new ot(f,i,m,r,g,p,v,n,c);return A.ln=a,d&&d>0&&await A.na(d,u),A}async play(){await this.Qh.play()}pause(){this.Qh.pause()}stop(){this.Qh.pause(),this.Qh.currentTime=0}speed(i){return this.Qh.playbackRate=i,this}loop(i=!0){return this.Qh.loop=i,this}time(i){return this.Qh.currentTime=i,this}volume(i){return this.Qh.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.Jr}get width(){return this.H}get height(){return this.G}get originalWidth(){return this.tn}get originalHeight(){return this.sn}get videoElement(){return this.Qh}get currentTime(){return this.Qh.currentTime}get duration(){return this.Qh.duration}get isPlaying(){return!this.Qh.paused&&!this.Qh.ended}get isPreloaded(){return this.Jh}get totalFrames(){return this.sa}get preloadFrameRate(){return this.Tn}get currentFrameIndex(){return this.ea}}const Xe=o=>class extends o{da(t,i,r,h){if(M.Wr(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,h);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.j.state.Zt(t),this.j.state.Vt(i),this.j.state.qt(r)}rotateX(t){this.j.state.Zt(t)}rotateY(t){this.j.state.Vt(t)}rotateZ(t){this.j.state.qt(t)}translate(t=0,i=0,r=0){this.j.state.Qt(t,i,r)}translateX(t){this.j.state.Qt(t,0,0)}translateY(t){this.j.state.Qt(0,t,0)}translateZ(t){this.j.state.Qt(0,0,t)}push(){this.j.state.rt()}pop(){this.j.state.nt()}color(t,i,r,h){const n=typeof t=="string"?c=>this.ir.er(c):void 0;return M.jr(t,n??i,r,h)}rect(t=1,i=1){this.j.gi(t,i)}point(){this.j.gi(1,1)}line(t,i,r,h){this.j.mi(t,i,r,h)}lineWeight(t){this.j.state.jt(t)}background(t,i,r,h=255){const n=this.da(t,i,r,h);this.j.Ci(n.r,n.g,n.b,n.a)}char(t){if(M.Wr(t)){const r=t.character;return void(r&&this.j.state.es(r))}const i=Array.from(t);if(i.length===0)throw Error("char() requires at least one character.");this.j.state.es(this.ir.sr(i[0]))}charColor(t,i,r,h){const n=this.da(t,i,r,h);this.j.state.rs(n.r,n.g,n.b,n.a)}cellColor(t,i,r,h){const n=this.da(t,i,r,h);this.j.state.ns(n.r,n.g,n.b,n.a)}flipX(t){this.j.state.hs(t)}flipY(t){this.j.state.cs(t)}charRotation(t){this.j.state.us(t)}invert(t){this.j.state.ls(t)}clear(){this.j.Ci(0,0,0,0)}ellipse(t,i){this.j._i(t/2,i/2)}triangle(t,i,r,h,n,c){this.j.Ai(t,i,r,h,n,c)}bezierCurve(t,i,r,h,n,c,a,u){this.j.yi(t,i,r,h,n,c,a,u)}arc(t,i,r,h){this.j.wi(t/2,i/2,r,h)}shader(t){this.j.li(t)}setUniform(t,i){this.j.O(t,i)}setUniforms(t){this.j.ui(t)}async createFilterShader(t){if(typeof t=="string"&&(t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const i=await fetch(t);if(!i.ok)throw Error(`Failed to load shader from ${t}: ${i.statusText}`);const r=await i.text();return this.j.fi(r)}return this.j.fi(t)}createFramebuffer(t){return this.j.bi(t.width??this.grid.cols,t.height??this.grid.rows,3)}image(t,i,r){this.j.di(t,i,r)}ortho(){this.j.state.ds(!0)}async loadImage(t){if(typeof t!="string"){const n=K.Cn(this.j,this.ir,t,this.Xn.cols,this.Xn.rows,c=>this.ir.er(c));return this.pa(n),n}const i=t,r=await new Promise((n,c)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a),a.onerror=u=>c(u),a.src=i}),h=K.Cn(this.j,this.ir,r,this.Xn.cols,this.Xn.rows,n=>this.ir.er(n));return this.pa(h),h}async loadVideo(t,i){const r=await ot.Cn(this.j,this.ir,t,this.Xn.cols,this.Xn.rows,h=>this.ir.er(h),i);return this.pa(r),r}},Se=o=>class extends o{async loadFont(t){return this.ir.br(t).then(()=>{const i=this.ir.maxGlyphDimensions;this.Xn.Sr(i.width,i.height),this.ga.resize(this.Xn.cols,this.Xn.rows),this.j.Mi(),this.Yo.uo(),this.va.uo(),this.ma()})}fontSize(t){if(!Z.m(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.ir.fontSize===t)return;this.ir.wr(t);const i=this.ir.maxGlyphDimensions;this.Xn.Sr(i.width,i.height),this.ga.resize(this.Xn.cols,this.Xn.rows),this.j.Mi(),this.Yo.uo(),this.va.uo(),this.ma()}},Ne=o=>class extends o{get frameCount(){return this._a.Gn}set frameCount(t){this._a.Gn=t}frameRate(t){return t===void 0?this._a.Bn:this._a.Ln(t,()=>this.ya())}noLoop(){this._a.In()}loop(){this._a.On(()=>this.ya())}redraw(t=1){if(Z.m(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.ya()}isLooping(){return this._a.Hn}},De=o=>class extends o{constructor(...t){super(...t)}mouseClicked(t){this.Yo.wo(t)}mousePressed(t){this.Yo.bo(t)}mouseReleased(t){this.Yo.Co(t)}mouseMoved(t){this.Yo.Mo(t)}mouseScrolled(t){this.Yo.xo(t)}get mouse(){return this.Yo.Fo()}cursor(t){this.Yo.lo(t)}},Le=o=>class extends o{constructor(...t){super(...t)}touchStarted(t){this.va.kh(t)}touchMoved(t){this.va.Mo(t)}touchEnded(t){this.va.zh(t)}touchCancelled(t){this.va.Ih(t)}tap(t){this.va.Oh(t)}doubleTap(t){this.va.Lh(t)}longPress(t){this.va.Dh(t)}swipe(t){this.va.Hh(t)}pinch(t){this.va.Bh(t)}rotateGesture(t){this.va.Gh(t)}get touches(){return this.va.Sh()}},Ie=o=>class extends o{constructor(...t){super(...t)}keyPressed(t){this.wa.bo(t)}keyReleased(t){this.wa.Co(t)}isKeyPressed(t){return this.wa.Lo(t)}get lastKeyPressed(){return this.wa.Ho()}get lastKeyReleased(){return this.wa.Bo()}get pressedKeys(){return this.wa.Go()}get modifierState(){return this.wa.No()}};class Be{constructor(t){l(this,"ba");l(this,"Ca",new Map);l(this,"Ma",[]);l(this,"xa",new Map);l(this,"Fa",new Map);this.ba=t}async $a(t){for(const i of t){if(this.Ca.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.Ta(i.name);try{await i.install(this.ba,r)}catch(h){throw this.Pa(i.name),h}this.Ca.set(i.name,i),this.Ma.push(i.name)}}async Ea(t){const i=this.Ca.get(t);if(!i)return;const r=this.Ta(t);i.uninstall&&await i.uninstall(this.ba,r),this.Ca.delete(t),this.Ma.splice(this.Ma.indexOf(t),1),this.Pa(t)}Ra(){this.Sa(this.xa)}ka(){this.Sa(this.Fa)}async za(){const t=[...this.Ca.keys()];for(const i of t)await this.Ea(i)}Ta(t){return{renderer:this.ba.j,font:this.ba.ir,grid:this.ba.Xn,canvas:this.ba.Pr,drawFramebuffer:this.ba.ga,asciiFramebuffer:this.ba.Ia,registerPreDrawHook:i=>this.Oa(this.xa,t,i),registerPostDrawHook:i=>this.Oa(this.Fa,t,i)}}Oa(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))}}Pa(t){this.xa.delete(t),this.Fa.delete(t)}Sa(t){for(const i of this.Ma){const r=t.get(i);r&&r.forEach(h=>h())}}}const Gt=`#version 300 es
|
|
11
|
+
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class jt{constructor(){l(this,"La",new Map);l(this,"Da",[]);l(this,"Ha",0);l(this,"Ba",0);l(this,"Ga")}get Na(){return this.Ha}get Xa(){if(this.Ha===0)return 0;let t=0;for(const i of this.Da){const r=this.La.get(i);r&&(t+=Math.min(1,Math.max(0,r.progress))*r.weight)}return Math.min(1,t/this.Ha)}Ya(t){this.Ga=t}Ka(t,i=1){const r=`phase-${this.Da.length+1}-${Date.now()}`,h={id:r,label:t,weight:Math.max(.001,i),progress:0,status:"running"};return this.La.set(r,h),this.Da.push(r),this.Ha+=h.weight,r}ja(t,i){const r=this.La.get(t);if(!r)return;r.progress=Math.max(0,Math.min(1,i)),r.status=r.progress>=1?"complete":"running";const h=this.Xa;Math.abs(h-this.Ba)>.001&&(this.Ba=h,this.Ga&&this.Ga(h))}Wa(t){const i=this.La.get(t);i&&(i.progress=1,i.status="complete",this.ja(t,1))}Za(t){const i=this.La.get(t);i&&(i.status="failed")}Va(){return this.Da.map(t=>{const i=this.La.get(t);return i?{id:i.id,label:i.label,weight:i.weight,progress:i.progress,status:i.status}:{id:t,label:t,weight:1,progress:0,status:"pending"}})}}class zt{constructor(t="active"){l(this,"qa");l(this,"Qa","");l(this,"Ja","");this.qa=t}get tc(){return this.qa}get sc(){return this.qa!=="disabled"}get ec(){return this.qa==="active"||this.qa==="transitioning"||this.qa==="error"}get rc(){return this.Qa}get nc(){return this.Ja}oc(){this.qa!=="done"&&this.qa!=="transitioning"||(this.qa="active")}hc(){this.qa!=="disabled"&&(this.qa="done")}ac(){this.qa!=="disabled"&&(this.qa="transitioning")}cc(){this.qa==="transitioning"&&(this.qa="done")}lc(t){this.qa!=="disabled"&&(this.qa="error",t instanceof Error?(this.Qa=t.message,this.Ja=t.stack||""):(this.Qa=t,this.Ja=""))}uc(){this.qa="disabled"}}class _t{constructor(t,i){l(this,"fc",0);l(this,"dc",1);l(this,"gc");l(this,"vc");this.gc=t,this.vc=i}get mc(){return this.dc}get _c(){return this.dc<1}kn(){this.gc!=="none"&&this.vc>0&&(this.fc=performance.now())}st(){if(this.gc==="none"||this.vc===0)return this.dc=1,!1;const t=performance.now()-this.fc,i=Math.min(1,t/this.vc);return i>=1?(this.dc=0,!0):(this.dc=1-i,!1)}qs(){this.dc=1,this.fc=0}}function bt(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,c,a]=h.map(f=>f/255),u=f=>f<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4);return .2126*u(n)+.7152*u(c)+.0722*u(a)}(t)>.5?"light":"dark"),{mode:r,background:t,textColor:r==="light"?"#1A1A1A":"#F8F8F8",subtleColor:r==="light"?"#4A4A4A":"#C0C0C0"}}function Ht(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 Ye=({textmodifier:o,grid:t,progress:i,frameCount:r,message:h,palette:n,theme:c,phases:a,transitionOpacity:u,isError:f,errorMessage:d})=>{const g="|/-\\",m=Math.floor(r/6)%4,p=o.color(c.textColor),v=Math.floor(255*u),A=o.color(p.r,p.g,p.b,v);if(o.charColor(A),o.cellColor(0,0,0,0),f){const E=o.color(c.mode==="light"?"#D32F2F":"#FF6B6B",v);o.charColor(E),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const y="SETUP ERROR",b=-Math.floor(y.length/2);o.push(),o.translate(b,0,0);for(const w of y)o.char(w),o.rect(1,1),o.translateX(1);if(o.pop(),d){const w=o.color(c.subtleColor),R=o.color(w.r,w.g,w.b,v);o.charColor(R);const T=Math.floor(.8*t.cols),U=d.split(" "),D=[];let X="";for(const N of U)(X+" "+N).length<=T?X=X?X+" "+N:N:(X&&D.push(X),X=N);X&&D.push(X);const I=D.slice(0,3);D.length>3&&(I[2]=I[2].substring(0,T-3)+"..."),I.forEach((N,ct)=>{const Ze=-Math.floor(N.length/2);o.push(),o.translate(Ze,3+ct,0);for(const Ve of N)o.char(Ve),o.rect(1,1),o.translateX(1);o.pop()})}return}if(o.push(),o.translate(0,0,0),o.char(g[m]),o.rect(1,1),o.pop(),i>0||a.some(E=>E.status!=="pending")){const E=Math.max(6,Math.floor(.6*t.cols)),y=-Math.floor(E/2),b=Math.floor(E*i),w=n.length?n:[o.color("#FFFFFF")];o.push(),o.translate(y,3,0);for(let R=0;R<E;R++){const T=R<b?"*":".",U=w[R%w.length],D=o.color(U.r,U.g,U.b,v);o.charColor(D),o.char(T),o.rect(1,1),o.translateX(1)}o.pop()}if(h){const E=o.color(c.subtleColor),y=o.color(E.r,E.g,E.b,v);o.charColor(y);const b=-Math.floor(h.toUpperCase().length/2);o.push(),o.translate(b,5,0);for(const w of h.toUpperCase())o.char(w),o.rect(1,1),o.translateX(1);o.pop()}},Oe={message:"loading...",tone:"auto",transition:"fade",transitionDuration:500};class Ge{constructor(t,i,r){this.yc=t,this.id=i,this.label=r}report(t){this.yc.ja(this.id,t)}complete(){this.yc.Wa(this.id)}fail(t){this.yc.Za(this.id)}async track(t){try{const i=typeof t=="function"?await t():await t;return this.complete(),i}catch(i){throw this.fail(),i}}}class Kt{constructor(t,i,r){l(this,"ba");l(this,"l");l(this,"wc");l(this,"yc");l(this,"bc");l(this,"Cc");l(this,"Mc");l(this,"xc");l(this,"Fc");l(this,"$c");l(this,"j");l(this,"Tc",[]);l(this,"Pc");l(this,"Ec",performance.now());l(this,"Rc",0);l(this,"Sc",!1);l(this,"kc",!1);l(this,"Lc");this.ba=t,this.l={...Oe,...i??{}},this.wc=new zt("active"),this.yc=new jt,this.bc=new _t(this.l.transition,this.l.transitionDuration),this.Cc=new It(60),this.Pc=bt(this.l,r);const h=Ht(this.Pc);this.Tc=kt(h,this.ba),this.j=this.zc(),this.yc.Ya(n=>{n>=.999&&this.hc()})}async _r(t){if(this.kc)return;const i=this.ba.j,r=this.ba.Pr;this.Mc=new mt(i,16),await this.Mc._r(t);const h=this.Mc.maxGlyphDimensions;this.xc=new vt(r.canvas,h.width,h.height),this.Fc=i.bi(this.xc.cols,this.xc.rows,3),this.$c=i.bi(this.xc.width,this.xc.height,1),this.kc=!0}get ec(){return this.wc.ec&&this.Sc}kn(){this.Sc||(this.Sc=!0,this.Ec=performance.now(),this.Rc=0,this.Cc.kn(()=>this.Ic()))}zn(){this.Sc&&(this.Sc=!1,this.Cc.zn())}Nr(){this.kc&&(this.xc.qs(),this.Fc.resize(this.xc.cols,this.xc.rows),this.$c.resize(this.xc.width,this.xc.height))}D(){this.zn(),this.kc&&(this.Mc.D(),this.Fc.D(),this.$c.D(),this.kc=!1)}get progress(){return this.yc.Xa}message(t){return typeof t=="string"&&(this.l.message=t),this.l.message}addPhase(t,i=1){this.wc.oc();const r=this.yc.Ka(t,i);return new Ge(this.yc,r,t)}hc(){this.l.transition!=="none"&&this.l.transitionDuration>0?(this.wc.ac(),this.bc.kn()):(this.wc.hc(),this.zn(),this.Oc())}Oc(){this.Lc&&this.Lc()}Dc(t){this.Lc=t}error(t){this.wc.lc(t)}Ic(){if(this.wc.ec){if(this.Rc++,this.wc.tc==="transitioning"&&this.bc.st())return this.wc.cc(),this.Oc(),void this.zn();this.Hc()}}Hc(){if(!this.kc)return;const t=this.Fc,i=this.Mc,r=this.xc,h=this.$c,n=this.ba.j,c=this.ba.Pr,a=this.ba.Bc,u=this.ba.Gc;n.state.Wt(),t.begin(),this.ba.clear(),this.ba.push();try{const f={textmodifier:this.ba,grid:r,progress:this.progress,elapsedMs:performance.now()-this.Ec,frameCount:this.Rc,message:this.l.message,palette:this.Tc,theme:this.Pc,phases:this.yc.Va(),transitionOpacity:this.bc.mc,isError:this.wc.tc==="error",errorMessage:this.wc.rc||void 0,errorDetails:this.wc.nc||void 0};this.j(f)}finally{this.ba.pop()}t.end(),h.begin(),n.ai(a),a.I({U0:i.fontFramebuffer,U1:[i.textureColumns,i.textureRows],U2:t.textures[0],U3:t.textures[1],U4:t.textures[2],U5:[r.cols,r.rows],U6:[h.width,h.height],U7:n.state.canvasBackgroundColor}),n.pi(0,0,c.width,c.height),h.end(),n.me(...n.state.canvasBackgroundColor),n.ai(u),u.I({U8:h.textures[0],U9:[h.width,h.height],Ua:[r.offsetX,r.offsetY],Ub:[r.width,r.height]}),n.pi(r.offsetX,r.offsetY,r.width,r.height)}Nc(t){this.Pc=bt(this.l,t)}zc(){const t=this.l.renderer||Ye;return i=>{t(i),this.Xc(i)}}Xc(t){const{textmodifier:i,grid:r,frameCount:h,theme:n,transitionOpacity:c}=t,a=[116,101,120,116,109,111,100,101,46,106,115].map(g=>String.fromCharCode(g)).join(""),u=(r.rows+1>>1)-2,f=2-(r.cols+1>>1),d=n.mode==="light"?[[233,30,99],[156,39,176],[255,111,0]]:[[142,249,243],[241,91,181],[255,155,113]];i.push(),i.translate(f,u,0);for(let g=0;g<a.length;g++){const m=a[g],p=Math.floor(.1*h+.5*g)%d.length,[v,A,E]=d[p],y=Math.floor(255*c),b=i.color(v,A,E,y);i.charColor(b),i.char(m),i.point(),i.translateX(1)}i.pop()}}class Wt extends function(i,...r){return r.reduce((h,n)=>n(h),i)}(class{},Xe,Se,Ne,De,Le,Ie){constructor(i={}){super();l(this,"j");l(this,"ir");l(this,"Pr");l(this,"Xn");l(this,"_a");l(this,"Yo");l(this,"va");l(this,"wa");l(this,"Yc");l(this,"ga");l(this,"Bc");l(this,"Ia");l(this,"Gc");l(this,"Kc");l(this,"jc",!1);l(this,"Wc",!1);l(this,"Zc",!1);l(this,"Vc",!1);l(this,"qc",()=>{});l(this,"Qc",()=>{});l(this,"Jc",()=>{});l(this,"tl");l(this,"sl");l(this,"zr",!1);l(this,"el");l(this,"il",new Set);this.Kc=new Be(this),this.zr=i.overlay??!1,this.Pr=new Nt(i),this.j=new ue(this.Pr.Xr()),this.ir=new mt(this.j,i.fontSize??16),this._a=new It(i.frameRate??60),this.Yc=new Kt(this,i.loadingScreen,this.Pr.Gr()),this.Yc.Dc(()=>{this._a.Gn=0,this.Vc=!0}),this.Yo=new Bt(this.Pr),this.va=new Ot(this.Pr,this.Yo),this.wa=new Yt,this.Bc=this.j.ci(Gt,`#version 300 es
|
|
12
|
+
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 U7;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(U7,J,J.a);fragColor=mix(d,I,c);}`),this.Yc.kn(),this.rl(i)}async rl(i){await Promise.all([this.ir._r(i.fontSource),this.Yc._r(i.fontSource)]);const r=this.ir.maxGlyphDimensions;this.Xn=new vt(this.Pr.canvas,r.width,r.height),this.Yo._r(this.Xn),this.va._r(this.Xn),this.ga=this.j.bi(this.Xn.cols,this.Xn.rows,3),this.Ia=this.j.bi(this.Xn.width,this.Xn.height,1),this.zr&&(this.el=K.Cn(this.j,this.ir,this.Pr.targetCanvas,this.Xn.cols,this.Xn.rows,h=>this.ir.er(h)),this.pa(this.el)),this.Gc=this.j.ci(Gt,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D U8;uniform vec2 U9;uniform vec2 Ua;uniform vec2 Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=gl_FragCoord.xy-Ua;vec2 B=A*(U9/Ub);vec2 C=(floor(B)+0.5)/U9;fragColor=texture(U8,C);}`),this.nl(),this._a.kn(()=>this.ya()),await this.Kc.$a(i.plugins??[]);try{await this.qc(),this.Yc.hc()}catch(h){console.error("Error during setup:",h),this.Yc.error(h)}}nl(){this.tl=()=>{this.zr&&this.resizeCanvas(this.Pr.targetCanvas.width,this.Pr.targetCanvas.height),this.Jc()},window.addEventListener("resize",this.tl),this.Yo.fo(),this.va.fo(),this.wa.fo(),window.addEventListener("blur",()=>{this.wa.Xo()}),this.zr&&(this.sl=new ResizeObserver(()=>{this.resizeCanvas(this.Pr.targetCanvas.width,this.Pr.targetCanvas.height)}),this.sl.observe(this.Pr.targetCanvas))}ya(){if(!this.Yc.ec&&this.Vc){this.Wc=!0;try{this._a.Dn(),this._a.Nn(),this.zr&&Pt(this.j.context,this.el.texture,this.Pr.targetCanvas),this.Kc.Ra(),this.j.state.Wt(),this.ga.begin(),this.Qc(),this.ga.end(),this.Ia.begin(),this.j.ai(this.Bc),this.Bc.I({U0:this.ir.fontFramebuffer,U1:[this.ir.textureColumns,this.ir.textureRows],U2:this.ga.textures[0],U3:this.ga.textures[1],U4:this.ga.textures[2],U5:[this.Xn.cols,this.Xn.rows],U6:[this.Ia.width,this.Ia.height],U7:this.j.state.canvasBackgroundColor}),this.j.pi(0,0,this.Pr.width,this.Pr.height),this.Ia.end(),this.j.me(...this.j.state.canvasBackgroundColor),this.j.ai(this.Gc),this.Gc.I({U8:this.Ia.textures[0],U9:[this.Ia.width,this.Ia.height],Ua:[this.Xn.offsetX,this.Xn.offsetY],Ub:[this.Xn.width,this.Xn.height]}),this.j.pi(this.Xn.offsetX,this.Xn.offsetY,this.Xn.width,this.Xn.height),this.Kc.ka()}finally{this.Wc=!1,this.jc&&!this.Zc&&this.ol()}}}resizeCanvas(i,r){this.Pr.Nr(i,r),this.Yc.Nc(this.Pr.Gr()),this.Xn.qs(),this.Yc.Nr(),this.ga.resize(this.Xn.cols,this.Xn.rows),this.Ia.resize(this.Xn.width,this.Xn.height),this.j.Mi(),this.Yo.uo(),this.va.uo(),this.ya()}destroy(){this.Zc||this.jc||(this.jc=!0,this._a.In(),this.Wc||this.ol())}ol(){var i,r;this.jc=!1,this.Yc.D(),this.Kc.za(),window.removeEventListener("resize",this.tl),(i=this.sl)==null||i.disconnect(),this.Yo.yo(),this.va.yo(),this.wa.yo(),this.ga.D(),this.Bc.D(),this.ir.D(),this.j.D(),this.Ia.D(),this.Gc.D(),(r=this.el)==null||r.D(),this.Pr.D(),this.Zc=!0}setup(i){this.qc=i}draw(i){this.Qc=i}windowResized(i){this.Jc=i}get grid(){return this.Xn}get font(){return this.ir}get width(){return this.Pr.width}get height(){return this.Pr.height}get canvas(){return this.Pr.canvas}get drawFramebuffer(){return this.ga}get isDisposed(){return this.Zc}get overlay(){return this.el}get loading(){return this.Yc}pa(i){this.il.has(i)||this.il.add(i)}ma(){for(const i of this.il)i._n(this.ir)}}class at{constructor(){}static create(t={}){return new Wt(t)}static setErrorLevel(t){Z._(t)}static get version(){return"0.6.0-beta.4"}}let Tt=null;const je={id:"brightness",createShader:({gl:o})=>(Tt||(Tt=new j(o,et,`#version 300 es
|
|
14
|
+
precision highp float;in vec2 v_uv;uniform sampler2D Uj;uniform bool Uk;uniform bool Ul;uniform bool Um;uniform float Un;uniform bool Uo;uniform vec4 Up;uniform bool Uq;uniform vec4 Ur;uniform vec4 Us;uniform int Ut;uniform vec3 Uu[255];uniform bool Uv;uniform int Uw;uniform vec4 Ux[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));}float C(vec3 D,vec3 E){vec3 F=D-E;return dot(F,F);}vec4 G(vec4 H){if(!Uv||Uw<=0){return H;}int I=min(Uw,64);vec3 J=Ux[0].rgb;float K=C(H.rgb,J);for(int L=1;L<64;++L){if(L>=I){break;}vec3 M=Ux[L].rgb;float N=C(H.rgb,M);if(N<K){K=N;J=M;}}return vec4(J,H.a);}void main(){vec2 O=vec2(v_uv.x,1.0f-v_uv.y);vec4 H=texture(Uj,O);H=G(H);float E=A(H.rgb);vec2 P=vec2(0.);if(Ut>0){float Q=float(Ut);float R=clamp(E*(Q-1.0f),0.0f,Q-1.0f);int S=int(floor(R+0.5f));vec3 T=Uu[S];P=T.xy;}else{P=vec2(E,0.0f);}vec4 U=Uo?Up:H;vec4 V=Uq?Ur:H;if(H.a<0.01f){U=Us;V=Us;}else{}o_primaryColor=vec4(U.rgb,U.a);o_secondaryColor=vec4(V.rgb,V.a);int W=int(Uk?1:0);int X=int(Ul?1:0);int Y=int(Um?1:0);float Z=float(W|(X<<1)|(Y<<2))/255.;o_character=vec4(P,Z,clamp(Un,0.0f,1.0f));}`)),Tt),createUniforms:({source:o})=>o.createBaseConversionUniforms()},ze=Object.freeze(Object.defineProperty({__proto__:null,LoadingPhaseTracker:jt,LoadingScreenManager:Kt,LoadingScreenStateMachine:zt,LoadingScreenTransition:_t,resolveColorInputs:kt,resolveDefaultPalette:Ht,resolveTheme:bt},Symbol.toStringTag,{value:"Module"})),_e=Object.freeze(Object.defineProperty({__proto__:null,TextmodeFont:mt,TextmodeImage:K,TextmodeSource:wt,TextmodeVideo:ot},Symbol.toStringTag,{value:"Module"})),He=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Me,mouse:Fe,touch:Ue},Symbol.toStringTag,{value:"Module"}));Dt(je);const ke=at.create,Ke=at.setErrorLevel,We=at.version;x.Shader=j,x.TextmodeCanvas=Nt,x.TextmodeColor=M,x.TextmodeErrorLevel=O,x.TextmodeFramebuffer=Q,x.TextmodeGrid=vt,x.Textmodifier=Wt,x.create=ke,x.getConversionStrategy=Lt,x.input=He,x.loadables=_e,x.loading=ze,x.registerConversionStrategy=Dt,x.setErrorLevel=Ke,x.textmode=at,x.unregisterConversionStrategy=function(o){Et.delete(o)},x.version=We,Object.defineProperty(x,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={});
|