textmode.js 0.6.0-beta.1 → 0.6.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.esm.js +2496 -2472
- package/dist/textmode.esm.min.js +2579 -2555
- package/dist/textmode.umd.js +11 -11
- package/dist/textmode.umd.min.js +11 -11
- package/dist/types/errors/ErrorHandler.d.ts +6 -1
- package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +6 -6
- package/dist/types/rendering/webgl/batching/InstanceBatch.d.ts +3 -3
- package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +9 -9
- package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +2 -2
- package/dist/types/rendering/webgl/core/Framebuffer.d.ts +3 -3
- package/dist/types/textmode/Textmodifier.d.ts +1 -6
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +13 -10
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +26 -0
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +14 -14
- package/dist/types/textmode/loadables/TextmodeVideo.d.ts +29 -1
- package/dist/types/textmode/loadables/font/TextmodeFont.d.ts +3 -0
- package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +8 -8
- package/dist/types/textmode/loading/LoadingScreenManager.d.ts +49 -8
- package/dist/types/textmode/loading/LoadingScreenState.d.ts +11 -11
- package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +3 -3
- package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +5 -5
- package/dist/types/textmode/loading/index.d.ts +1 -1
- package/dist/types/textmode/managers/PluginManager.d.ts +6 -1
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +218 -179
- package/package.json +1 -1
package/dist/textmode.umd.min.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ke=Object.defineProperty;var Ke=(L,A,H)=>A in L?ke(L,A,{enumerable:!0,configurable:!0,writable:!0,value:H}):L[A]=H;var l=(L,A,H)=>Ke(L,typeof A!="symbol"?A+"":A,H);var s,i;s=this,i=function(L){class A extends Error{constructor(t,e={}){super(A.i(t,e)),this.name="TextmodeError"}static i(t,e){return`${t}${e&&Object.keys(e).length>0?`
|
|
2
2
|
|
|
3
|
-
📋 Context
|
|
4
|
-
- ${r}: ${
|
|
3
|
+
📋 Context:`+Object.entries(e).map(([r,h])=>`
|
|
4
|
+
- ${r}: ${A.o(h)}`).join(""):""}
|
|
5
5
|
|
|
6
6
|
${"↓".repeat(24)}
|
|
7
|
-
`}static
|
|
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 Ud;uniform sampler2D Ue;uniform sampler2D Uf;uniform vec2 Ug;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Ug;vec2 C=(floor(B)+0.5f)/Ug;vec4 D=texture(Ud,C);vec4 E=texture(Ue,C);if(E.a==0.){discard;}vec4 F=texture(Uf,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;}`));const f=t.getParameter(t.MAX_DRAW_BUFFERS),p=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.K=Math.min(this.K,f,p),this.G=t.createFramebuffer(),this.V(),this.q(),this.h.Z&&this.J()}V(){const t=this.m,i=this.h.filter==="linear"?t.LINEAR:t.NEAREST,r=this.h.wrap==="repeat"?t.REPEAT:t.CLAMP_TO_EDGE,n=this.h.type==="float"?t.FLOAT:t.UNSIGNED_BYTE,h=n===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),et(t,i,i,r,r),t.texImage2D(t.TEXTURE_2D,0,h,this.O,this.B,0,a,n,null),this.W.push(u)}t.bindTexture(t.TEXTURE_2D,null)}q(){const t=this.m;if(t.bindFramebuffer(t.FRAMEBUFFER,this.G),this.K===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.W[0],0);else{const i=[];for(let r=0;r<this.K;r++){const n=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,n,t.TEXTURE_2D,this.W[r],0),i.push(n)}t.drawBuffers(i)}t.bindFramebuffer(t.FRAMEBUFFER,null)}J(){const t=this.m;this.H=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.H),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.O,this.B),t.bindFramebuffer(t.FRAMEBUFFER,this.G),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.H),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}tt(t){Rt(this.m,this.W[0],t)}resize(t,i){this.O=t,this.B=i,this.N.clear();const r=this.m,n=this.h.type==="float"?r.FLOAT:r.UNSIGNED_BYTE,h=n===r.FLOAT?r.RGBA32F:r.RGBA8,a=r.RGBA;for(const c of this.W)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,h,this.O,this.B,0,a,n,null);r.bindTexture(r.TEXTURE_2D,null),this.H&&(r.bindRenderbuffer(r.RENDERBUFFER,this.H),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT24,this.O,this.B),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const i=this.N.get(t);if(i)return i;const r=this.m,n=this.O,h=this.B,a=new Uint8Array(n*h*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.G),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,n,h,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.READ_FRAMEBUFFER,c);const u=4*n,d=new Uint8Array(a.length);for(let f=0;f<h;f++){const p=(h-1-f)*u,g=f*u;d.set(a.subarray(p,p+u),g)}return this.N.set(t,d),d}st(){const t=this.m;this.N.clear(),this.Y.et(),this.Y.it(this.G,this.O,this.B),this.h.Z&&t.clear(t.DEPTH_BUFFER_BIT),this.Y.state.rt()}end(){this.Y.state.nt(),this.Y.ot();const t=this.Y.ht();this.Y.it(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.j||this.lt(),this.j}lt(){if(!this.Y)return;const t={ut:this.W[0],ft:this.W[1],dt:this.W[2],_t:[this.O,this.B]},i=k.X;this.j=this.Y.vt.gt(i,t,!0)}D(){const t=this.m;t.deleteFramebuffer(this.G);for(const i of this.W)t.deleteTexture(i);this.H&&t.deleteRenderbuffer(this.H)}get width(){return this.O}get height(){return this.B}get L(){return this.W}get yt(){return this.K}};l(k,"X",null);let Z=k;const Lt=new WeakMap;function pt(o,t){Lt.set(o,t)}function Mt(o){return Lt.get(o)}function X(o,t,i,r,n=255){o[0]=t/255,o[1]=(i??t)/255,o[2]=(r??t)/255,o[3]=n/255}class rt{constructor(){l(this,"wt",1);l(this,"bt",0);l(this,"Ct",0);l(this,"$t",0);l(this,"Mt",0);l(this,"xt",0);l(this,"At",0);l(this,"Ft",[0,0,0]);l(this,"Ut",[1,1,1,1]);l(this,"Tt",[0,0,0,1]);l(this,"St",!1);l(this,"Et",!1);l(this,"Rt",!1);l(this,"kt",0);l(this,"Pt",[0,0,0,1]);l(this,"Lt",!1);l(this,"It",[]);l(this,"zt",[])}static Dt(){return{Ot:1,Bt:0,Gt:0,Wt:0,Mt:0,xt:0,At:0,kt:0,Ht:!1,Kt:!1,Rt:!1,Lt:!1,Yt:[0,0,0],jt:[1,1,1,1],Nt:[0,0,0,1]}}Xt(t){t.Ot=this.wt,t.Bt=this.bt,t.Gt=this.Ct,t.Wt=this.$t,t.Mt=this.Mt,t.xt=this.xt,t.At=this.At,t.Ht=this.St,t.Kt=this.Et,t.Rt=this.Rt,t.kt=this.kt,t.Lt=this.Lt,t.Yt[0]=this.Ft[0],t.Yt[1]=this.Ft[1],t.Yt[2]=this.Ft[2],t.jt[0]=this.Ut[0],t.jt[1]=this.Ut[1],t.jt[2]=this.Ut[2],t.jt[3]=this.Ut[3],t.Nt[0]=this.Tt[0],t.Nt[1]=this.Tt[1],t.Nt[2]=this.Tt[2],t.Nt[3]=this.Tt[3]}Zt(t){this.wt=t.Ot,this.bt=t.Bt,this.Ct=t.Gt,this.$t=t.Wt,this.Mt=t.Mt,this.xt=t.xt,this.At=t.At,this.St=t.Ht,this.Et=t.Kt,this.Rt=t.Rt,this.kt=t.kt,this.Lt=t.Lt,this.Ft[0]=t.Yt[0],this.Ft[1]=t.Yt[1],this.Ft[2]=t.Yt[2],this.Ut[0]=t.jt[0],this.Ut[1]=t.jt[1],this.Ut[2]=t.jt[2],this.Ut[3]=t.jt[3],this.Tt[0]=t.Nt[0],this.Tt[1]=t.Nt[1],this.Tt[2]=t.Nt[2],this.Tt[3]=t.Nt[3]}rt(){let t=this.zt.pop();t||(t=rt.Dt()),this.Xt(t),this.It.push(t)}nt(){const t=this.It.pop();t?(this.Zt(t),this.zt.push(t)):console.warn("pop() called without matching push()")}Vt(t){this.Xt(t)}qt(t){this.wt=Math.abs(t)}Jt(){this.bt=0,this.Ct=0,this.$t=0,this.Mt=0,this.xt=0,this.At=0,this.Lt=!1}Qt(t){t!==0&&(this.Mt+=t*Math.PI/180)}ts(t){t!==0&&(this.xt+=t*Math.PI/180)}ss(t){t!==0&&(this.At+=t*Math.PI/180)}es(t=0,i=0,r=0){t===0&&i===0&&r===0||(this.bt+=t,this.Ct+=i,this.$t+=r)}rs(t){this.es(t,0,0)}ns(t){this.es(0,t,0)}hs(t){this.es(0,0,t)}cs(t){this.Ft[0]=t[0],this.Ft[1]=t[1],this.Ft[2]=t[2]}ls(t,i,r,n=255){X(this.Ut,t,i,r,n)}us(t,i,r,n=255){X(this.Tt,t,i,r,n)}fs(t){this.St=t}ds(t){this.Et=t}ps(t){this.Rt=t}_s(t){this.kt=Tt(t)}gs(t,i,r,n){X(this.Pt,t,i,r,n)}vs(t){this.Lt=t}get ys(){return this.Pt}get ws(){return this.Lt}get bs(){return this.Mt}get Cs(){return this.xt}get $s(){return this.At}}const gt=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={Ms:16,xs:WebGL2RenderingContext.TRIANGLES,As:{Fs:{size:2,offset:0},Us:{size:2,offset:8}}};class zt{constructor(t){l(this,"m");l(this,"Ts");l(this,"Ss");this.m=t,this.Ts=t.createBuffer(),this.Ss=new Float32Array(gt.length)}Es(t,i,r,n){const h=this.m,a=Mt(this.m),c=a[2],u=a[3],d=t/c*2-1,f=(t+r)/c*2-1,p=1-(i+n)/u*2,g=1-i/u*2,m=gt,v=this.Ss;for(let y=0;y<m.length;y+=4){const w=m[y],b=m[y+1],E=m[y+2],A=m[y+3],x=d+(w+.5)*(f-d),T=p+(b+.5)*(g-p);v[y]=x,v[y+1]=T,v[y+2]=E,v[y+3]=A}h.bindBuffer(h.ARRAY_BUFFER,this.Ts),h.bufferData(h.ARRAY_BUFFER,v,h.DYNAMIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,16,0),h.drawArrays(h.TRIANGLES,0,6),h.disableVertexAttribArray(0),h.bindBuffer(h.ARRAY_BUFFER,null)}D(){this.m.deleteBuffer(this.Ts)}}var _=(o=>(o.RECTANGLE="rectangle",o.LINE="line",o.ELLIPSE="ellipse",o.ARC="arc",o.TRIANGLE="triangle",o.BEZIER_CURVE="bezier_curve",o))(_||{});const Kt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class kt{constructor(t){l(this,"m");l(this,"Rs",new Map);this.m=t}ks(t,i,r,n){const h=this.m;let a=this.Rs.get(t);a||(a=new Map,this.Rs.set(t,a));let c=a.get(i)||null;if(!c){c=h.createVertexArray(),a.set(i,c),h.bindVertexArray(c),h.bindBuffer(h.ARRAY_BUFFER,n);const u=h.getAttribLocation(t,"A0");u!==-1&&dt(h,u,r.As.Fs.size,r.Ms,r.As.Fs.offset,0,h.FLOAT,!1);const d=h.getAttribLocation(t,"A1");d!==-1&&dt(h,d,r.As.Us.size,r.Ms,r.As.Us.offset,0,h.FLOAT,!1)}h.bindVertexArray(c)}Ps(){this.m.bindVertexArray(null)}D(){for(const[,t]of this.Rs)for(const[,i]of t)i&&this.m.deleteVertexArray(i)}}const I=class I{static zs(t,i,r=0){const n=i||new Float32Array(I.Is);let h=r;n[h++]=t.Fs[0],n[h++]=t.Fs[1],n[h++]=t.Ds[0],n[h++]=t.Ds[1],n[h++]=t.Yt[0],n[h++]=t.Yt[1],n[h++]=t.Yt[2],n[h++]=t.jt[0],n[h++]=t.jt[1],n[h++]=t.jt[2],n[h++]=t.jt[3],n[h++]=t.Nt[0],n[h++]=t.Nt[1],n[h++]=t.Nt[2],n[h++]=t.Nt[3],n[h++]=t.Os[0],n[h++]=t.Os[1],n[h++]=t.Os[2],n[h++]=t.kt;const a=t.Bs;n[h++]=(a==null?void 0:a[0])??0,n[h++]=(a==null?void 0:a[1])??0,n[h++]=(a==null?void 0:a[2])??0;const c=t.Gs;n[h++]=(c==null?void 0:c[0])??0,n[h++]=(c==null?void 0:c[1])??0,n[h++]=(c==null?void 0:c[2])??0;const u=t.Ws,d=t.Hs,f=t.Ks,p=t.Ys,g=t.js,m=!(!d||!f);return m?(n[h++]=(p==null?void 0:p[0])??0,n[h++]=(p==null?void 0:p[1])??0,n[h++]=(g==null?void 0:g[0])??0,n[h++]=(g==null?void 0:g[1])??0,n[h++]=d[0],n[h++]=d[1],n[h++]=f[0],n[h++]=f[1]):!m&&!!u?(n[h++]=u[0],n[h++]=u[1],n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0):(n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0,n[h++]=0),n[h++]=t.Ns??0,n[h++]=t.Xs??0,n[h++]=t.Zs??0,n}static Vs(t,i){const r=t.length*I.Is,n=i||new Float32Array(r);for(let h=0;h<t.length;h++){const a=h*I.Is;I.zs(t[h],n,a)}return n}};l(I,"Ls",144),l(I,"Is",36);let O=I;const P=class P{};l(P,"qs",O.Ls),l(P,"Js",{Qs:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:0,divisor:1},ee:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:8,divisor:1},ie:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:16,divisor:1},re:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:28,divisor:1},ne:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:44,divisor:1},oe:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:60,divisor:1},he:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:76,divisor:1},ae:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:88,divisor:1},ce:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:100,divisor:1},le:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:116,divisor:1},ue:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,te:!1,se:P.qs,offset:132,divisor:1}});let J=P;class Wt{constructor(t=1e3,i=1.5){l(this,"fe");l(this,"de");l(this,"pe");l(this,"_e",0);l(this,"ge",0);this.de=t,this.pe=i;const r=t*O.Is;this.fe=new Float32Array(r)}ve(t){if(t<=this.de)return;const i=Math.ceil(t*this.pe),r=this.de;this.de=i;const n=i*O.Is,h=new Float32Array(n),a=r*O.Is;h.set(this.fe.subarray(0,Math.min(a,this._e))),this.fe=h}me(){return{buffer:this.fe,offset:this._e}}ye(t){this._e+=t,this.ge++}reset(){this._e=0,this.ge=0}subarray(t=0,i){return this.fe.subarray(t,i??this._e)}get we(){return this.ge}get be(){return this.de}get Ce(){return this._e}get $e(){return this.ge===0}}class qt{constructor(t){l(this,"fe");this.fe=t}Me(t){this.fe.ve(this.fe.we+1);const{buffer:i,offset:r}=this.fe.me();i[r+0]=t.x,i[r+1]=t.y,i[r+2]=t.width,i[r+3]=t.height,i[r+4]=t.xe,i[r+5]=t.Ae,i[r+6]=t.Fe,i[r+7]=t.r1,i[r+8]=t.Ue,i[r+9]=t.Te,i[r+10]=t.Se,i[r+11]=t.r2,i[r+12]=t.Ee,i[r+13]=t.Re,i[r+14]=t.ke,i[r+15]=t.Pe,i[r+16]=t.flipX,i[r+17]=t.flipY,i[r+18]=t.Le,i[r+19]=t.translationX,i[r+20]=t.translationY,i[r+21]=t.Ie,i[r+22]=t.bs,i[r+23]=t.Cs,i[r+24]=t.$s;const n=t.ze,h=t.De;return i[r+25]=n[0],i[r+26]=n[1],i[r+27]=n[2],i[r+28]=n[3],i[r+29]=h[0],i[r+30]=h[1],i[r+31]=h[2],i[r+32]=h[3],i[r+33]=t.Z,i[r+34]=t.Oe,i[r+35]=t.Be,this.fe.ye(O.Is),this.fe.we-1}get we(){return this.fe.we}}class $t{constructor(t,i=1e3){l(this,"m");l(this,"Ge",null);l(this,"We",0);l(this,"He",new Map);this.m=t,this.Ke(i)}Ke(t){const i=this.m;this.Ge&&i.deleteBuffer(this.Ge),this.Ge=i.createBuffer();const r=t*O.Ls;Ft(i,i.ARRAY_BUFFER,this.Ge,r,i.DYNAMIC_DRAW),this.We=t}Ye(t){this.Ke(t)}get be(){return this.We}upload(t,i){if(i===0)return;const r=this.m;r.bindBuffer(r.ARRAY_BUFFER,this.Ge);const n=i*O.Is;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,n)}je(t){let i=this.He.get(t);if(!i){i=new Map;const r=this.m;for(const n in J.Js){const h=r.getAttribLocation(t,n);h!==-1&&i.set(n,h)}this.He.set(t,i)}return i}Ne(t){const i=this.m,r=t.I,n=this.je(r);for(const[h,a]of n){const c=J.Js[h];c&&dt(i,a,c.size,c.se,c.offset,c.divisor,c.type,c.te)}}Xe(t){const i=this.m,r=this.je(t.I);for(const[n,h]of r)J.Js[n]&&(i.disableVertexAttribArray(h),i.vertexAttribDivisor(h,0))}dispose(){this.Ge&&(this.m.deleteBuffer(this.Ge),this.Ge=null),this.He.clear()}}class Vt{constructor(t,i=1e3,r=1.5){l(this,"m");l(this,"fe");l(this,"Ze");l(this,"Ve");this.m=t,this.fe=new Wt(i,r),this.Ze=new qt(this.fe),this.Ve=new $t(t,i)}qe(t){var n,h,a,c,u,d,f,p,g,m;const i=[0,0,0,0],r=[0,0,0,0];return t.Hs&&t.Ks?(i[0]=((n=t.Ys)==null?void 0:n[0])??0,i[1]=((h=t.Ys)==null?void 0:h[1])??0,i[2]=((a=t.js)==null?void 0:a[0])??0,i[3]=((c=t.js)==null?void 0:c[1])??0,r[0]=t.Hs[0],r[1]=t.Hs[1],r[2]=t.Ks[0],r[3]=t.Ks[1]):t.Ws&&(i[0]=t.Ws[0],i[1]=t.Ws[1]),this.Je({x:t.Fs[0],y:t.Fs[1],width:t.Ds[0],height:t.Ds[1],xe:t.Yt[0],Ae:t.Yt[1],Fe:t.Yt[2],r1:t.jt[0],Ue:t.jt[1],Te:t.jt[2],Se:t.jt[3],r2:t.Nt[0],Ee:t.Nt[1],Re:t.Nt[2],ke:t.Nt[3],Pe:t.Os[0],flipX:t.Os[1],flipY:t.Os[2],Le:t.kt,translationX:((u=t.Bs)==null?void 0:u[0])??0,translationY:((d=t.Bs)==null?void 0:d[1])??0,Ie:((f=t.Bs)==null?void 0:f[2])??0,bs:((p=t.Gs)==null?void 0:p[0])??0,Cs:((g=t.Gs)==null?void 0:g[1])??0,$s:((m=t.Gs)==null?void 0:m[2])??0,ze:i,De:r,Z:t.Ns||0,Oe:t.Xs||0,Be:t.Zs||0})}Je(t){const i=this.Ze.Me(t);return this.fe.be>this.Ve.be&&this.Ve.Ye(this.fe.be),i}get count(){return this.fe.we}get $e(){return this.fe.$e}clear(){this.fe.reset()}Qe(t){const i=this.fe.we;if(i===0)return;const r=this.fe.subarray();this.Ve.upload(r,i),this.Ve.Ne(t)}ti(t){this.Ve.Xe(t)}Es(t,i){const r=this.fe.we;r!==0&&this.m.drawArraysInstanced(t,0,i,r)}D(){this.Ve.dispose()}}class H{constructor(t,i,r,n){l(this,"m");l(this,"si");l(this,"ei");l(this,"ii");l(this,"ri",null);this.m=t,this.si=i,this.ei=r,this.ii=n;const h=this.m.createBuffer();Ft(this.m,this.m.ARRAY_BUFFER,h,this.ii.ni,this.m.STATIC_DRAW),this.ri=h}get type(){return this.ei}get oi(){return this.ii}get hi(){return this.ri}get ai(){return this.si}ci(){this.si.clear()}li(){return!this.si.$e}D(){this.si.D(),this.m.deleteBuffer(this.ri)}ui(t,i,r){return this.si.qe(t)}fi(t,i,r,n,h,a){const c=h.Bt??0,u=h.Gt??0,d=h.Wt??0,f=h.Mt??0,p=h.xt??0,g=h.At??0,m=[0,0,0,0],v=[0,0,0,0];a&&(a.di!==void 0&&a.pi!==void 0&&a._i!==void 0&&a.gi!==void 0?(m[0]=a.mi??0,m[1]=a.yi??0,m[2]=a.wi??0,m[3]=a.bi??0,v[0]=a.di??0,v[1]=a.pi??0,v[2]=a._i??0,v[3]=a.gi??0):a.Ci===void 0&&a.$i===void 0||(m[0]=a.Ci??0,m[1]=a.$i??0));const y={x:t,y:i,width:r,height:n,xe:h.Yt[0],Ae:h.Yt[1],Fe:h.Yt[2],r1:h.jt[0],Ue:h.jt[1],Te:h.jt[2],Se:h.jt[3],r2:h.Nt[0],Ee:h.Nt[1],Re:h.Nt[2],ke:h.Nt[3],Pe:h.Rt?1:0,flipX:h.Ht?1:0,flipY:h.Kt?1:0,Le:h.kt,translationX:c,translationY:u,Ie:d,bs:f,Cs:p,$s:g,ze:m,De:v,Z:(a==null?void 0:a.Z)??0,Oe:(a==null?void 0:a.Oe)??0,Be:Kt[this.ei]??0};return this.si.Je(y)}}const Zt={ni:gt,Mi:6,...j},Jt={ni:new Float32Array([0,-.5,0,0,1,-.5,1,0,0,.5,0,1,0,.5,0,1,1,-.5,1,0,1,.5,1,1]),Mi:6,...j},Qt={ni:function(o=32){const t=[],i=2*Math.PI/o;for(let r=0;r<o;r++){const n=r*i,h=(r+1)%o*i,a=Math.cos(n),c=Math.sin(n),u=.5*(a+1),d=.5*(c+1),f=Math.cos(h),p=Math.sin(h),g=.5*(f+1),m=.5*(p+1);t.push(0,0,.5,.5,a,c,u,d,f,p,g,m)}return new Float32Array(t)}(32),Mi:96,...j};let ti={ni:function(o){const t=[];for(let i=0;i<o;i++){const r=i/o,n=(i+1)/o;t.push(r,0,r,0,r,1,r,1,n,1,n,1)}return new Float32Array(t)}(32),Mi:96,...j};const ii={ni:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Mi:3,...j},ei={ni:function(o=16){const t=[];for(let i=0;i<o;i++){const r=i/o,n=(i+1)/o;t.push(r,-.5,r,0,n,-.5,n,0,r,.5,r,1,r,.5,r,1,n,-.5,n,0,n,.5,n,1)}return new Float32Array(t)}(16),Mi:96,...j},si={[_.RECTANGLE]:class extends H{constructor(o,t){super(o,t,_.RECTANGLE,Zt)}qe(o,t){return this.fi(0,0,o.width,o.height,t)}},[_.LINE]:class extends H{constructor(o,t){super(o,t,_.LINE,Jt)}qe(o,t){const i=o.x2-o.x1,r=o.y2-o.y1,n=Math.hypot(i,r),h=t.Ot||1,a=o.x1+i/2-n/2,c=o.y1+r/2;return this.fi(a,c,n,h,t)}},[_.ELLIPSE]:class extends H{constructor(o,t){super(o,t,_.ELLIPSE,Qt)}qe(o,t){return this.fi(0,0,o.width,o.height,t)}},[_.ARC]:class extends H{constructor(o,t){super(o,t,_.ARC,ti)}qe(o,t){const i=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.fi(0,0,o.width,o.height,t,{Ci:i,$i:r})}},[_.TRIANGLE]:class extends H{constructor(o,t){super(o,t,_.TRIANGLE,ii)}qe(o,t){const i=Math.min(o.x1,o.x2,o.xi),r=Math.max(o.x1,o.x2,o.xi),n=Math.min(o.y1,o.y2,o.Ai),h=r-i,a=Math.max(o.y1,o.y2,o.Ai)-n;return this.fi(i,n,h,a,t)}},[_.BEZIER_CURVE]:class extends H{constructor(o,t){super(o,t,_.BEZIER_CURVE,ei)}qe(o,t){return this.fi(0,0,1,t.Ot||1,t,{mi:o.mi,yi:o.yi,wi:o.wi,bi:o.bi,di:o.x1,pi:o.y1,_i:o.x2,gi:o.y2})}}};class ri{constructor(t){l(this,"m");l(this,"Fi");l(this,"Ui");this.m=t,this.Ui=new kt(t),this.Fi=new Map;for(const i of Object.values(_)){const r=new Vt(t),n=new si[i](t,r);this.Fi.set(i,n)}}Ti(t){const i=this.Si(t);for(const r of i)this.Ei(r)}Si(t){const i=[];let r=null,n=null,h=null;for(const a of t)n!==a.Ri||h!==a.type?(r&&r.length>0&&i.push({Ri:n,type:h,commands:r}),r=[a],n=a.Ri,h=a.type):r.push(a);return r&&r.length>0&&i.push({Ri:n,type:h,commands:r}),i}Ei(t){const{Ri:i,type:r,commands:n}=t,h=this.Fi.get(r);i.ki.S(),i.ki.k(i.Pi);const a=Mt(this.m),c=n.length>0&&n[0].state.Lt;i.ki.k({Li:a[2]/a[3],Ii:[a[2],a[3]],zi:1,Di:c?1:0}),h.ci();for(const u of n)h.qe(u.Oi,u.state);if(h.li()){const u=h.oi,d=h.hi;try{this.Ui.ks(i.ki.I,String(r),u,d),h.ai.Qe(i.ki),h.ai.Es(u.xs,u.Mi)}finally{h.ai.ti(i.ki),this.Ui.Ps(),h.ci()}}}D(){for(const t of this.Fi.values())t.D();this.Fi.clear(),this.Ui.D()}}function _t(o){let t=0;for(let i=0;i<o.length;i++)t=(t<<5)-t+o.charCodeAt(i),t&=t;return t}function Ut(o){return _t(String(o))}function Q(o,t){return(o<<5)-o+t}class hi{constructor(t){l(this,"m");l(this,"Bi",0);l(this,"Gi");l(this,"Wi");l(this,"Hi",new Map);this.m=t,this.Gi=new $(t,st,`#version 300 es
|
|
10
|
-
precision highp float;in vec3 v_glyphIndex;in vec4 v_glyphColor;in vec4 v_cellColor;in vec4 v_glyphFlags;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;void main(){int A=int(v_glyphFlags.r>0.5?1:0);int B=int(v_glyphFlags.g>0.5?1:0);int C=int(v_glyphFlags.b>0.5?1:0);float D=float(A|(B<<1)|(C<<2))/255.;o_character=vec4(v_glyphIndex.xy,D,clamp(v_glyphFlags.a,0.,1.));o_primaryColor=vec4(v_glyphColor.rgb,v_glyphColor.a);o_secondaryColor=vec4(v_cellColor.rgb,v_cellColor.a);}`),this.Wi={id:this.Bi++,ki:this.Gi,Pi:Object.freeze({}),hash:this.Ki(this.Gi,{}),Yi:!0}}get ji(){return this.Wi}gt(t,i={},r=!1){const n=this.Ki(t,i),h=this.Hi.get(n);if(h)return h;const a={id:this.Bi++,ki:t,Pi:Object.freeze({...i}),hash:n,Yi:r};return this.Hi.set(n,a),a}Ni(t,i={}){return{id:this.Bi++,ki:t,Pi:Object.freeze({...i}),hash:0,Yi:!1}}Ki(t,i){const r=Ut(t.I),n=function(h,a){let c=0;const u=Object.keys(h).sort();for(const d of u)c=Q(c,_t(d)),c=Q(c,a(h[d]));return c}(i,this.Xi.bind(this));return Q(r,n)}Xi(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 n=Array.isArray(i[0])?i.flat():i;for(const h of n)r=Q(r,typeof h=="number"?h:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(i){let r=0;const n=Math.min(i.length,16);for(let h=0;h<n;h++)r=Q(r,i[h]);return r}(t):t instanceof WebGLTexture?Ut(t):0}D(){this.Gi!=this.Gi&&this.Gi.D(),this.Gi.D(),this.Hi.clear()}}class ni{constructor(){l(this,"Zi",[]);l(this,"Vi",1);l(this,"Ds",0)}qi(t,i){if(this.Ds>=this.Zi.length){const n={id:this.Vi++,type:t,Oi:{},state:rt.Dt(),Ri:i};this.Zi.push(n)}const r=this.Zi[this.Ds];return r.id=this.Vi++,r.type=t,r.Ri=i,this.Ds++,r}Ji(t,i,r){const n=this.qi(_.RECTANGLE,r),h=n.Oi;return h.width=t.width,h.height=t.height,i.Vt(n.state),n.id}Qi(t,i,r){const n=this.qi(_.LINE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.tr=t.tr,i.Vt(n.state),n.id}sr(t,i,r){const n=this.qi(_.ELLIPSE,r),h=n.Oi;return h.width=t.width,h.height=t.height,h.er=t.er,h.ir=t.ir,h.rr=t.rr,i.Vt(n.state),n.id}nr(t,i,r){const n=this.qi(_.ARC,r),h=n.Oi;return h.width=t.width,h.height=t.height,h.start=t.start,h.stop=t.stop,i.Vt(n.state),n.id}hr(t,i,r){const n=this.qi(_.TRIANGLE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.x2=t.x2,h.y2=t.y2,h.xi=t.xi,h.Ai=t.Ai,i.Vt(n.state),n.id}ar(t,i,r){const n=this.qi(_.BEZIER_CURVE,r),h=n.Oi;return h.x1=t.x1,h.y1=t.y1,h.mi=t.mi,h.yi=t.yi,h.wi=t.wi,h.bi=t.bi,h.x2=t.x2,h.y2=t.y2,h.tr=t.tr,h.rr=t.rr,i.Vt(n.state),n.id}cr(){this.Ds=0}[Symbol.iterator](){let t=0;const i=this.Ds,r=this.Zi;return{next:()=>t<i?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class oi{constructor(t){l(this,"m");l(this,"lr",null);l(this,"ur");l(this,"vt");l(this,"dr");l(this,"pr");l(this,"_r");l(this,"gr",null);l(this,"vr",{});l(this,"mr",[]);l(this,"yr",[]);l(this,"wr",null);l(this,"br",[0,0,0,0]);this.m=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.dr=new rt,this.vt=new hi(t),this.pr=new ni,this.ur=new ri(t),this._r=new zt(t);const i=[0,0,t.canvas.width,t.canvas.height];pt(t,i),this.mr.push(null),this.yr.push(i),this.wr=null,this.br=i}et(){this.mr.push(this.wr),this.yr.push([...this.br])}ht(){return{framebuffer:this.mr.pop()??null,viewport:this.yr.pop()??[0,0,this.m.canvas.width,this.m.canvas.height]}}it(t,i,r){const n=this.m;this.wr!==t&&(n.bindFramebuffer(n.FRAMEBUFFER,t),this.wr=t);const h=[0,0,i,r];this.br[0]===h[0]&&this.br[1]===h[1]&&this.br[2]===h[2]&&this.br[3]===h[3]||(n.viewport(...h),pt(n,h),this.br=h)}Cr(t){this.lr!==t&&(this.lr=t,t.S())}$r(t,i){return new $(this.m,t,i)}Mr(t){this.gr=t,t&&(this.vr={})}P(t,i){this.vr[t]=i}Ar(t){Object.assign(this.vr,t)}Fr(t){return new $(this.m,st,t)}Ur(t,i,r){this.pr.Ji({width:i??t.width,height:r??t.height},this.dr,t.ct())}Tr(t,i,r,n){this._r.Es(t,i,r,n)}Sr(t,i){if(this.gr){const r=this.vt.Ni(this.gr,this.vr);this.pr.Ji({width:t,height:i},this.dr,r),this.gr=null,this.vr={}}else this.pr.Ji({width:t,height:i},this.dr,this.vt.ji)}Er(t,i,r,n){this.pr.Qi({x1:t,y1:i,x2:r,y2:n},this.dr,this.vt.ji)}Rr(t,i){this.pr.sr({width:t,height:i},this.dr,this.vt.ji)}kr(t,i,r,n,h,a){this.pr.hr({x1:t,y1:i,x2:r,y2:n,xi:h,Ai:a},this.dr,this.vt.ji)}Pr(t,i,r,n,h,a,c,u){this.pr.ar({x1:t,y1:i,mi:r,yi:n,wi:h,bi:a,x2:c,y2:u},this.dr,this.vt.ji)}Lr(t,i,r,n){this.pr.nr({width:t,height:i,start:r,stop:n},this.dr,this.vt.ji)}Ir(t,i,r=1,n={}){return new Z(this.m,t,i,r,n,this)}zr(t,i=t,r=t,n=255){this.dr.gs(t,i??t,r??t,n);const[h,a,c,u]=this.dr.ys;this.cr(h,a,c,u)}cr(t=0,i=0,r=0,n=0){this.m.clearColor(t,i,r,n),this.m.clear(this.m.COLOR_BUFFER_BIT)}Dr(){this.m.viewport(0,0,this.m.canvas.width,this.m.canvas.height),pt(this.m,[0,0,this.m.canvas.width,this.m.canvas.height])}ot(){const t=this.pr;this.ur.Ti(t),t.cr()}D(){this.vt.D(),this.ur.D(),this._r.D()}get context(){return this.m}get state(){return this.dr}}const U={Or:(o,t)=>(U.Br.uint16[0]=o[t]<<8|o[t+1],U.Br.int16[0]),Gr:(o,t)=>o[t]<<8|o[t+1],Wr(o,t,i){const r=[];for(let n=0;n<i;n++)r.push(U.Gr(o,t+2*n));return r},Hr(o,t){const i=U.Br.uint8;return i[3]=o[t],i[2]=o[t+1],i[1]=o[t+2],i[0]=o[t+3],U.Br.uint32[0]},Kr(o,t,i){let r="";for(let n=0;n<i;n++)r+=String.fromCharCode(o[t+n]);return r},Br:(()=>{const o=new ArrayBuffer(8);return{uint8:new Uint8Array(o),int16:new Int16Array(o),uint16:new Uint16Array(o),uint32:new Uint32Array(o)}})()};function ht(o){return o+3&-4}function nt(o,t,i){o[t]=i>>>8&255,o[t+1]=255&i}function N(o,t,i){o[t]=i>>>24&255,o[t+1]=i>>>16&255,o[t+2]=i>>>8&255,o[t+3]=255&i}function ai(o,t,i){for(let r=0;r<i.length;r++)o[t+r]=255&i.charCodeAt(r)}function mt(o,t,i){const r=t+i;let n=0;const h=U.Br;for(let a=t;a<r;a+=4)h.uint8[3]=o[a]||0,h.uint8[2]=o[a+1]||0,h.uint8[1]=o[a+2]||0,h.uint8[0]=o[a+3]||0,n=n+(h.uint32[0]>>>0)>>>0;return n>>>0}class ci{constructor(t){l(this,"b");l(this,"Yr",0);l(this,"jr",0);l(this,"Nr",0);this.b=t}Xr(t){for(;this.Nr<t;){const r=this.b[this.Yr++]||0;this.jr|=r<<this.Nr,this.Nr+=8}const i=this.jr&(1<<t)-1;return this.jr>>>=t,this.Nr-=t,i}Zr(){this.jr=0,this.Nr=0}get offset(){return this.Yr}}function tt(o){let t=32,i=0;for(const c of o)c&&(c<t&&(t=c),c>i&&(i=c));if(i===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(i+1);for(const c of o)c&&r[c]++;const n=new Uint32Array(i+1);let h=0;r[0]=0;for(let c=1;c<=i;c++)h=h+r[c-1]<<1,n[c]=h;const a=new Map;for(let c=0;c<o.length;c++){const u=o[c];if(!u)continue;const d=n[u]++;let f=a.get(u);f||(f=[],a.set(u,f)),f[li(d,u)]=c}return{min:t,max:i,table:a}}function vt(o,t){let i=0;for(let r=1;r<=t.max;r++){i|=o.Xr(1)<<r-1;const n=t.table.get(r);if(n&&i<n.length){const h=n[i];if(h!==void 0)return h}}throw new Error("Invalid Huffman code")}function li(o,t){let i=0;for(let r=0;r<t;r++)i=i<<1|1&o,o>>>=1;return i>>>0}function ui(o){if(o.length<2)throw new Error("ZLIB data too short");const t=o[0],i=o[1];if((15&t)!=8)throw new Error("Unsupported ZLIB compression method");if(((t<<8)+i)%31!=0)throw new Error("Bad ZLIB header check");let r=2;32&i&&(r+=4);const n=[];return function(h,a){const c=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],f=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];let p=0;for(;!p;){p=h.Xr(1);const g=h.Xr(2);if(g===0){h.Zr();const m=h.Xr(16);if((65535&(65535^m))!==h.Xr(16))throw new Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let v=0;v<m;v++)a.push(h.Xr(8))}else{if(g!==1&&g!==2)throw new Error("Unsupported DEFLATE type");{let m,v;if(g===1){const y=new Array(288).fill(0);for(let w=0;w<=143;w++)y[w]=8;for(let w=144;w<=255;w++)y[w]=9;for(let w=256;w<=279;w++)y[w]=7;for(let w=280;w<=287;w++)y[w]=8;m=tt(y),v=tt(new Array(32).fill(5))}else{const y=h.Xr(5)+257,w=h.Xr(5)+1,b=h.Xr(4)+4,E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=new Array(19).fill(0);for(let L=0;L<b;L++)A[E[L]]=h.Xr(3);const x=tt(A),T=[];for(;T.length<y+w;){const L=vt(h,x);if(L<=15)T.push(L);else if(L===16){const B=h.Xr(2)+3,D=T[T.length-1]||0;for(let ut=0;ut<B;ut++)T.push(D)}else if(L===17){const B=h.Xr(3)+3;for(let D=0;D<B;D++)T.push(0)}else{if(L!==18)throw new Error("Invalid code length symbol");{const B=h.Xr(7)+11;for(let D=0;D<B;D++)T.push(0)}}}const R=T.slice(0,y),Y=T.slice(y,y+w);m=tt(R),v=tt(Y)}for(;;){const y=vt(h,m);if(y<256)a.push(y);else{if(y===256)break;if(y>256&&y<286){const w=y-257;let b=c[w];const E=u[w];E&&(b+=h.Xr(E));const A=vt(h,v);if(A>=30)throw new Error("Invalid distance symbol");let x=d[A];const T=f[A];T&&(x+=h.Xr(T));const R=a.length-x;if(R<0)throw new Error("Invalid distance");for(let Y=0;Y<b;Y++)a.push(a[R+Y]||0)}else if(y===286||y===287)throw new Error("Reserved length symbol")}}}}}}(new ci(o.subarray(r)),n),new Uint8Array(n)}function fi(o){const t=U,i=new Uint8Array(o);if(t.Kr(i,0,4)!=="wOFF")throw new Error("Invalid WOFF signature");const r=t.Hr(i,4),n=t.Gr(i,12),h=t.Hr(i,16),a=[];let c=44;for(let E=0;E<n;E++){const A=t.Kr(i,c,4),x=t.Hr(i,c+4),T=t.Hr(i,c+8),R=t.Hr(i,c+12),Y=t.Hr(i,c+16);a.push({tag:A,offset:x,Vr:T,qr:R,Jr:Y}),c+=20}for(const E of a){const A=new Uint8Array(i.buffer,E.offset,E.Vr);if(E.Vr===E.qr)E.data=new Uint8Array(A);else if(E.data=ui(A),E.data.length!==E.qr)if(E.data.length<E.qr){const x=new Uint8Array(E.qr);x.set(E.data),E.data=x}else E.data=E.data.subarray(0,E.qr)}const u=n;let d=1,f=0;for(;d<<1<=u;)d<<=1,f++;const p=16*d,g=16*u-p;let m=12+16*u;const v={};for(const E of a)v[E.tag]=m,m=ht(m+E.data.length);const y=Math.max(h||0,m),w=new Uint8Array(y);N(w,0,r),nt(w,4,u),nt(w,6,p),nt(w,8,f),nt(w,10,g);let b=12;for(const E of a){ai(w,b,E.tag),b+=4;let A=E.data;if(E.tag==="head"&&A.length>=12){const x=new Uint8Array(A);N(x,8,0),N(w,b,mt(x,0,ht(x.length))),b+=4}else N(w,b,mt(A,0,ht(A.length))),b+=4;N(w,b,v[E.tag]),b+=4,N(w,b,E.data.length),b+=4}for(const E of a){const A=v[E.tag];w.set(E.data,A)}if(a.find(E=>E.tag==="head")){const E=v.head,A=function(x,T){const R=T+8,Y=[x[R],x[R+1],x[R+2],x[R+3]];N(x,R,0);const L=2981146554-(mt(x,0,ht(x.length))>>>0)>>>0;return x[R]=Y[0],x[R+1]=Y[1],x[R+2]=Y[2],x[R+3]=Y[3],L>>>0}(w,E);N(w,E+8,A)}return w.buffer}const di={Qr(o,t,i){const r={tn:[],sn:{},off:t};o=new Uint8Array(o.buffer,t,i),t=0;const n=U,h=n.Gr,a=h(o,t+=2);t+=2;const c=[];for(let u=0;u<a;u++){const d=h(o,t),f=h(o,t+=2);t+=2;const p=n.Hr(o,t);t+=4;const g=`p${d}e${f}`;let m=c.indexOf(p);if(m===-1){let v;m=r.tn.length,c.push(p);const y=h(o,p);v=y===4?this.en(o,p):y===12?this.rn(o,p):{format:y},r.tn.push(v)}r.sn[g]=m}return r},en(o,t){const i=U,r=i.Gr,n=i.Wr,h=t,a=r(o,t+=2);t+=2;const c=r(o,t+=2)>>>1,u={format:4,nn:r(o,t+=2),hn:0,an:0,cn:[],ln:[],un:[],fn:[],dn:[]};t+=2,u.hn=r(o,t),t+=2,u.an=r(o,t),t+=2,u.cn=n(o,t,c),t+=2*c,t+=2,u.ln=n(o,t,c),t+=2*c;for(let d=0;d<c;d++)u.un.push(i.Or(o,t)),t+=2;return u.fn=n(o,t,c),t+=2*c,u.dn=n(o,t,h+a-t>>1),u},rn(o,t){const i=U.Hr;i(o,t+=4),i(o,t+=4);const r=i(o,t+=4);t+=4;const n=new Uint32Array(3*r);for(let h=0;h<3*r;h+=3)n[h]=i(o,t+(h<<2)),n[h+1]=i(o,t+(h<<2)+4),n[h+2]=i(o,t+(h<<2)+8);return{format:12,groups:n}}},pi={Qr(o,t,i){const r=U;t+=18;const n=r.Gr(o,t);t+=2,t+=16;const h=r.Or(o,t);t+=2;const a=r.Or(o,t);t+=2;const c=r.Or(o,t);t+=2;const u=r.Or(o,t);return t+=2,t+=6,{pn:n,_n:h,gn:a,vn:c,mn:u,yn:r.Or(o,t)}}},gi={Qr(o,t,i){const r=U;t+=4;const n=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],h={};for(let a=0;a<n.length;a++){const c=n[a],u=c==="advanceWidthMax"||c==="numberOfHMetrics"?r.Gr:r.Or;h[c]=u(o,t+2*a)}return h}},mi={Qr(o,t,i,r){const n=U,h=[],a=[],c=r.bn.wn,u=r.$n.Cn;let d=0,f=0,p=0;for(;p<u;)d=n.Gr(o,t+(p<<2)),f=n.Or(o,t+(p<<2)+2),h.push(d),a.push(f),p++;for(;p<c;)h.push(d),a.push(f),p++;return{Mn:h,xn:a}}},Yt={An:di,head:pi,$n:gi,bn:{Qr(o,t,i){const r=U;return r.Hr(o,t),t+=4,{wn:r.Gr(o,t)}}},Fn:mi,Un:{Qr(o,t,i,r){const n=U,h=[],a=r.head.yn,c=r.bn.wn+1;if(a===0)for(let u=0;u<c;u++)h.push(n.Gr(o,t+(u<<1))<<1);else if(a===1)for(let u=0;u<c;u++)h.push(n.Hr(o,t+(u<<2)));return h}},Tn:{Qr(o,t,i,r){const n=[],h=r.bn.wn;for(let a=0;a<h;a++)n.push(null);return n},Sn(o,t){const i=U,r=o.En,n=o.Un;if(n[t]===n[t+1])return null;const h=z.Rn(r,"glyf",o.kn);if(!h)return null;let a=h[0]+n[t];const c={};if(c.Pn=i.Or(r,a),a+=2,c._n=i.Or(r,a),a+=2,c.gn=i.Or(r,a),a+=2,c.vn=i.Or(r,a),a+=2,c.mn=i.Or(r,a),a+=2,c._n>=c.vn||c.gn>=c.mn)return null;if(c.Pn>0){c.Ln=[];for(let g=0;g<c.Pn;g++)c.Ln.push(i.Gr(r,a)),a+=2;const u=i.Gr(r,a);if(a+=2,r.length-a<u)return null;a+=u;const d=c.Ln[c.Pn-1]+1;c.flags=[];for(let g=0;g<d;g++){const m=r[a];if(a++,c.flags.push(m),8&m){const v=r[a];a++;for(let y=0;y<v;y++)c.flags.push(m),g++}}c.In=[];for(let g=0;g<d;g++){const m=c.flags[g],v=!!(16&m);2&m?(c.In.push(v?r[a]:-r[a]),a++):v?c.In.push(0):(c.In.push(i.Or(r,a)),a+=2)}c.zn=[];for(let g=0;g<d;g++){const m=c.flags[g],v=!!(32&m);4&m?(c.zn.push(v?r[a]:-r[a]),a++):v?c.zn.push(0):(c.zn.push(i.Or(r,a)),a+=2)}let f=0,p=0;for(let g=0;g<d;g++)f+=c.In[g],p+=c.zn[g],c.In[g]=f,c.zn[g]=p}else c.Dn=[],c.Ln=[],c.flags=[],c.In=[],c.zn=[];return c}}},z={parse(o){const t=new Uint8Array(o);U.Kr(t,0,4)==="wOFF"&&(o=fi(o));const i=new Uint8Array(o),r=Yt,n={},h={En:i,On:0,kn:0};for(const a in r){const c=a,u=z.Rn(i,c,0);if(u){const[d,f]=u;let p=n[d];p==null&&(p=r[c].Qr(i,d,f,h),n[d]=p),h[c]=p}}return[h]},Rn(o,t,i){const r=U,n=r.Gr(o,i+4);let h=i+12;for(let a=0;a<n;a++){const c=r.Kr(o,h,4);r.Hr(o,h+4);const u=r.Hr(o,h+8),d=r.Hr(o,h+12);if(c===t)return[u,d];h+=16}return null},Bn:Yt,Gn:U};class vi{Wn(t){var r;const i=[];return(r=t.An)!=null&&r.tn?(t.An.tn.forEach(n=>{if(n.format===4){const h=this.Hn(n);i.push(...h)}else if(n.format===12){const h=this.Kn(n);i.push(...h)}}),[...new Set(i)]):[]}Hn(t){const i=[];if(!(t.ln&&t.cn&&t.fn&&t.un))return i;for(let r=0;r<t.ln.length;r++){const n=t.ln[r],h=t.cn[r];if(n!==65535||h!==65535){for(let a=n;a<=h;a++)if(this.Yn(t,a,r)>0)try{const c=String.fromCodePoint(a);i.push(c)}catch{}}}return i}Kn(t){const i=[];if(!t.groups)return i;for(let r=0;r<t.groups.length;r+=3){const n=t.groups[r],h=t.groups[r+1],a=t.groups[r+2];for(let c=n;c<=h;c++)if(a+(c-n)>0)try{const u=String.fromCodePoint(c);i.push(u)}catch{}}return i}Yn(t,i,r){if(t.fn[r]===0)return i+t.un[r]&65535;{const n=t.fn[r]/2+(i-t.ln[r])-(t.ln.length-r);if(n>=0&&t.dn&&n<t.dn.length){const h=t.dn[n];if(h!==0)return h+t.un[r]&65535}}return 0}}class wt{constructor(){l(this,"jn",new Map);l(this,"Nn",new Map)}Xn(t,i){const r=`${this.Zn(t)}_${i}`;if(this.jn.has(r))return this.jn.get(r);const n=t.An;if(!n||!n.tn)return this.jn.set(r,0),0;let h=0;for(const a of n.tn)if(a.format===4?h=this.Vn(i,a):a.format===12&&(h=this.qn(i,a)),h>0)break;return this.jn.set(r,h),h}Jn(t,i){const r=i.codePointAt(0);return r===void 0?0:this.Xn(t,r)}Qn(t,i){const r=t.Fn;return r&&r.Mn&&r.Mn.length!==0?i<r.Mn.length?r.Mn[i]:r.Mn[r.Mn.length-1]:0}so(t,i){const r=i/t.head.pn,n=t.$n.eo*r,h=t.$n.io*r,a=t.$n.ro*r;return{eo:n,io:h,ro:a,lineHeight:n-h+a,pn:t.head.pn,scale:r}}no(){this.jn.clear(),this.Nn.clear()}Zn(t){return`${t.kn}_${t.En.length}`}Vn(t,i){const r=i.cn.length;let n=-1;for(let h=0;h<r;h++)if(t<=i.cn[h]){n=h;break}if(n===-1||t<i.ln[n])return 0;if(i.fn[n]===0)return t+i.un[n]&65535;{const h=i.fn[n]/2+(t-i.ln[n])-(r-n);if(h>=0&&h<i.dn.length){const a=i.dn[h];return a===0?0:a+i.un[n]&65535}}return 0}qn(t,i){const r=i.groups.length/3;for(let n=0;n<r;n++){const h=i.groups[3*n],a=i.groups[3*n+1],c=i.groups[3*n+2];if(t>=h&&t<=a)return c+(t-h)}return 0}}class wi{constructor(t){l(this,"oo");l(this,"ho");l(this,"Y");l(this,"ao");this.Y=t,this.ao=new wt,this.oo=document.createElement("canvas"),this.ho=this.oo.getContext("2d",{co:!0,alpha:!0})}lo(t,i,r,n){const h=t.length,a=Math.ceil(Math.sqrt(h)),c=Math.ceil(h/a),u=i.width*a,d=i.height*c;this.uo(u,d),this.fo(t,i,a,r,n);const f=this.Y.Ir(u,d,1,{filter:"nearest"});return f.tt(this.oo),{framebuffer:f,columns:a,rows:c}}uo(t,i){this.oo.width=t,this.oo.height=i,this.oo.style.width=t+"px",this.oo.style.height=i+"px",this.ho.imageSmoothingEnabled=!1,this.oo.style.imageRendering="pixelated",this.ho.clearRect(0,0,t,i),this.ho.textBaseline="top",this.ho.textAlign="left",this.ho.fillStyle="white"}fo(t,i,r,n,h){const a=n/h.head.pn;for(let c=0;c<t.length;c++){const u=c%r,d=Math.floor(c/r),f=t[c].do,p=this.po(h,f);if(!p)continue;const g=f.codePointAt(0)||0,m=this.ao.Xn(h,g),v=this.ao.Qn(h,m)*a,y=u*i.width,w=d*i.height,b=y+.5*i.width,E=w+.5*i.height,A=Math.round(b-.5*i.width),x=Math.round(E-.5*n),T=A+.5*(i.width-v),R=x+h.$n.eo*a;this._o(p,T,R,a)}}po(t,i){const r=i.codePointAt(0)||0,n=this.ao.Xn(t,r);return n===0?null:z.Bn.Tn.Sn(t,n)}_o(t,i,r,n){if(!t||!t.In||t.Pn===0)return;let{In:h,zn:a,Ln:c,flags:u}=t;if(!(h&&a&&c&&u))return;this.ho.beginPath();let d=0;for(let f=0;f<c.length;f++){const p=c[f];if(!(p<d)){if(p>=d){const g=i+h[d]*n,m=r-a[d]*n;this.ho.moveTo(g,m);let v=d+1;for(;v<=p;)if(1&u[v]){const y=i+h[v]*n,w=r-a[v]*n;this.ho.lineTo(y,w),v++}else{const y=i+h[v]*n,w=r-a[v]*n;if(v+1>p){const E=i+h[d]*n,A=r-a[d]*n;if(1&u[d])this.ho.quadraticCurveTo(y,w,E,A);else{const x=(y+E)/2,T=(w+A)/2;this.ho.quadraticCurveTo(y,w,x,T)}break}const b=v+1;if(1&u[b]){const E=i+h[b]*n,A=r-a[b]*n;this.ho.quadraticCurveTo(y,w,E,A),v=b+1}else{const E=(y+(i+h[b]*n))/2,A=(w+(r-a[b]*n))/2;this.ho.quadraticCurveTo(y,w,E,A),v=b}}this.ho.closePath()}d=p+1}}this.ho.fill()}}class yi{constructor(){l(this,"vo");this.vo=new wt}mo(t,i,r){let n=0;const h=this.vo.so(r,i),a=h.lineHeight;for(const c of t){const u=this.vo.Jn(r,c);if(u===0)continue;const d=this.vo.Qn(r,u)*h.scale;n=Math.max(n,d)}return{width:Math.ceil(n),height:Math.ceil(a)}}no(){this.vo.no()}}class Ei{constructor(){l(this,"ao");this.ao=new wt}yo(t,i){return t.map((r,n)=>{const h=r.codePointAt(0)||0,a=this.wo(n);let c=0;if(i.Fn&&i.Fn.Mn){const u=this.ao.Xn(i,h);u>0&&i.Fn.Mn[u]!==void 0&&(c=i.Fn.Mn[u])}return{do:r,unicode:h,color:a,bo:c}})}wo(t){return[t%256/255,Math.floor(t/256)%256/255,0]}Co(t,i){if(!q._(typeof t=="string","Character must be a string.",{method:"getCharacterColor",$o:t}))return[0,0,0];const r=i.find(n=>n.do===t);return r?r.color:[0,0,0]}Mo(t,i){return q._(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",$o:t})?Array.from(t).map(r=>this.Co(r,i)||[0,0,0]):[[0,0,0]]}}class yt{constructor(t,i=16){l(this,"xo");l(this,"Ao",[]);l(this,"Fo");l(this,"Uo",16);l(this,"To",0);l(this,"So",0);l(this,"Eo",{width:0,height:0});l(this,"Ro");l(this,"ko",new Map);l(this,"Po");l(this,"Lo");l(this,"Io");l(this,"zo");this.Uo=i,this.Po=new vi,this.Lo=new wi(t),this.Io=new yi,this.zo=new Ei}async Do(t){let i;if(!t)throw new F("Embedded font not available. This appears to be a minified build - please provide `fontSource` or use the non-minified version.");{const r=await fetch(t);if(!r.ok)throw new F(`Failed to load font file: ${r.status} ${r.statusText}`);i=await r.arrayBuffer()}await this.Oo(i),this.xo=z.parse(i)[0],await this.Bo()}Go(t){if(t===void 0)return this.Uo;this.Uo=t,this.Eo=this.Io.mo(this.Ao.map(r=>r.do),this.Uo,this.xo);const i=this.Lo.lo(this.Ao,this.Eo,this.Uo,this.xo);this.Fo=i.framebuffer,this.To=i.columns,this.So=i.rows}async Wo(t){try{const i=await fetch(t);if(!i.ok)throw new F(`Failed to load font file: ${i.status} ${i.statusText}`);const r=await i.arrayBuffer();await this.Oo(r);const n=z.parse(r);if(!n||n.length===0)throw new Error("Failed to parse font file");this.xo=n[0],await this.Bo()}catch(i){throw new F(`Failed to load font: ${i instanceof Error?i.message:"Unknown error"}`,i)}}async Oo(t){const i=Date.now();this.Ro=new FontFace(`CustomFont_${i}`,t),await this.Ro.load(),document.fonts.add(this.Ro)}async Bo(){const t=this.Po.Wn(this.xo);this.ko.clear(),this.Ao=this.zo.yo(t,this.xo),this.Eo=this.Io.mo(t,this.Uo,this.xo);const i=this.Lo.lo(this.Ao,this.Eo,this.Uo,this.xo);this.Fo=i.framebuffer,this.To=i.columns,this.So=i.rows}Co(t){return this.zo.Co(t,this.Ao)}Mo(t){return this.zo.Mo(t,this.Ao)}Ho(t){if(!Number.isFinite(t))return null;const i=this.ko.get(t);if(i!==void 0)return i;const r=this.Ko(t);if(r<0)return this.ko.set(t,null),null;const n=this.xo.Tn;if(!n)return this.ko.set(t,null),null;let h=n[r]??null;return h==null&&(h=z.Bn.Tn.Sn(this.xo,r)??null,n[r]=h),this.ko.set(t,h),h}Ko(t){const i=this.xo.An;for(const r of i.tn)if(r.format===4){const n=r;for(let h=0;h<n.ln.length;h++)if(t>=n.ln[h]&&t<=n.cn[h]){if(n.fn[h]===0)return t+n.un[h]&65535;{const a=n.fn[h]/2+(t-n.ln[h])-(n.ln.length-h);if(a>=0&&a<n.dn.length){const c=n.dn[a];if(c!==0)return c+n.un[h]&65535}}}}else if(r.format===12){const n=r;for(let h=0;h<n.groups.length;h+=3){const a=n.groups[h],c=n.groups[h+1],u=n.groups[h+2];if(t>=a&&t<=c)return u+(t-a)}}return 0}D(){this.Fo.D(),document.fonts.delete(this.Ro)}get Yo(){return this.Fo}get jo(){return this.Ao}get No(){return this.To}get Xo(){return this.So}get Zo(){return this.Eo}get fontSize(){return this.Uo}get font(){return this.xo}}class Et{constructor(t,i,r){l(this,"Vo");l(this,"qo");l(this,"O");l(this,"B");l(this,"Jo");l(this,"Qo");l(this,"th");l(this,"sh");l(this,"eh");this.th=t,this.sh=i,this.eh=r,this.ih()}ih(){this.Vo=Math.floor(this.th.width/this.sh),this.qo=Math.floor(this.th.height/this.eh),this.O=this.Vo*this.sh,this.B=this.qo*this.eh,this.Jo=Math.floor((this.th.width-this.O)/2),this.Qo=Math.floor((this.th.height-this.B)/2)}rh(t,i){this.sh=t,this.eh=i,this.ih()}get nh(){return this.sh}get oh(){return this.eh}get cols(){return this.Vo}get rows(){return this.qo}get width(){return this.O}get height(){return this.B}get offsetX(){return this.Jo}get offsetY(){return this.Qo}}const Ai=/^#([0-9a-f]{3,8})$/i,bi=/^rgba?\(([^)]+)\)$/i;function At(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function xi(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t||t==="transparent")return null;let i=null;return t.startsWith("#")?i=function(r){const n=Ai.exec(r.trim());if(!n)return null;const h=n[1];return h.length===3?[parseInt(h[0]+h[0],16),parseInt(h[1]+h[1],16),parseInt(h[2]+h[2],16),255]:h.length===4?[parseInt(h[0]+h[0],16),parseInt(h[1]+h[1],16),parseInt(h[2]+h[2],16),parseInt(h[3]+h[3],16)]:h.length===6||h.length===8?[parseInt(h.slice(0,2),16),parseInt(h.slice(2,4),16),parseInt(h.slice(4,6),16),h.length===8?parseInt(h.slice(6,8),16):255]:null}(t):t.startsWith("rgb")&&(i=function(r){const n=bi.exec(r.trim());if(!n)return null;const h=n[1].split(",").map(f=>f.trim());if(h.length<3)return null;const a=At(parseFloat(h[0])),c=At(parseFloat(h[1])),u=At(parseFloat(h[2])),d=h[3]!==void 0?255*Math.max(0,Math.min(1,parseFloat(h[3]))):255;return[a,c,u,Math.round(d)]}(t)),i?i[3]===0?null:i:null}class Ct{constructor(t={}){l(this,"th");l(this,"hh",null);l(this,"ah",!1);l(this,"uh");this.ah=t.fh??!1,this.ah&&t.canvas?(this.hh=t.canvas,this.th=this.dh(),this.uh=!0,this.ph()):t.canvas?(this.th=t.canvas,this.uh=!1):(this.th=this._h(t.width,t.height),this.uh=!0),this.th.style.imageRendering="pixelated"}_h(t,i){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=i||600,document.body.appendChild(r),r}dh(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const i=this.hh.getBoundingClientRect();let r=Math.round(i.width),n=Math.round(i.height);if(this.hh instanceof HTMLVideoElement){const c=this.hh;(r===0||n===0)&&c.videoWidth>0&&c.videoHeight>0&&(r=c.videoWidth,n=c.videoHeight)}t.width=r,t.height=n,t.style.position="absolute",t.style.pointerEvents="none";const h=window.getComputedStyle(this.hh);let a=parseInt(h.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=(a+1).toString(),t}ph(){var t;this.gh(),(t=this.hh.parentNode)==null||t.insertBefore(this.th,this.hh.nextSibling)}mh(){const t=[];return this.ah&&this.hh instanceof HTMLElement&&(t.push(this.hh),this.hh.parentElement&&t.push(this.hh.parentElement)),this.th.parentElement&&t.push(this.th.parentElement),t.push(this.th),t.push(document.body),t.push(document.documentElement),t}yh(){const t=this.mh();for(const i of t){if(!i)continue;const r=xi(window.getComputedStyle(i).backgroundColor);if(r)return r}return[255,255,255,255]}gh(){if(!this.hh)return;const t=this.hh.getBoundingClientRect();let i=this.hh.offsetParent;if(i&&i!==document.body){const r=i.getBoundingClientRect();this.th.style.top=t.top-r.top+"px",this.th.style.left=t.left-r.left+"px"}else this.th.style.top=t.top+window.scrollY+"px",this.th.style.left=t.left+window.scrollX+"px"}wh(t,i){if(this.ah){const r=this.hh.getBoundingClientRect();this.th.width=Math.round(r.width),this.th.height=Math.round(r.height),this.gh()}else this.th.width=t??this.th.width,this.th.height=i??this.th.height}bh(){const t=this.th.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,Ch:!0,antialias:!1,Z:!0,$h:!1,powerPreference:"high-performance"});if(!t)throw new F("`textmode.js` requires WebGL2 support.");return t}D(){const t=this.th.getContext("webgl")||this.th.getContext("webgl2");if(t){const i=t.getExtension("WEBGL_lose_context");i==null||i.Mh()}this.uh&&this.th.parentNode&&this.th.parentNode.removeChild(this.th)}get canvas(){return this.th}get xh(){return this.hh}get width(){return this.th.width}get height(){return this.th.height}}const Ti=/^#|0x/gi;function it(o){return Number.isNaN(o)||!Number.isFinite(o)||o<=0?0:o>=255?255:Math.round(o)}function ot(o){return it(parseInt(o,16))}class C{constructor(t,i,r,n,h){l(this,"Ah");l(this,"Fh");l(this,"Yt");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=it(t),this.g=it(i),this.b=it(r),this.a=it(n),this.Ah=[this.r,this.g,this.b,this.a],this.Fh=[this.r/255,this.g/255,this.b/255,this.a/255],this.Yt=h?[...h]:void 0}static Uh(t,i,r,n=255){return new C(t,i,r,n)}static Th(t,i=255){return new C(t,t,t,i)}static Sh(t){const[i,r,n,h]=function(a){const c=a.replace(Ti,""),u=(d=c).length===3||d.length===4?d.split("").map(f=>f+f).join(""):d;var d;if(u.length!==6&&u.length!==8)throw new Error(`Invalid hex color: ${a}`);return[ot(u.slice(0,2)),ot(u.slice(2,4)),ot(u.slice(4,6)),u.length===8?ot(u.slice(6,8)):255]}(t);return new C(i,r,n,h)}static Eh(t){const[i,r,n]=t;return new C(255*i,255*r,255*n,255,t)}get Rh(){return[this.r,this.g,this.b]}get kh(){return[...this.Ah]}get te(){return[...this.Fh]}get do(){return this.Yt?[...this.Yt]:void 0}static Ph(t){return t instanceof C}}const W=class W{constructor(t,i,r,n,h,a,c){l(this,"m");l(this,"Y");l(this,"Lh");l(this,"Ih");l(this,"zh");l(this,"O");l(this,"B");l(this,"j",null);l(this,"Rt",0);l(this,"Ht",0);l(this,"Kt",0);l(this,"kt",0);l(this,"Dh","sampled");l(this,"Oh","fixed");l(this,"jt",[1,1,1,1]);l(this,"Nt",[0,0,0,1]);l(this,"Bh",[0,0,0,1]);l(this,"Gh",[[.1,0,0]]);l(this,"Wh");this.m=t,this.Y=i,this.Lh=r,this.Ih=n,this.zh=h,this.O=a,this.B=c}dispose(){this.m.deleteTexture(this.Lh)}Pe(t=!0){return this.Rt=t?1:0,this.j=null,this}flipX(t=!0){return this.Ht=t?1:0,this.j=null,this}flipY(t=!0){return this.Kt=t?1:0,this.j=null,this}Kh(t){return this.kt=Tt(t),this.j=null,this}Yh(t){return this.Dh=t,this.j=null,this}jh(t){return this.Oh=t,this.j=null,this}Nh(t,i,r,n){return this.Xh(this.jt,t,i,r,n),this.j=null,this}Zh(t,i,r,n){return this.Xh(this.Nt,t,i,r,n),this.j=null,this}background(t,i,r,n){return this.Xh(this.Bh,t,i,r,n),this.j=null,this}jo(t){if(!this.Wh)throw new Error("Glyph color resolver not initialized");const i=this.Wh(t).filter(r=>Array.isArray(r)).slice(0,64);return this.Gh=i,this.j=null,this}get texture(){return this.Lh}get width(){return this.O}get height(){return this.B}get Vh(){return this.Ih}get qh(){return this.zh}ct(){return this.j||this.lt(),this.j}Jh(){}lt(){this.Jh();const t=this.Qh(),i=this.ta();this.j=this.Y.vt.Ni(t,i)}Xh(t,i,r,n,h){if(C.Ph(i))X(t,i.r,i.g,i.b,i.a);else{if(typeof i=="string"){const a=C.Sh(i);return void X(t,a.r,a.g,a.b,a.a)}X(t,i,r,n,h)}}Qh(){return W.Hh||(W.Hh=new $(this.m,st,`#version 300 es
|
|
11
|
-
precision highp float;in vec2 v_uv;uniform sampler2D Uh;uniform bool Ui;uniform bool Uj;uniform bool Uk;uniform float Ul;uniform bool Um;uniform vec4 Un;uniform bool Uo;uniform vec4 Up;uniform vec4 Uq;uniform int Ur;uniform vec3 Us[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uh,C);float E=A(D.rgb);vec2 F=vec2(0.);if(Ur>0){float G=float(Ur);float H=clamp(E*(G-1.0f),0.0f,G-1.0f);int I=int(floor(H+0.5f));vec3 J=Us[I];F=J.xy;}else{F=vec2(E,0.0f);}vec4 K=Um?Un:D;vec4 L=Uo?Up:D;if(D.a<0.01f){K=Uq;L=Uq;}else{}o_primaryColor=vec4(K.rgb,K.a);o_secondaryColor=vec4(L.rgb,L.a);int M=int(Ui?1:0);int N=int(Uj?1:0);int O=int(Uk?1:0);float P=float(M|(N<<1)|(O<<2))/255.;o_character=vec4(F,P,clamp(Ul,0.0f,1.0f));}`)),W.Hh}ta(){return{sa:this.ea(),ia:!!this.Rt,ra:!!this.Ht,na:!!this.Kt,oa:this.kt,ha:this.Dh==="fixed",aa:this.jt,ca:this.Oh==="fixed",la:this.Nt,ua:this.Bh,fa:this.Gh.length,da:this.Gh}}};l(W,"Hh",null);let at=W;class K extends at{constructor(t,i,r,n,h,a,c){const u=Math.min(a/n,c/h);super(t,i,r,n,h,Math.max(1,Math.floor(n*u)),Math.max(1,Math.floor(h*u)))}static pa(t,i,r,n,h){const a=t.context,c=a.createTexture();a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),et(a,a.NEAREST,a.NEAREST,a.CLAMP_TO_EDGE,a.CLAMP_TO_EDGE),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i),a.bindTexture(a.TEXTURE_2D,null);const u=i.naturalWidth??i.width??i.videoWidth??0,d=i.naturalHeight??i.height??i.videoHeight??0,f=new K(a,t,c,u,d,r,n);return f.Wh=h,f}ea(){return this.Lh}}class Ri{constructor(t=60){l(this,"_a");l(this,"ga",null);l(this,"va",0);l(this,"ma",!0);l(this,"ya",0);l(this,"wa",0);l(this,"ba",[]);l(this,"Ca",10);l(this,"$a",0);this._a=1e3/t}Ma(t){if(!this.ma)return;this.va=performance.now();const i=r=>{if(!this.ma)return void(this.ga=null);const n=r-this.va;n>=this._a&&(t(),this.va=r-n%this._a),this.ma&&(this.ga=requestAnimationFrame(i))};this.ga=requestAnimationFrame(i)}xa(){this.ga&&(cancelAnimationFrame(this.ga),this.ga=null)}Aa(){this.ma&&(this.ma=!1,this.xa())}Fa(t){this.ma||(this.ma=!0,this.Ma(t))}Ua(t,i){if(t===void 0)return this.ya;this._a=1e3/t,this.ma&&i&&(this.xa(),this.Ma(i))}Ta(){const t=performance.now();if(this.wa>0){const i=t-this.wa;this.ba.push(i),this.ba.length>this.Ca&&this.ba.shift();const r=this.ba.reduce((n,h)=>n+h,0)/this.ba.length;this.ya=1e3/r}this.wa=t}get Sa(){return this.ma}get Ea(){return this.ya}get Ra(){return this.$a}set Ra(t){this.$a=t}ka(){this.$a++}}class Pt{constructor(t){l(this,"th");l(this,"Pa");l(this,"La",{x:-1,y:-1});l(this,"Ia",{x:-1,y:-1});l(this,"za",null);l(this,"Da",0);l(this,"Oa");l(this,"Ba");l(this,"Ga");l(this,"Wa");l(this,"Ha");l(this,"Ka");l(this,"Ya",!1);l(this,"ja");l(this,"Na");l(this,"Xa");l(this,"Za");l(this,"Va");this.th=t}qa(t){const i=performance.now()+Math.max(0,t);i>this.Da&&(this.Da=i)}Ja(){return performance.now()<this.Da}Qa(t){const i=this.th.canvas;i.style.cursor=t==null||t===""?"":t}Do(t){this.Pa=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.Oa=i=>{this.ec(i),this.rc(i)},this.Ba=()=>{this.Ia={...this.La},this.La.x=-1,this.La.y=-1,this.za=null},this.Ga=i=>{this.ec(i),this.nc(i)},this.Wa=i=>{this.ec(i),this.oc(i)},this.Ha=i=>{this.ec(i),this.hc(i)},this.Ka=i=>{this.ec(i),this.ac(i)},t.addEventListener("mousemove",this.Oa,{passive:!0}),t.addEventListener("mouseleave",this.Ba,{passive:!0}),t.addEventListener("mousedown",this.Ga,{passive:!0}),t.addEventListener("mouseup",this.Wa,{passive:!0}),t.addEventListener("click",this.Ha,{passive:!0}),t.addEventListener("wheel",this.Ka,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("mousemove",this.Oa),t.removeEventListener("mouseleave",this.Ba),t.removeEventListener("mousedown",this.Ga),t.removeEventListener("mouseup",this.Wa),t.removeEventListener("click",this.Ha),t.removeEventListener("wheel",this.Ka),this.Ya=!1}tc(){if(this.Ya)try{if(this.za){const t=new MouseEvent("mousemove",{clientX:this.za.x,clientY:this.za.y,bubbles:!1,cancelable:!1});this.ec(t)}else this.La.x!==-1&&this.La.y!==-1&&(this.La.x>=this.Pa.cols||this.La.y>=this.Pa.rows)&&(this.La.x=-1,this.La.y=-1)}catch{this.La.x=-1,this.La.y=-1}}lc(t){this.ja=t}uc(t){this.Na=t}fc(t){this.Xa=t}dc(t){this.Za=t}_c(t){this.Va=t}gc(){return{x:this.La.x,y:this.La.y}}rc(t){if(this.Za&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},mc:t};this.Za(i)}}nc(t){if(this.Na&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.Na(i)}}oc(t){if(this.Xa&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.Xa(i)}}hc(t){if(this.ja&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},button:t.button,mc:t};this.ja(i)}}ac(t){if(this.Va&&!this.Ja()){const i={position:{...this.La},vc:{...this.Ia},delta:{x:t.deltaX,y:t.deltaY},mc:t};this.Va(i)}}ec(t){const i=this.th.canvas;this.Ia={...this.La},this.za={x:t.clientX,y:t.clientY};const r=i.getBoundingClientRect(),n=t.clientX-r.left,h=t.clientY-r.top,a=i.width/r.width,c=h*(i.height/r.height),u=n*a-this.Pa.offsetX,d=c-this.Pa.offsetY,f=Math.floor(u/this.Pa.nh),p=Math.floor(d/this.Pa.oh);f>=0&&f<this.Pa.cols&&p>=0&&p<this.Pa.rows?(this.La.x=f,this.La.y=p):(this.La.x=-1,this.La.y=-1)}}const Fi=Object.freeze(Object.defineProperty({__proto__:null,yc:Pt},Symbol.toStringTag,{value:"Module"}));class Dt{constructor(){l(this,"wc",new Map);l(this,"bc",null);l(this,"Cc",null);l(this,"$c");l(this,"Mc");l(this,"Ya",!1);l(this,"xc");l(this,"Ac");l(this,"Fc",{ArrowUp:"UP_ARROW",ArrowDown:"DOWN_ARROW",ArrowLeft:"LEFT_ARROW",ArrowRight:"RIGHT_ARROW",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",Enter:"ENTER",Return:"RETURN",Tab:"TAB",Escape:"ESCAPE",Backspace:"BACKSPACE",Delete:"DELETE",Insert:"INSERT",Home:"HOME",End:"END",PageUp:"PAGE_UP",PageDown:"PAGE_DOWN",Shift:"SHIFT",Control:"CONTROL",Alt:"ALT",Meta:"META"," ":"SPACE"})}sc(){this.Ya||(this.$c=t=>{this.Uc(t)},this.Mc=t=>{this.Tc(t)},window.addEventListener("keydown",this.$c,{passive:!1}),window.addEventListener("keyup",this.Mc,{passive:!1}),this.Ya=!0)}cc(){this.Ya&&(window.removeEventListener("keydown",this.$c),window.removeEventListener("keyup",this.Mc),this.Ya=!1,this.wc.clear(),this.bc=null,this.Cc=null)}uc(t){this.xc=t}fc(t){this.Ac=t}Sc(t){const i=this.Ec(t),r=this.wc.get(t)||this.wc.get(i);return(r==null?void 0:r.Rc)||!1}kc(){return this.bc}Pc(){return this.Cc}Lc(){const t=[];for(const[i,r]of this.wc)r.Rc&&t.push(i);return t}Ic(){return{zc:this.Sc("Control"),shift:this.Sc("Shift"),alt:this.Sc("Alt"),Dc:this.Sc("Meta")}}Oc(){this.wc.clear(),this.bc=null,this.Cc=null}Uc(t){const i=t.key,r=Date.now();this.wc.has(i)||this.wc.set(i,{Rc:!1,Bc:0,Gc:0});const n=this.wc.get(i);if(!n.Rc&&(n.Rc=!0,n.Bc=r,this.bc=i,this.xc)){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,Rc:!0,mc:t};this.xc(h)}}Tc(t){const i=t.key,r=Date.now();this.wc.has(i)||this.wc.set(i,{Rc:!1,Bc:0,Gc:0});const n=this.wc.get(i);if(n.Rc=!1,n.Gc=r,this.Cc=i,this.Ac){const h={key:i,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,Rc:!1,mc:t};this.Ac(h)}}Ec(t){return this.Fc[t]||t.toLowerCase()}}const Li=Object.freeze(Object.defineProperty({__proto__:null,Wc:Dt},Symbol.toStringTag,{value:"Module"}));class Ot{constructor(t,i){l(this,"th");l(this,"Hc");l(this,"Pa");l(this,"Kc",new Map);l(this,"Yc",new Map);l(this,"jc",new Map);l(this,"Nc",null);l(this,"Xc");l(this,"Zc");l(this,"Vc");l(this,"qc");l(this,"Jc");l(this,"Qc");l(this,"Ya",!1);l(this,"tl");l(this,"sl");l(this,"el");l(this,"il");l(this,"rl");l(this,"nl");l(this,"ol");l(this,"hl");l(this,"al");l(this,"cl");l(this,"ll",320);l(this,"ul",350);l(this,"fl",10);l(this,"dl",550);l(this,"pl",14);l(this,"_l",48);l(this,"gl",650);l(this,"vl",.02);l(this,"ml",2);l(this,"yl",600);l(this,"wl",0);l(this,"bl",null);this.th=t,this.Hc=i;const r=this.th.canvas;this.Xc=r.style.touchAction,this.Zc=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}Do(t){this.Pa=t,this.tc()}sc(){if(this.Ya)return;const t=this.th.canvas;this.Vc=i=>{this.Cl(i)},this.qc=i=>{this.$l(i)},this.Jc=i=>{this.Ml(i)},this.Qc=i=>{this.xl(i)},t.addEventListener("touchstart",this.Vc,{passive:!1}),t.addEventListener("touchmove",this.qc,{passive:!1}),t.addEventListener("touchend",this.Jc,{passive:!1}),t.addEventListener("touchcancel",this.Qc,{passive:!1}),this.Ya=!0}cc(){if(!this.Ya)return;const t=this.th.canvas;t.removeEventListener("touchstart",this.Vc),t.removeEventListener("touchmove",this.qc),t.removeEventListener("touchend",this.Jc),t.removeEventListener("touchcancel",this.Qc),this.Ya=!1,this.Nc=null,this.Kc.clear(),this.Yc.clear(),this.jc.forEach(i=>{i.Al!==null&&window.clearTimeout(i.Al)}),this.jc.clear(),this.bl=null,this.wl=0,t.style.touchAction=this.Xc,t.style.userSelect=this.Zc}tc(){if(!this.Pa||this.Kc.size===0)return;const t=new Map;for(const i of this.Kc.values()){const r=this.Fl(i.clientX,i.clientY,i.id,i);t.set(i.id,r)}this.Kc=t}Ul(){return Array.from(this.Kc.values()).map(t=>({...t}))}Tl(t){this.tl=t}dc(t){this.sl=t}Sl(t){this.el=t}El(t){this.il=t}Rl(t){this.rl=t}kl(t){this.nl=t}Pl(t){this.ol=t}Ll(t){this.hl=t}Il(t){this.al=t}zl(t){this.cl=t}Cl(t){var n;if(!this.Pa)return;t.preventDefault(),(n=this.Hc)==null||n.qa(this.yl);const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const a=this.Kc.get(h.id);a&&this.Yc.set(h.id,this.Ol(a)),this.Kc.set(h.id,h);const c={id:h.id,Bl:h,Gl:h,startTime:i,Wl:i,Al:null,Hl:!1};this.ol&&(c.Al=window.setTimeout(()=>{const u=this.Kc.get(h.id);u&&(c.Hl=!0,this.ol({Kl:this.Ol(u),duration:performance.now()-c.startTime,mc:t}))},this.dl)),this.jc.set(h.id,c),this.tl&&this.tl(this.Yl(h,t,void 0,i))}this.Kc.size===2&&this.jl()}$l(t){var n;if(!this.Pa)return;t.preventDefault(),(n=this.Hc)==null||n.qa(this.yl);const i=performance.now(),r=this.Dl(t.changedTouches);for(const h of r){const a=this.Kc.get(h.id),c=a?this.Ol(a):void 0;c&&this.Yc.set(h.id,c),this.Kc.set(h.id,h);const u=this.jc.get(h.id);u&&(u.Gl=h,u.Wl=i,c)&&V(c.clientX,c.clientY,h.clientX,h.clientY)>this.pl&&u.Al!==null&&(window.clearTimeout(u.Al),u.Al=null),this.sl&&this.sl(this.Yl(h,t,c,i))}this.Kc.size===2?this.Nl(t):this.Nc=null}Ml(t){if(!this.Pa)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const h=this.Kc.get(n.id),a=h?this.Ol(h):void 0,c=this.jc.get(n.id);c&&c.Al!==null&&(window.clearTimeout(c.Al),c.Al=null),this.el&&this.el(this.Yl(n,t,a,i)),c&&this.Xl(c,t),this.jc.delete(n.id),this.Yc.delete(n.id),this.Kc.delete(n.id)}this.Kc.size<2&&(this.Nc=null)}xl(t){if(!this.Pa)return;t.preventDefault();const i=performance.now(),r=this.Dl(t.changedTouches);for(const n of r){const h=this.Kc.get(n.id),a=h?this.Ol(h):void 0,c=this.jc.get(n.id);c&&c.Al!==null&&(window.clearTimeout(c.Al),c.Al=null),this.il&&this.il(this.Yl(n,t,a,i)),this.jc.delete(n.id),this.Yc.delete(n.id),this.Kc.delete(n.id)}this.Kc.size<2&&(this.Nc=null)}Dl(t){const i=[];for(let r=0;r<t.length;r+=1){const n=t.item(r);n&&i.push(this.Zl(n))}return i}Zl(t){return this.Fl(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})}Fl(t,i,r,n){const h=this.th.canvas,a=h.getBoundingClientRect(),c=t-a.left,u=i-a.top,d=h.width/a.width,f=u*(h.height/a.height),p=c*d-this.Pa.offsetX,g=f-this.Pa.offsetY,m=Math.floor(p/this.Pa.nh),v=Math.floor(g/this.Pa.oh),y=m>=0&&m<this.Pa.cols&&v>=0&&v<this.Pa.rows;return{id:r,x:y?m:-1,y:y?v:-1,clientX:t,clientY:i,pressure:n.pressure,radiusX:n.radiusX,radiusY:n.radiusY,rotationAngle:n.rotationAngle}}Yl(t,i,r,n){const h=this.jc.get(t.id),a=Array.from(this.Yc.values()).map(d=>this.Ol(d)),c=Array.from(this.Kc.values()).map(d=>this.Ol(d)),u=this.Dl(i.changedTouches);return{Kl:this.Ol(t),Vl:r?this.Ol(r):void 0,touches:c,ql:a,changedTouches:u,Jl:h?n-h.Wl:0,mc:i}}jl(){if(this.Kc.size!==2)return void(this.Nc=null);const t=Array.from(this.Kc.values()),[i,r]=t,n=V(i.x,i.y,r.x,r.y),h=xt(i.clientX,i.clientY,r.clientX,r.clientY);this.Nc={sn:[i.id,r.id],Ql:Math.max(n,1e-4),tu:h,su:1,eu:0}}Nl(t){if(this.Nc||this.jl(),!this.Nc)return;const[i,r]=this.Nc.sn,n=this.Kc.get(i),h=this.Kc.get(r);if(!n||!h)return;const a=V(n.x,n.y,h.x,h.y)/this.Nc.Ql,c=a-this.Nc.su;this.al&&Math.abs(c)>this.vl&&(this.al({touches:[this.Ol(n),this.Ol(h)],scale:a,iu:c,ru:this.nu(n,h),mc:t}),this.Nc.su=a);let u=xt(n.clientX,n.clientY,h.clientX,h.clientY)-this.Nc.tu;u=(u+180)%360-180;const d=u-this.Nc.eu;this.cl&&Math.abs(d)>this.ml&&(this.cl({touches:[this.Ol(n),this.Ol(h)],rotation:u,ou:d,ru:this.nu(n,h),mc:t}),this.Nc.eu=u)}nu(t,i){const r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,h=this.Fl(r,n,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:n});return{x:h.x,y:h.y}}Xl(t,i){const r=performance.now(),n=r-t.startTime,h=V(t.Bl.clientX,t.Bl.clientY,t.Gl.clientX,t.Gl.clientY);if(!t.Hl&&n<=this.ll&&h<=this.fl)this.hu(t.Gl,r)&&this.nl?this.nl({Kl:this.Ol(t.Gl),au:2,mc:i}):this.rl&&this.rl({Kl:this.Ol(t.Gl),au:1,mc:i});else if(!t.Hl&&n<=this.gl&&h>=this._l){const a={x:t.Gl.clientX-t.Bl.clientX,y:t.Gl.clientY-t.Bl.clientY},c=Math.max(Math.hypot(a.x,a.y),1e-4),u={x:a.x/c,y:a.y/c},d={x:a.x/n,y:a.y/n};this.hl&&this.hl({Kl:this.Ol(t.Gl),direction:u,cu:c,lu:d,mc:i})}this.wl=r,this.bl=this.Ol(t.Gl)}hu(t,i){return!!this.bl&&!(i-this.wl>this.ul)&&V(t.clientX,t.clientY,this.bl.clientX,this.bl.clientY)<=this.fl}Ol(t){return{...t}}}const Mi=Object.freeze(Object.defineProperty({__proto__:null,uu:Ot},Symbol.toStringTag,{value:"Module"}));class ct extends at{constructor(i,r,n,h,a,c,u,d){const f=a/c;let p,g;f>1?(p=u,g=Math.round(u/f)):(g=d,p=Math.round(d*f));super(i,r,n,a,c,p,g);l(this,"fu");l(this,"du",!1);l(this,"pu",[]);l(this,"ya",null);l(this,"_u",0);l(this,"gu",0);l(this,"vu",-1);this.fu=h}dispose(){super.dispose();for(const i of this.pu)this.m.deleteTexture(i);this.pu=[],this.fu.pause(),this.fu.src="",this.fu.load()}mu(){if(!this.du&&this.fu.readyState>=this.fu.HAVE_CURRENT_DATA){const i=this.m;i.bindTexture(i.TEXTURE_2D,this.Lh),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this.fu),i.bindTexture(i.TEXTURE_2D,null)}}ea(){if(this.du&&this.pu.length>0){const i=this.gu%this.pu.length;return this.pu[i]}return this.Lh}ct(){return this.j=null,super.ct()}Jh(){this.mu()}async yu(i,r){var n;try{if(i<=0)throw new Error("Video preload requires a frameRate greater than 0.");const h=this.fu.duration;if(!isFinite(h)||h<=0)throw new Error("Video duration is invalid, cannot preload frames.");const a=Math.max(1,Math.ceil(h*i));if(this.wu(i,a),await this.bu(i,r))return void this.Cu("captureStream",r);await this.$u(i,r),this.Cu("seeking",r)}catch(h){const a=h instanceof Error?h:new Error(String(h));throw(n=r==null?void 0:r.Mu)==null||n.call(r,a),a}}wu(i,r){this.ya=i,this._u=r,this.pu=[],this.du=!1,this.gu=0,this.vu=-1}Cu(i,r){var n;if(this.pu.length===0)throw new Error(`Video preload via ${i} completed but produced 0 frames.`);this._u=this.pu.length,this.du=!0,this.gu=0,this.vu=-1,this.fu.pause(),this.fu.currentTime=0,r!=null&&r.xu&&r.xu({percent:100,Au:this._u,totalFrames:this._u,Fu:i}),(n=r==null?void 0:r.Uu)==null||n.call(r,{totalFrames:this._u,Fu:i})}Tu(i){const r=this.m,n=r.createTexture();return r.bindTexture(r.TEXTURE_2D,n),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,1),et(r,r.LINEAR,r.LINEAR,r.CLAMP_TO_EDGE,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),r.bindTexture(r.TEXTURE_2D,null),n}Su(i,r){if(!(r!=null&&r.xu)||this._u===0)return;const n=Math.min(99,Math.floor(this.pu.length/this._u*100)),h=10*Math.floor(n/10);h>this.vu&&(this.vu=h,r.xu({percent:n,Au:this.pu.length,totalFrames:this._u,Fu:i}))}async bu(i,r){const n=globalThis,h=n==null?void 0:n.MediaStreamTrackProcessor,a=this.fu.captureStream;if(typeof h!="function"||typeof a!="function")return!1;let c,u=null;try{const d=a.call(this.fu);if(c=d.getVideoTracks()[0],!c)return d.getTracks().forEach(g=>g.stop()),!1;if(u=new h({track:c}).readable.getReader(),this.fu.currentTime=0,this.fu.muted=!0,await this.fu.play().catch(()=>{}),this.fu.paused)return!1;const f=1e6/i;let p=0;for(;this.pu.length<this._u;){const g=await u.read();if(g.done)break;const m=g.value;if(m)try{const v=typeof m.timestamp=="number"?m.timestamp:p;(this.pu.length===0||v>=p)&&(this.pu.push(this.Tu(m)),p=v+f,this.Su("captureStream",r))}finally{m.close()}}return u.releaseLock(),c.stop(),u=null,c=void 0,this.fu.pause(),this.fu.currentTime=0,this.pu.length!==0}catch{return this.pu=[],this.vu=-1,!1}finally{if(u)try{await u.cancel()}catch{}c&&c.stop(),this.fu.pause(),this.fu.currentTime=0}}async $u(i,r){const n=1/i,h=this._u,a=this.fu;a.pause();for(let c=0;c<h;c++){const u=Math.min(a.duration,c*n);await this.Eu(u),this.pu.push(this.Tu(a)),this.Su("seeking",r)}a.currentTime=0}Eu(i){return new Promise((r,n)=>{const h=this.fu,a=()=>{h.removeEventListener("seeked",c),h.removeEventListener("error",u)},c=()=>{a(),r()},u=()=>{a(),n(new Error("Video seek failed while preloading frames."))};h.addEventListener("seeked",c,{once:!0}),h.addEventListener("error",u,{once:!0});const d=isFinite(h.duration)?h.duration:i,f=Math.min(Math.max(i,0),d);if(Math.abs(h.currentTime-f)<1e-4)return a(),void r();h.currentTime=f})}frame(i){return this.du&&i!==void 0&&this._u>0&&(this.gu=(i%this._u+this._u)%this._u,this.j=null),this}static async pa(i,r,n,h,a,c){const u=i.context,d=c==null?void 0:c.Ru;let f;if(typeof r=="string"){if(f=document.createElement("video"),f.crossOrigin="anonymous",f.loop=!0,f.muted=!0,f.playsInline=!0,await new Promise((y,w)=>{f.addEventListener("loadedmetadata",()=>y(),{once:!0}),f.addEventListener("error",b=>{var A;const E=b.target;w(new Error(`Failed to load video: ${((A=E.error)==null?void 0:A.message)||"Unknown error"}`))},{once:!0}),f.src=r}),!d)try{await f.play()}catch(y){console.warn("Video autoplay prevented - you may need to call video.play() after user interaction:",y)}}else f=r,f.readyState<f.HAVE_METADATA&&await new Promise((y,w)=>{f.addEventListener("loadedmetadata",()=>y(),{once:!0}),f.addEventListener("error",b=>{var E;return w(new Error(`Video error: ${(E=b.target.error)==null?void 0:E.message}`))},{once:!0})});const p=u.createTexture();u.bindTexture(u.TEXTURE_2D,p),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,1),et(u,u.LINEAR,u.LINEAR,u.CLAMP_TO_EDGE,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,u.RGBA,u.UNSIGNED_BYTE,f),u.bindTexture(u.TEXTURE_2D,null);const g=f.videoWidth,m=f.videoHeight,v=new ct(u,i,p,f,g,m,n,h);return v.Wh=a,d&&d>0&&await v.yu(d,c),v}async play(){await this.fu.play()}pause(){this.fu.pause()}stop(){this.fu.pause(),this.fu.currentTime=0}speed(i){return this.fu.playbackRate=i,this}loop(i=!0){return this.fu.loop=i,this}time(i){return this.fu.currentTime=i,this}volume(i){return this.fu.volume=Math.max(0,Math.min(1,i)),this}get texture(){return this.Lh}get width(){return this.O}get height(){return this.B}get Vh(){return this.Ih}get qh(){return this.zh}get ku(){return this.fu}get currentTime(){return this.fu.currentTime}get duration(){return this.fu.duration}get Pu(){return!this.fu.paused&&!this.fu.ended}get Lu(){return this.du}get totalFrames(){return this._u}get Iu(){return this.ya}get zu(){return this.gu}}const _i=o=>class extends o{Du(t,i,r,n){if(C.Ph(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,i,r,n);throw new Error("Unsupported color input passed to color-capable method.")}rotate(t=0,i=0,r=0){this.Y.state.Qt(t),this.Y.state.ts(i),this.Y.state.ss(r)}Ou(t){this.Y.state.Qt(t)}Bu(t){this.Y.state.ts(t)}Gu(t){this.Y.state.ss(t)}translate(t=0,i=0,r=0){this.Y.state.es(t,i,r)}Wu(t){this.Y.state.es(t,0,0)}Hu(t){this.Y.state.es(0,t,0)}Ku(t){this.Y.state.es(0,0,t)}push(){this.Y.state.rt()}pop(){this.Y.state.nt()}color(t,i,r,n){if(C.Ph(t))return t;if(typeof t=="string"){const h=Array.from(t);if(h.length===1){const a=h[0],c=this.xo.Co(a);return C.Eh(c)}return C.Sh(t)}if(typeof t=="number")return typeof i=="number"&&typeof r=="number"?C.Uh(t,i,r,n??255):typeof i=="number"&&r===void 0?C.Th(t,i):C.Th(t,n??255);throw new Error("Unsupported color input passed to color().")}rect(t=1,i=1){this.Y.Sr(t,i)}Yu(){this.Y.Sr(1,1)}line(t,i,r,n){this.Y.Er(t,i,r,n)}ju(t){this.Y.state.qt(t)}background(t,i,r,n=255){const h=this.Du(t,i,r,n);this.Y.zr(h.r,h.g,h.b,h.a)}char(t){if(C.Ph(t)){const r=t.do;return void(r&&this.Y.state.cs(r))}const i=Array.from(t);if(i.length===0)throw new Error("char() requires at least one character.");this.Y.state.cs(this.xo.Co(i[0]))}Nh(t,i,r,n){const h=this.Du(t,i,r,n);this.Y.state.ls(h.r,h.g,h.b,h.a)}Zh(t,i,r,n){const h=this.Du(t,i,r,n);this.Y.state.us(h.r,h.g,h.b,h.a)}flipX(t){this.Y.state.fs(t)}flipY(t){this.Y.state.ds(t)}Kh(t){this.Y.state._s(t)}Pe(t){this.Y.state.ps(t)}clear(){this.Y.zr(0,0,0,0)}ellipse(t,i){this.Y.Rr(t/2,i/2)}Nu(t,i,r,n,h,a){this.Y.kr(t,i,r,n,h,a)}Xu(t,i,r,n,h,a,c,u){this.Y.Pr(t,i,r,n,h,a,c,u)}arc(t,i,r,n){this.Y.Lr(t/2,i/2,r,n)}ki(t){this.Y.Mr(t)}Zu(t,i){this.Y.P(t,i)}Vu(t){this.Y.Ar(t)}qu(t){return this.Y.Fr(t)}createFramebuffer(t){return this.Y.Ir(t.width,t.height,3)}image(t,i,r){this.Y.Ur(t,i,r)}Ju(){this.Y.state.vs(!0)}async Qu(t){if(typeof t!="string")return K.pa(this.Y,t,this.Pa.cols,this.Pa.rows,n=>this.xo.Mo(n));const i=t,r=await new Promise((n,h)=>{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a),a.onerror=c=>h(c),a.src=i});return K.pa(this.Y,r,this.Pa.cols,this.Pa.rows,n=>this.xo.Mo(n))}async tf(t,i){return ct.pa(this.Y,t,this.Pa.cols,this.Pa.rows,r=>this.xo.Mo(r),i)}},Ui=o=>class extends o{async sf(t){return this.xo.Wo(t).then(()=>{const i=this.xo.Zo;this.Pa.rh(i.width,i.height),this.ef.resize(this.Pa.cols,this.Pa.rows),this.Y.Dr(),this.Hc.tc(),this.if.tc()})}fontSize(t){if(!q._(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",$o:t})||this.xo.fontSize===t)return;this.xo.Go(t);const i=this.xo.Zo;this.Pa.rh(i.width,i.height),this.ef.resize(this.Pa.cols,this.Pa.rows),this.Y.Dr(),this.Hc.tc(),this.if.tc()}},Yi=o=>class extends o{get frameCount(){return this.rf.Ra}set frameCount(t){this.rf.Ra=t}Ru(t){return t===void 0?this.rf.Ea:this.rf.Ua(t,()=>this.nf())}hf(){this.rf.Aa()}loop(){this.rf.Fa(()=>this.nf())}af(t=1){if(q._(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",$o:t}))for(let i=0;i<t;i++)this.nf()}cf(){return this.rf.Sa}},Ci=o=>class extends o{constructor(...t){super(...t)}lf(t){this.Hc.lc(t)}uf(t){this.Hc.uc(t)}ff(t){this.Hc.fc(t)}df(t){this.Hc.dc(t)}pf(t){this.Hc._c(t)}get _f(){return this.Hc.gc()}cursor(t){this.Hc.Qa(t)}},Pi=o=>class extends o{constructor(...t){super(...t)}gf(t){this.if.Tl(t)}vf(t){this.if.dc(t)}mf(t){this.if.Sl(t)}yf(t){this.if.El(t)}wf(t){this.if.Rl(t)}bf(t){this.if.kl(t)}Cf(t){this.if.Pl(t)}$f(t){this.if.Ll(t)}Mf(t){this.if.Il(t)}xf(t){this.if.zl(t)}get touches(){return this.if.Ul()}},Di=o=>class extends o{constructor(...t){super(...t)}Af(t){this.Ff.uc(t)}Uf(t){this.Ff.fc(t)}Tf(t){return this.Ff.Sc(t)}get Sf(){return this.Ff.kc()}get Ef(){return this.Ff.Pc()}get Rf(){return this.Ff.Lc()}get kf(){return this.Ff.Ic()}};class Oi{constructor(t){l(this,"Pf");l(this,"Lf",new Map);l(this,"If",[]);l(this,"zf",new Map);l(this,"Df",new Map);this.Pf=t}async Of(t){for(const i of t){if(this.Lf.has(i.name))return void console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`);const r=this.Bf(i.name);try{await i.install(this.Pf,r)}catch(n){throw this.Gf(i.name),n}this.Lf.set(i.name,i),this.If.push(i.name)}}async Wf(t){const i=this.Lf.get(t);if(!i)return;const r=this.Bf(t);i.Hf&&await i.Hf(this.Pf,r),this.Lf.delete(t),this.If.splice(this.If.indexOf(t),1),this.Gf(t)}Kf(){this.Yf(this.zf)}jf(){this.Yf(this.Df)}async Nf(){const t=[...this.Lf.keys()];for(const i of t)await this.Wf(i)}Bf(t){return{Xf:this.Pf.Y,font:this.Pf.xo,grid:this.Pf.Pa,canvas:this.Pf.th,Zf:this.Pf.ef,Vf:this.Pf.qf,Jf:i=>this.Qf(this.zf,t,i),td:i=>this.Qf(this.Df,t,i)}}Qf(t,i,r){const n=t.get(i)??new Set;return n.add(r),t.set(i,n),()=>{const h=t.get(i);h&&(h.delete(r),h.size===0&&t.delete(i))}}Gf(t){this.zf.delete(t),this.Df.delete(t)}Yf(t){for(const i of this.If){const r=t.get(i);r&&r.forEach(n=>n())}}}const Bt=`#version 300 es
|
|
12
|
-
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class
|
|
13
|
-
precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U2;uniform vec2 U5;uniform vec2 U6;uniform vec4
|
|
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(e=>A.o(e)).join(", ")}]`:`[${t.slice(0,3).map(e=>A.o(e)).join(", ")}, ... +${t.length-3} more]`;if(typeof t=="object"){const e=Object.keys(t);return e.length===0?"{}":e.length<=3?`{ ${e.map(r=>`${r}: ${A.o(t[r])}`).join(", ")} }`:`{ ${e.slice(0,2).map(r=>`${r}: ${A.o(t[r])}`).join(", ")}, ... +${e.length-2} more }`}return t+""}}var H=(o=>(o[o.SILENT=0]="SILENT",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o[o.THROW=3]="THROW",o))(H||{});const $=class ${constructor(){l(this,"l",{globalLevel:3})}static u(){return $.h||($.h=new $),$.h}_(t,e){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(A.i(t,e)),console.groupEnd(),!1;case 2:return console.group(r,h),console.error(A.i(t,e)),console.groupEnd(),!1;default:throw new A(t,e)}}v(t,e,r){return!!t||(this._(e,r),!1)}m(t){this.l.globalLevel=t}};l($,"h",null);let ft=$;const K=ft.u();class V{constructor(t,e,r){l(this,"$");l(this,"C");l(this,"M",new Map);l(this,"A",new Map);l(this,"F",0);this.$=t,this.C=this.U(e,r),this.R()}R(){const t=this.$.getProgramParameter(this.C,this.$.ACTIVE_UNIFORMS);for(let e=0;e<t;e++){const r=this.$.getActiveUniform(this.C,e);if(r){const h=r.name.replace(/\[0\]$/,""),n=this.$.getUniformLocation(this.C,h);n&&(this.M.set(h,n),this.A.set(h,{type:r.type,size:r.size}))}}}U(t,e){const r=this.S(this.$.VERTEX_SHADER,t),h=this.S(this.$.FRAGMENT_SHADER,e),n=this.$.createProgram();if(this.$.attachShader(n,r),this.$.attachShader(n,h),this.$.linkProgram(n),!this.$.getProgramParameter(n,this.$.LINK_STATUS)){const a=this.$.getProgramInfoLog(n);throw Error("Shader program link error: "+a)}return this.$.deleteShader(r),this.$.deleteShader(h),n}S(t,e){const r=this.$.createShader(t);if(this.$.shaderSource(r,e),this.$.compileShader(r),!this.$.getShaderParameter(r,this.$.COMPILE_STATUS)){const h=this.$.getShaderInfoLog(r);throw this.$.deleteShader(r),Error("Shader compilation error: "+h)}return r}k(){this.$.useProgram(this.C),this.P()}P(){this.F=0}L(t){for(const e in t)this.I(e,t[e])}I(t,e){var u,f;const r=this.M.get(t);if(!r)return;const h=this.A.get(t);if(!h)return;const{type:n,size:a}=h,c=this.$;if(e instanceof WebGLTexture){const d=this.F++;return c.uniform1i(r,d),c.activeTexture(c.TEXTURE0+d),void c.bindTexture(c.TEXTURE_2D,e)}if(e instanceof J){const d=this.F++;return c.uniform1i(r,d),c.activeTexture(c.TEXTURE0+d),void c.bindTexture(c.TEXTURE_2D,e.textures[0])}if(typeof e!="number")if(typeof e!="boolean")if(Array.isArray(e[0])){const d=e.flat(),g={[c.FLOAT_VEC2]:()=>c.uniform2fv(r,d),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,d),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,d)};(u=g[n])==null||u.call(g)}else{const d=e,g={[c.FLOAT]:()=>a>1?c.uniform1fv(r,d):c.uniform1f(r,d[0]),[c.FLOAT_VEC2]:()=>c.uniform2fv(r,d),[c.FLOAT_VEC3]:()=>c.uniform3fv(r,d),[c.FLOAT_VEC4]:()=>c.uniform4fv(r,d),[c.INT]:()=>a>1?c.uniform1iv(r,d):c.uniform1i(r,d[0]),[c.INT_VEC2]:()=>c.uniform2iv(r,d),[c.INT_VEC3]:()=>c.uniform3iv(r,d),[c.INT_VEC4]:()=>c.uniform4iv(r,d),[c.BOOL]:()=>c.uniform1iv(r,d),[c.FLOAT_MAT2]:()=>c.uniformMatrix2fv(r,!1,d),[c.FLOAT_MAT3]:()=>c.uniformMatrix3fv(r,!1,d),[c.FLOAT_MAT4]:()=>c.uniformMatrix4fv(r,!1,d)};(f=g[n])==null||f.call(g)}else c.uniform1i(r,e?1:0);else n===c.INT||n===c.BOOL?c.uniform1i(r,e):c.uniform1f(r,e)}get D(){return this.C}O(){this.$.deleteProgram(this.C)}}function bt(o,t,e,r){return 180*Math.atan2(r-t,e-o)/Math.PI}function Z(o,t,e,r){return Math.hypot(e-o,r-t)}function At(o){return(o%360+360)%360/360}function xt(o,t,e){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,e),o.bindTexture(o.TEXTURE_2D,null)}function it(o,t,e,r,h){o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,h)}function dt(o,t,e,r,h,n=0,a=WebGL2RenderingContext.FLOAT,c=!1){o.enableVertexAttribArray(t),o.vertexAttribPointer(t,e,a,c,r,h),o.vertexAttribDivisor(t,n)}function Lt(o,t,e,r,h){o.bindBuffer(t,e),o.bufferData(t,r,h),o.bindBuffer(t,null)}const rt=`#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 Us;uniform float Ut;uniform float Uu;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/Us)*2.0f;AA.y=-AA.y;float AB=y.z/Us.y;float AC=clamp(-AB*Ut,-0.99f,0.99f);if(Uu>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);}}`,j=class j{constructor(t,e,r=e,h=1,n={},a){l(this,"G");l(this,"W");l(this,"l");l(this,"$");l(this,"H");l(this,"K",[]);l(this,"Y",null);l(this,"j");l(this,"N");l(this,"X",null);l(this,"Z",new Map);var c;this.G=e,this.W=r,this.$=t,this.j=(c=8,Math.min(Math.max(h,1),c)),this.N=a,this.l={filter:"nearest",wrap:"clamp",format:"rgba",type:"unsigned_byte",depth:!0,...n},j.V||(j.V=new V(t,rt,`#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 u=t.getParameter(t.MAX_DRAW_BUFFERS),f=t.getParameter(t.MAX_COLOR_ATTACHMENTS);this.j=Math.min(this.j,u,f),this.H=t.createFramebuffer(),this.q(),this.J(),this.l.depth&&this.tt()}q(){const t=this.$,e=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.j;c++){const u=t.createTexture();t.bindTexture(t.TEXTURE_2D,u),it(t,e,e,r,r),t.texImage2D(t.TEXTURE_2D,0,n,this.G,this.W,0,a,h,null),this.K.push(u)}t.bindTexture(t.TEXTURE_2D,null)}J(){const t=this.$;if(t.bindFramebuffer(t.FRAMEBUFFER,this.H),this.j===1)t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.K[0],0);else{const e=[];for(let r=0;r<this.j;r++){const h=t.COLOR_ATTACHMENT0+r;t.framebufferTexture2D(t.FRAMEBUFFER,h,t.TEXTURE_2D,this.K[r],0),e.push(h)}t.drawBuffers(e)}t.bindFramebuffer(t.FRAMEBUFFER,null)}tt(){const t=this.$;this.Y=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.Y),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT24,this.G,this.W),t.bindFramebuffer(t.FRAMEBUFFER,this.H),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.Y),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}st(t){xt(this.$,this.K[0],t)}resize(t,e){this.G=t,this.W=e,this.Z.clear();const r=this.$,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.K)r.bindTexture(r.TEXTURE_2D,c),r.texImage2D(r.TEXTURE_2D,0,n,this.G,this.W,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.G,this.W),r.bindRenderbuffer(r.RENDERBUFFER,null))}readPixels(t){const e=this.Z.get(t);if(e)return e;const r=this.$,h=this.G,n=this.W,a=new Uint8Array(h*n*4),c=r.getParameter(r.READ_FRAMEBUFFER_BINDING);r.bindFramebuffer(r.READ_FRAMEBUFFER,this.H),r.readBuffer(r.COLOR_ATTACHMENT0+t),r.readPixels(0,0,h,n,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.READ_FRAMEBUFFER,c);const u=4*h,f=new Uint8Array(a.length);for(let d=0;d<n;d++){const g=(n-1-d)*u,m=d*u;f.set(a.subarray(g,g+u),m)}return this.Z.set(t,f),f}begin(){const t=this.$;this.Z.clear(),this.N.it(),this.N.et(this.H,this.G,this.W),this.l.depth&&t.clear(t.DEPTH_BUFFER_BIT),this.N.state.rt()}end(){this.N.state.nt(),this.N.ot();const t=this.N.ht();this.N.et(t.framebuffer,t.viewport[2],t.viewport[3])}ct(){return this.X||this.lt(),this.X}lt(){if(!this.N)return;const t={Uc:this.K[0],Ud:this.K[1],Ue:this.K[2],Uf:[this.G,this.W]},e=j.V;this.X=this.N.ft.ut(e,t,!0)}O(){const t=this.$;t.deleteFramebuffer(this.H);for(const e of this.K)t.deleteTexture(e);this.Y&&t.deleteRenderbuffer(this.Y)}get width(){return this.G}get height(){return this.W}get textures(){return this.K}get attachmentCount(){return this.j}};l(j,"V",null);let J=j;const Ct=new WeakMap;function gt(o,t){Ct.set(o,t)}function Ft(o){return Ct.get(o)}function G(o,t,e,r,h=255){o[0]=t/255,o[1]=(e??t)/255,o[2]=(r??t)/255,o[3]=h/255}class st{constructor(){l(this,"dt",1);l(this,"_t",0);l(this,"gt",0);l(this,"vt",0);l(this,"yt",0);l(this,"wt",0);l(this,"bt",0);l(this,"$t",[0,0,0]);l(this,"Ct",[1,1,1,1]);l(this,"Mt",[0,0,0,1]);l(this,"xt",!1);l(this,"At",!1);l(this,"Ft",!1);l(this,"Tt",0);l(this,"Rt",[0,0,0,1]);l(this,"Et",!1);l(this,"St",[]);l(this,"kt",[])}static Pt(){return{Lt:1,It:0,zt:0,Dt:0,yt:0,wt:0,bt:0,Tt:0,Ot:!1,Bt:!1,Ft:!1,Et:!1,Gt:[0,0,0],Wt:[1,1,1,1],Ht:[0,0,0,1]}}Kt(t){t.Lt=this.dt,t.It=this._t,t.zt=this.gt,t.Dt=this.vt,t.yt=this.yt,t.wt=this.wt,t.bt=this.bt,t.Ot=this.xt,t.Bt=this.At,t.Ft=this.Ft,t.Tt=this.Tt,t.Et=this.Et,t.Gt[0]=this.$t[0],t.Gt[1]=this.$t[1],t.Gt[2]=this.$t[2],t.Wt[0]=this.Ct[0],t.Wt[1]=this.Ct[1],t.Wt[2]=this.Ct[2],t.Wt[3]=this.Ct[3],t.Ht[0]=this.Mt[0],t.Ht[1]=this.Mt[1],t.Ht[2]=this.Mt[2],t.Ht[3]=this.Mt[3]}Yt(t){this.dt=t.Lt,this._t=t.It,this.gt=t.zt,this.vt=t.Dt,this.yt=t.yt,this.wt=t.wt,this.bt=t.bt,this.xt=t.Ot,this.At=t.Bt,this.Ft=t.Ft,this.Tt=t.Tt,this.Et=t.Et,this.$t[0]=t.Gt[0],this.$t[1]=t.Gt[1],this.$t[2]=t.Gt[2],this.Ct[0]=t.Wt[0],this.Ct[1]=t.Wt[1],this.Ct[2]=t.Wt[2],this.Ct[3]=t.Wt[3],this.Mt[0]=t.Ht[0],this.Mt[1]=t.Ht[1],this.Mt[2]=t.Ht[2],this.Mt[3]=t.Ht[3]}rt(){let t=this.kt.pop();t||(t=st.Pt()),this.Kt(t),this.St.push(t)}nt(){const t=this.St.pop();t?(this.Yt(t),this.kt.push(t)):console.warn("pop() called without matching push()")}jt(t){this.Kt(t)}Nt(t){this.dt=Math.abs(t)}Xt(){this._t=0,this.gt=0,this.vt=0,this.yt=0,this.wt=0,this.bt=0,this.Et=!1}Zt(t){t!==0&&(this.yt+=t*Math.PI/180)}Vt(t){t!==0&&(this.wt+=t*Math.PI/180)}qt(t){t!==0&&(this.bt+=t*Math.PI/180)}Jt(t=0,e=0,r=0){t===0&&e===0&&r===0||(this._t+=t,this.gt+=e,this.vt+=r)}Qt(t){this.Jt(t,0,0)}ts(t){this.Jt(0,t,0)}ss(t){this.Jt(0,0,t)}es(t){this.$t[0]=t[0],this.$t[1]=t[1],this.$t[2]=t[2]}rs(t,e,r,h=255){G(this.Ct,t,e,r,h)}ns(t,e,r,h=255){G(this.Mt,t,e,r,h)}hs(t){this.xt=t}cs(t){this.At=t}ls(t){this.Ft=t}us(t){this.Tt=At(t)}fs(t,e,r,h){G(this.Rt,t,e,r,h)}ds(t){this.Et=t}get canvasBackgroundColor(){return this.Rt}get useOrtho(){return this.Et}get rotationX(){return this.yt}get rotationY(){return this.wt}get rotationZ(){return this.bt}}const pt=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]),Y={ps:16,_s:WebGL2RenderingContext.TRIANGLES,gs:{vs:{size:2,offset:0},ws:{size:2,offset:8}}};class Wt{constructor(t){l(this,"$");l(this,"bs");l(this,"$s");this.$=t,this.bs=t.createBuffer(),this.$s=new Float32Array(pt.length)}Cs(t,e,r,h){const n=this.$,a=Ft(this.$),c=a[2],u=a[3],f=t/c*2-1,d=(t+r)/c*2-1,g=1-(e+h)/u*2,m=1-e/u*2,v=pt,y=this.$s;for(let p=0;p<v.length;p+=4){const w=v[p],E=v[p+1],R=v[p+2],T=v[p+3],x=f+(w+.5)*(d-f),b=g+(E+.5)*(m-g);y[p]=x,y[p+1]=b,y[p+2]=R,y[p+3]=T}n.bindBuffer(n.ARRAY_BUFFER,this.bs),n.bufferData(n.ARRAY_BUFFER,y,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)}O(){this.$.deleteBuffer(this.bs)}}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 jt={rectangle:2,line:2,ellipse:2,triangle:2,arc:3,bezier_curve:4};class kt{constructor(t){l(this,"$");l(this,"Ms",new Map);this.$=t}As(t,e,r,h){const n=this.$;let a=this.Ms.get(t);a||(a=new Map,this.Ms.set(t,a));let c=a.get(e)||null;if(!c){c=n.createVertexArray(),a.set(e,c),n.bindVertexArray(c),n.bindBuffer(n.ARRAY_BUFFER,h);const u=n.getAttribLocation(t,"A0");u!==-1&&dt(n,u,r.gs.vs.size,r.ps,r.gs.vs.offset,0,n.FLOAT,!1);const f=n.getAttribLocation(t,"A1");f!==-1&&dt(n,f,r.gs.ws.size,r.ps,r.gs.ws.offset,0,n.FLOAT,!1)}n.bindVertexArray(c)}Fs(){this.$.bindVertexArray(null)}O(){for(const[,t]of this.Ms)for(const[,e]of t)e&&this.$.deleteVertexArray(e)}}const D=class D{static Ts(t,e,r=0){const h=e||new Float32Array(D.FLOATS_PER_INSTANCE);let n=r;h[n++]=t.vs[0],h[n++]=t.vs[1],h[n++]=t.Rs[0],h[n++]=t.Rs[1],h[n++]=t.Gt[0],h[n++]=t.Gt[1],h[n++]=t.Gt[2],h[n++]=t.Wt[0],h[n++]=t.Wt[1],h[n++]=t.Wt[2],h[n++]=t.Wt[3],h[n++]=t.Ht[0],h[n++]=t.Ht[1],h[n++]=t.Ht[2],h[n++]=t.Ht[3],h[n++]=t.Es[0],h[n++]=t.Es[1],h[n++]=t.Es[2],h[n++]=t.Tt;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 c=t.ks;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.Ps,f=t.Ls,d=t.Is,g=t.zs,m=t.Ds,v=!(!f||!d);return v?(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]):!v&&!!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.Os??0,h[n++]=t.Bs??0,h[n++]=t.Gs??0,h}static Ws(t,e){const r=t.length*D.FLOATS_PER_INSTANCE,h=e||new Float32Array(r);for(let n=0;n<t.length;n++){const a=n*D.FLOATS_PER_INSTANCE;D.Ts(t[n],h,a)}return h}};l(D,"BYTES_PER_INSTANCE",144),l(D,"FLOATS_PER_INSTANCE",36);let S=D;const P=class P{};l(P,"STRIDE",S.BYTES_PER_INSTANCE),l(P,"ATTRIBUTES",{A2:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:0,divisor:1},A3:{location:-1,size:2,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:8,divisor:1},A4:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:16,divisor:1},A5:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:28,divisor:1},A6:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:44,divisor:1},A7:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:60,divisor:1},A8:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:76,divisor:1},A9:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:88,divisor:1},Aa:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:100,divisor:1},Ab:{location:-1,size:4,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:116,divisor:1},Ac:{location:-1,size:3,type:WebGL2RenderingContext.FLOAT,normalized:!1,stride:P.STRIDE,offset:132,divisor:1}});let q=P;class Kt{constructor(t=1e3,e=1.5){l(this,"Hs");l(this,"Ks");l(this,"Ys");l(this,"js",0);l(this,"Ns",0);this.Ks=t,this.Ys=e;const r=t*S.FLOATS_PER_INSTANCE;this.Hs=new Float32Array(r)}Xs(t){if(t<=this.Ks)return;const e=Math.ceil(t*this.Ys),r=this.Ks;this.Ks=e;const h=e*S.FLOATS_PER_INSTANCE,n=new Float32Array(h),a=r*S.FLOATS_PER_INSTANCE;n.set(this.Hs.subarray(0,Math.min(a,this.js))),this.Hs=n}Zs(){return{buffer:this.Hs,offset:this.js}}Vs(t){this.js+=t,this.Ns++}qs(){this.js=0,this.Ns=0}Js(t=0,e){return this.Hs.subarray(t,e??this.js)}get Qs(){return this.Ns}get ti(){return this.Ks}get si(){return this.js}get ii(){return this.Ns===0}}class Vt{constructor(t){l(this,"Hs");this.Hs=t}ei(t){this.Hs.Xs(this.Hs.Qs+1);const{buffer:e,offset:r}=this.Hs.Zs();e[r+0]=t.x,e[r+1]=t.y,e[r+2]=t.width,e[r+3]=t.height,e[r+4]=t.char0,e[r+5]=t.char1,e[r+6]=t.char2,e[r+7]=t.r1,e[r+8]=t.g1,e[r+9]=t.b1,e[r+10]=t.a1,e[r+11]=t.r2,e[r+12]=t.g2,e[r+13]=t.b2,e[r+14]=t.a2,e[r+15]=t.invert,e[r+16]=t.flipX,e[r+17]=t.flipY,e[r+18]=t.charRot,e[r+19]=t.translationX,e[r+20]=t.translationY,e[r+21]=t.translationZ,e[r+22]=t.rotationX,e[r+23]=t.rotationY,e[r+24]=t.rotationZ;const h=t.curveParams0,n=t.curveParams1;return e[r+25]=h[0],e[r+26]=h[1],e[r+27]=h[2],e[r+28]=h[3],e[r+29]=n[0],e[r+30]=n[1],e[r+31]=n[2],e[r+32]=n[3],e[r+33]=t.depth,e[r+34]=t.baseZ,e[r+35]=t.geometryType,this.Hs.Vs(S.FLOATS_PER_INSTANCE),this.Hs.Qs-1}get Qs(){return this.Hs.Qs}}class Zt{constructor(t,e=1e3){l(this,"$");l(this,"ri",null);l(this,"ni",0);l(this,"oi",new Map);this.$=t,this.hi(e)}hi(t){const e=this.$;this.ri&&e.deleteBuffer(this.ri),this.ri=e.createBuffer();const r=t*S.BYTES_PER_INSTANCE;Lt(e,e.ARRAY_BUFFER,this.ri,r,e.DYNAMIC_DRAW),this.ni=t}ai(t){this.hi(t)}get ti(){return this.ni}ci(t,e){if(e===0)return;const r=this.$;r.bindBuffer(r.ARRAY_BUFFER,this.ri);const h=e*S.FLOATS_PER_INSTANCE;r.bufferSubData(r.ARRAY_BUFFER,0,t,0,h)}li(t){let e=this.oi.get(t);if(!e){e=new Map;const r=this.$;for(const h in q.ATTRIBUTES){const n=r.getAttribLocation(t,h);n!==-1&&e.set(h,n)}this.oi.set(t,e)}return e}ui(t){const e=this.$,r=t.D,h=this.li(r);for(const[n,a]of h){const c=q.ATTRIBUTES[n];c&&dt(e,a,c.size,c.stride,c.offset,c.divisor,c.type,c.normalized)}}fi(t){const e=this.$,r=this.li(t.D);for(const[h,n]of r)q.ATTRIBUTES[h]&&(e.disableVertexAttribArray(n),e.vertexAttribDivisor(n,0))}O(){this.ri&&(this.$.deleteBuffer(this.ri),this.ri=null),this.oi.clear()}}class Jt{constructor(t,e=1e3,r=1.5){l(this,"$");l(this,"Hs");l(this,"di");l(this,"pi");this.$=t,this.Hs=new Kt(e,r),this.di=new Vt(this.Hs),this.pi=new Zt(t,e)}_i(t){var h,n,a,c,u,f,d,g,m,v;const e=[0,0,0,0],r=[0,0,0,0];return t.Ls&&t.Is?(e[0]=((h=t.zs)==null?void 0:h[0])??0,e[1]=((n=t.zs)==null?void 0:n[1])??0,e[2]=((a=t.Ds)==null?void 0:a[0])??0,e[3]=((c=t.Ds)==null?void 0:c[1])??0,r[0]=t.Ls[0],r[1]=t.Ls[1],r[2]=t.Is[0],r[3]=t.Is[1]):t.Ps&&(e[0]=t.Ps[0],e[1]=t.Ps[1]),this.ei({x:t.vs[0],y:t.vs[1],width:t.Rs[0],height:t.Rs[1],char0:t.Gt[0],char1:t.Gt[1],char2:t.Gt[2],r1:t.Wt[0],g1:t.Wt[1],b1:t.Wt[2],a1:t.Wt[3],r2:t.Ht[0],g2:t.Ht[1],b2:t.Ht[2],a2:t.Ht[3],invert:t.Es[0],flipX:t.Es[1],flipY:t.Es[2],charRot:t.Tt,translationX:((u=t.Ss)==null?void 0:u[0])??0,translationY:((f=t.Ss)==null?void 0:f[1])??0,translationZ:((d=t.Ss)==null?void 0:d[2])??0,rotationX:((g=t.ks)==null?void 0:g[0])??0,rotationY:((m=t.ks)==null?void 0:m[1])??0,rotationZ:((v=t.ks)==null?void 0:v[2])??0,curveParams0:e,curveParams1:r,depth:t.Os||0,baseZ:t.Bs||0,geometryType:t.Gs||0})}ei(t){const e=this.di.ei(t);return this.Hs.ti>this.pi.ti&&this.pi.ai(this.Hs.ti),e}get gi(){return this.Hs.Qs}get ii(){return this.Hs.ii}mi(){this.Hs.qs()}ui(t){const e=this.Hs.Qs;if(e===0)return;const r=this.Hs.Js();this.pi.ci(r,e),this.pi.ui(t)}fi(t){this.pi.fi(t)}Cs(t,e){const r=this.Hs.Qs;r!==0&&this.$.drawArraysInstanced(t,0,e,r)}O(){this.pi.O()}}class X{constructor(t,e,r,h){l(this,"$");l(this,"yi");l(this,"wi");l(this,"bi");l(this,"$i",null);this.$=t,this.yi=e,this.wi=r,this.bi=h;const n=this.$.createBuffer();Lt(this.$,this.$.ARRAY_BUFFER,n,this.bi.Ci,this.$.STATIC_DRAW),this.$i=n}get type(){return this.wi}get unitGeometry(){return this.bi}get unitBuffer(){return this.$i}get batch(){return this.yi}Mi(){this.yi.mi()}xi(){return!this.yi.ii}O(){this.yi.O(),this.$.deleteBuffer(this.$i)}Ai(t,e,r){return this.yi._i(t)}Fi(t,e,r,h,n,a){const c=n.It??0,u=n.zt??0,f=n.Dt??0,d=n.yt??0,g=n.wt??0,m=n.bt??0,v=[0,0,0,0],y=[0,0,0,0];a&&(a.bezStartX!==void 0&&a.bezStartY!==void 0&&a.bezEndX!==void 0&&a.bezEndY!==void 0?(v[0]=a.cp1x??0,v[1]=a.cp1y??0,v[2]=a.cp2x??0,v[3]=a.cp2y??0,y[0]=a.bezStartX??0,y[1]=a.bezStartY??0,y[2]=a.bezEndX??0,y[3]=a.bezEndY??0):a.arcStart===void 0&&a.arcStop===void 0||(v[0]=a.arcStart??0,v[1]=a.arcStop??0));const p={x:t,y:e,width:r,height:h,char0:n.Gt[0],char1:n.Gt[1],char2:n.Gt[2],r1:n.Wt[0],g1:n.Wt[1],b1:n.Wt[2],a1:n.Wt[3],r2:n.Ht[0],g2:n.Ht[1],b2:n.Ht[2],a2:n.Ht[3],invert:n.Ft?1:0,flipX:n.Ot?1:0,flipY:n.Bt?1:0,charRot:n.Tt,translationX:c,translationY:u,translationZ:f,rotationX:d,rotationY:g,rotationZ:m,curveParams0:v,curveParams1:y,depth:(a==null?void 0:a.depth)??0,baseZ:(a==null?void 0:a.baseZ)??0,geometryType:jt[this.wi]??0};return this.yi.ei(p)}}const qt={Ci:pt,Ti:6,...Y},Qt={Ci: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]),Ti:6,...Y},te={Ci:function(o=32){const t=[],e=2*Math.PI/o;for(let r=0;r<o;r++){const h=r*e,n=(r+1)%o*e,a=Math.cos(h),c=Math.sin(h),u=.5*(a+1),f=.5*(c+1),d=Math.cos(n),g=Math.sin(n),m=.5*(d+1),v=.5*(g+1);t.push(0,0,.5,.5,a,c,u,f,d,g,m,v)}return new Float32Array(t)}(32),Ti:96,...Y};let ee={Ci:function(o){const t=[];for(let e=0;e<o;e++){const r=e/o,h=(e+1)/o;t.push(r,0,r,0,r,1,r,1,h,1,h,1)}return new Float32Array(t)}(32),Ti:96,...Y};const ie={Ci:new Float32Array([0,0,0,0,1,0,1,0,.5,1,.5,1]),Ti:3,...Y},re={Ci:function(o=16){const t=[];for(let e=0;e<o;e++){const r=e/o,h=(e+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),Ti:96,...Y},se={[C.RECTANGLE]:class extends X{constructor(o,t){super(o,t,C.RECTANGLE,qt)}_i(o,t){return this.Fi(0,0,o.width,o.height,t)}},[C.LINE]:class extends X{constructor(o,t){super(o,t,C.LINE,Qt)}_i(o,t){const e=o.x2-o.x1,r=o.y2-o.y1,h=Math.hypot(e,r),n=Math.atan2(r,e),a=t.Lt||1,c=o.x1+e/2-h/2,u=o.y1+r/2,f={...t,bt:(t.bt||0)+n};return this.Fi(c,u,h,a,f)}},[C.ELLIPSE]:class extends X{constructor(o,t){super(o,t,C.ELLIPSE,te)}_i(o,t){return this.Fi(0,0,o.width,o.height,t)}},[C.ARC]:class extends X{constructor(o,t){super(o,t,C.ARC,ee)}_i(o,t){const e=o.start*Math.PI/180,r=o.stop*Math.PI/180;return this.Fi(0,0,o.width,o.height,t,{arcStart:e,arcStop:r})}},[C.TRIANGLE]:class extends X{constructor(o,t){super(o,t,C.TRIANGLE,ie)}_i(o,t){const e=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-e,a=Math.max(o.y1,o.y2,o.y3)-h;return this.Fi(e,h,n,a,t)}},[C.BEZIER_CURVE]:class extends X{constructor(o,t){super(o,t,C.BEZIER_CURVE,re)}_i(o,t){return this.Fi(0,0,1,t.Lt||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,"$");l(this,"Ri");l(this,"Ei");this.$=t,this.Ei=new kt(t),this.Ri=new Map;for(const e of Object.values(C)){const r=new Jt(t),h=new se[e](t,r);this.Ri.set(e,h)}}Si(t){const e=this.ki(t);for(const r of e)this.Pi(r)}ki(t){const e=[];let r=null,h=null,n=null;for(const a of t)h!==a.material||n!==a.type?(r&&r.length>0&&e.push({material:h,type:n,commands:r}),r=[a],h=a.material,n=a.type):r.push(a);return r&&r.length>0&&e.push({material:h,type:n,commands:r}),e}Pi(t){const{material:e,type:r,commands:h}=t,n=this.Ri.get(r);e.shader.k(),e.shader.L(e.uniforms);const a=Ft(this.$),c=h.length>0&&h[0].state.Et;e.shader.L({Uv:a[2]/a[3],Us:[a[2],a[3]],Ut:1,Uu:c?1:0}),n.Mi();for(const u of h)n._i(u.params,u.state);if(n.xi()){const u=n.unitGeometry,f=n.unitBuffer;try{this.Ei.As(e.shader.D,r+"",u,f),n.batch.ui(e.shader),n.batch.Cs(u._s,u.Ti)}finally{n.batch.fi(e.shader),this.Ei.Fs(),n.Mi()}}}O(){for(const t of this.Ri.values())t.O();this.Ri.clear(),this.Ei.O()}}function Ut(o){let t=0;for(let e=0;e<o.length;e++)t=(t<<5)-t+o.charCodeAt(e),t&=t;return t}function Mt(o){return Ut(o+"")}function Q(o,t){return(o<<5)-o+t}class he{constructor(t){l(this,"$");l(this,"Li",0);l(this,"Ii");l(this,"zi");l(this,"Di",new Map);this.$=t,this.Ii=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.zi={id:this.Li++,shader:this.Ii,uniforms:Object.freeze({}),hash:this.Oi(this.Ii,{}),isBuiltIn:!0}}get Bi(){return this.zi}ut(t,e={},r=!1){const h=this.Oi(t,e),n=this.Di.get(h);if(n)return n;const a={id:this.Li++,shader:t,uniforms:Object.freeze({...e}),hash:h,isBuiltIn:r};return this.Di.set(h,a),a}Gi(t,e={}){return{id:this.Li++,shader:t,uniforms:Object.freeze({...e}),hash:0,isBuiltIn:!1}}Oi(t,e){const r=Mt(t.D),h=function(n,a){let c=0;const u=Object.keys(n).sort();for(const f of u)c=Q(c,Ut(f)),c=Q(c,a(n[f]));return c}(e,this.Wi.bind(this));return Q(r,h)}Wi(t){return typeof t=="number"||typeof t=="boolean"?function(e){return typeof e=="boolean"?e?1:0:Math.floor(e)}(t):Array.isArray(t)?function(e){let r=0;const h=Array.isArray(e[0])?e.flat():e;for(const n of h)r=Q(r,typeof n=="number"?n:0);return r}(t):t instanceof Float32Array||t instanceof Int32Array?function(e){let r=0;const h=Math.min(e.length,16);for(let n=0;n<h;n++)r=Q(r,e[n]);return r}(t):t instanceof WebGLTexture?Mt(t):0}O(){this.Ii!=this.Ii&&this.Ii.O(),this.Ii.O(),this.Di.clear()}}class oe{constructor(){l(this,"Hi",[]);l(this,"Ki",1);l(this,"Rs",0)}Yi(t,e){if(this.Rs>=this.Hi.length){const h={id:this.Ki++,type:t,params:{},state:st.Pt(),material:e};this.Hi.push(h)}const r=this.Hi[this.Rs];return r.id=this.Ki++,r.type=t,r.material=e,this.Rs++,r}ji(t,e,r){const h=this.Yi(C.RECTANGLE,r),n=h.params;return n.width=t.width,n.height=t.height,e.jt(h.state),h.id}Ni(t,e,r){const h=this.Yi(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,e.jt(h.state),h.id}Xi(t,e,r){const h=this.Yi(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,e.jt(h.state),h.id}Zi(t,e,r){const h=this.Yi(C.ARC,r),n=h.params;return n.width=t.width,n.height=t.height,n.start=t.start,n.stop=t.stop,e.jt(h.state),h.id}Vi(t,e,r){const h=this.Yi(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,e.jt(h.state),h.id}qi(t,e,r){const h=this.Yi(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,e.jt(h.state),h.id}mi(){this.Rs=0}[Symbol.iterator](){let t=0;const e=this.Rs,r=this.Hi;return{next:()=>t<e?{value:r[t++],done:!1}:{value:void 0,done:!0}}}}class ae{constructor(t){l(this,"$");l(this,"Ji",null);l(this,"Qi");l(this,"ft");l(this,"te");l(this,"se");l(this,"ie");l(this,"ee",null);l(this,"re",{});l(this,"ne",[]);l(this,"oe",[]);l(this,"he",null);l(this,"ae",[0,0,0,0]);this.$=t,t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clearDepth(1),t.depthMask(!0),t.disable(t.CULL_FACE),this.te=new st,this.ft=new he(t),this.se=new oe,this.Qi=new ne(t),this.ie=new Wt(t);const e=[0,0,t.canvas.width,t.canvas.height];gt(t,e),this.ne.push(null),this.oe.push(e),this.he=null,this.ae=e}it(){this.ne.push(this.he),this.oe.push([...this.ae])}ht(){return{framebuffer:this.ne.pop()??null,viewport:this.oe.pop()??[0,0,this.$.canvas.width,this.$.canvas.height]}}et(t,e,r){const h=this.$;this.he!==t&&(h.bindFramebuffer(h.FRAMEBUFFER,t),this.he=t);const n=[0,0,e,r];this.ae[0]===n[0]&&this.ae[1]===n[1]&&this.ae[2]===n[2]&&this.ae[3]===n[3]||(h.viewport(...n),gt(h,n),this.ae=n)}ce(t){this.Ji!==t&&(this.Ji=t,t.k())}le(t,e){return new V(this.$,t,e)}ue(t){this.ee=t,t&&(this.re={})}I(t,e){this.re[t]=e}fe(t){Object.assign(this.re,t)}de(t){return new V(this.$,rt,t)}pe(t,e,r){this.se.ji({width:e??t.width,height:r??t.height},this.te,t.ct())}_e(t,e,r,h){this.ie.Cs(t,e,r,h)}ge(t,e){if(this.ee){const r=this.ft.Gi(this.ee,this.re);this.se.ji({width:t,height:e},this.te,r),this.ee=null,this.re={}}else this.se.ji({width:t,height:e},this.te,this.ft.Bi)}ve(t,e,r,h){this.se.Ni({x1:t,y1:e,x2:r,y2:h},this.te,this.ft.Bi)}me(t,e){this.se.Xi({width:t,height:e},this.te,this.ft.Bi)}ye(t,e,r,h,n,a){this.se.Vi({x1:t,y1:e,x2:r,y2:h,x3:n,y3:a},this.te,this.ft.Bi)}we(t,e,r,h,n,a,c,u){this.se.qi({x1:t,y1:e,cp1x:r,cp1y:h,cp2x:n,cp2y:a,x2:c,y2:u},this.te,this.ft.Bi)}be(t,e,r,h){this.se.Zi({width:t,height:e,start:r,stop:h},this.te,this.ft.Bi)}$e(t,e,r=1,h={}){return new J(this.$,t,e,r,h,this)}Ce(t,e=t,r=t,h=255){this.te.fs(t,e??t,r??t,h);const[n,a,c,u]=this.te.canvasBackgroundColor;this.mi(n,a,c,u)}mi(t=0,e=0,r=0,h=0){this.$.clearColor(t,e,r,h),this.$.clear(this.$.COLOR_BUFFER_BIT)}Me(){const t=[0,0,this.$.canvas.width,this.$.canvas.height];this.$.viewport(...t),gt(this.$,t),this.ae=t,this.oe.length>0&&(this.oe[0]=t)}ot(){const t=this.se;this.Qi.Si(t),t.mi()}O(){this.ft.O(),this.Qi.O(),this.ie.O()}get context(){return this.$}get state(){return this.te}}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,e){const r=[];for(let h=0;h<e;h++)r.push(F.readUshort(o,t+2*h));return r},readUint(o,t){const e=F.t.uint8;return e[3]=o[t],e[2]=o[t+1],e[1]=o[t+2],e[0]=o[t+3],F.t.uint32[0]},readASCII(o,t,e){let r="";for(let h=0;h<e;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,e){o[t]=e>>>8&255,o[t+1]=255&e}function O(o,t,e){o[t]=e>>>24&255,o[t+1]=e>>>16&255,o[t+2]=e>>>8&255,o[t+3]=255&e}function ce(o,t,e){for(let r=0;r<e.length;r++)o[t+r]=255&e.charCodeAt(r)}function mt(o,t,e){const r=t+e;let h=0;const n=F.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 e=this.bitbuf&(1<<t)-1;return this.bitbuf>>>=t,this.bitcnt-=t,e}alignToByte(){this.bitbuf=0,this.bitcnt=0}get offset(){return this.p}}function tt(o){let t=32,e=0;for(const c of o)c&&(c<t&&(t=c),c>e&&(e=c));if(e===0)return{min:0,max:0,table:new Map};const r=new Uint32Array(e+1);for(const c of o)c&&r[c]++;const h=new Uint32Array(e+1);let n=0;r[0]=0;for(let c=1;c<=e;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:e,table:a}}function vt(o,t){let e=0;for(let r=1;r<=t.max;r++){e|=o.readBits(1)<<r-1;const h=t.table.get(r);if(h&&e<h.length){const n=h[e];if(n!==void 0)return n}}throw Error("Invalid Huffman code")}function ue(o,t){let e=0;for(let r=0;r<t;r++)e=e<<1|1&o,o>>>=1;return e>>>0}function fe(o){if(o.length<2)throw Error("ZLIB data too short");const t=o[0],e=o[1];if((15&t)!=8)throw Error("Unsupported ZLIB compression method");if(((t<<8)+e)%31!=0)throw Error("Bad ZLIB header check");let r=2;32&e&&(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 m=n.readBits(2);if(m===0){n.alignToByte();const v=n.readBits(16);if((65535&(65535^v))!==n.readBits(16))throw Error("DEFLATE uncompressed LEN/NLEN mismatch");for(let y=0;y<v;y++)a.push(n.readBits(8))}else{if(m!==1&&m!==2)throw Error("Unsupported DEFLATE type");{let v,y;if(m===1){const p=Array(288).fill(0);for(let w=0;w<=143;w++)p[w]=8;for(let w=144;w<=255;w++)p[w]=9;for(let w=256;w<=279;w++)p[w]=7;for(let w=280;w<=287;w++)p[w]=8;v=tt(p),y=tt(Array(32).fill(5))}else{const p=n.readBits(5)+257,w=n.readBits(5)+1,E=n.readBits(4)+4,R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T=Array(19).fill(0);for(let M=0;M<E;M++)T[R[M]]=n.readBits(3);const x=tt(T),b=[];for(;b.length<p+w;){const M=vt(n,x);if(M<=15)b.push(M);else if(M===16){const B=n.readBits(2)+3,N=b[b.length-1]||0;for(let ut=0;ut<B;ut++)b.push(N)}else if(M===17){const B=n.readBits(3)+3;for(let N=0;N<B;N++)b.push(0)}else{if(M!==18)throw Error("Invalid code length symbol");{const B=n.readBits(7)+11;for(let N=0;N<B;N++)b.push(0)}}}const U=b.slice(0,p),_=b.slice(p,p+w);v=tt(U),y=tt(_)}for(;;){const p=vt(n,v);if(p<256)a.push(p);else{if(p===256)break;if(p>256&&p<286){const w=p-257;let E=c[w];const R=u[w];R&&(E+=n.readBits(R));const T=vt(n,y);if(T>=30)throw Error("Invalid distance symbol");let x=f[T];const b=d[T];b&&(x+=n.readBits(b));const U=a.length-x;if(U<0)throw Error("Invalid distance");for(let _=0;_<E;_++)a.push(a[U+_]||0)}else if(p===286||p===287)throw Error("Reserved length symbol")}}}}}}(new le(o.subarray(r)),h),new Uint8Array(h)}function de(o){const t=F,e=new Uint8Array(o);if(t.readASCII(e,0,4)!=="wOFF")throw Error("Invalid WOFF signature");const r=t.readUint(e,4),h=t.readUshort(e,12),n=t.readUint(e,16),a=[];let c=44;for(let E=0;E<h;E++){const R=t.readASCII(e,c,4),T=t.readUint(e,c+4),x=t.readUint(e,c+8),b=t.readUint(e,c+12),U=t.readUint(e,c+16);a.push({tag:R,offset:T,compLength:x,origLength:b,checksum:U}),c+=20}for(const E of a){const R=new Uint8Array(e.buffer,E.offset,E.compLength);if(E.compLength===E.origLength)E.data=new Uint8Array(R);else if(E.data=fe(R),E.data.length!==E.origLength)if(E.data.length<E.origLength){const T=new Uint8Array(E.origLength);T.set(E.data),E.data=T}else E.data=E.data.subarray(0,E.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 v=12+16*u;const y={};for(const E of a)y[E.tag]=v,v=nt(v+E.data.length);const p=new Uint8Array(Math.max(n||0,v));O(p,0,r),ht(p,4,u),ht(p,6,g),ht(p,8,d),ht(p,10,m);let w=12;for(const E of a){ce(p,w,E.tag),w+=4;let R=E.data;if(E.tag==="head"&&R.length>=12){const T=new Uint8Array(R);O(T,8,0),O(p,w,mt(T,0,nt(T.length))),w+=4}else O(p,w,mt(R,0,nt(R.length))),w+=4;O(p,w,y[E.tag]),w+=4,O(p,w,E.data.length),w+=4}for(const E of a){const R=y[E.tag];p.set(E.data,R)}if(a.find(E=>E.tag==="head")){const E=y.head,R=function(T,x){const b=x+8,U=[T[b],T[b+1],T[b+2],T[b+3]];O(T,b,0);const _=2981146554-(mt(T,0,nt(T.length))>>>0)>>>0;return T[b]=U[0],T[b+1]=U[1],T[b+2]=U[2],T[b+3]=U[3],_>>>0}(p,E);O(p,E+8,R)}return p.buffer}const ge={parseTab(o,t,e){const r={tables:[],ids:{},off:t};o=new Uint8Array(o.buffer,t,e),t=0;const h=F,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 m=`p${f}e${d}`;let v=c.indexOf(g);if(v===-1){let y;v=r.tables.length,c.push(g);const p=n(o,g);y=p===4?this.parse4(o,g):p===12?this.parse12(o,g):{format:p},r.tables.push(y)}r.ids[m]=v}return r},parse4(o,t){const e=F,r=e.readUshort,h=e.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(e.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 e=F.readUint;e(o,t+=4),e(o,t+=4);const r=e(o,t+=4);t+=4;const h=new Uint32Array(3*r);for(let n=0;n<3*r;n+=3)h[n]=e(o,t+(n<<2)),h[n+1]=e(o,t+(n<<2)+4),h[n+2]=e(o,t+(n<<2)+8);return{format:12,groups:h}}},pe={parseTab(o,t,e){const r=F;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)}}},me={parseTab(o,t,e){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 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}},ve={parseTab(o,t,e,r){const h=F,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:pe,hhea:me,maxp:{parseTab(o,t,e){const r=F;return r.readUint(o,t),t+=4,{numGlyphs:r.readUshort(o,t)}}},hmtx:ve,loca:{parseTab(o,t,e,r){const h=F,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,e,r){const h=[],n=r.maxp.numGlyphs;for(let a=0;a<n;a++)h.push(null);return h},xe(o,t){const e=F,r=o.Ae,h=o.loca;if(h[t]===h[t+1])return null;const n=z.findTable(r,"glyf",o.Fe);if(!n)return null;let a=n[0]+h[t];const c={};if(c.noc=e.readShort(r,a),a+=2,c.xMin=e.readShort(r,a),a+=2,c.yMin=e.readShort(r,a),a+=2,c.xMax=e.readShort(r,a),a+=2,c.yMax=e.readShort(r,a),a+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(let m=0;m<c.noc;m++)c.endPts.push(e.readUshort(r,a)),a+=2;const u=e.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 m=0;m<f;m++){const v=r[a];if(a++,c.flags.push(v),8&v){const y=r[a];a++;for(let p=0;p<y;p++)c.flags.push(v),m++}}c.xs=[];for(let m=0;m<f;m++){const v=c.flags[m],y=!!(16&v);2&v?(c.xs.push(y?r[a]:-r[a]),a++):y?c.xs.push(0):(c.xs.push(e.readShort(r,a)),a+=2)}c.ys=[];for(let m=0;m<f;m++){const v=c.flags[m],y=!!(32&v);4&v?(c.ys.push(y?r[a]:-r[a]),a++):y?c.ys.push(0):(c.ys.push(e.readShort(r,a)),a+=2)}let d=0,g=0;for(let m=0;m<f;m++)d+=c.xs[m],g+=c.ys[m],c.xs[m]=d,c.ys[m]=g}else c.parts=[],c.endPts=[],c.flags=[],c.xs=[],c.ys=[];return c}}},z={parse(o){const t=new Uint8Array(o);F.readASCII(t,0,4)==="wOFF"&&(o=de(o));const e=new Uint8Array(o),r=It,h={},n={Ae:e,Te:0,Fe:0};for(const a in r){const c=a,u=z.findTable(e,c,0);if(u){const[f,d]=u;let g=h[f];g==null&&(g=r[c].parseTab(e,f,d,n),h[f]=g),n[c]=g}}return[n]},findTable(o,t,e){const r=F,h=r.readUshort(o,e+4);let n=e+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:F};class ye{Re(t){var r;const e=[];return(r=t.cmap)!=null&&r.tables?(t.cmap.tables.forEach(h=>{if(h.format===4){const n=this.Ee(h);e.push(...n)}else if(h.format===12){const n=this.Se(h);e.push(...n)}}),[...new Set(e)]):[]}Ee(t){const e=[];if(!(t.startCount&&t.endCount&&t.idRangeOffset&&t.idDelta))return e;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.ke(t,a,r)>0)try{const c=String.fromCodePoint(a);e.push(c)}catch{}}}return e}Se(t){const e=[];if(!t.groups)return e;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);e.push(u)}catch{}}return e}ke(t,e,r){if(t.idRangeOffset[r]===0)return e+t.idDelta[r]&65535;{const h=t.idRangeOffset[r]/2+(e-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 yt{constructor(){l(this,"Pe",new Map);l(this,"Le",new Map)}Ie(t,e){const r=`${this.ze(t)}_${e}`;if(this.Pe.has(r))return this.Pe.get(r);const h=t.cmap;if(!h||!h.tables)return this.Pe.set(r,0),0;let n=0;for(const a of h.tables)if(a.format===4?n=this.De(e,a):a.format===12&&(n=this.Oe(e,a)),n>0)break;return this.Pe.set(r,n),n}Be(t,e){const r=e.codePointAt(0);return r===void 0?0:this.Ie(t,r)}Ge(t,e){const r=t.hmtx;return r&&r.aWidth&&r.aWidth.length!==0?e<r.aWidth.length?r.aWidth[e]:r.aWidth[r.aWidth.length-1]:0}We(t,e){const r=e/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}}He(){this.Pe.clear(),this.Le.clear()}ze(t){return`${t.Fe}_${t.Ae.length}`}De(t,e){const r=e.endCount.length;let h=-1;for(let n=0;n<r;n++)if(t<=e.endCount[n]){h=n;break}if(h===-1||t<e.startCount[h])return 0;if(e.idRangeOffset[h]===0)return t+e.idDelta[h]&65535;{const n=e.idRangeOffset[h]/2+(t-e.startCount[h])-(r-h);if(n>=0&&n<e.glyphIdArray.length){const a=e.glyphIdArray[n];return a===0?0:a+e.idDelta[h]&65535}}return 0}Oe(t,e){const r=e.groups.length/3;for(let h=0;h<r;h++){const n=e.groups[3*h],a=e.groups[3*h+1],c=e.groups[3*h+2];if(t>=n&&t<=a)return c+(t-n)}return 0}}class Ee{constructor(t){l(this,"Ke");l(this,"Ye");l(this,"N");l(this,"je");this.N=t,this.je=new yt,this.Ke=document.createElement("canvas"),this.Ye=this.Ke.getContext("2d",{willReadFrequently:!0,alpha:!0})}Ne(t,e,r,h){const n=t.length,a=Math.ceil(Math.sqrt(n)),c=Math.ceil(n/a),u=e.width*a,f=e.height*c;this.Xe(u,f),this.Ze(t,e,a,r,h);const d=this.N.$e(u,f,1,{filter:"nearest"});return d.st(this.Ke),{framebuffer:d,columns:a,rows:c}}Xe(t,e){this.Ke.width=t,this.Ke.height=e,this.Ke.style.width=t+"px",this.Ke.style.height=e+"px",this.Ye.imageSmoothingEnabled=!1,this.Ke.style.imageRendering="pixelated",this.Ye.clearRect(0,0,t,e),this.Ye.textBaseline="top",this.Ye.textAlign="left",this.Ye.fillStyle="white"}Ze(t,e,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.Ve(n,d);if(!g)continue;const m=d.codePointAt(0)||0,v=this.je.Ie(n,m),y=this.je.Ge(n,v)*a,p=u*e.width,w=f*e.height,E=p+.5*e.width,R=w+.5*e.height,T=Math.round(E-.5*e.width),x=Math.round(R-.5*h),b=T+.5*(e.width-y),U=x+n.hhea.ascender*a;this.qe(g,b,U,a)}}Ve(t,e){const r=e.codePointAt(0)||0,h=this.je.Ie(t,r);return h===0?null:z.T.glyf.xe(t,h)}qe(t,e,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.Ye.beginPath();let f=0;for(let d=0;d<c.length;d++){const g=c[d];if(!(g<f)){if(g>=f){const m=e+n[f]*h,v=r-a[f]*h;this.Ye.moveTo(m,v);let y=f+1;for(;y<=g;)if(1&u[y]){const p=e+n[y]*h,w=r-a[y]*h;this.Ye.lineTo(p,w),y++}else{const p=e+n[y]*h,w=r-a[y]*h;if(y+1>g){const R=e+n[f]*h,T=r-a[f]*h;if(1&u[f])this.Ye.quadraticCurveTo(p,w,R,T);else{const x=(p+R)/2,b=(w+T)/2;this.Ye.quadraticCurveTo(p,w,x,b)}break}const E=y+1;if(1&u[E]){const R=e+n[E]*h,T=r-a[E]*h;this.Ye.quadraticCurveTo(p,w,R,T),y=E+1}else{const R=(p+(e+n[E]*h))/2,T=(w+(r-a[E]*h))/2;this.Ye.quadraticCurveTo(p,w,R,T),y=E}}this.Ye.closePath()}f=g+1}}this.Ye.fill()}}class we{constructor(){l(this,"Je");this.Je=new yt}Qe(t,e,r){let h=0;const n=this.Je.We(r,e),a=n.lineHeight;for(const c of t){const u=this.Je.Be(r,c);if(u===0)continue;const f=this.Je.Ge(r,u)*n.scale;h=Math.max(h,f)}return{width:Math.ceil(h),height:Math.ceil(a)}}He(){this.Je.He()}}class Te{constructor(){l(this,"je");this.je=new yt}createCharacterObjects(t,e){return t.map((r,h)=>{const n=r.codePointAt(0)||0,a=this.tr(h);let c=0;if(e.hmtx&&e.hmtx.aWidth){const u=this.je.Ie(e,n);u>0&&e.hmtx.aWidth[u]!==void 0&&(c=e.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,e){if(!K.v(typeof t=="string","Character must be a string.",{method:"getCharacterColor",providedValue:t}))return[0,0,0];const r=e.find(h=>h.character===t);return r?r.color:[0,0,0]}ir(t,e){return K.v(typeof t=="string"&&t.length>0,"Characters must be a string with at least one character.",{method:"getCharacterColors",providedValue:t})?Array.from(t).map(r=>this.sr(r,e)||[0,0,0]):[[0,0,0]]}}class Et{constructor(t,e=16){l(this,"er");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,"_r");l(this,"gr");l(this,"vr");this.hr=e,this.pr=new ye,this._r=new Ee(t),this.gr=new we,this.vr=new Te}async mr(t){let e;if(!t)throw new A("Embedded font not available. This appears to be a minified build - please provide `fontSource` or use the non-minified version.");{const r=await fetch(t);if(!r.ok)throw new A(`Failed to load font file: ${r.status} ${r.statusText}`);e=await r.arrayBuffer()}await this.yr(e),this.er=z.parse(e)[0],await this.wr()}br(t){if(t===void 0)return this.hr;this.hr=t,this.lr=this.gr.Qe(this.rr.map(r=>r.character),this.hr,this.er);const e=this._r.Ne(this.rr,this.lr,this.hr,this.er);this.nr=e.framebuffer,this.ar=e.columns,this.cr=e.rows}async $r(t){try{const e=await fetch(t);if(!e.ok)throw new A(`Failed to load font file: ${e.status} ${e.statusText}`);const r=await e.arrayBuffer();await this.yr(r);const h=z.parse(r);if(!h||h.length===0)throw Error("Failed to parse font file");this.er=h[0],await this.wr()}catch(e){throw new A("Failed to load font: "+(e instanceof Error?e.message:"Unknown error"),e)}}async yr(t){const e=Date.now();this.ur=new FontFace("CustomFont_"+e,t),await this.ur.load(),document.fonts.add(this.ur)}async wr(){const t=this.pr.Re(this.er);this.dr.clear(),this.rr=this.vr.createCharacterObjects(t,this.er),this.lr=this.gr.Qe(t,this.hr,this.er);const e=this._r.Ne(this.rr,this.lr,this.hr,this.er);this.nr=e.framebuffer,this.ar=e.columns,this.cr=e.rows}sr(t){return this.vr.sr(t,this.rr)}ir(t){return this.vr.ir(t,this.rr)}getGlyphData(t){if(!Number.isFinite(t))return null;const e=this.dr.get(t);if(e!==void 0)return e;const r=this.Cr(t);if(r<0)return this.dr.set(t,null),null;const h=this.er.glyf;if(!h)return this.dr.set(t,null),null;let n=h[r]??null;return n==null&&(n=z.T.glyf.xe(this.er,r)??null,h[r]=n),this.dr.set(t,n),n}Cr(t){const e=this.er.cmap;for(const r of e.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}O(){this.nr.O(),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.er}}class wt{constructor(t,e,r){l(this,"Mr");l(this,"Ar");l(this,"G");l(this,"W");l(this,"Fr");l(this,"Tr");l(this,"Rr");l(this,"Er");l(this,"Sr");this.Rr=t,this.Er=e,this.Sr=r,this.qs()}qs(){this.Mr=Math.floor(this.Rr.width/this.Er),this.Ar=Math.floor(this.Rr.height/this.Sr),this.G=this.Mr*this.Er,this.W=this.Ar*this.Sr,this.Fr=Math.floor((this.Rr.width-this.G)/2),this.Tr=Math.floor((this.Rr.height-this.W)/2)}kr(t,e){this.Er=t,this.Sr=e,this.qs()}get cellWidth(){return this.Er}get cellHeight(){return this.Sr}get cols(){return this.Mr}get rows(){return this.Ar}get width(){return this.G}get height(){return this.W}get offsetX(){return this.Fr}get offsetY(){return this.Tr}}const Re=/^#([0-9a-f]{3,8})$/i,be=/^rgba?\(([^)]+)\)$/i;function Tt(o){return Number.isNaN(o)?0:Math.max(0,Math.min(255,o))}function Ae(o){if(!o)return null;const t=o.trim().toLowerCase();if(!t||t==="transparent")return null;let e=null;return t.startsWith("#")?e=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")&&(e=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=Tt(parseFloat(n[0])),c=Tt(parseFloat(n[1])),u=Tt(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)),e?e[3]===0?null:e:null}class Pt{constructor(t={}){l(this,"Rr");l(this,"Pr",null);l(this,"Lr",!1);l(this,"Ir");this.Lr=t.overlay??!1,this.Lr&&t.canvas?(this.Pr=t.canvas,this.Rr=this.zr(),this.Ir=!0,this.Dr()):t.canvas?(this.Rr=t.canvas,this.Ir=!1):(this.Rr=this.Or(t.width,t.height),this.Ir=!0),this.Rr.style.imageRendering="pixelated"}Or(t,e){const r=document.createElement("canvas");return r.className="textmodeCanvas",r.style.imageRendering="pixelated",r.width=t||800,r.height=e||600,document.body.appendChild(r),r}zr(){const t=document.createElement("canvas");t.className="textmodeCanvas",t.style.imageRendering="pixelated";const e=this.Pr.getBoundingClientRect();let r=Math.round(e.width),h=Math.round(e.height);if(this.Pr instanceof HTMLVideoElement){const c=this.Pr;(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.Pr);let a=parseInt(n.zIndex||"0",10);return isNaN(a)&&(a=0),t.style.zIndex=""+(a+1),t}Dr(){var t;this.Br(),(t=this.Pr.parentNode)==null||t.insertBefore(this.Rr,this.Pr.nextSibling)}Gr(){const t=[];return this.Lr&&this.Pr instanceof HTMLElement&&(t.push(this.Pr),this.Pr.parentElement&&t.push(this.Pr.parentElement)),this.Rr.parentElement&&t.push(this.Rr.parentElement),t.push(this.Rr),t.push(document.body),t.push(document.documentElement),t}Wr(){const t=this.Gr();for(const e of t){if(!e)continue;const r=Ae(window.getComputedStyle(e).backgroundColor);if(r)return r}return[255,255,255,255]}Br(){if(!this.Pr)return;const t=this.Pr.getBoundingClientRect();let e=this.Pr.offsetParent;if(e&&e!==document.body){const r=e.getBoundingClientRect();this.Rr.style.top=t.top-r.top+"px",this.Rr.style.left=t.left-r.left+"px"}else this.Rr.style.top=t.top+window.scrollY+"px",this.Rr.style.left=t.left+window.scrollX+"px"}Hr(t,e){if(this.Lr){const r=this.Pr.getBoundingClientRect();this.Rr.width=Math.round(r.width),this.Rr.height=Math.round(r.height),this.Br()}else this.Rr.width=t??this.Rr.width,this.Rr.height=e??this.Rr.height}Kr(){const t=this.Rr.getContext("webgl2",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance"});if(!t)throw new A("`textmode.js` requires WebGL2 support.");return t}O(){const t=this.Rr.getContext("webgl")||this.Rr.getContext("webgl2");if(t){const e=t.getExtension("WEBGL_lose_context");e==null||e.loseContext()}this.Ir&&this.Rr.parentNode&&this.Rr.parentNode.removeChild(this.Rr)}get canvas(){return this.Rr}get targetCanvas(){return this.Pr}get width(){return this.Rr.width}get height(){return this.Rr.height}}const xe=/^#|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,e,r,h,n){l(this,"Yr");l(this,"jr");l(this,"Gt");l(this,"r");l(this,"g");l(this,"b");l(this,"a");this.r=et(t),this.g=et(e),this.b=et(r),this.a=et(h),this.Yr=[this.r,this.g,this.b,this.a],this.jr=[this.r/255,this.g/255,this.b/255,this.a/255],this.Gt=n?[...n]:void 0}static Nr(t,e,r,h=255){return new I(t,e,r,h)}static Xr(t,e=255){return new I(t,t,t,e)}static Zr(t){const[e,r,h,n]=function(a){const c=a.replace(xe,""),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(e,r,h,n)}static Vr(t){const[e,r,h]=t;return new I(255*e,255*r,255*h,255,t)}get rgb(){return[this.r,this.g,this.b]}get rgba(){return[...this.Yr]}get normalized(){return[...this.jr]}get character(){return this.Gt?[...this.Gt]:void 0}static qr(t){return t instanceof I}}const k=class k{constructor(t,e,r,h,n,a,c){l(this,"$");l(this,"N");l(this,"Jr");l(this,"Qr");l(this,"tn");l(this,"G");l(this,"W");l(this,"X",null);l(this,"Ft",0);l(this,"Ot",0);l(this,"Bt",0);l(this,"Tt",0);l(this,"sn","sampled");l(this,"en","fixed");l(this,"Wt",[1,1,1,1]);l(this,"Ht",[0,0,0,1]);l(this,"rn",[0,0,0,1]);l(this,"nn",[[.1,0,0]]);l(this,"hn");this.$=t,this.N=e,this.Jr=r,this.Qr=h,this.tn=n,this.G=a,this.W=c}O(){this.$.deleteTexture(this.Jr)}invert(t=!0){return this.Ft=t?1:0,this.X=null,this}flipX(t=!0){return this.Ot=t?1:0,this.X=null,this}flipY(t=!0){return this.Bt=t?1:0,this.X=null,this}charRotation(t){return this.Tt=At(t),this.X=null,this}charColorMode(t){return this.sn=t,this.X=null,this}cellColorMode(t){return this.en=t,this.X=null,this}charColor(t,e,r,h){return this.cn(this.Wt,t,e,r,h),this.X=null,this}cellColor(t,e,r,h){return this.cn(this.Ht,t,e,r,h),this.X=null,this}background(t,e,r,h){return this.cn(this.rn,t,e,r,h),this.X=null,this}characters(t){if(!this.hn)throw Error("Glyph color resolver not initialized");const e=this.hn(t).filter(r=>Array.isArray(r)).slice(0,64);return this.nn=e,this.X=null,this}get texture(){return this.Jr}get width(){return this.G}get height(){return this.W}get originalWidth(){return this.Qr}get originalHeight(){return this.tn}ct(){return this.X||this.lt(),this.X}ln(){}lt(){this.ln();const t=this.un(),e=this.fn();this.X=this.N.ft.Gi(t,e)}cn(t,e,r,h,n){if(I.qr(e))G(t,e.r,e.g,e.b,e.a);else{if(typeof e=="string"){const a=I.Zr(e);return void G(t,a.r,a.g,a.b,a.a)}G(t,e,r,h,n)}}un(){return k.an||(k.an=new V(this.$,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));}`)),k.an}fn(){return{Ug:this.dn(),Uh:!!this.Ft,Ui:!!this.Ot,Uj:!!this.Bt,Uk:this.Tt,Ul:this.sn==="fixed",Um:this.Wt,Un:this.en==="fixed",Uo:this.Ht,Up:this.rn,Uq:this.nn.length,Ur:this.nn}}};l(k,"an",null);let at=k;class W extends at{constructor(t,e,r,h,n,a,c){const u=Math.min(a/h,c/n);super(t,e,r,h,n,Math.max(1,Math.floor(h*u)),Math.max(1,Math.floor(n*u)))}static pn(t,e,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,e),a.bindTexture(a.TEXTURE_2D,null);const u=e.naturalWidth??e.width??e.videoWidth??0,f=e.naturalHeight??e.height??e.videoHeight??0,d=new W(a,t,c,u,f,r,h);return d.hn=n,d}dn(){return this.Jr}}class Nt{constructor(t=60){l(this,"_n");l(this,"gn",null);l(this,"vn",0);l(this,"mn",!0);l(this,"yn",0);l(this,"wn",0);l(this,"bn",[]);l(this,"$n",10);l(this,"Cn",0);this._n=1e3/t}Mn(t){if(!this.mn)return;this.vn=performance.now();const e=r=>{if(!this.mn)return void(this.gn=null);const h=r-this.vn;h>=this._n&&(t(),this.vn=r-h%this._n),this.mn&&(this.gn=requestAnimationFrame(e))};this.gn=requestAnimationFrame(e)}xn(){this.gn&&(cancelAnimationFrame(this.gn),this.gn=null)}An(){this.mn&&(this.mn=!1,this.xn())}Fn(t){this.mn||(this.mn=!0,this.Mn(t))}Tn(t,e){if(t===void 0)return this.yn;this._n=1e3/t,this.mn&&e&&(this.xn(),this.Mn(e))}Rn(){const t=performance.now();if(this.wn>0){const e=t-this.wn;this.bn.push(e),this.bn.length>this.$n&&this.bn.shift();const r=this.bn.reduce((h,n)=>h+n,0)/this.bn.length;this.yn=1e3/r}this.wn=t}get En(){return this.mn}get Sn(){return this.yn}get kn(){return this.Cn}set kn(t){this.Cn=t}Pn(){this.Cn++}}class _t{constructor(t){l(this,"Rr");l(this,"Ln");l(this,"In",{x:-1,y:-1});l(this,"zn",{x:-1,y:-1});l(this,"Dn",null);l(this,"On",0);l(this,"Bn");l(this,"Gn");l(this,"Wn");l(this,"Hn");l(this,"Kn");l(this,"Yn");l(this,"jn",!1);l(this,"Nn");l(this,"Xn");l(this,"Zn");l(this,"Vn");l(this,"qn");this.Rr=t}Jn(t){const e=performance.now()+Math.max(0,t);e>this.On&&(this.On=e)}Qn(){return performance.now()<this.On}so(t){const e=this.Rr.canvas;e.style.cursor=t==null||t===""?"":t}mr(t){this.Ln=t,this.io()}eo(){if(this.jn)return;const t=this.Rr.canvas;this.Bn=e=>{this.ro(e),this.no(e)},this.Gn=()=>{this.zn={...this.In},this.In.x=-1,this.In.y=-1,this.Dn=null},this.Wn=e=>{this.ro(e),this.oo(e)},this.Hn=e=>{this.ro(e),this.ho(e)},this.Kn=e=>{this.ro(e),this.ao(e)},this.Yn=e=>{this.ro(e),this.co(e)},t.addEventListener("mousemove",this.Bn,{passive:!0}),t.addEventListener("mouseleave",this.Gn,{passive:!0}),t.addEventListener("mousedown",this.Wn,{passive:!0}),t.addEventListener("mouseup",this.Hn,{passive:!0}),t.addEventListener("click",this.Kn,{passive:!0}),t.addEventListener("wheel",this.Yn,{passive:!1}),this.jn=!0}lo(){if(!this.jn)return;const t=this.Rr.canvas;t.removeEventListener("mousemove",this.Bn),t.removeEventListener("mouseleave",this.Gn),t.removeEventListener("mousedown",this.Wn),t.removeEventListener("mouseup",this.Hn),t.removeEventListener("click",this.Kn),t.removeEventListener("wheel",this.Yn),this.jn=!1}io(){if(this.jn)try{if(this.Dn){const t=new MouseEvent("mousemove",{clientX:this.Dn.x,clientY:this.Dn.y,bubbles:!1,cancelable:!1});this.ro(t)}else this.In.x!==-1&&this.In.y!==-1&&(this.In.x>=this.Ln.cols||this.In.y>=this.Ln.rows)&&(this.In.x=-1,this.In.y=-1)}catch{this.In.x=-1,this.In.y=-1}}uo(t){this.Nn=t}fo(t){this.Xn=t}do(t){this.Zn=t}po(t){this.Vn=t}_o(t){this.qn=t}vo(){return{x:this.In.x,y:this.In.y}}no(t){if(this.Vn&&!this.Qn()){const e={position:{...this.In},previousPosition:{...this.zn},originalEvent:t};this.Vn(e)}}oo(t){if(this.Xn&&!this.Qn()){const e={position:{...this.In},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Xn(e)}}ho(t){if(this.Zn&&!this.Qn()){const e={position:{...this.In},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Zn(e)}}ao(t){if(this.Nn&&!this.Qn()){const e={position:{...this.In},previousPosition:{...this.zn},button:t.button,originalEvent:t};this.Nn(e)}}co(t){if(this.qn&&!this.Qn()){const e={position:{...this.In},previousPosition:{...this.zn},delta:{x:t.deltaX,y:t.deltaY},originalEvent:t};this.qn(e)}}ro(t){const e=this.Rr.canvas;this.zn={...this.In},this.Dn={x:t.clientX,y:t.clientY};const r=e.getBoundingClientRect(),h=t.clientX-r.left,n=t.clientY-r.top,a=e.width/r.width,c=n*(e.height/r.height),u=h*a-this.Ln.offsetX,f=c-this.Ln.offsetY,d=Math.floor(u/this.Ln.cellWidth),g=Math.floor(f/this.Ln.cellHeight);d>=0&&d<this.Ln.cols&&g>=0&&g<this.Ln.rows?(this.In.x=d,this.In.y=g):(this.In.x=-1,this.In.y=-1)}}const Le=Object.freeze(Object.defineProperty({__proto__:null,MouseManager:_t},Symbol.toStringTag,{value:"Module"}));class St{constructor(){l(this,"mo",new Map);l(this,"yo",null);l(this,"wo",null);l(this,"bo");l(this,"$o");l(this,"jn",!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"})}eo(){this.jn||(this.bo=t=>{this.Ao(t)},this.$o=t=>{this.Fo(t)},window.addEventListener("keydown",this.bo,{passive:!1}),window.addEventListener("keyup",this.$o,{passive:!1}),this.jn=!0)}lo(){this.jn&&(window.removeEventListener("keydown",this.bo),window.removeEventListener("keyup",this.$o),this.jn=!1,this.mo.clear(),this.yo=null,this.wo=null)}fo(t){this.Co=t}do(t){this.Mo=t}To(t){const e=this.Ro(t),r=this.mo.get(t)||this.mo.get(e);return(r==null?void 0:r.isPressed)||!1}Eo(){return this.yo}So(){return this.wo}ko(){const t=[];for(const[e,r]of this.mo)r.isPressed&&t.push(e);return t}Po(){return{ctrl:this.To("Control"),shift:this.To("Shift"),alt:this.To("Alt"),meta:this.To("Meta")}}Lo(){this.mo.clear(),this.yo=null,this.wo=null}Ao(t){const e=t.key,r=Date.now();this.mo.has(e)||this.mo.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this.mo.get(e);if(!h.isPressed&&(h.isPressed=!0,h.lastPressTime=r,this.yo=e,this.Co)){const n={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!0,originalEvent:t};this.Co(n)}}Fo(t){const e=t.key,r=Date.now();this.mo.has(e)||this.mo.set(e,{isPressed:!1,lastPressTime:0,lastReleaseTime:0});const h=this.mo.get(e);if(h.isPressed=!1,h.lastReleaseTime=r,this.wo=e,this.Mo){const n={key:e,keyCode:t.keyCode,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,isPressed:!1,originalEvent:t};this.Mo(n)}}Ro(t){return this.xo[t]||t.toLowerCase()}}const Ce=Object.freeze(Object.defineProperty({__proto__:null,KeyboardManager:St},Symbol.toStringTag,{value:"Module"}));class Bt{constructor(t,e){l(this,"Rr");l(this,"Io");l(this,"Ln");l(this,"zo",new Map);l(this,"Do",new Map);l(this,"Oo",new Map);l(this,"Bo",null);l(this,"Go");l(this,"Wo");l(this,"Ho");l(this,"Ko");l(this,"Yo");l(this,"jo");l(this,"jn",!1);l(this,"No");l(this,"Xo");l(this,"Zo");l(this,"Vo");l(this,"qo");l(this,"Jo");l(this,"Qo");l(this,"th");l(this,"sh");l(this,"ih");l(this,"eh",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,"_h",0);l(this,"gh",null);this.Rr=t,this.Io=e;const r=this.Rr.canvas;this.Go=r.style.touchAction,this.Wo=r.style.userSelect,r.style.touchAction||(r.style.touchAction="none"),r.style.userSelect||(r.style.userSelect="none")}mr(t){this.Ln=t,this.io()}eo(){if(this.jn)return;const t=this.Rr.canvas;this.Ho=e=>{this.mh(e)},this.Ko=e=>{this.yh(e)},this.Yo=e=>{this.wh(e)},this.jo=e=>{this.bh(e)},t.addEventListener("touchstart",this.Ho,{passive:!1}),t.addEventListener("touchmove",this.Ko,{passive:!1}),t.addEventListener("touchend",this.Yo,{passive:!1}),t.addEventListener("touchcancel",this.jo,{passive:!1}),this.jn=!0}lo(){if(!this.jn)return;const t=this.Rr.canvas;t.removeEventListener("touchstart",this.Ho),t.removeEventListener("touchmove",this.Ko),t.removeEventListener("touchend",this.Yo),t.removeEventListener("touchcancel",this.jo),this.jn=!1,this.Bo=null,this.zo.clear(),this.Do.clear(),this.Oo.forEach(e=>{e.longPressTimer!==null&&window.clearTimeout(e.longPressTimer)}),this.Oo.clear(),this.gh=null,this._h=0,t.style.touchAction=this.Go,t.style.userSelect=this.Wo}io(){if(!this.Ln||this.zo.size===0)return;const t=new Map;for(const e of this.zo.values()){const r=this.$h(e.clientX,e.clientY,e.id,e);t.set(e.id,r)}this.zo=t}Ch(){return Array.from(this.zo.values()).map(t=>({...t}))}Mh(t){this.No=t}po(t){this.Xo=t}xh(t){this.Zo=t}Ah(t){this.Vo=t}Fh(t){this.qo=t}Th(t){this.Jo=t}Rh(t){this.Qo=t}Eh(t){this.th=t}Sh(t){this.sh=t}kh(t){this.ih=t}mh(t){var h;if(!this.Ln)return;t.preventDefault(),(h=this.Io)==null||h.Jn(this.ph);const e=performance.now(),r=this.Ph(t.changedTouches);for(const n of r){const a=this.zo.get(n.id);a&&this.Do.set(n.id,this.Lh(a)),this.zo.set(n.id,n);const c={id:n.id,startPosition:n,lastPosition:n,startTime:e,lastTime:e,longPressTimer:null,longPressFired:!1};this.Qo&&(c.longPressTimer=window.setTimeout(()=>{const u=this.zo.get(n.id);u&&(c.longPressFired=!0,this.Qo({touch:this.Lh(u),duration:performance.now()-c.startTime,originalEvent:t}))},this.oh)),this.Oo.set(n.id,c),this.No&&this.No(this.Ih(n,t,void 0,e))}this.zo.size===2&&this.zh()}yh(t){var h;if(!this.Ln)return;t.preventDefault(),(h=this.Io)==null||h.Jn(this.ph);const e=performance.now(),r=this.Ph(t.changedTouches);for(const n of r){const a=this.zo.get(n.id),c=a?this.Lh(a):void 0;c&&this.Do.set(n.id,c),this.zo.set(n.id,n);const u=this.Oo.get(n.id);u&&(u.lastPosition=n,u.lastTime=e,c)&&Z(c.clientX,c.clientY,n.clientX,n.clientY)>this.hh&&u.longPressTimer!==null&&(window.clearTimeout(u.longPressTimer),u.longPressTimer=null),this.Xo&&this.Xo(this.Ih(n,t,c,e))}this.zo.size===2?this.Dh(t):this.Bo=null}wh(t){if(!this.Ln)return;t.preventDefault();const e=performance.now(),r=this.Ph(t.changedTouches);for(const h of r){const n=this.zo.get(h.id),a=n?this.Lh(n):void 0,c=this.Oo.get(h.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.Zo&&this.Zo(this.Ih(h,t,a,e)),c&&this.Oh(c,t),this.Oo.delete(h.id),this.Do.delete(h.id),this.zo.delete(h.id)}this.zo.size<2&&(this.Bo=null)}bh(t){if(!this.Ln)return;t.preventDefault();const e=performance.now(),r=this.Ph(t.changedTouches);for(const h of r){const n=this.zo.get(h.id),a=n?this.Lh(n):void 0,c=this.Oo.get(h.id);c&&c.longPressTimer!==null&&(window.clearTimeout(c.longPressTimer),c.longPressTimer=null),this.Vo&&this.Vo(this.Ih(h,t,a,e)),this.Oo.delete(h.id),this.Do.delete(h.id),this.zo.delete(h.id)}this.zo.size<2&&(this.Bo=null)}Ph(t){const e=[];for(let r=0;r<t.length;r+=1){const h=t.item(r);h&&e.push(this.Bh(h))}return e}Bh(t){return this.$h(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})}$h(t,e,r,h){const n=this.Rr.canvas,a=n.getBoundingClientRect(),c=t-a.left,u=e-a.top,f=n.width/a.width,d=u*(n.height/a.height),g=c*f-this.Ln.offsetX,m=d-this.Ln.offsetY,v=Math.floor(g/this.Ln.cellWidth),y=Math.floor(m/this.Ln.cellHeight),p=v>=0&&v<this.Ln.cols&&y>=0&&y<this.Ln.rows;return{id:r,x:p?v:-1,y:p?y:-1,clientX:t,clientY:e,pressure:h.pressure,radiusX:h.radiusX,radiusY:h.radiusY,rotationAngle:h.rotationAngle}}Ih(t,e,r,h){const n=this.Oo.get(t.id),a=Array.from(this.Do.values()).map(f=>this.Lh(f)),c=Array.from(this.zo.values()).map(f=>this.Lh(f)),u=this.Ph(e.changedTouches);return{touch:this.Lh(t),previousTouch:r?this.Lh(r):void 0,touches:c,previousTouches:a,changedTouches:u,deltaTime:n?h-n.lastTime:0,originalEvent:e}}zh(){if(this.zo.size!==2)return void(this.Bo=null);const t=Array.from(this.zo.values()),[e,r]=t,h=Z(e.x,e.y,r.x,r.y),n=bt(e.clientX,e.clientY,r.clientX,r.clientY);this.Bo={ids:[e.id,r.id],initialDistance:Math.max(h,1e-4),initialAngle:n,lastScale:1,lastRotation:0}}Dh(t){if(this.Bo||this.zh(),!this.Bo)return;const[e,r]=this.Bo.ids,h=this.zo.get(e),n=this.zo.get(r);if(!h||!n)return;const a=Z(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.Lh(h),this.Lh(n)],scale:a,deltaScale:c,center:this.Gh(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.ih&&Math.abs(f)>this.dh&&(this.ih({touches:[this.Lh(h),this.Lh(n)],rotation:u,deltaRotation:f,center:this.Gh(h,n),originalEvent:t}),this.Bo.lastRotation=u)}Gh(t,e){const r=(t.clientX+e.clientX)/2,h=(t.clientY+e.clientY)/2,n=this.$h(r,h,-1,{id:-1,x:-1,y:-1,clientX:r,clientY:h});return{x:n.x,y:n.y}}Oh(t,e){const r=performance.now(),h=r-t.startTime,n=Z(t.startPosition.clientX,t.startPosition.clientY,t.lastPosition.clientX,t.lastPosition.clientY);if(!t.longPressFired&&h<=this.eh&&n<=this.nh)this.Wh(t.lastPosition,r)&&this.Jo?this.Jo({touch:this.Lh(t.lastPosition),taps:2,originalEvent:e}):this.qo&&this.qo({touch:this.Lh(t.lastPosition),taps:1,originalEvent:e});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.Lh(t.lastPosition),direction:u,distance:c,velocity:f,originalEvent:e})}this._h=r,this.gh=this.Lh(t.lastPosition)}Wh(t,e){return!!this.gh&&!(e-this._h>this.rh)&&Z(t.clientX,t.clientY,this.gh.clientX,this.gh.clientY)<=this.nh}Lh(t){return{...t}}}const Fe=Object.freeze(Object.defineProperty({__proto__:null,TouchManager:Bt},Symbol.toStringTag,{value:"Module"}));class ct extends at{constructor(e,r,h,n,a,c,u,f){const d=a/c;let g,m;d>1?(g=u,m=Math.round(u/d)):(m=f,g=Math.round(f*d));super(e,r,h,a,c,g,m);l(this,"Hh");l(this,"Kh",!1);l(this,"Yh",[]);l(this,"yn",null);l(this,"jh",0);l(this,"Nh",0);l(this,"Xh",-1);this.Hh=n}O(){super.O();for(const e of this.Yh)this.$.deleteTexture(e);this.Yh=[],this.Hh.pause(),this.Hh.src="",this.Hh.load()}Zh(){if(!this.Kh&&this.Hh.readyState>=this.Hh.HAVE_CURRENT_DATA){const e=this.$;e.bindTexture(e.TEXTURE_2D,this.Jr),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.Hh),e.bindTexture(e.TEXTURE_2D,null)}}dn(){if(this.Kh&&this.Yh.length>0){const e=this.Nh%this.Yh.length;return this.Yh[e]}return this.Jr}ct(){return this.X=null,super.ct()}ln(){this.Zh()}async Vh(e,r){var h;try{if(e<=0)throw Error("Video preload requires a frameRate greater than 0.");const n=this.Hh.duration;if(!isFinite(n)||n<=0)throw Error("Video duration is invalid, cannot preload frames.");const a=Math.max(1,Math.ceil(n*e));if(this.qh(e,a),await this.Jh(e,r))return void this.Qh("captureStream",r);await this.ta(e,r),this.Qh("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}}qh(e,r){this.yn=e,this.jh=r,this.Yh=[],this.Kh=!1,this.Nh=0,this.Xh=-1}Qh(e,r){var h;if(this.Yh.length===0)throw Error(`Video preload via ${e} completed but produced 0 frames.`);this.jh=this.Yh.length,this.Kh=!0,this.Nh=0,this.Xh=-1,this.Hh.pause(),this.Hh.currentTime=0,r!=null&&r.onProgress&&r.onProgress({percent:100,loadedFrames:this.jh,totalFrames:this.jh,strategy:e}),(h=r==null?void 0:r.onComplete)==null||h.call(r,{totalFrames:this.jh,strategy:e})}sa(e){const r=this.$,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,e),r.bindTexture(r.TEXTURE_2D,null),h}ia(e,r){if(!(r!=null&&r.onProgress)||this.jh===0)return;const h=Math.min(99,Math.floor(this.Yh.length/this.jh*100)),n=10*Math.floor(h/10);n>this.Xh&&(this.Xh=n,r.onProgress({percent:h,loadedFrames:this.Yh.length,totalFrames:this.jh,strategy:e}))}async Jh(e,r){const h=globalThis,n=h==null?void 0:h.MediaStreamTrackProcessor,a=this.Hh.captureStream;if(typeof n!="function"||typeof a!="function")return!1;let c,u=null;try{const f=a.call(this.Hh);if(c=f.getVideoTracks()[0],!c)return f.getTracks().forEach(m=>m.stop()),!1;if(u=new n({track:c}).readable.getReader(),this.Hh.currentTime=0,this.Hh.muted=!0,await this.Hh.play().catch(()=>{}),this.Hh.paused)return!1;const d=1e6/e;let g=0;for(;this.Yh.length<this.jh;){const m=await u.read();if(m.done)break;const v=m.value;if(v)try{const y=typeof v.timestamp=="number"?v.timestamp:g;(this.Yh.length===0||y>=g)&&(this.Yh.push(this.sa(v)),g=y+d,this.ia("captureStream",r))}finally{v.close()}}return u.releaseLock(),c.stop(),u=null,c=void 0,this.Hh.pause(),this.Hh.currentTime=0,this.Yh.length!==0}catch{return this.Yh=[],this.Xh=-1,!1}finally{if(u)try{await u.cancel()}catch{}c&&c.stop(),this.Hh.pause(),this.Hh.currentTime=0}}async ta(e,r){const h=1/e,n=this.jh,a=this.Hh;a.pause();for(let c=0;c<n;c++){const u=Math.min(a.duration,c*h);await this.ea(u),this.Yh.push(this.sa(a)),this.ia("seeking",r)}a.currentTime=0}ea(e){return new Promise((r,h)=>{const n=this.Hh,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:e,d=Math.min(Math.max(e,0),f);if(Math.abs(n.currentTime-d)<1e-4)return a(),void r();n.currentTime=d})}frame(e){return this.Kh&&e!==void 0&&this.jh>0&&(this.Nh=(e%this.jh+this.jh)%this.jh,this.X=null),this}static async pn(e,r,h,n,a,c){const u=e.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((p,w)=>{d.addEventListener("loadedmetadata",()=>p(),{once:!0}),d.addEventListener("error",E=>{var T;const R=E.target;w(Error("Failed to load video: "+(((T=R.error)==null?void 0:T.message)||"Unknown error")))},{once:!0}),d.src=r})):(d=r,d.readyState<d.HAVE_METADATA&&await new Promise((p,w)=>{d.addEventListener("loadedmetadata",()=>p(),{once:!0}),d.addEventListener("error",E=>{var R;return w(Error("Video error: "+((R=E.target.error)==null?void 0:R.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 m=d.videoWidth,v=d.videoHeight,y=new ct(u,e,g,d,m,v,h,n);return y.hn=a,f&&f>0&&await y.Vh(f,c),y}async play(){await this.Hh.play()}pause(){this.Hh.pause()}stop(){this.Hh.pause(),this.Hh.currentTime=0}speed(e){return this.Hh.playbackRate=e,this}loop(e=!0){return this.Hh.loop=e,this}time(e){return this.Hh.currentTime=e,this}volume(e){return this.Hh.volume=Math.max(0,Math.min(1,e)),this}get texture(){return this.Jr}get width(){return this.G}get height(){return this.W}get originalWidth(){return this.Qr}get originalHeight(){return this.tn}get videoElement(){return this.Hh}get currentTime(){return this.Hh.currentTime}get duration(){return this.Hh.duration}get isPlaying(){return!this.Hh.paused&&!this.Hh.ended}get isPreloaded(){return this.Kh}get totalFrames(){return this.jh}get preloadFrameRate(){return this.yn}get currentFrameIndex(){return this.Nh}}const Ue=o=>class extends o{ra(t,e,r,h){if(I.qr(t))return t;if(typeof t=="number"||typeof t=="string")return this.color(t,e,r,h);throw Error("Unsupported color input passed to color-capable method.")}rotate(t=0,e=0,r=0){this.N.state.Zt(t),this.N.state.Vt(e),this.N.state.qt(r)}rotateX(t){this.N.state.Zt(t)}rotateY(t){this.N.state.Vt(t)}rotateZ(t){this.N.state.qt(t)}translate(t=0,e=0,r=0){this.N.state.Jt(t,e,r)}translateX(t){this.N.state.Jt(t,0,0)}translateY(t){this.N.state.Jt(0,t,0)}translateZ(t){this.N.state.Jt(0,0,t)}push(){this.N.state.rt()}pop(){this.N.state.nt()}color(t,e,r,h){if(I.qr(t))return t;if(typeof t=="string"){const n=Array.from(t);if(n.length===1){const a=n[0],c=this.er.sr(a);return I.Vr(c)}return I.Zr(t)}if(typeof t=="number")return typeof e=="number"&&typeof r=="number"?I.Nr(t,e,r,h??255):typeof e=="number"&&r===void 0?I.Xr(t,e):I.Xr(t,h??255);throw Error("Unsupported color input passed to color().")}rect(t=1,e=1){this.N.ge(t,e)}point(){this.N.ge(1,1)}line(t,e,r,h){this.N.ve(t,e,r,h)}lineWeight(t){this.N.state.Nt(t)}background(t,e,r,h=255){const n=this.ra(t,e,r,h);this.N.Ce(n.r,n.g,n.b,n.a)}char(t){if(I.qr(t)){const r=t.character;return void(r&&this.N.state.es(r))}const e=Array.from(t);if(e.length===0)throw Error("char() requires at least one character.");this.N.state.es(this.er.sr(e[0]))}charColor(t,e,r,h){const n=this.ra(t,e,r,h);this.N.state.rs(n.r,n.g,n.b,n.a)}cellColor(t,e,r,h){const n=this.ra(t,e,r,h);this.N.state.ns(n.r,n.g,n.b,n.a)}flipX(t){this.N.state.hs(t)}flipY(t){this.N.state.cs(t)}charRotation(t){this.N.state.us(t)}invert(t){this.N.state.ls(t)}clear(){this.N.Ce(0,0,0,0)}ellipse(t,e){this.N.me(t/2,e/2)}triangle(t,e,r,h,n,a){this.N.ye(t,e,r,h,n,a)}bezierCurve(t,e,r,h,n,a,c,u){this.N.we(t,e,r,h,n,a,c,u)}arc(t,e,r,h){this.N.be(t/2,e/2,r,h)}shader(t){this.N.ue(t)}setUniform(t,e){this.N.I(t,e)}setUniforms(t){this.N.fe(t)}async createFilterShader(t){if(typeof t=="string"&&(t.includes("/")||t.startsWith("./")||t.startsWith("../")||t.endsWith(".frag")||t.endsWith(".glsl"))){const e=await fetch(t);if(!e.ok)throw Error(`Failed to load shader from ${t}: ${e.statusText}`);const r=await e.text();return this.N.de(r)}return this.N.de(t)}createFramebuffer(t){return this.N.$e(t.width??this.grid.cols,t.height??this.grid.rows,3)}image(t,e,r){this.N.pe(t,e,r)}ortho(){this.N.state.ds(!0)}async loadImage(t){if(typeof t!="string")return W.pn(this.N,t,this.Ln.cols,this.Ln.rows,h=>this.er.ir(h));const e=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=e});return W.pn(this.N,r,this.Ln.cols,this.Ln.rows,h=>this.er.ir(h))}async loadVideo(t,e){return ct.pn(this.N,t,this.Ln.cols,this.Ln.rows,r=>this.er.ir(r),e)}},Me=o=>class extends o{async loadFont(t){return this.er.$r(t).then(()=>{const e=this.er.maxGlyphDimensions;this.Ln.kr(e.width,e.height),this.na.resize(this.Ln.cols,this.Ln.rows),this.N.Me(),this.Io.io(),this.oa.io()})}fontSize(t){if(!K.v(typeof t=="number"&&t>0,"Font size must be a positive number greater than 0.",{method:"fontSize",providedValue:t})||this.er.fontSize===t)return;this.er.br(t);const e=this.er.maxGlyphDimensions;this.Ln.kr(e.width,e.height),this.na.resize(this.Ln.cols,this.Ln.rows),this.N.Me(),this.Io.io(),this.oa.io()}},Ie=o=>class extends o{get frameCount(){return this.ha.kn}set frameCount(t){this.ha.kn=t}frameRate(t){return t===void 0?this.ha.Sn:this.ha.Tn(t,()=>this.aa())}noLoop(){this.ha.An()}loop(){this.ha.Fn(()=>this.aa())}redraw(t=1){if(K.v(typeof t=="number"&&t>0&&Number.isInteger(t),"Redraw count must be a positive integer.",{method:"redraw",providedValue:t}))for(let e=0;e<t;e++)this.aa()}isLooping(){return this.ha.En}},Pe=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._o(t)}get mouse(){return this.Io.vo()}cursor(t){this.Io.so(t)}},Ne=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.Ah(t)}tap(t){this.oa.Fh(t)}doubleTap(t){this.oa.Th(t)}longPress(t){this.oa.Rh(t)}swipe(t){this.oa.Eh(t)}pinch(t){this.oa.Sh(t)}rotateGesture(t){this.oa.kh(t)}get touches(){return this.oa.Ch()}},_e=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.So()}get pressedKeys(){return this.ca.ko()}get modifierState(){return this.ca.Po()}};class Se{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 _a(t){for(const e of t){if(this.ua.has(e.name))return void console.warn(`[textmode.js] Plugin "${e.name}" is already installed.`);const r=this.ga(e.name);try{await e.install(this.la,r)}catch(h){throw this.va(e.name),h}this.ua.set(e.name,e),this.fa.push(e.name)}}async ma(t){const e=this.ua.get(t);if(!e)return;const r=this.ga(t);e.uninstall&&await e.uninstall(this.la,r),this.ua.delete(t),this.fa.splice(this.fa.indexOf(t),1),this.va(t)}ya(){this.wa(this.da)}ba(){this.wa(this.pa)}async $a(){const t=[...this.ua.keys()];for(const e of t)await this.ma(e)}ga(t){return{renderer:this.la.N,font:this.la.er,grid:this.la.Ln,canvas:this.la.Rr,drawFramebuffer:this.la.na,asciiFramebuffer:this.la.Ca,registerPreDrawHook:e=>this.Ma(this.da,t,e),registerPostDrawHook:e=>this.Ma(this.pa,t,e)}}Ma(t,e,r){const h=t.get(e)??new Set;return h.add(r),t.set(e,h),()=>{const n=t.get(e);n&&(n.delete(r),n.size===0&&t.delete(e))}}va(t){this.da.delete(t),this.pa.delete(t)}wa(t){for(const e of this.fa){const r=t.get(e);r&&r.forEach(h=>h())}}}const Ot=`#version 300 es
|
|
12
|
+
in vec2 A0;in vec2 A1;out vec2 v_uv;void main(){v_uv=A1;gl_Position=vec4(A0,0.,1.);}`;class Dt{constructor(){l(this,"xa",new Map);l(this,"Fa",[]);l(this,"Ta",0);l(this,"Ra",0);l(this,"Ea")}get Sa(){return this.Ta}get ka(){if(this.Ta===0)return 0;let t=0;for(const e of this.Fa){const r=this.xa.get(e);r&&(t+=Math.min(1,Math.max(0,r.progress))*r.weight)}return Math.min(1,t/this.Ta)}Pa(t){this.Ea=t}La(t,e=1){const r=`phase-${this.Fa.length+1}-${Date.now()}`,h={id:r,label:t,weight:Math.max(.001,e),progress:0,status:"running"};return this.xa.set(r,h),this.Fa.push(r),this.Ta+=h.weight,r}Ia(t,e){const r=this.xa.get(t);if(!r)return;r.progress=Math.max(0,Math.min(1,e)),r.status=r.progress>=1?"complete":"running";const h=this.ka;Math.abs(h-this.Ra)>.001&&(this.Ra=h,this.Ea&&this.Ea(h))}za(t){const e=this.xa.get(t);e&&(e.progress=1,e.status="complete",this.Ia(t,1))}Da(t){const e=this.xa.get(t);e&&(e.status="failed")}Oa(){return this.Fa.map(t=>{const e=this.xa.get(t);return e?{id:e.id,label:e.label,weight:e.weight,progress:e.progress,status:e.status}:{id:t,label:t,weight:1,progress:0,status:"pending"}})}}class Ht{constructor(t="active"){l(this,"Ba");l(this,"Ga","");l(this,"Wa","");this.Ba=t}get Ha(){return this.Ba}get Ka(){return this.Ba!=="disabled"}get Ya(){return this.Ba==="active"||this.Ba==="transitioning"||this.Ba==="error"}get ja(){return this.Ga}get Na(){return this.Wa}Xa(){this.Ba!=="done"&&this.Ba!=="transitioning"||(this.Ba="active")}Za(){this.Ba!=="disabled"&&(this.Ba="done")}Va(){this.Ba!=="disabled"&&(this.Ba="transitioning")}qa(){this.Ba==="transitioning"&&(this.Ba="done")}Ja(t){this.Ba!=="disabled"&&(this.Ba="error",t instanceof Error?(this.Ga=t.message,this.Wa=t.stack||""):(this.Ga=t,this.Wa=""))}Qa(){this.Ba="disabled"}}class $t{constructor(t,e){l(this,"tc",0);l(this,"sc",1);l(this,"ec");l(this,"rc");this.ec=t,this.rc=e}get nc(){return this.sc}get oc(){return this.sc<1}Mn(){this.ec!=="none"&&this.rc>0&&(this.tc=performance.now())}st(){if(this.ec==="none"||this.rc===0)return this.sc=1,!1;const t=performance.now()-this.tc,e=Math.min(1,t/this.rc);return e>=1?(this.sc=0,!0):(this.sc=1-e,!1)}qs(){this.sc=1,this.tc=0}}function Rt(o,t){const e=o.tone??"auto";let r="dark";return e==="light"||e==="dark"?r=e:t&&(r=function(h){if(!h)return 0;const[n,a,c]=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(a)+.0722*u(c)}(t)>.5?"light":"dark"),{mode:r,background:t,textColor:r==="light"?"#1A1A1A":"#F8F8F8",subtleColor:r==="light"?"#4A4A4A":"#C0C0C0"}}function Gt(o){return o.mode==="light"?["#E91E63","#9C27B0","#FF6F00"]:["#8EF9F3","#F15BB5","#FF9B71"]}function Yt(o,t){return o.length?o.map(e=>t.color(e)):[t.color("#FFFFFF")]}const Be=({textmodifier:o,grid:t,progress:e,frameCount:r,message:h,palette:n,theme:a,phases:c,transitionOpacity:u,isError:f,errorMessage:d})=>{const g="|/-\\",m=Math.floor(r/6)%4,v=o.color(a.textColor),y=Math.floor(255*u),p=o.color(v.r,v.g,v.b,y);if(o.charColor(p),o.cellColor(0,0,0,0),f){const w=o.color(a.mode==="light"?"#D32F2F":"#FF6B6B",y);o.charColor(w),o.push(),o.translate(0,-2,0),o.char("X"),o.rect(1,1),o.pop();const E="SETUP ERROR",R=-Math.floor(E.length/2);o.push(),o.translate(R,0,0);for(const T of E)o.char(T),o.rect(1,1),o.translateX(1);if(o.pop(),d){const T=o.color(a.subtleColor),x=o.color(T.r,T.g,T.b,y);o.charColor(x);const b=Math.floor(.8*t.cols),U=d.split(" "),_=[];let M="";for(const N of U)(M+" "+N).length<=b?M=M?M+" "+N:N:(M&&_.push(M),M=N);M&&_.push(M);const B=_.slice(0,3);_.length>3&&(B[2]=B[2].substring(0,b-3)+"..."),B.forEach((N,ut)=>{const We=-Math.floor(N.length/2);o.push(),o.translate(We,3+ut,0);for(const je of N)o.char(je),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(),e>0||c.some(w=>w.status!=="pending")){const w=Math.max(6,Math.floor(.6*t.cols)),E=-Math.floor(w/2),R=Math.floor(w*e),T=n.length?n:[o.color("#FFFFFF")];o.push(),o.translate(E,3,0);for(let x=0;x<w;x++){const b=x<R?"*":".",U=T[x%T.length],_=o.color(U.r,U.g,U.b,y);o.charColor(_),o.char(b),o.rect(1,1),o.translateX(1)}o.pop()}if(h){const w=o.color(a.subtleColor),E=o.color(w.r,w.g,w.b,y);o.charColor(E);const R=-Math.floor(h.toUpperCase().length/2);o.push(),o.translate(R,5,0);for(const T of h.toUpperCase())o.char(T),o.rect(1,1),o.translateX(1);o.pop()}},Oe={message:"loading...",tone:"auto",transition:"fade",transitionDuration:500};class De{constructor(t,e,r){this.hc=t,this.id=e,this.label=r}report(t){this.hc.Ia(this.id,t)}complete(){this.hc.za(this.id)}fail(t){this.hc.Da(this.id)}async track(t){try{const e=typeof t=="function"?await t():await t;return this.complete(),e}catch(e){throw this.fail(),e}}}class Xt{constructor(t,e,r){l(this,"la");l(this,"l");l(this,"ac");l(this,"hc");l(this,"cc");l(this,"lc");l(this,"uc");l(this,"fc");l(this,"dc");l(this,"_c");l(this,"N");l(this,"gc",[]);l(this,"vc");l(this,"mc",performance.now());l(this,"yc",0);l(this,"wc",!1);l(this,"bc",!1);l(this,"xc");this.la=t,this.l={...Oe,...e??{}},this.ac=new Ht("active"),this.hc=new Dt,this.cc=new $t(this.l.transition,this.l.transitionDuration),this.lc=new Nt(60),this.vc=Rt(this.l,r);const h=Gt(this.vc);this.gc=Yt(h,this.la),this.N=this.$c(),this.hc.Pa(n=>{n>=.999&&this.Za()})}async mr(t){if(this.bc)return;const e=this.la.N,r=this.la.Rr;this.uc=new Et(e,16),await this.uc.mr(t);const h=this.uc.maxGlyphDimensions;this.fc=new wt(r.canvas,h.width,h.height),this.dc=e.$e(this.fc.cols,this.fc.rows,3),this._c=e.$e(this.fc.width,this.fc.height,1),this.bc=!0}get Ya(){return this.ac.Ya&&this.wc}Mn(){this.wc||(this.wc=!0,this.mc=performance.now(),this.yc=0,this.lc.Mn(()=>this.Cc()))}xn(){this.wc&&(this.wc=!1,this.lc.xn())}Hr(){this.bc&&(this.fc.qs(),this.dc.resize(this.fc.cols,this.fc.rows),this._c.resize(this.fc.width,this.fc.height))}O(){this.xn(),this.bc&&(this.uc.O(),this.dc.O(),this._c.O(),this.bc=!1)}get progress(){return this.hc.ka}message(t){return typeof t=="string"&&(this.l.message=t),this.l.message}addPhase(t,e=1){this.ac.Xa();const r=this.hc.La(t,e);return new De(this.hc,r,t)}Za(){this.l.transition!=="none"&&this.l.transitionDuration>0?(this.ac.Va(),this.cc.Mn()):(this.ac.Za(),this.xn(),this.Mc())}Mc(){this.xc&&this.xc()}Fc(t){this.xc=t}error(t){this.ac.Ja(t)}Cc(){if(this.ac.Ya){if(this.yc++,this.ac.Ha==="transitioning"&&this.cc.st())return this.ac.qa(),this.Mc(),void this.xn();this.Tc()}}Tc(){if(!this.bc)return;const t=this.dc,e=this.uc,r=this.fc,h=this._c,n=this.la.N,a=this.la.Rr,c=this.la.Rc,u=this.la.Ec;n.state.Xt(),t.begin(),this.la.clear(),this.la.push();try{const f={textmodifier:this.la,grid:r,progress:this.progress,elapsedMs:performance.now()-this.mc,frameCount:this.yc,message:this.l.message,palette:this.gc,theme:this.vc,phases:this.hc.Oa(),transitionOpacity:this.cc.nc,isError:this.ac.Ha==="error",errorMessage:this.ac.ja||void 0,errorDetails:this.ac.Na||void 0};this.N(f)}finally{this.la.pop()}t.end(),h.begin(),n.ce(c),c.L({U0:e.fontFramebuffer,U1:[e.textureColumns,e.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._e(0,0,a.width,a.height),h.end(),n.mi(...n.state.canvasBackgroundColor),n.ce(u),u.L({U8:h.textures[0],U9:[h.width,h.height],Ua:[r.offsetX,r.offsetY],Ub:[r.width,r.height]}),n._e(r.offsetX,r.offsetY,r.width,r.height)}Sc(t){this.vc=Rt(this.l,t)}$c(){const t=this.l.renderer||Be;return e=>{t(e),this.kc(e)}}kc(t){const{textmodifier:e,grid:r,frameCount:h,theme:n,transitionOpacity:a}=t,c=[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]];e.push(),e.translate(f,u,0);for(let g=0;g<c.length;g++){const m=c[g],v=Math.floor(.1*h+.5*g)%d.length,[y,p,w]=d[v],E=Math.floor(255*a),R=e.color(y,p,w,E);e.charColor(R),e.char(m),e.point(),e.translateX(1)}e.pop()}}class zt extends function(e,...r){return r.reduce((h,n)=>n(h),e)}(class{},Ue,Me,Ie,Pe,Ne,_e){constructor(e={}){super();l(this,"N");l(this,"er");l(this,"Rr");l(this,"Ln");l(this,"ha");l(this,"Io");l(this,"oa");l(this,"ca");l(this,"Pc");l(this,"na");l(this,"Rc");l(this,"Ca");l(this,"Ec");l(this,"Lc");l(this,"Ic",!1);l(this,"zc",!1);l(this,"Dc",!1);l(this,"Oc",!1);l(this,"Bc",()=>{});l(this,"Gc",()=>{});l(this,"Wc",()=>{});l(this,"Hc");l(this,"Kc");l(this,"Lr",!1);l(this,"Yc");this.Lc=new Se(this),this.Lr=e.overlay??!1,this.Rr=new Pt(e),this.N=new ae(this.Rr.Kr()),this.er=new Et(this.N,e.fontSize??16),this.ha=new Nt(e.frameRate??60),this.Pc=new Xt(this,e.loadingScreen,this.Rr.Wr()),this.Pc.Fc(()=>{this.ha.kn=0,this.Oc=!0}),this.Io=new _t(this.Rr),this.oa=new Bt(this.Rr,this.Io),this.ca=new St,this.Rc=this.N.le(Ot,`#version 300 es
|
|
13
|
+
precision highp float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U2;uniform vec2 U5;uniform vec2 U6;uniform vec4 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.Pc.Mn(),this.jc(e)}async jc(e){await Promise.all([this.er.mr(e.fontSource),this.Pc.mr(e.fontSource)]);const r=this.er.maxGlyphDimensions;this.Ln=new wt(this.Rr.canvas,r.width,r.height),this.Io.mr(this.Ln),this.oa.mr(this.Ln),this.na=this.N.$e(this.Ln.cols,this.Ln.rows,3),this.Ca=this.N.$e(this.Ln.width,this.Ln.height,1),this.Lr&&(this.Yc=W.pn(this.N,this.Rr.targetCanvas,this.Ln.cols,this.Ln.rows,h=>this.er.ir(h))),this.Ec=this.N.le(Ot,`#version 300 es
|
|
14
|
+
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.Nc(),this.ha.Mn(()=>this.aa()),await this.Lc._a(e.plugins??[]);try{await this.Bc(),this.Pc.Za()}catch(h){console.error("Error during setup:",h),this.Pc.error(h)}}Nc(){this.Hc=()=>{this.Lr&&this.resizeCanvas(this.Rr.targetCanvas.width,this.Rr.targetCanvas.height),this.Wc()},window.addEventListener("resize",this.Hc),this.Io.eo(),this.oa.eo(),this.ca.eo(),window.addEventListener("blur",()=>{this.ca.Lo()}),this.Lr&&(this.Kc=new ResizeObserver(()=>{this.resizeCanvas(this.Rr.targetCanvas.width,this.Rr.targetCanvas.height)}),this.Kc.observe(this.Rr.targetCanvas))}aa(){if(!this.Pc.Ya&&this.Oc){this.zc=!0;try{this.ha.Rn(),this.ha.Pn(),this.Lr&&xt(this.N.context,this.Yc.texture,this.Rr.targetCanvas),this.Lc.ya(),this.N.state.Xt(),this.na.begin(),this.Gc(),this.na.end(),this.Ca.begin(),this.N.ce(this.Rc),this.Rc.L({U0:this.er.fontFramebuffer,U1:[this.er.textureColumns,this.er.textureRows],U2:this.na.textures[0],U3:this.na.textures[1],U4:this.na.textures[2],U5:[this.Ln.cols,this.Ln.rows],U6:[this.Ca.width,this.Ca.height],U7:this.N.state.canvasBackgroundColor}),this.N._e(0,0,this.Rr.width,this.Rr.height),this.Ca.end(),this.N.mi(...this.N.state.canvasBackgroundColor),this.N.ce(this.Ec),this.Ec.L({U8:this.Ca.textures[0],U9:[this.Ca.width,this.Ca.height],Ua:[this.Ln.offsetX,this.Ln.offsetY],Ub:[this.Ln.width,this.Ln.height]}),this.N._e(this.Ln.offsetX,this.Ln.offsetY,this.Ln.width,this.Ln.height),this.Lc.ba()}finally{this.zc=!1,this.Ic&&!this.Dc&&this.Xc()}}}resizeCanvas(e,r){this.Rr.Hr(e,r),this.Pc.Sc(this.Rr.Wr()),this.Ln.qs(),this.Pc.Hr(),this.na.resize(this.Ln.cols,this.Ln.rows),this.Ca.resize(this.Ln.width,this.Ln.height),this.N.Me(),this.Io.io(),this.oa.io(),this.aa()}destroy(){this.Dc||this.Ic||(this.Ic=!0,this.ha.An(),this.zc||this.Xc())}Xc(){var e,r;this.Ic=!1,this.Pc.O(),this.Lc.$a(),window.removeEventListener("resize",this.Hc),(e=this.Kc)==null||e.disconnect(),this.Io.lo(),this.oa.lo(),this.ca.lo(),this.na.O(),this.Rc.O(),this.er.O(),this.N.O(),this.Ca.O(),this.Ec.O(),(r=this.Yc)==null||r.O(),this.Rr.O(),this.Dc=!0}setup(e){this.Bc=e}draw(e){this.Gc=e}windowResized(e){this.Wc=e}get grid(){return this.Ln}get font(){return this.er}get width(){return this.Rr.width}get height(){return this.Rr.height}get canvas(){return this.Rr.canvas}get drawFramebuffer(){return this.na}get isDisposed(){return this.Dc}get overlay(){return this.Yc}get loading(){return this.Pc}}class lt{constructor(){}static create(t={}){return new zt(t)}static setErrorLevel(t){K.m(t)}static get version(){return"0.6.0-beta.2"}}const He=Object.freeze(Object.defineProperty({__proto__:null,LoadingPhaseTracker:Dt,LoadingScreenManager:Xt,LoadingScreenStateMachine:Ht,LoadingScreenTransition:$t,resolveColorInputs:Yt,resolveDefaultPalette:Gt,resolveTheme:Rt},Symbol.toStringTag,{value:"Module"})),$e=Object.freeze(Object.defineProperty({__proto__:null,TextmodeFont:Et,TextmodeImage:W,TextmodeVideo:ct},Symbol.toStringTag,{value:"Module"})),Ge=Object.freeze(Object.defineProperty({__proto__:null,keyboard:Ce,mouse:Le,touch:Fe},Symbol.toStringTag,{value:"Module"})),Ye=lt.create,Xe=lt.setErrorLevel,ze=lt.version;L.TextmodeCanvas=Pt,L.TextmodeColor=I,L.TextmodeErrorLevel=H,L.TextmodeFramebuffer=J,L.TextmodeGrid=wt,L.Textmodifier=zt,L.create=Ye,L.input=Ge,L.loadables=$e,L.loading=He,L.setErrorLevel=Xe,L.textmode=lt,L.version=ze,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):i((s=typeof globalThis<"u"?globalThis:s||self).textmode={});
|
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
* Determines how validation failures and errors are processed throughout the library.
|
|
5
5
|
* Each level provides different behavior for error reporting and execution flow control.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @note
|
|
8
|
+
* This feature is currently not fully implemented across all modules,
|
|
9
|
+
* and most `textmode.js` functions will still throw errors if used incorrectly.
|
|
8
10
|
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```javascript
|
|
9
13
|
* // Set to `WARNING` level to log errors without stopping execution
|
|
10
14
|
* textmode.setErrorLevel(TextmodeErrorLevel.WARNING);
|
|
15
|
+
* ```
|
|
11
16
|
*/
|
|
12
17
|
export declare enum TextmodeErrorLevel {
|
|
13
18
|
/**
|